mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3631] [Engine] STRATA_WINDOW_TRACE: a record per decode window (opt-in, record only) #4726
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4726
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3631
Author: @SanghunYun
Created: 10/21/2026
Status: 🔄 Open
Base:
main← Head:codex/window-trace-v022-20261022📝 Commits (1)
0511ae3STRATA_WINDOW_TRACE: a binary record per decode window of the serial serve loop (record only)📊 Changes
4 files changed (+174 additions, -0 deletions)
View changed files
📝
docs/DETAILS.md(+9 -0)📝
src/program/generate.cpp(+64 -0)➕
tools/test_window_trace.py(+54 -0)➕
tools/window_trace.py(+47 -0)📄 Description
Problem and result
STRATA_DECODE_TIMING=1gives one line per request: the average decode window. It cannot show what happens across windows: a cost paid at one window boundary (an adaptive swap, aSTRATA_RAM_ADAPTmove) and what it saves in the windows after it, or which windows are slow and what they read.With
STRATA_WINDOW_TRACE=<path>the serial serve loop appends one 216-byte record per decode window: when it started, its boundary work (the adaptive tier's wait, theSTRATA_RAM_ADAPTmoves, the--adapt-asyncstep), the verify window, commit and draft, and the expert reads it made (VRAM hits, CPU expert entries, RAM and file reads and bytes, RAM moves, adaptive swaps).tools/window_trace.pyreads it (summary, or--csvfor every window). Unset, nothing is timed or written.Measured on an RTX 3060 12 GB, IQ3_XXS, 120 ShareGPT requests (about 12,000 windows, 2.6 MB of records), trace off / on / off, fresh engine each. This was measured on v0.2.1 with #3060 applied (
e26c68d6) plus this change, before v0.2.2; the change itself is the same:The records cover 99.99% of the request's decode time, and their count equals the windows in the
strata decode timing:lines.What it showed, as an example: #3060 against main's
STRATA_RAM_ADAPT=8saves 4.40 ms per token on this workload. 92% of it is the verify window (expert reads from the file 40.9 → 17.9 per window, VRAM hits and CPU entries unchanged), 7.5% the boundary (a move 0.91 → 0.17 ms). The decode timing line alone could not separate the two.Related discussion
#610 (
STRATA_DECODE_TIMING, where a decode window's time goes) and #1864 (its serial sum). This is the same loop, per window instead of per request.Approach
All in the serial serve loop of
src/program/generate.cpp: a staticFILE*opened once from the variable (nullptrwhen unset), clock reads at the points the decode timing already uses plus three around the boundary work, and counter snapshots of fields that already exist (ver.ms_wait/ms_pool,drive.d.*,src.ram_reads()/file_reads()/file_read_bytes()/ram_adapts(), the adaptive swap count). The clock reads, counter reads and writes are all behindif (wt_f); unset, a window does five null checks and initialises a few locals (an empty snapshot, the flags word, four time points), and no existing variable is written. The file starts with a 12-byte magic and the record size; astatic_assertpins the record at 216 bytes, which the reader checks. The file is flushed at the end of each request. The--pipeline-windowsloop and the batch loop are not traced.docs/DETAILS.mdhas a paragraph next to the decode timing one.Validation
Passed:
011c9e60, today's main) + this commit, clean build folders: compile and link, no warnings in the changed lines.cmake --build build-cuda-sm86 --target strata -j 14andcmake --build build-hip-gfx1100 --target strata -j 14(revisionfe37cbb3, environments above).python -m unittest tools.test_window_trace: 4 tests (record size, order, a partial last record, a foreign file).011c9e60) against this build (fe37cbb3),STRATA_WINDOW_TRACEunset: the same standard-v1performance-short-r1request once per build, after the same warm-up. IQ2_XS, 77 prompt tokens (0 reused), 413 generated tokens; returned content byte-identical (807 characters, SHA-2569e91210d…).--adapt-async 0 --pcie-frac 0,STRATA_ADAPT_NOWAIT=0 STRATA_PREFILL_CPU_SHARE=0 STRATA_IQ_MT_MIN=1, RAM adaptation unset. One output pair only.generate.cppgives a file byte-identical to v0.2.2's (sha25689cdeb94…). With the variable unsetwt_fisnullptr, so nothing is timed, read or written; the added locals are not read by any existing code.e26c68d6+ this change, IQ3_XXS read in place,--resident-budget-gib 20.5,STRATA_RAM_ADAPT=1,--spec 3 --mtp-max-t 3, greedy, ShareGPT 120 requests, one run per column).Failed: none observed.
Not run:
Limits
wait,poolandjobsare the verifier's and the pool's own sums (overlapping threads). GPU stages are not split (no events, so no synchronisation is added).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.