Repository navigation
Appendix E: backbone GEMM and RMSNorm microbenchmarks (#91) - #129
Conversation
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: df5c1aa5eb
ℹ️ 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".
|
|
||
| \paragraph{Backbone GEMMs and RMSNorm} The weight GEMMs' time above the head GEMM's bandwidth and the 65 RMSNorm launches are the fourth and seventh rows of Table~\ref{tab:profile-ranked}. Isolated microbenchmarks under CUDA graphs locate the slow GEMMs and test faster kernels that read the same BF16 weights~\ev{backbone}. Each timed call multiplies every layer's own checkpoint weight by its own input, so the weights stream from HBM as in the model; times are medians of 30 timed replays in one exclusive session, include any split-$K$ reduction and the gap to the next kernel, and are compared only within these files. The three projections with 2,560 outputs, the GDN and attention output projections and the MLP down-projection, run as split-$K$ kernels followed by a reduction kernel up to $M=32$ (128 for the down-projection) and reach 49\% (output projections) and 68\% (down-projection) of the measured 3.79~TB/s read bandwidth~\ev{profile-bw} at $M=1$, against 80--87\% for the large projections; disabling cuBLAS's reduced-precision reduction changes neither their time nor any output bit. At $M=1$ SGLang's own Hopper GEMV is the fastest kernel for every projection: it takes 0.77 of cuBLAS's time on the output projections (8.57 against 11.20~\textmu s per call for the GDN one), 0.91 on the down-projection, 0.95--0.97 on the other large projections and 0.51 on the 64-row GDN projection, which cuBLAS runs on a single block. At the pin it is unreachable: \code{-{}-bf16-gemm-backend gemv} loads it, but the unquantized linear layers call the dispatcher only for another backend (code reading; patch \path{engine/sglang/patches/backbone/0001} lets them reach it). At $M=2$--16 a Triton skinny GEMM pays only with programmatic dependent launch, at 0.88--0.92 of cuBLAS's time on the output projections and 0.96--0.98 on the GDN input and MLP projections, with no gain on the attention QKV projection; in this benchmark each call overlaps its successor, which in the model is a different kernel. From $M=64$ cuBLAS, or a cuBLASLt algorithm within 2--5\% of it, is best, except on the down-projection, where PyTorch's cuBLASLt choice takes 0.92 of the time. None of these routes leaves the target's arithmetic unchanged in general: the GEMV and the Triton kernel are bitwise equal to cuBLAS on 99.6 to 100\% of output elements, and the cuBLASLt choice differs from it on the down-projection from $M=16$, while all arms lie within the same distance of a float64 product. If every projection ran at its best isolated time, a plain step's backbone GEMMs would take 197~\textmu s less at $M=1$, at most 5.7\% of the 3,460~\textmu s step, and 92 to 120~\textmu s less at $M=2$--16 (derived from the microbenchmarks, not a served result). | ||
|
|
||
| SGLang's packed GDN input projection, one GEMM over the concatenated $12{,}352\times2{,}560$ weight instead of a $12{,}288$-row and a 64-row GEMM, gives every output element bitwise equal to the separate pair's at each tested $M$, the powers of two from 1 to 1,024, with the real weights of all 24 GDN layers and random BF16 inputs, under cuBLAS 13.1 on this GPU~\ev{backbone}. That is a statement about one isolated GEMM, not about served tokens. Against the stock pair, which runs the 64-row GEMM on a side stream, it is as fast up to $M=16$, 3\% slower at 32 and 5 to 13\% faster from 64. The stock fused add-RMSNorm takes 1.47~\textmu s per launch at $M=1$ and 2.0 to 2.2~\textmu s at $M=4$--32 inside a graph of 64 norms. Folding the norm and the SiLU into the next GEMM's prologue reproduces the stock norm bit for bit up to $M=32$ (one element in $10^5$ is one BF16 step away at $M=64$ and 128) and the stock SiLU bit for bit, but as built it makes each layer 13 to 70~\textmu s slower in MLP and GDN layer skeletons, far more than the two launches of about 1.5 to 2~\textmu s that it removes. In the same skeletons the Triton kernel with programmatic dependent launch saves 1.2 to 2.3~\textmu s per MLP layer and 1.4 to 1.8~\textmu s per GDN layer up to $M=16$, except the GDN layer at $M=4$, and loses at 32. The engine patches that route each projection by a table are committed and off by default; the exactness class of each switch, from greedy outputs against stock plain decoding compared with the noise floor, and paired serving runs against the tuned arms are \pend{backbone-served}. |
There was a problem hiding this comment.
Qualify the folding slowdown to M ≤ 32
For the measured M=64 and M=128 cases, the committed skeleton table shows much larger regressions than 70 µs: MLP folding adds about 149 and 543 µs per layer, while GDN folding adds about 82 and 160 µs. Because this sentence also discusses the M=64/128 exactness results, the unqualified 13–70 µs range misreports the measured timing results; either limit the range explicitly to M≤32 or include the larger losses (and update the repeated range below).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f7ee32a (head 24e33ae). I scoped the loss by M range in all three places: the paragraph, the levers-table row and "What did not work". It is now 12-90 us per layer up to M = 32, with or without PDL (the PDL variant reaches 90 us at M = 16), and 82-543 us at M = 64 and 128 (tables.md, layer skeletons: MLP +149/+543, GDN +82/+160).
|
|
||
| The host gap of the speculative cycle at low concurrency (Appendix~\ref{app:profile}) has a configuration-level lever~\ev{host-levers}. With Triton attention for the target and the draft, neither attention backend needs host-side sequence lengths, so the overlap scheduler stops copying them to the host and FlashInfer's planning leaves the cycle. MTP with three steps then gains $1.18\times$ in per-request rate at concurrency 1 and $1.14\times$ in throughput at concurrency 4, with unchanged accepted length; Triton attention for the draft alone gains $1.08\times$ and $1.06\times$ (single runs). The draft-only change is exact, because it changes only which tokens are proposed. Triton attention for the target changes the target's arithmetic, and its class is \pend{bench-equality}. SGLang's overlapped planning stream fails at the first verify on this hybrid model, whose GDN backend does not implement a call the stream needs. | ||
|
|
||
| \paragraph{Backbone GEMMs and RMSNorm} The weight GEMMs' time above the head GEMM's bandwidth and the 65 RMSNorm launches are the fourth and seventh rows of Table~\ref{tab:profile-ranked}. Isolated microbenchmarks under CUDA graphs locate the slow GEMMs and test faster kernels that read the same BF16 weights~\ev{backbone}. Each timed call multiplies every layer's own checkpoint weight by its own input, so the weights stream from HBM as in the model; times are medians of 30 timed replays in one exclusive session, include any split-$K$ reduction and the gap to the next kernel, and are compared only within these files. The three projections with 2,560 outputs, the GDN and attention output projections and the MLP down-projection, run as split-$K$ kernels followed by a reduction kernel up to $M=32$ (128 for the down-projection) and reach 49\% (output projections) and 68\% (down-projection) of the measured 3.79~TB/s read bandwidth~\ev{profile-bw} at $M=1$, against 80--87\% for the large projections; disabling cuBLAS's reduced-precision reduction changes neither their time nor any output bit. At $M=1$ SGLang's own Hopper GEMV is the fastest kernel for every projection: it takes 0.77 of cuBLAS's time on the output projections (8.57 against 11.20~\textmu s per call for the GDN one), 0.91 on the down-projection, 0.95--0.97 on the other large projections and 0.51 on the 64-row GDN projection, which cuBLAS runs on a single block. At the pin it is unreachable: \code{-{}-bf16-gemm-backend gemv} loads it, but the unquantized linear layers call the dispatcher only for another backend (code reading; patch \path{engine/sglang/patches/backbone/0001} lets them reach it). At $M=2$--16 a Triton skinny GEMM pays only with programmatic dependent launch, at 0.88--0.92 of cuBLAS's time on the output projections and 0.96--0.98 on the GDN input and MLP projections, with no gain on the attention QKV projection; in this benchmark each call overlaps its successor, which in the model is a different kernel. From $M=64$ cuBLAS, or a cuBLASLt algorithm within 2--5\% of it, is best, except on the down-projection, where PyTorch's cuBLASLt choice takes 0.92 of the time. None of these routes leaves the target's arithmetic unchanged in general: the GEMV and the Triton kernel are bitwise equal to cuBLAS on 99.6 to 100\% of output elements, and the cuBLASLt choice differs from it on the down-projection from $M=16$, while all arms lie within the same distance of a float64 product. If every projection ran at its best isolated time, a plain step's backbone GEMMs would take 197~\textmu s less at $M=1$, at most 5.7\% of the 3,460~\textmu s step, and 92 to 120~\textmu s less at $M=2$--16 (derived from the microbenchmarks, not a served result). |
There was a problem hiding this comment.
Include the slow MLP-down Triton cases in the range
At M=2 and M=4, the PDL Triton MLP down-projection takes 0.993 and 0.986 of cuBLAS time, respectively, rather than falling in the stated 0.96–0.98 range. The approximately 0.98 alternatives in those cells are cuBLASLt algorithms, so attributing that entire range to Triton overstates the Triton route's gain at the small batch sizes; distinguish those algorithms or report the Triton range as roughly 0.96–0.99.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
|
Verdict: REQUEST CHANGES Review of the exact head df5c1aa: b9c8ae1 (Appendix E, register, H6 and axes rows) plus the rebuilt PDF. What I verified
Blocking: both Codex P2s on df5c1aa are valid and unanswered.
Suggestion (non-blocking). "Times are medians of 30 timed replays": each of the 30 timings spans 10 graph replays ( |
Fold in evidence/backbone/ as isolated microbenchmarks: what cuBLAS runs per projection, the faster kernels reading the same weights (Hopper GEMV at M = 1, Triton with PDL at M = 2-16, cuBLASLt picks) and their bitwise agreement with cuBLAS, the packed GDN input projection (bitwise equal per GEMM at power-of-two M from 1 to 1024), the norm and SiLU prologues and the layer skeletons, where folding is 13-70 us per layer slower as built. The derived 197 us (at most 5.7% of a plain step at M = 1) is labelled as derived from isolated timings. New register entry backbone, a Backbone GEMMs row in the levers table, the folded norm under what did not work, the H6 status row, and the backbone and repair patch series in the pins table. Served exactness and paired serving runs are pending (new entry backbone-served).
…N input and MLP projections Codex P2s on #129: the 13-70 us folding loss holds only up to M = 32 without PDL; with PDL it reaches 90 us at M = 16, and at M = 64 and 128 the folded MLP and GDN skeletons are 82-543 us slower (tables.md, layer skeletons). The Triton+PDL kernel takes 0.96-0.99 of cuBLAS's time on the GDN input and MLP projections at M = 2-16 (MLP down 0.993 and 0.986 at M = 2 and 4), not 0.96-0.98.
df5c1aa to
24e33ae
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…N input and MLP projections Codex P2s on #129: the 13-70 us folding loss holds only up to M = 32 without PDL; with PDL it reaches 90 us at M = 16, and at M = 64 and 128 the folded MLP and GDN skeletons are 82-543 us slower (tables.md, layer skeletons). The Triton+PDL kernel takes 0.96-0.99 of cuBLAS's time on the GDN input and MLP projections at M = 2-16 (MLP down 0.993 and 0.986 at M = 2 and 4), not 0.96-0.98.
|
Verdict: APPROVE Re-review on the exact head 24e33ae: rebased on main, with #121's appendix changes from main underneath. The PR's own new commits are f7ee32a, e4ac110 and the PDF.
Everything else from my review of df5c1aa stands. |
Folds #91 (
evidence/backbone/) into Appendix E as isolated microbenchmarks. Every number is from the committed README,tables.mdor the four JSON files. The served exactness class and the paired serving runs are pending under a new entry, D22backbone-served.What the appendix now says
New paragraphs in E.6 "Levers by axis", before Table
tab:axes:Also:
tab:axes(class pending);backbone(the four JSON files,tables.md, README,hostload/, and the patch series as code; produced bygemm_bench.py,summarize.pyandmake_table.py);repair/andbackbone/patch series, which were missing.Checks
latexmk -pdf: 0 warnings. The main text ends on p10 and References start on p11 (80 pages; 78 on main).scripts/check_paper_references.pyis clean.This PR and #121 both touch
app_register.texandpaper.pdf. Whichever merges second gets rebased and its PDF rebuilt.