mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[GH-ISSUE #23] Two-GPU GLM pack: ~11 ms fixed device time per call and a 9.2 ms host wait dominate the token #10
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#10
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?
Originally created by @ZackO2o on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/23
Batching / speculative-decoding off: decode is 4.1x faster than the streaming path on the same box
Context: I run a 2x 64 GB Ampere-class machine (GA100, 128 GB total, PCIe Gen2 x4) with
GLM-5.3-Flash-Maya-Mfully resident in VRAM. Serve mode and--bench-style direct engineinvocation give very different numbers on identical settings, and the gap looks like it is in how
work is enqueued rather than in the model.
What I measured
Direct engine (server's own config,
--spec 6 --native <shard> --kv int8, 32K context), 400generated tokens, thinking off:
The last line is the one that puzzles me:
CUDA1 DEVICEstays at ~11 ms per call whether or notspeculation is on, whether the two GPUs are both visible, and regardless of the KV dtype. For 21
layers of a 2-bit-expert MoE that is ~520 us/layer, while the expert bytes alone would be
8 experts x 8.98 MB = 71.8 MBper layer — ~48 us at the card's nominal bandwidth. So the deviceside is running at roughly 9% of its memory bandwidth, and
wait tail(the host-side wait beforethe next layer's work can be enqueued) is the single largest term.
Why I am filing this
This looks like the same shape as another data point in your issue list / linked repos: a machine
where
expert copies 12.4 ms + expert kernels 0.2 ms + dense/routers/sync 37.2 msper token, i.e.the ceiling is the dense/sync path, not the expert stream. Two questions:
does it look like the expert dequantize/dispatch path is serialising?
and 24..45 on the other being enqueued so that
wait tailoverlaps the other card's compute)?I tried
--stream-token(it raised acceptance on short prompts but leftCUDA1 DEVICEat11.25 ms) and
--adapt-every, but I am not sure I am using them as intended.If it would help, I can produce a
STRATA_GLM_TIMING=1trace with the per-phase numbers at a fixedprompt and seed, so the two sides of the comparison are exactly reproducible.
@mw00 commented on GitHub (Oct 8, 2026):
Thanks for the careful numbers. Your reading is right, and it's the main limit once every expert is in VRAM.
The ~11 ms per call is expected today. It isn't the experts. A decode step on a half runs, per layer:
That's a few dozen short, dependent kernels, each a few to a few tens of µs. So the time is launch and latency, not bandwidth: ~0.5 ms a layer on a V100 as on your GA100, and the bytes alone would take a tenth of that. We see the same ~11 ms of compute per half per token on 2x V100.
The
wait tailis the critical path, not idle time. The two-GPU decode is already pipelined: while the tail finishes position q+1 (its layers, the MTP draft block and the output head), the head speculatively runs position q+2. The host waits on the tail because the tail carries the most work. Two things you can try now:STRATA_GLM_SPLIT=25or26puts more layers on the head to balance the halves (the default is the midpoint + 2);What will move it: capturing each half's per-token work as a CUDA graph (one launch instead of dozens) and fusing the small kernels (norm + quantize, router + top-k, the shared expert into the routed launch). That's now the top engine item on our list, because your machine and every fully resident setup is bound by exactly this. If you'd like to work on it, a PR is very welcome: see CONTRIBUTING.md. Your box, with everything in VRAM, is the ideal test bench for it.
(
--spec,--nativeand--stream-tokenare Strata's engine flags. The GLM path doesn't use them, which is whyCUDA1 DEVICEdidn't move.)@ZackO2o commented on GitHub (Oct 9, 2026):
Follow-up on v1.0.16, as you suggested. Two things you can use, and one question.
Same machine as #22: 2x CMP 170HX (64 GB each, PCIe Gen2 x4, 74 SMs, driver 610.43.03), Maya-M with every
expert in VRAM, 32K context, Xeon E5-2690 v4, 91 GB RAM.
1.
STRATA_GLM_SPLIT=25is the better split here — confirmed, thank youYou were right that 25 balances the halves. Same harness (three questions of 256 tokens, greedy, thinking
off, one warm-up first), same machine, one boot per configuration, new build from source at v1.0.16 with
--native+--kv int8+--spec 6:So v1.0.6 -> v1.0.16 is +11.4% on mean decode at split 25, and most of it is the acceptance rate moving
from 65-80% to 86-97%. The per-call device time barely moved (11.12 -> 11.00 ms on the tail half), which is
what you said to expect. 26 has the lowest device time of the three (10.43 ms on the tail) but a lower
mean than 25.
2. The CPU lane is not idle here, and switching it off costs 12%
The
glm fast:lines at start:That PCIe figure is the interesting one on a Gen2 x4 link: 9.4 MB in ~5.5 ms is about 1.7 GB/s, which is
within 15% of what a Gen2 x4 link can do, so the measurement is honest. It also means the CPU lane takes
every RAM-tier expert it is offered.
STRATA_GLM_CPU_LANE=0on the same build and split:ram fetchespromotions=0)With the lane off, experts leave VRAM and have to be brought back every token over that 1.7 GB/s link;
decode goes 14.9 -> 18.9-22.9 ms/token. Since the reports in the README describe the lane as something that
helps when experts don't fit, it may be worth a line in the docs that it is not a no-op on a fully
resident setup either — it is what keeps the last few promotions off the PCIe path. (I can send the full
glm stat:lines if useful.)3. Question: what is the smallest piece of the graph work that would be a useful PR?
You mentioned capturing each half's per-token work as a CUDA graph and fusing the small kernels as the top
engine item. I have a sm_80 box with every expert in VRAM, so I am in the target case, and I would like to
work on it rather than just report.
My question is where to start so the PR is useful to you and not a rewrite I cannot validate:
first PR, or the graph capture side? The fused kernels look like they can be measured one at a time
on the existing harness; a graph capture for a half's step looks harder to land incrementally.
graph per layer, or one per half per token? A per-token graph over the tail half is the shape I would
guess, but I would rather build the one you can review.
I have the harness and the before/after discipline from CONTRIBUTING.md in place (same session, three
questions, and I keep the
glm spec/glm statlines plus the per-callDEVICEnumbers, because theacceptance rate moves around enough that the wall-clock alone is misleading).
Thanks again for the earlier answer — the split advice and the note about
wait tailbeing the criticalpath rather than idle time both changed what I was optimising for.
@ZackO2o commented on GitHub (Oct 9, 2026):
One more measurement while I wait — I profiled the decode step with
nsyson this machine so I couldsize the three fusions you named before starting. The answer surprised me: on a fully resident
--nativesetup most of them are already paid for, and the GEMV launches are where the time is. If myreading is wrong, telling me now saves a wasted PR.
The step, measured
Build from source at v1.0.16, split 25,
--native+--kv int8+--spec 6, 32K context, Maya-M withevery expert in VRAM. Six answers x 60 tokens,
nsys--trace=cuda.glm_link_wakeis excluded (twocalls of 1.5 s at start, not per token).
659 kernel launches per token, average 30 us. Per layer that is about 14.6 launches, which lines up
with the per-layer story you gave.
Sizing the three fusions you suggested
rms_q8_kernelmoe_route_kernel--nativepathI suspect these are sized for the tiered path (experts leaving VRAM, the CPU lane, prefill) where they are
worth much more — I am not saying they are wrong in general, just that they are not what this box is paying
for.
rms_q8_kernelruns 2 times a token here, so fusing norm into quantize touches something that isalready ~free.
What this box is actually paying for
mv_kernel_t<14>(135.5/token, 8.84 ms, 42 %) andmv_kernelgeneric (87.5/token, 1.14 ms, 5.5 %) —223 small GEMV launches a token, 47.8 % of the GPU time between them. From
ncuon a couple of them,mv_kernel_t<14>reads 27-83 MB at 35-44 % of DRAM peak, so they are latency-bound rather thanbandwidth-bound, which matches your point that the bytes alone would take a tenth of the time.
So the two things I would actually work on, in this order:
graph (or just batched harder —
kMaxMvJobsis 8 and a layer issues severalmv()calls of 1-6 jobs),the launch count is the thing that moves. Simple experiment I already ran that supports this:
raising
MV_ROWSfrom 8 to 32 (blockDim 256 -> 1024) moved decode from 56.1 to 59.6 tok/s on the samesession, so these kernels respond to being given more work per launch.
hc3_kernel— 78.7 launches/token, 1.22 ms, 5.9 %. It wasn't in your list; is it fusable with aneighbour, or is it already at its floor?
The question
Given that, is graph capture over the per-layer small kernels the PR you want, or would you rather I
did the narrower "batch more GEMV jobs per launch" change first (
kMaxMvJobs/MV_ROWS/ grouping themv()call sites in a layer)? The second is a much smaller diff and I can measure it standalone; thefirst is the one that removes the launch latency you described.
Either way I will send before/after on this machine with the harness CONTRIBUTING.md asks for, and say if
the outputs change (they should not for a launch change; a graph capture may change the last bits the way
a different expert placement does).
If you have the branch or notes for this already, point me at them and I will extend that instead of
starting a parallel one.
@mw00 commented on GitHub (Oct 9, 2026):
Thank you, the profile settles it, and your reading is right. On a fully resident
--nativesetup the small GEMV launches are the cost, and the three fusions I named matter on the tiered path, not here.Please do the narrower change first: more GEMV work per launch (
kMaxMvJobs,MV_ROWS, grouping a layer'smv()calls).MV_ROWS8 -> 32 run (56.1 -> 59.6 tokens/s) is a good sign. Please also check it doesn't slow down older or smaller cards; we'll A/B it on 1x and 2x Tesla V100 before merging.Graph capture exists since v1.0.25 for one GPU:
STRATA_GLM_KDA_GRAPH=1, from #59, described indocs/GLM-KDA-GRAPHS.md. It replays the KDA decode layers. DSA layers, splits and MTP still run direct. Extending that infrastructure to your two-GPU spec path would be a later PR, best started from that code rather than a parallel one.hc3_kernelis already the third, fused version of the hyper-connection step. Merging it into its neighbouring norm might save part of its 1.2 ms, but that's worth less than the GEMV launches.Please rebase on v1.0.27 (it has
#39's synchronisation changes in the same file). Before/after with the CONTRIBUTING harness, plus a note on whether the tokens change, is exactly what we need.@mw00 commented on GitHub (Oct 12, 2026):
Closing this thread. The launch-overhead work you described is still welcome as a PR, rebased on v1.1.3, with the CONTRIBUTING harness before and after and a note on whether the tokens change.