Repository navigation
Profiles: ncu bandwidth regimes for the head and GDN kernels, GDN kernel bench, reproduction reruns - #173
Conversation
run_profiles.py now takes the DFlash arms whole from bench/arms.toml (dflash-tuned-b16 and dflash-tuned), so the profile runs the frontier's server flags; the old dflash16/dflash8 arms used FlashInfer GDN kernels and the overlap plan stream, which the bench treats as ablations. max_new_tokens is sized from the resolved KV pool, which keeps the old budget for plain and MTP and lets all 64 DFlash requests be admitted at once. The dflash step adds untraced windows for the cycle time. ncu_summary.py scaled durations only for 'nsecond'/'usecond'; ncu 2025.3 reports 'us', so durations stayed in microseconds and dram_tb_per_s came out 1e12 too small. Units are now checked against a table and a missing metric fails the run. It also records ncu's DRAM peak and percent of peak, theoretical occupancy, tensor-pipe use and waves per SM. clock_summary.py reports the samples under load with the SM clock below its maximum, which shows when a power limit lowered the clock.
kernel_bandwidth.py puts the head GEMM and the GDN kernels' achieved bandwidth side by side by batch from the microbenchmark, the GDN kernel bench, the serving traces and Nsight Compute, and classifies each ncu launch by the speed-of-light rule. compare_attribution.py compares two attributions of the same configurations component by component. analyze_all.sh now reads the plain traces behind the committed plain evidence from plain_nsys_v0/ (plain_nsys/ holds the 2026-10-01 rerun), attributes the rerun into attribution/plain_rerun/ with its comparison, collects the rerun's windows as plain_nsys_rerun, and runs the new steps. summarize.py gives rerun windows their own rows in the runs table.
From the profile holds of 2026-10-01 (repository 0aec3e0, SGLang bd66ce34): ncu_key_kernels.json regenerated from the four Nsight Compute reports with the fixed units, gdn_kernel_bench.json, kernel_bandwidth.csv, the head microbenchmark rerun with its clock log (microbench_rerun/), and the plain trace rerun with its comparison (attribution/plain_rerun/, plain_rerun_check.csv, windows/plain_nsys_rerun*). The cited head microbenchmark, bandwidth and plain attribution files are unchanged. The evidence README gains a section on whether each kernel is bandwidth- or latency-bound: the head GEMM is bandwidth-bound (88-90% of ncu's DRAM peak at M = 1 and 32); the GDN decode kernel at B = 32 and the verify kernel at B = 8 are latency-bound. It corrects the claim that the decode kernel streams the state at 92% of the read peak (27 MB of its writes at B = 32 are still in L2 when it ends), records the clock throttling behind the large-M spread, resolves the plain-trace provenance caveat, and updates the pending list.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3421b4bbaf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -171,6 +171,9 @@ def runs_table(evidence: Path) -> str: | |||
| kind = 'SGLang /start_profile (CUDA_PROFILER) under nsys' | |||
| else: | |||
| continue | |||
There was a problem hiding this comment.
Regenerate the table after adding rerun windows
With the newly committed windows/plain_nsys_rerun.jsonl, this branch makes runs_table() emit rerun records, but the tracked evidence/profiles/tables.md was not regenerated. Running summarize.py --evidence evidence/profiles adds eight rerun rows, so the committed table omits the measurements and analyze_all.sh immediately leaves a diff. Commit the regenerated table with this logic change.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3db5fd2: tables.md regenerated with summarize.py; the rerun windows now appear as their own rows (labelled ", rerun"), and the original rows are unchanged.
| | `ncu_key_kernels.json` | one Nsight Compute launch each of the head GEMM (M = 1, 32), the GDN decode kernel (B = 32) and the GDN verify kernel (B = 8): DRAM bytes, throughput against ncu's DRAM peak, SM throughput, occupancy, stalls | `run_ncu.sh` (`ncu_summary.py`) | measured (profiler timings) | | ||
| | `gdn_kernel_bench.json` | one GDN layer's decode, verify and verify-without-saves kernels at B = 1-128 under CUDA graphs, L2 evicted | `run_all.sh gdn` (`gdn_kernel_bench.py`) | measured | | ||
| | `kernel_bandwidth.csv` | achieved bandwidth of the head GEMM and the GDN kernels by batch and source (microbenchmark, GDN bench, serving traces, ncu), with the ncu regime | `kernel_bandwidth.py` | measured; regime by rule | | ||
| | `microbench_rerun/` | 2026-10-01 rerun of `run_microbench.sh` with the clock log: `hbm_bandwidth.json`, `head_microbench.json`, `microbench_clocks.csv` (nvidia-smi, 100 ms), `microbench_clocks.json` | `run_all.sh microbench` (`clock_summary.py`) | measured; reproduction check | |
There was a problem hiding this comment.
Make the rerun command write to the documented directory
When this documented run_all.sh microbench command is used to reproduce microbench_rerun/, run_microbench.sh actually writes hbm_bandwidth.json, head_microbench.json, and microbench_clocks.json directly under evidence/profiles/; it never writes or copies anything into microbench_rerun/. Following the instructions therefore overwrites the cited originals and cannot recreate the committed rerun files without the undocumented manual move described later. Provide a command/output option that targets the rerun directory.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3db5fd2: run_microbench.sh takes MICROBENCH_EVIDENCE (default evidence/profiles), writes hbm_bandwidth.json, head_microbench.json, microbench_clocks.csv and microbench_clocks.json there, and the README documents MICROBENCH_EVIDENCE=evidence/profiles/microbench_rerun experiments/profiling/run_all.sh microbench. The README also says the 2026-10-01 files were moved by hand because that hold predates the option.
…tory Address Codex review on #173: tables.md now carries the rerun windows' rows that summarize.py emits, and run_microbench.sh takes MICROBENCH_EVIDENCE, so the documented command recreates evidence/profiles/microbench_rerun/ (with the clock log) instead of overwriting the cited files. The README says how the 2026-10-01 rerun's files got there and corrects the M = 256 FLOP rate to 572 TFLOP/s.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3db5fd2c1d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| # Attribution per configuration. | ||
| for arm_kind in plain:plain mtp:spec dflash16:dflash dflash8:dflash; do | ||
| for arm_kind in plain:plain mtp:spec dflash-tuned-b16:dflash dflash-tuned:dflash; do |
There was a problem hiding this comment.
Teach the summarizer the renamed DFlash arms
When run_all.sh dflash completes, this loop writes attribution/dflash-tuned-b16_bs*.json and attribution/dflash-tuned_bs*.json, but summarize.py still restricts CONFIGS to the removed dflash16 and dflash8 names. Consequently analyze_all.sh silently omits every new tuned DFlash attribution from tables.md, step_share.csv, and breakdown.csv; update the summarizer's arm names or normalize them before writing the evidence.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9b18965: summarize.py now uses dflash-tuned-b16 and dflash-tuned (DFLASH_ARMS). breakdown.csv stays plain + MTP because the paper's Figure 1 plots every row of it; the DFlash rows, same columns, go to dflash_breakdown.csv once the attributions exist. tables.md and step_share.csv include them.
| # The plain traces behind the committed plain evidence (2026-09-30 18:28) are kept in | ||
| # plain_nsys_v0/; plain_nsys/ now holds the 2026-10-01 rerun with the committed driver, | ||
| # which is attributed separately below and compared with them. | ||
| PLAIN_CITED="$VP_DATA/plain_nsys_v0" |
There was a problem hiding this comment.
Make the reproduction command create the cited trace directory
With a fresh $VP_DATA, the documented run_all.sh plain command creates plain_nsys/, never plain_nsys_v0/. Hard-coding the cited input to this uncreated directory therefore makes the attribution loop skip all cited plain traces and leaves the committed attribution files untouched rather than regenerating them; if the evidence directory is cleaned, downstream generation also lacks those inputs. Document and automate creation of plain_nsys_v0/, or provide an explicit fallback/input option.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9b18965: PLAIN_CITED overrides the cited directory, and when plain_nsys_v0/ does not exist (fresh VP_DATA) analyze_all.sh takes the plain evidence from plain_nsys/ and skips the rerun comparison. The evidence README's Reproduction section says so.
…ed plain traces Address Codex review on #173. summarize.py knew only the removed dflash16/dflash8 names, so the tuned DFlash attributions would have been left out of the tables; it now uses dflash-tuned-b16 and dflash-tuned. breakdown.csv keeps plain decoding and MTP only, because the paper's Figure 1 plots every row of it, and the DFlash rows (same columns) go to dflash_breakdown.csv once they exist. analyze_all.sh read the cited plain traces only from plain_nsys_v0/, which a fresh run_all.sh never creates. PLAIN_CITED now overrides the path, and without that directory the plain evidence comes from plain_nsys/ with no rerun comparison. The evidence README documents both.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9b18965617
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Derived bytes and label checks. | ||
| shopt -s nullglob | ||
| windows=("$VP_DATA"/plain_nsys/windows.jsonl "$VP_DATA"/mtp_nsys/windows.jsonl) | ||
| windows=("$EV"/windows/plain_nsys.jsonl "$VP_DATA"/mtp_nsys/windows.jsonl) |
There was a problem hiding this comment.
Collect the cited plain windows before consuming them
When both plain_nsys_v0/ and plain_nsys/ exist—the documented cited-plus-rerun layout—the collection loop writes only plain_nsys_rerun.jsonl, but this line still requires windows/plain_nsys.jsonl. Consequently, running analyze_all.sh after clearing generated evidence fails in bytes_model.py unless the old tracked file already exists, so the documented command cannot regenerate the evidence solely from the raw run directories. Collect $PLAIN_CITED/windows.jsonl under plain_nsys before using it here.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 4500b4f: the cited run is collected as plain_nsys from $PLAIN_CITED (plain_nsys_v0/ holds its windows.jsonl, run_meta.json and server.log) before bytes_model.py reads windows/plain_nsys.jsonl, and the rerun as plain_nsys_rerun. Collecting plain_nsys_v0/ reproduces the committed windows/plain_nsys.jsonl, _meta.json and _server_startup.log byte for byte (checked in a CPU window).
Address Codex review on #173: with both plain_nsys_v0/ and plain_nsys/ present, analyze_all.sh collected only the rerun's windows, so after a clean of the evidence the bytes model would find no windows/plain_nsys.jsonl. The cited run is now collected as plain_nsys from $PLAIN_CITED, and the rerun as plain_nsys_rerun. Collecting plain_nsys_v0/ reproduces the committed windows/plain_nsys.jsonl, _meta.json and _server_startup.log byte for byte.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4500b4f765
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if have "$EV/attribution/plain_rerun/plain_bs1.json"; then | ||
| run compare_attribution.py --base "$EV/attribution" --test "$EV/attribution/plain_rerun" \ | ||
| --arm plain --batch 1 8 32 128 --out "$EV/plain_rerun_check.csv" |
There was a problem hiding this comment.
Require every rerun batch before producing the comparison
If the plain rerun is interrupted after B=1, this guard succeeds and compare_attribution.py still requests B=1,8,32,128. Because the destination already contains committed rerun JSONs, the refreshed B=1 result can be silently compared alongside stale results for the other batches; if those files were cleaned, analysis instead aborts. Verify that every requested raw/rebuilt batch exists—or compare only the completed batch set—before regenerating plain_rerun_check.csv.
AGENTS.md reference: AGENTS.md:L15-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 366dc66: analyze_all.sh stops with an error if any of plain_bs{1,8,32,128}.nsys-rep is missing from the rerun directory, and re-attributes all four before compare_attribution.py runs, so fresh and stale results cannot mix.
…aces Address Codex review on #173: an interrupted rerun with only some batches could have mixed fresh and stale attributions in plain_rerun_check.csv. analyze_all.sh now stops if any of the four rerun traces is missing and re-attributes all four before the comparison.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 366dc669f2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| prof --arm "$arm" --mode none --concurrency 1 4 16 64 --repeats 3 \ | ||
| --out-dir "$VP_DATA/${arm}_none" |
There was a problem hiding this comment.
Resume incomplete DFlash sweeps instead of skipping them
When this newly added untraced sweep is interrupted after any window (for example, after the first B=1 repetition), run_profiles.py has already appended to windows.jsonl; rerunning run_all.sh dflash then makes prof() treat that nonempty file as a completed run and skip all remaining repetitions and batch sizes. The subsequent collection and summarization accept the partial file, so the queued DFlash experiment can silently produce incomplete throughput evidence unless the operator notices and deletes the directory or sets VP_RERUN=1; verify the expected windows before skipping or resume the missing points.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Scoped: this only bites an interrupted and resubmitted DFlash sweep. Nothing at this head depends on it: no DFlash window, attribution or summary is committed (git ls-tree -r HEAD evidence/profiles has no dflash file), and the one queued DFlash hold runs once from a worktree pinned at 5bc91db. The follow-up DFlash PR will (1) make prof() skip a run only when windows.jsonl holds every expected (concurrency, window kind, repeat) record, with a test, and (2) have the DFlash cycle analysis refuse a windows file that lacks any planned point or did not hold its batch. If the hold is interrupted, its partial output will be discarded and rerun, not resumed.
|
Verdict: APPROVE at 366dc66 I checked the README's and body's numbers against Head GEMM.
GDN decode at B = 32.
GDN verify.
The regime rule (80% for bandwidth-bound; under 70% on both, with memory stalls, for latency-bound) is applied as stated. Reruns.
The proposed Suggested replacement, to route to the paper agent: "which would be 3.47-3.48 TB/s if every state byte reached DRAM during the kernel; Nsight Compute shows that at B = 32 about 27 of the 67 MB it writes are still in L2 when it ends and DRAM runs at 67% of peak, and at B = 128 the same per-request rate puts DRAM at about 82% of peak (derived)." Codex. Six comments were fixed, with replies. The one at 366dc66 (run_all.sh:78, resuming an interrupted DFlash sweep) has a scoped reply, which I verified: Hygiene. No hostname in the commit log, including the regenerated Optional: the B = 128 figure of "about 82%" assumes the 27 MB left in L2 at B = 32 carries over. The L2 holds at most 60 MB, so the same per-request time bounds DRAM at 77-87% of peak (537 MB less 0 to 60 MB, in 154 µs). Giving the range beside the point estimate would show how much rests on that assumption. |
The profile workstream's queued GPU chain finished on 2026-10-01, and nobody had summarised its output. Two of its four holds ran: the plain nsys rerun (02:44 UTC) and
gdn ncu microbench(ended 11:25 UTC), both from repository 0aec3e0 with SGLangbd66ce34, CUDA graphs and the overlap scheduler on. The DFlash attribution never ran. It was deferred at 16:01 and is now queued again (below). This PR adds what the finished holds measured, fixes a units bug in the ncu summary, and points the queued DFlash attribution at the frontier's tuned arms.What the runs show (all in
evidence/profiles/README.md)Head GEMM: bandwidth-bound. Under Nsight Compute, the M = 1 and M = 32 launches read 1.27 GB, the weight itself, at 3.61 and 3.53 TB/s. That is 89.6% and 87.8% of ncu's DRAM peak (1,536 B per DRAM cycle at 2.619 GHz = 4.02 TB/s). SM throughput is 4.5-12% and the tensor pipe is busy 3% of the time. The served head GEMM runs at 3.48-3.62 TB/s (92-96% of the measured 3.79 TB/s read peak) up to M = 128.
GDN decode kernel: latency-bound up to at least B = 32. The B = 32 launch moves 107.7 MB in 40.3 us: the 67.7 MB state read plus 40.1 of the 67.1 MB written. The other 27 MB of writes are still in L2 when the launch ends. DRAM runs at 67% of peak and the SMs at 19%. Achieved occupancy is 11% of a theoretical 12.5%: 205 registers per thread in one-warp blocks allow 8 blocks per SM. The served time per request is the same at B = 32 and 128 (1.21 and 1.20 us per layer). At B = 128 that rate puts DRAM at about 82% of peak (derived), close to the limit. This corrects a claim on main. The evidence README and the research notes (
paper/notes/stack.tex, "The plain step beyond the head") say the kernel streams the state "at 92% of the read peak", from bytes divided by the served duration. That counts writes that reach DRAM only after the kernel ends.GDN verify kernel: latency-bound at B = 8 (54% of DRAM peak, 51% SM throughput). The kernel bench shows what the four per-position state saves cost. Without them the kernel reads only the state and runs at 0.15-1.18 TB/s. With them its traffic is five times larger and it takes 63-89% longer at B = 8-128. Below B = 128 the no-save launch also uses a different value tile (SGLang's
_select_recurrent_launch_configgives target verify with up to 64 requests a 4-wide tile on SM90), so only the B = 128 comparison isolates the saves: +204 us on 228 us per layer, about 4.9 ms per verify forward (derived).The reruns reproduce the cited numbers.
The cited files (
head_microbench.json,hbm_bandwidth.json,attribution/plain_bs*.json) are unchanged, so no paper number moves. The reruns sit beside them as reproduction checks (microbench_rerun/,attribution/plain_rerun/,plain_rerun_check.csv).Changes
ncu_summary.py: ncu 2025.3 reportsgpu__time_durationinus, which the old unit table missed. Durations stayed in microseconds, and the hold'sdram_tb_per_scame out 10^12 too small. Units are now checked against a table, and an unknown unit or a missing metric fails the run. The script also records ncu's DRAM peak and percent of peak, theoretical occupancy, tensor-pipe use and waves per SM.ncu_key_kernels.jsonis regenerated from the same reports.kernel_bandwidth.py(new):kernel_bandwidth.csvputs the microbenchmark, the GDN bench, the serving traces and ncu side by side by batch. It classifies each ncu launch by the speed-of-light rule (bandwidth-bound at 80% of DRAM peak; latency-bound when memory and SM throughput both stay under 70% and warps wait on memory).compare_attribution.py(new):plain_rerun_check.csv.clock_summary.py: reports the samples under load with the SM clock below its maximum.run_profiles.py,run_all.sh dflash: the DFlash arms are nowdflash-tuned-b16anddflash-tuned, resolved whole frombench/arms.toml, so the profile runs the frontier's exact server flags. The olddflash16/dflash8arms used FlashInfer GDN kernels and the overlap plan stream, which the bench treats as ablations.max_new_tokensis now sized from the resolved KV pool: the plain and MTP pools give the old budget, and all 64 DFlash requests are admitted. The step adds untraced windows for the cycle time.analyze_all.shreads the cited plain traces fromplain_nsys_v0/, so it still regenerates the committed plain evidence. It attributes the rerun separately and runs the new steps./start_profile, graph-level and eager-label runs were dropped with main's agreement, since nothing in the paper depends on them.DFlash attribution (queued, not in this PR)
run_all.sh dflashis queued at its original FIFO arrival (main's go) from a worktree pinned at 5bc91db, this branch's first commit. It runs nsys node-level windows and untraced windows at c = 1, 4, 16 and 64 for both tuned arms. The cycle split (draft, verify, GDN commit, head, sampling, host gaps) and a breakdown figure will follow as their own PR.Validation
scripts/check_host_identity.shon every new or changed file: no matches. The raw ncu CSV pages carry a host-name column, whichncu_summary.pydoes not keep.plain_nsys_v0/reproduces the committedattribution/plain_bs*.json: every value is identical. The committed B = 8 and 32 files lack thehost_sync_callsfield that the committed B = 1 and 128 files and the current code write.summarize.pyon the updated tree leavesstep_share.csvandbreakdown.csv(the inputs of Figure 1) unchanged;tables.mdgains eight rows for the rerun windows, committed in 3db5fd2.scripts/verify_artifact.pyand the paper build, because nothing underpaper/orsrc/changed.Codex review
summarize.py:173, regenerate the table after adding rerun windows: done in 3db5fd2.evidence/profiles/README.md, the rerun command wrote toevidence/profiles/rather thanmicrobench_rerun/:run_microbench.shnow takesMICROBENCH_EVIDENCE, and the README documents the command that recreatesmicrobench_rerun/(3db5fd2).analyze_all.sh:26, the summarizer did not know the renamed DFlash arms:summarize.pyusesdflash-tuned-b16/dflash-tuned;breakdown.csvstays plain + MTP (Figure 1 plots every row), and DFlash rows go todflash_breakdown.csv(9b18965).analyze_all.sh:23, the documented command never createsplain_nsys_v0/:PLAIN_CITEDoverrides it, and on a fresh$VP_DATAthe plain evidence comes fromplain_nsys/without the rerun comparison (9b18965).analyze_all.sh:76, collect the cited plain windows before the bytes model reads them: the cited run is collected asplain_nsysfrom$PLAIN_CITEDand the rerun asplain_nsys_rerun; collectingplain_nsys_v0/reproduces the committed window files byte for byte (4500b4f).analyze_all.sh:56, require every rerun batch before the comparison: the script stops if any rerun trace is missing and re-attributes all four (366dc66).run_all.sh:78, resume incomplete DFlash sweeps instead of skipping them: scoped reply. No DFlash evidence is committed here, and the queued hold runs once from a worktree pinned at 5bc91db. The follow-up DFlash PR makesprof()check every expected window record (with a test), and its analysis refuses a partial windows file.