Repository navigation
[Feat] [VR200] glm5_3: Serve the TP4 kernel units on Rubin (SM107) - #75
Conversation
1bfdfca to
9674c6b
Compare
On SM107 every TP4 kernel unit declined (ll.attention, ll.hops, ll.moe and ll.sparse_mla_fd gated on SM103 with 152 SMs, ll.gemm on GB300's plan only, and the TP4 draft required an SM103 GPU), so a TP4 build served no width and stopped. The kernels are the same sources on both GPUs: the JIT units compile for the device and the CuTe DSL kernels for its arch. - ll/device.py: the GPUs the units serve, GB300 (plans measured) and Rubin (plans derived from GB300's); each unit logs once when its plan is derived. - ll.attention, ll.hops, ll.moe and the TP4 draft accept both GPUs. - ll.sparse_mla_fd: on Rubin the row caps are GB300's cut to the clusters the device co-schedules, queried at build; a width Rubin cannot launch in one wave declines to TRTLLM-Gen instead of stopping the server. GB300 keeps its fail-stop on the same facts. - ll.gemm: one plan per GPU. Rubin runs GB300's ranges with every split-K tactic re-checked for one wave of 212 SMs, and keeps SGLang's router GEMM. The split-K source on SM107 is the vendored copy, since FlashInfer's explicit tactics serve SM100 / SM103. - The vendored split-K reserves the device's opt-in shared memory instead of CuTe DSL's SM100 constant (the same 232448 bytes on both GPUs). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rubin composes every TP4 width and draft graph as GB300 does, other GPUs take no unit, the TP4 draft admits SM107, the per-GPU GEMM plans (no router split-K on Rubin, every split-K tactic within one wave of 212 SMs), the split-K source on SM107, the sparse MLA's declines on Rubin against GB300's fail-stop, and the split-K shared memory read from the device. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The TP4 all-reduce + residual + RMSNorm hop (ll.hops) squared each bf16 element in bf16 before summing in FP32 on its one-shot form, as FlashInfer 0.7.1's MNNVL one-shot did. FlashInfer 0.7.3 squares in FP32 (flashinfer-ai/flashinfer#6818), as its two-shot and our two-shot already did, so on the FlashInfer that SGLang pins (0.7.3 and later) the one-shot hop was no longer bit-identical to FlashInfer's one-shot, and its norm output was up to 1 bf16 ulp off the stock path's on some elements. The one-shot now converts each element to FP32 and squares it there. With the same launch geometry it is bit-identical to FlashInfer 0.7.3's one-shot again; every other step of the hop is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
9674c6b to
76fb700
Compare
|
Thanks for bringing the TP4 units to Rubin. Two points from AGENTS.md, and one request about E2E tests:
|
…in's in sm107/ The Rubin plans, caps and device selection moved out of glm5_3/ll, so ll/ holds GB300's code only and no longer checks the architecture (AGENTS.md: architecture directories do not overlap). - ll/target.py (replaces ll/device.py): Target, the GPU the ll.* units run on and the plans they run there (GEMM plan, SM count, GPCs, whether FlashInfer's explicit split-K tactics run, measured or derived), and GB300's, measured. - sm107/tp4.py: RUBIN, Rubin's target: GB300's GEMM plan without the router's split-K, 212 SMs, 16 GPCs, the vendored split-K, derived caps, and the notes each unit logs once. - targets.py: select(), the one place that maps an architecture to a target. Profile.from_args calls it once and the profile carries the result (Profile.target); the units read it from there. - ll.attention / ll.hops / ll.moe / ll.sparse_mla_fd decline when the profile has no target, instead of comparing the compute capability; ll.gemm and ll.build_linear take the target instead of (sm, sms); gemm_plan.PLANS, RUBIN_PLAN, device_plan and device_gpcs are gone. - The vendored split-K reserves CuTe DSL's sm_100 shared memory again, as on main: 232,448 bytes, which is also Rubin's opt-in. Same plans, caps and kernels on both GPUs as before. Tests: the selection happens once per profile, no ll/ file names SM107 or imports sm107/, and Rubin's GEMM plan is GB300's without the router. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since sgl-project#19 the GLM-5.3 spec checks its environment per TP size (pinned_reasons) instead of declaring it in Requirements.env, so SGLang's FLAG_SETS_ENV no longer sets SGLANG_ENABLE_EMBED_REPLICATION with --enable-nvidia-megakernel, and without it the server stops at startup, naming it. The docs still said the flag turns it on. Say that slot draft needs it set to 1, as benchmark/README.md already does, and add it to the launch example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the review. Pushed 194be37 (refactor) and af0936c (docs) on top of the three earlier commits (no history rewrite). 1. Architecture directories.
2. Rerun on this head with current SGLang
3. E2E tests. They are in a separate draft PR, #92, so that the 🤖 Generated with Claude Code |
YAMY1234
left a comment
There was a problem hiding this comment.
Thanks, all three are addressed. LGTM; please do open the small follow-up that restores SGLANG_ENABLE_EMBED_REPLICATION automatically, since on main a GLM-5.3 server with the draft doesn't start without it.
|
Opened #95 for the |
Motivation
#24 serves GLM-5.3 / GLM-5.2 NVFP4 at TP4 on one GB300 tray, including the decode role of a PD-disaggregated deployment. On Rubin (SM107), a TP4 build serves no width and stops, because every TP4 kernel unit is gated on SM103 with 152 SMs. One Rubin node (4 GPUs) is the TP4 decode worker of mid-latency PD layouts. The units' kernels are the same sources on both GPUs (JIT CUDA compiled for the device, CuTe DSL compiled for its arch); only the gates and the plans tied to GB300's SM count stop them.
Modifications
glm5_3/ll/keeps GB300's code and never checks the architecture.glm5_3/ll/target.py(new):Target, the GPU thell.*units run on and the plans they run there (GEMM plan, SM count, GPCs, whether FlashInfer's explicit split-K tactics run, measured or derived caps), andGB300, the measured one.glm5_3/sm107/tp4.py(new):RUBIN, Rubin's plans, derived from GB300's. Each unit logs once that its plan is derived.glm5_3/targets.py(new):select(), the one place that maps an architecture to a target.Profile.from_argscalls it once per build and the profile carries the result (Profile.target). Any other GPU has no target and declines every unit, as before.ll.attention,ll.hops,ll.moeandll.sparse_mla_fddecline when the profile has no target, instead of comparing the compute capability. The TP4 draft (draft_units.check_draft_config) accepts a GPU that has a target.ll.sparse_mla_fd: on a derived target (Rubin) the row caps are GB300's, cut to the 16-CTA clusters the device co-schedules (queried at build). A width Rubin cannot launch in one wave declines to TRTLLM-Gen instead of stopping the server. GB300 keeps its fail-stop.ll.gemm: runs the target's plan (ll.build_linear(..., target=)). Rubin's plan is GB300's ranges, with every split-K tactic re-checked for one wave of 212 SMs.docs/models/glm5_3.md/ spec docstring: TP4 on one GB300 tray or one Rubin node. The docs also say to setSGLANG_ENABLE_EMBED_REPLICATION=1for slotdraft: since [Feat] [RUBIN] glm5_3/sm107: GLM-5.2 TP16 bs=1 megakernels and EAGLE v2 step CUDA graph (spec_step) #19 the flag no longer sets it.glm5_3/spec.pystill sends TP16 toglm5_3/sm107by TP size; the TP4 units serve SM107 at TP4 only, and the TP16 gates are unchanged.ll.hopsone-shot squares in FP32 (its own commit, both GPUs). The hop's RMSNorm squared each bf16 element in bf16, as FlashInfer 0.7.1's MNNVL one-shot did. FlashInfer 0.7.3 squares in FP32 (fix(comm): square in fp32 in MNNVL one-shot fused allreduce+RMSNorm flashinfer-ai/flashinfer#6818), so on the FlashInfer that SGLang pins (0.7.3 and later) the hop was up to 1 ulp off FlashInfer's one-shot on some elements. The one-shot now squares in FP32 and is bit-identical to FlashInfer's one-shot again. The two-shot already squared in FP32.test/unit/test_glm5_3_ll_rubin.py(new, CPU), checking that:glm5_3/ll/file names SM107 or importsglm5_3/sm107;Apart from the hop's FP32 squares, no kernel source changes. GB300 takes the same code path as before: the same plan objects and the same gates.
Accuracy Tests
GSM8K, 5-shot, greedy, 512 tokens, MTP 5/1/6 (EAGLE top-1, natural acceptance), 2 requests in flight, TP4.
Rubin, one node, aggregated, full GSM8K test set (1,319 questions). Each run is one pass over the test set. A server start runs it twice, the second pass in a shuffled submission order. Greedy outputs are not reproducible from run to run here (2 requests in flight with MTP), so each setup has several runs:
cutedsl(the low-latency recipe's)auto(FlashInfer MNNVL)auto(the plugin refusescutedsl)auto): −0.4 pp in the same job (paired Cochran–Mantel–Haenszel test stratified by question, p = 0.25).cutedsl): −1.4 pp in the same job (p = 0.0001).cutedsltoauto(5 vs 4 runs, p = 0.001).auto. Its hops are bit-identical to FlashInfer's MNNVL one-shot and two-shot, which round the all-reduced sum to BF16 and then add the residual in BF16.cutedsladds the rank sum and the residual in FP32 and rounds once.ll.moe.nvfp4off, −0.15 pp (p = 0.52).cutedslin the same job (p = 0.12), and −0.1 pp against stockauto.cutedsl's, on GB300 too, so it is left for a separate change.NVIDIA megakernel: activewith the TP4 units (ll.attention,ll.hops,ll.moe.nvfp4,ll.sparse_mla_fd) and the TP4 NextN draft. No tracebacks in any run.GB300, GSM8K-200 (same image and settings; one run per arm, before the FP32-squares change):
cutedsl)Rerun on this head with current SGLang
main(stock nightly images, no SGLang patches, the plugin installed from this branch). The nightlies from 2026-11-22 on require megakernel plugin API version 3, which this repository'smaindoes not declare yet, so these use the 2026-11-21 nightlies, which contain sgl-project/sglang#46210. Same GSM8K protocol, full test set. Both megakernel runs setSGLANG_ENABLE_EMBED_REPLICATION=1: since #19 the GLM-5.3 spec checks its environment per TP size instead of inRequirements.env, so SGLang'sFLAG_SETS_ENVno longer sets it (the docs now say so).cutedsl0.9484 (AL 4.01): −0.4 pp, 21 vs 26 discordant questions (exact McNemar p = 0.56). TP0–3 active for target and draft, with the same plans and kernels as before the refactor; 0 tracebacks.GLM-5.3 kernel tests. These are not in this repository yet; #24 notes that they follow in a separate PR. They were run from that set.
ll_hops(6 tests) passes: the one-shot is bit-identical to FlashInfer's at every one-shot row count (1–36), and so are the two-shot and the NVFP4 hop at every row count.ll_moe(4) passes: the layer is bit-identical to the stock layer on the hop's FP4 input and at the P10 skip rows.draft_eh_proj(2) passes.ll_hopsandll_moefailed only on these bitwise comparisons; the hop stayed within 1 ulp of its reference.draft_rowselect: it callscan_use_tiny_gemm(max_m=), which this SGLang does not have.ll_gemmpasses: 39 passed, 29 skipped (the router's cases, which Rubin's plan leaves to SGLang). For this run, its device gate was changed from GB300-only to the per-GPU plans; that change goes with the kernel tests.ll_hopsandll_moefail on the FlashInfer 0.7.3 squares drift, anddraft_rowselectfails as on Rubin. These were not rerun with the FP32 squares.Unit tests (CPU) on this branch: see Checklist.
Speed Tests and Profiling
Rubin, served end to end (agentic coding workload, 60-minute profile).
NVIDIA megakernel: activefor the target and the NextN draft. Each worker logs the draft as armed, and no setup is refused. There were 0 KV-transfer failures.Rubin, one node, aggregated (step sandwich).
--enable-nvidia-megakernel,--moe-runner-backend flashinfer_trtllm(stock:auto, which resolves to the same runner), and no--flashinfer-allreduce-fusion-backend cutedsl(stock keeps it).Units on Rubin, µs per call.
Sparse MLA flash decode (16 heads, per layer of a 78-layer chain in one CUDA graph, ours / TRTLLM-Gen + bmm) at 8k context, with 64k within 0.2 µs:
At 12 rows the one-tile kernel needs two waves and loses on its own (10.76 vs 10.22 µs bare). That is the width the plan hands to TRTLLM-Gen.
GEMMs (plan kernel minus SGLang's GEMM, chain context, weights streamed from HBM) at 1–24 rows:
wk_weights_projsplit-K: −0.7 to −1.8.dense_down/eh_projTGV: −0.3 to −2.2.o_proj: ±0.03.lm_headTGV: −3.2 at 1 row. At 2–16 rows SGLang's GEMM is 0.9–1.7 µs faster per call. Rubin's plan keeps GB300'slm_headrange (TGV at every width), as served in all the runs above; moving 2–16 rows to SGLang's GEMM on Rubin is a possible follow-up.Checklist
pre-commit run --all-filespasses.test/cover the change:test/unit/test_glm5_3_ll_rubin.py. Unit tests on CPU,python3 -m pytest test/unitwith SGLang atcf6133a(the commitunit-test.ymlpins): 1450 passed, 59 skipped on this branch (main76ab864: 1404 passed, 59 skipped); the 46 tests intest_glm5_3_ll_rubin.pypass. The GLM-5.3 kernel tests are not in the repository yet (see Accuracy Tests).043cfc4) with [Feat] [NVIDIA] megakernels: DSA / MLA binding view, EAGLE draft capture checks, early draft embedding sharing sglang#46210 ported onto it (atf11893053d, before it merged).main(d529c38,1185681,6d518e5ond5eb692), plus a local commit that pins the mirrored SGLang bodies for that SGLang tree. That pin commit is not part of this PR. The rebases changed no code: the one onto [Feat] [RUBIN] glm5_3/sm107: GLM-5.2 TP16 bs=1 megakernels and EAGLE v2 step CUDA graph (spec_step) #19 merged a comment inspec.pyand moved the README lines todocs/models/glm5_3.md. Since then, the only changes are comments, a docstring and the removal of the unused constantll.attention.SM.test/e2e/ci_models.yaml). GB300 TP4 was rerun with the FP32 squares on one tray (aggregated, see Accuracy Tests); the two-tray PD layout was not..github/CODEOWNERSthat names its owner: not applicable (no new model).🤖 Generated with Claude Code