Repository navigation
Profile SGLang decode and MTP on GH200: attribution, head baseline, bytes per step - #13
Conversation
hbm_bandwidth.py measures the local read and copy bandwidth that the attribution uses as its peak (3.83 TB/s read, 3.79 TB/s over the head's 1.27 GB footprint). head_microbench.py times the exact PyTorch calls SGLang runs for the tied 248320 x 2560 BF16 head (matmul, FP32 logits copy, greedy argmax, and the EAGLE top-1 kernels) under CUDA graphs at M = 1..256 with warm and cold L2; head_kernel_names.py recovers the cuBLAS kernel behind each shape from an nsys trace.
run_profiles.py launches one server per arm under nsys launch, drives C concurrent long greedy generations (drive_decode.py) and collects a 2 s steady-state window per concurrency with CUDA-graph node tracing, plus an uncollected window for the perturbation check. attribute.py splits each decode step into kernel categories (GEMMs labelled by their neighbours in the graph replay), eager work, copies and idle time inside and outside graph replays; bytes_model.py converts the step into HBM bytes by component and checks them against the kernel times.
attribute.py now reports, per step, the host lead of each graph launch, the host synchronizations, per-category wall time and whether every eager launch has a kernel record (CUPTI can drop them when its buffers fill). bytes_model.py adds per-GEMM achieved bandwidth and a derived bytes sweep over batch size for plain decode and MTP; summarize.py writes tables.md and the CSVs the paper figures read.
run_all.sh reproduces every profile, one exclusive hold per step (or several steps under one hold with VP_LOCKED=1). New pieces: a CUPTI flush interval for nsys (the MTP windows lost eager kernel records without it), run metadata with repo SHA and nsys version, an NVTX host-function trace for the speculative worker (diagnostic), a standalone GDN decode/verify kernel bench, Nsight Compute on the head GEMM and the GDN kernels, and a check of the GEMM labels against module NVTX ranges in an eager run.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 153b6d78c8
ℹ️ 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".
| fi | ||
| RUN=(python "$REPO/experiments/profiling/run_profiles.py") | ||
| # shellcheck source=/dev/null | ||
| source "$HOME/verified-progress/scripts/sglang_env.sh" |
There was a problem hiding this comment.
Resolve helper scripts from the computed repository root
When the checkout is not exactly $HOME/verified-progress—including this configured /workspace/verified-progress checkout—the runner exits here before starting any experiment because the sourced file does not exist. The GPU-lock path on line 20 and the same environment-source path in run_microbench.sh and run_ncu.sh are hard-coded likewise; use the already computed $REPO/scripts/... paths so the documented runner works from the actual checkout.
AGENTS.md reference: AGENTS.md:L7-L10
Useful? React with 👍 / 👎.
| header, units, first = rows[0], rows[1], rows[2] | ||
| out: dict = {'report': report.name} | ||
| stalls = {} | ||
| for name, unit, value in zip(header, units, first, strict=True): |
There was a problem hiding this comment.
Parse every row of Nsight Compute raw CSV
ncu --csv --page raw emits a header followed by one row per metric, using columns such as Metric Name, Metric Unit, and Metric Value, rather than separate header/unit/value rows (Nsight Compute CLI guide). Consequently, this assignment treats the first two metric records as units and first, and the subsequent loop compares fixed column names such as ID and Metric Name against KEEP; the generated summary contains none of the requested duration, traffic, throughput, or stall measurements. Iterate over the metric rows and read those three named columns instead.
Useful? React with 👍 / 👎.
Speculative cycles are host-bound, so CPU work from other jobs during a window would inflate their idle gaps; the window summary now carries the 1-minute load average before and after.
host_gaps.py intersects the GPU's idle intervals in each cycle with the innermost NVTX range on the scheduler thread, from a run whose host functions were annotated with nsys --python-functions-trace.
|
Verdict: REQUEST CHANGES Reviewed at What I ran and checked
Blocking1. The evidence README and the evidence behind half of the PR's claims are missing.
2. The throughput table is not labelled as profiler-attached.
3. The plain profiles were not produced by the committed code, and the provenance is incomplete.
4. The PR body is stale.
Profile-specific checklist
Suggestions (non-blocking)
|
Removing layer 0's in_proj GEMMs entirely would save 0.33-0.60% of a plain decode step at batch 1-128 (ceiling at most 1.006x), below P5's pre-registered 1% threshold.
…ghput run_profiles.py gains dflash16/dflash8 arms (flags from the drafter workstream; one server covers B = 1-64) and an optional py-spy sample of the scheduler during collected windows; attribute.py and host_gaps.py attribute DFlash cycles verify-to-verify with the draft graph's non-head work as draft_model. summarize.py now says that only unprofiled repeated windows are throughput results; the nsys windows measure perturbation.
…s review Per the per-workstream patch convention, the series moves to engine/sglang/patches/moonshot/0001-0007 and engine/sglang/README.md keeps the geometry section with a moonshot section below it. Figures from unmerged PRs are marked as under review (profile PR #13), the drafter's tau cites evidence/drafter on main, strict replay is described as designed to be bit-identical with validation pending, the FP8 W8A8 sentence matches the CSV, and reproduction uses repository paths (bench is on main).
Review (Codex, PR #13): the shell scripts now take gpu_lock.sh and sglang_env.sh from the checkout they live in, and run_profiles.py reads the SGLang SHA from the imported package. ncu_summary.py accepts both the one-row-per-metric and the one-column-per-metric layouts of 'ncu --csv --page raw'; no ncu numbers had been committed yet.
|
Handled the two Codex P1 comments in 87f5e65:
|
The window summary now carries the mean number of busy cores machine-wide, for the server's process tree plus this client, and their difference (load from other jobs), from /proc/stat and psutil CPU times. Host-bound phases (the speculative cycle's gaps) are only reported from windows with low foreign load.
The MTP rerun (CUPTI flush interval, all eager kernel records present) attributes each speculative cycle; host_gaps_mtp_bs*.json names the host functions running while the GPU idles (NVTX on the EAGLE worker's host functions) and pyspy_*.json summarizes py-spy samples of the scheduler. Foreign CPU load stayed below 1.4 cores in every window.
py-spy hung for 18 minutes on the traced MTP scheduler at batch 8 during the host-gap run; the driver now waits at most the window plus 20 s and then kills the sampler (that window's py-spy output was lost).
windows/{plain,mtp}_none.jsonl hold three no-profiler windows per
configuration (the only throughput numbers here); tables.md separates them
from nsys-attached and host-trace windows. check_labels.py confirms, for every
complete plain and MTP target replay, the per-step GEMM counts and kernel
configurations the model's structure implies. The README documents the plain
traces' producing state and the MTP perturbation measured against the
no-profiler cycle.
|
Verdict: APPROVE This re-review covers head 0aec3e0 (86 behind main; a trial merge into main is clean and pre-commit passes on the merged code). All four blocking items from my review at 7e8a257, and both Codex P1s, are resolved.
What I reran (CPU, no GPU):
Suggestions (not blocking):
|
…n byte arithmetic With PR #13 merged, bandwidth, kernel attribution and the MTP idle share cite evidence/profiles. README section 2b derives the MTP cycle at c = 128 from bench's tuning throughput and shows that snapshot-free verification beyond ReplaySSM-spec is worth ~4% of the cycle, while the cycle is 2-2.7x the sum of its parts.
Profiles of SGLang serving Qwen3.5-4B on the GH200 in the production configuration (CUDA graphs, overlap scheduler, FlashInfer attention, greedy), for plain decode at B = 1, 8, 32, 128 and native-MTP speculation at B = 1, 8, 32: per-step attribution, the LM-head baseline microbenchmark, the measured HBM bandwidth, a bytes-per-step model, the host functions behind MTP's idle time, and unprofiled throughput baselines. This answers H1 and gives the first ranked list of stack-wide bottlenecks.
evidence/profiles/README.mdhas the findings, the command behind every file and the caveats.Findings (all in
evidence/profiles/)torch.matmul-> cuBLASnvjet_sm90_tst_*with BF16 logits, an in-graph FP32 copy, and an eagertorch.argmax(plain and verify) or SGLang's Triton top-1 (MTP drafts). The GEMM runs at 93-95% of the read peak up to M = 32 (354.5 us at M = 1), so a kernel reading the same bytes cannot gain much; at M >= 64 the FP32 copy and argmax add 22-50%.eagle_prepare_for_verify>load_batch> FlashInferplan, 1.2-1.5 ms per cycle) and the draft'skv_indptrcopy (0.5 ms).Deliberately deferred to a follow-up PR
These scripts are in this PR but have not produced committed outputs yet; their runs are queued in the GPU lock: the plain traces regenerated with the committed code (the README documents the producing state of the current ones; their eager records are complete),
gdn_kernel_bench.json,ncu_key_kernels.json,microbench_clocks.json(with the cuBLAS API trace), the eager-run GEMM-label validation against module NVTX ranges, the/start_profilecomparison, the graph-level-trace calibration of MTP idle time, and the DFlash attribution for the drafter workstream.Testing and review
pre-commit runon the changed files passes (ruff, mypy after mergingmain, codespell, shellcheck). Early commits usedSKIP=mypywhilemainhad 9 unrelated mypy errors; they are fixed onmain.attribution/plain_bs{1,128}andtables.mdbyte for byte from the raw traces.label_structure_check.jsonconfirms the GEMM labels against the model's per-step structure in every complete plain and MTP replay; every committed trace has a kernel record for every eager launch.nvtx==0.2.16into~/sglang/.venv(uv) for the host-function trace; py-spy and ncu run undersudobecause ofptrace_scope=1and admin-only GPU counters.