Repository navigation
[Feat] [NVIDIA] muse_spark: Serve the Muse Spark Open kernels on GB300 (sm_103) - #42
Merged
Merged
Conversation
… step Registers MuseSparkForConditionalGeneration through the interface deepseek_v41 uses, scoped to what SGLang's binding dispatches today: the target-verify step, as SGLang captures it. The requirements are the values the measured configuration actually ran with -- NVFP4 KV with modelopt_fp4 weights, DFLASH speculative decoding, the FlashInfer TRT-LLM MoE runner with the FlashInfer all-to-all, trtllm_mha, sm_107 at TP4 -- so a setup that differs is refused rather than served by kernels that were never measured on it. build() offers no width yet, so a server started with --enable-nvidia-megakernel keeps running SGLang's own forward and logs that the spec covers no step. Each slot lands here one at a time with its own A/B against the stock forward. Two things this deliberately does not do. plan.py carries a per-width slot table whose entries are all width-independent, because no slot has a measured row bound yet and inventing one would imply a measurement that was never made. NUMERICS declares TOLERANCE with an empty map and a TODO, because the agreement with the stock forward has not been measured either; it has to be filled before this spec is offered to anyone. The model's prefill and extend kernels are not registered here: SGLang's binding dispatches decode and target-verify steps only, so a spec cannot declare coverage of a prefill step today. Co-authored-by: Rohan Varma <rohanv@nvidia.com>
Twenty components, each replacing one call inside SGLang's forward -- a norm, an attention call, a MoE finalize, a boundary reduction -- through sglang.srt.plugins.hook_registry, the same mechanism this repository already uses for its parity test hooks. This is deliberately not the shape deepseek_v41 uses. That spec replaces an entire decode step with a rewritten forward; these kernels are twenty separate optimizations at twenty points inside the stock forward, and there is no single step function to hand over. Writing one would be a rewrite of the model rather than a port of the kernels, and it would discard the only version of this code whose numbers have been measured. Every component is opt-in and default off, so a server that sets no MUSE_VR_* switch runs stock SGLang; registration failures are recorded and leave SGLang stock rather than taking the server down. The order of COMPONENTS is load-bearing -- several hook the same call and must wrap each other in a fixed order, which the comments give. Carried with them: the kernels under components/csrc (57 .cuh, 1 .cu), their Python entry points under components/ops, and bed/sgl_compat, which pin the SGLang sources each component hooks by sha256 so a moved source makes a component step aside instead of engaging against code it was not written for. The spec from the previous commit still offers no width; it stays as the registration point and as the place the step-shaped slots will land if the binding later dispatches them. Co-authored-by: Rohan Varma <rohanv@nvidia.com>
… warp header override
The first commit carried twenty of the plugin's forty-five opt-in components.
This brings the rest of those that belong upstream; the four instruments
(graph_audit, teacher_force, draft_probe, kv_evict_probe) stay out, since they
validate a run and are never served.
Added, by group:
NVFP4 KV nvfp4_kv, kv4_dec, kv_draftwin, kv_hostbook, kv_accounting, swa_hostsplit
MoE moe_ld, bf16_ldw, moe_tail, unorm_boundary, fin2, hb0_rr, mid_rs
GEMM gemm_pick, gemm_lt
Sampling spec_sample_split, softmax_split, sampling_graph, draft_kv_append,
verify_topk_sample, ctx_proj_overlap
Prefill sp_gate, prefill_attn, sb_lite, dflash_prefill_async
plus their support modules, copied unchanged. COMPONENTS keeps the plugin's
order, which is load-bearing.
Three defects in the first commit's components/__init__.py, fixed here:
* ENTRY was empty, but twelve components (pull_bounded, moe_tactic, xattn_b,
...) expose ``engage``, not ``register``: each failed to register and was
reported as stepping aside.
* the warp_redux_volatile include override was not carried over.
* sgl_compat.install_aliases / sgl_shims.install were never called.
Every .py now has the SPDX header; kernels under csrc that are derived from
SGLang keep their attribution line and gain the same two lines below it. The
vendored headers under include/ are untouched (LICENSE.* / NOTICE.* cover them).
The repository's pre-commit passes (isort, ruff, ruff-format, codespell; two
identifiers, ``pres`` and ``ot``, added to the codespell ignore list).
Not validated on a GPU: this commit was checked for import and registration
only. The NVFP4 KV group needs the hybrid SWA pool fix in sgl-project/sglang
#47807; the prefill group needs the megakernel prefill/extend contract in
#47930.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Rohan Varma <rohanv@nvidia.com>
…r custom_pipeline.py NOTICE: add the attribution paragraphs for what the muse_spark components take from SGLang (26 files, Apache-2.0) and FlashInfer (4 files, Apache-2.0, plus three BSD-3-Clause CuTe-DSL kernels), in the form the existing paragraphs use. SPDX: softmax_split.cuh (keeps its FlashInfer header), include/sgl_kernel/warp.cuh (copy of SGLang's, keeps its origin line, SGLang Team copyright from LICENSE.sglang) and the five compat_main forwarding headers. moe_x_kernels/custom_pipeline.py carried two stacked headers, Apache-2.0 and then BSD-3-Clause, both NVIDIA 2025. Keep the BSD-3-Clause one, like its two siblings gather_swiglu_gemm.py and grouped_gemm_rows.py. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Rohan Varma <rohanv@nvidia.com>
…x a dangling path include/NOTICE.flashinfer (verbatim, 435 bytes, same as FlashInfer v0.7.1) says "See licenses/ for text of these licenses", and the branch had no licenses/ directory. Add include/licenses/ with FlashInfer v0.7.1's four texts unchanged (CUTLASS, FlashAttention-3, fmt, spdlog; sizes match the upstream listing) and say so in NOTICE. csrc/nvfp4_kv_store.cuh pointed to ../third_party/flashinfer/LICENSE, which this branch does not have; it now points to ../include/LICENSE.flashinfer. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Rohan Varma <rohanv@nvidia.com>
…-of-tree plugin
Twelve function-local imports in components/ops/{unorm,wfc_c4_fr,wfc_c4_norm,wfc_c4f,
wfc_front_roles,wfc_k1s}.py still named the old package muse_vr_plugin
(sgl_compat.csrc_include_paths, bal). Outside the original plugin install they raise
ModuleNotFoundError the first time the kernel is built, so the components that use these
ops could not engage. Point them at sgl_nvidia_mega.muse_spark.components.
Log and error strings that still say "muse_vr_plugin" are unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Rohan Varma <rohanv@nvidia.com>
Per OSRB guidance (W. Kaluarachchi, 2026-10-27): files adapted from SGLang retain the original copyright line next to NVIDIA's SPDX copyright. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Rohan Varma <rohanv@nvidia.com>
…_quant_early REUSE lint flagged 12 .cuh files with an SPDX license but no copyright line. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: Rohan Varma <rohanv@nvidia.com>
Mechanical only: ruff-format and isort on five files (spec.py, runtime/__init__.py, fin2_cutedsl.py and two moe_x_kernels files) and ruff's removal of the unused ARCHITECTURE import in spec.py. pre-commit run --all-files passes after this. Co-authored-by: Rohan Varma <rohanv@nvidia.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
`optin` (a local that holds cudaDevAttrMaxSharedMemoryPerBlockOptin), `nown` and `kOwn` are names in the kernels, not typos; they join the list that already holds CopyIn, kInf, pres and ot. pre-commit run --all-files passes with this. Co-authored-by: Rohan Varma <rohanv@nvidia.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
SGLang splits a megakernel into a kernel half (`--enable-nvidia-megakernel`: the plugin's kernels replace operations) and a runtime half (`SGLANG_ENABLE_NV_MEGA_RUNTIME_OPTIMIZATION`: SGLang's own host-side work, one optimization per SGLang PR). Seven components are the runtime half and move out of this package: sampling_graph, eager_commit, dflash_prefill_async, sb_lite, kv_hostbook, swa_hostsplit and kv_accounting, with csrc/dflash_commit.cuh (used only by eager_commit) and their NOTICE entries. softmax_split and spec_sample_split consulted sampling_graph only to allow a CUDA-graph capture inside its own capture. Without it a capture is always refused, which is what they did whenever sampling_graph was not engaged; the import that would now fail is gone. COMPONENTS goes from 45 to 38 entries; the order of the rest is unchanged. Co-authored-by: Rohan Varma <rohanv@nvidia.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ncurrency line) The components were ported from muse_vr_plugin 1c223d4e (the P52 / P58 / P61 rows). 96facb4e (P108's site) contains every file of that commit and adds to it; this takes its kernel half. Adds 9 components (47 registered, up from 38 after the runtime half moved out): ctx_kv_counter, proj_publish, fin_2shot, o_rowshard, fp8_prefill (MXFP8 prefill projections), rs_samem, car_table, draft_topk, draft_head_lt, with their kernels (a2a_pull, b3_norm_mx, draft_topk*, mc_push*, mxfp8_fq, prefill_qkn_q8, proj_publish, uc_push_dense) and helpers (mxfp8_ops, mxfp8_fq, opp_tgv_gemm). Updates 21 existing files: ar_attn_boundary, ld_layout, moe_ld, prefill_moe_x, prefill_qkn, nvfp4_kv_verify, nvfp4_prefill_dq, xattn_b, extend_attn_b, moe_x_kernels and five kernels. The other 138 files are byte for byte what the branch already had. components/vendor/ carries the two SGLang pull requests that ar_attn_boundary (#47174) and fin_2shot (#46724) bind and the pinned SGLang does not yet contain, as Apache-2.0 copies with their provenance in vendor/README.md. NOTICE names them and the new SGLang- and FlashInfer- derived files; every new file has an SPDX line and a copyright line. rust_treecore (the host-side Rust TreeCore loader) and the plugin's validation instruments stay out, as do the runtime-half modules removed in the previous commit. Co-authored-by: Rohan Varma <rohanv@nvidia.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…cepted rows CODEOWNERS gets the one line the PR template asks of a new model: Shu Wang (wenscarl), who ported it, and Rohan Varma (nvrohanv), who wrote the kernels. REQUIREMENTS already match P108's launch line (NVFP4 KV, modelopt_fp4, DFLASH, flashinfer_trtllm + flashinfer all-to-all, trtllm_mha, disable_attn_tp_gather); only the comment that names the rows is updated. Co-authored-by: Rohan Varma <rohanv@nvidia.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
test/unit/test_contract.py requires every module that imports `from sglang.* import` to list what it reads in SGLANG_READS and checks that the pinned SGLang provides it. The 101 muse_spark modules declared nothing, so 104 of its cases failed. Each now carries a SGLANG_READS with the SGLang file that provides the name, newest layout first (the moved Muse modules use the same mapping as sgl_compat). Two import forms the test cannot express are rewritten without changing what they bind: `from P import sub` becomes `import P.sub as sub` (63 places), and `from M import a as b` becomes `import M as _sgl_M` + `b = _sgl_M.a` (4 places). Every local name the old imports bound is still bound in the same function; all 101 files compile. Reads that SGLang does not have at the pinned revision stay out of the declaration when the code guards them (hasattr / getattr default, or "branch layout only"): expert_tp, get_tc_piecewise_forward_context, get_tp_group. One real rename is declared as either name: MuseSpark1xForCausalLM | MuseSparkTextForCausalLM; sp_gate still uses the old name and steps aside by its source pin on the new layout. With SGLang aa3e34aa (the unit-test workflow's pin) the contract test passes for muse_spark. Three qwen3_5 cases fail there; they fail the same on unmodified origin/main. Co-authored-by: Rohan Varma <rohanv@nvidia.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Point the spec at sm_103 only, and keep draft_gemv off token tiles whose shared-memory ring exceeds the device's per-block opt-in (227 KiB on sm_103; the default SwiGLU tactic needs 240 KiB at tile 32 and 298 KiB at 64). PORT-NOTES-sm103.md records the sm_103 limits, what was built and launched on a GB300, and what is still open (multi-GPU kernels, served-model runs, GB300 tuning tables). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
moe_x_kernels refused to build without MUSE_VR_MOE_X_MMA_HELPERS, and the recipes name the sm_107 helper module. This line serves sm_103 only, so default to cutlass.utils.blackwell_helpers; the variable still overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eight run The moe_x_kernels grouped GEMMs issue K=128 block-scaled MMAs with operand-collector hints and write the activation scale factors to tensor memory in that instruction's layout. sm_100-family builders (sm_103 included) make K=64 MMAs without collector hints, so with blackwell_helpers the first launch fails and the component falls back. Revert the blackwell_helpers default and report the component off on any architecture outside moe_x_kernels.arch.SUPPORTED_ARCHS, before any launch. PORT-NOTES-sm103.md: GSM8K on a GB300 TP4 with real weights (0.950 with the components, 0.951 stock), the served bench, the trace structure, and the corrected reading of SGLang's "multicast = False". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wenscarl
marked this pull request as ready for review
November 6, 2026 18:01
Collaborator
|
Thanks!
Will review again after adjustment |
Drop the components (and their ops, CUDA sources and data) that the GB300 TP4 DFLASH + NVFP4 KV configuration does not engage, among them the moe_x_kernels / prefill_moe_x path that cannot run on sm_103, and trim the registry to the components that remain. Remove the debug shadow comparisons (ar_attn_boundary, ctx_proj_overlap, nvfp4_kv_verify, spec_sample_split, verify_topk_sample) and xattn_b's dump mode; the runtime guards (gemm_lt's precision check, the device and backend checks) stay. Rewrite PORT-NOTES-sm103.md for the trimmed set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… set Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- verify_topk_sample: drop the import the removed shadow path left unused, and keep declaring dflash_utils._get_or_create_chain_verify_buffers in SGLANG_READS (the chain-buffer path still reads it). - spec: state a tolerance, so the spec imports under SGLang's Numerics check. It is the end-to-end GSM8K agreement measured on a GB300 TP4 (0.953 with the components, 0.951 stock; bound 0.01, about one standard error of the difference); per-slot bounds stay a TODO. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
All Utest passed |
4 of 5 tasks
wenscarl
added a commit
to wenscarl/sgl-nvidia-mega
that referenced
this pull request
Nov 9, 2026
Both sides added sgl_nvidia_mega/muse_spark (main via sgl-project#42/sgl-project#43, this branch with the newer kernel half). Resolved the 12 add/add conflicts by keeping this branch's newer components and re-applying main's GB300 (sm_103) changes: the ISAS/GSM8K tolerance in spec.py, draft_gemv.fits() and its check in draft_boundary, and BuiltMuseSpark.speculative_runtime_hooks = None. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2 of 5 tasks
rohithrr9
added a commit
to wenscarl/sgl-nvidia-mega
that referenced
this pull request
Nov 22, 2026
…hecks, no xattn_b dump mode) Review: sgl-project#42 removed the debug shadow checks (MUSE_VR_<NAME>_SHADOW in ar_attn_boundary, ctx_proj_overlap, nvfp4_kv_verify, spec_sample_split and verify_topk_sample) and xattn_b's dump mode (MUSE_VR_XATTN_B_MODE=dump) on purpose; this pull request had brought them back. The six files are main's again. Both were debug only and off by default, so the served paths do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
#39 adds the Muse Spark Open kernel half, written for sm_107. This PR serves the same kernels on GB300, and only on GB300:
spec.REQUIREMENTS.isasbecomes{"sm_103"}.It is branched from #39, but carries only the components a GB300 TP4 DFLASH + NVFP4 KV server engages: 24 of #39's 47 components, 44.7k of its 99.3k lines. Components written for other configurations are left out:
moe_ld*,moe_tail,fin2,fin_2shot,hb0_rr,mid_rs);fp8_prefill,o_rowshard,rs_samem,prefill_attn);opp_tgv_gemm, and themoe_tactic/car_tabletuning tables;moe_x_kernels/prefill_moe_x, which cannot run on sm_103: its grouped GEMMs issue K=128 block-scaled MMAs with operand-collector hints, while sm_100-family MMAs are K=64 without collectors.The debug shadow comparisons and
xattn_b's dump mode are removed as well.Modifications
spec.py:isas=frozenset({"sm_103"}).components/ops/draft_gemv.py: newfits(tok_tile, epi, device_index). It compares the tactic's shared-memory ring with the device'sshared_memory_per_block_optin.components/draft_boundary.py:_gemv_eligiblekeeps the stock projections when a token tile does not fit, instead of failing at the launch. Each such case is counted asdraft_gemv: token tile exceeds the device's shared memory.MUSE_VR_DRAFT_GEMV_MAX_M=16nothing changes.components/__init__.py: the registry lists the 24 kept components.Shadow and dump code removed:
*_SHADOWcomparisons inar_attn_boundary,ctx_proj_overlap,nvfp4_kv_verify,spec_sample_splitandverify_topk_sample;xattn_b'sMUSE_VR_XATTN_B_MODE=dump.The runtime guards stay, among them
gemm_lt's precision check and the device and backend checks.PORT-NOTES-sm103.md: the sm_103 limits, what was checked on GB300, and what is still open.How the kernels meet the sm_103 limits:
draft_gemvtiles 32 and 64 exceed it; they are now guardedmoe_x_kernelsassume K=128 + collectors; not includedAccuracy Tests
Setup:
lmsysorg/sglang@sha256:9e6f6097…(SGLang306ccf6).--speculative-algorithm DFLASH --speculative-num-draft-tokens 8 --speculative-draft-attention-backend fa4.--enable-layernorm-sp --moe-a2a-backend flashinfer --enable-hierarchical-cache, CUDA graphs on.MUSE_VR_*components on, NVFP4 KVThe stock row uses FP8 KV because stock SGLang rejects DFLASH over native NVFP4 KV; this package's
nvfp4_kvresolution step is what accepts it. The two rows therefore also differ in KV dtype.Speed Tests and Profiling
Served run with real weights. Same setup, components on,
bench_servingwith random data, ISL 8192 / OSL 512, concurrency 112, 448 prompts, on this head:Before the trim, the same bench gave 2241 tok/s and a median TPOT of 15.4 ms; that run was the first after a cold boot. Neither is a tuned performance number.
Torch-profiler GPU trace (TP0, concurrency 112):
Decode step: the DFLASH draft CUDA graph (~1 ms), then the target-verify CUDA graph (~8 ms). The verify sampling and the draft KV append run eagerly between them.
Prefill step: SGLang's breakable prefill graph, with eager attention between layers.
Components engaged on every rank:
nvfp4_kv(all parts),nvfp4_kv_verify,nvfp4_kv_verify_wide,nvfp4_prefill_dq,kv4_dec,kv_draftwinswa_verify_attn,full_verify_attn,full_attn_wide,attn_qk_prologue,prefill_qkn,xattn_bar_attn_boundary,ctx_proj_overlap,ctx_proj_prefill_sharddraft_boundary,draft_candidates,draft_kv_appendfinal_norm,input_norm,spec_sample_split,verify_topk_samplegemm_pick,gemm_ltsp_gate,sp_combine_inplace,sp_fp4_dispatch,pfin,pfrontdraft_gemvnever hit the new shared-memory guard.Single GPU (earlier).
components/ops, plusbal,final_normanddraft_kv_append, builds forsm_103a.preloadlaunches run for the attention kernels,nvfp4_kv_store,norm_fp4_quant_early,moe_ldw,moe_ldwbandbal.Notes from testing:
multicast = Falsefor its all-reduce at TP4 on GB300. That comes from its sm_100-family tuning table, which has no multicast block count for 4 ranks. It is not a hardware limit:cuMulticastCreateand PyTorch symmetric memory both return a multicast address on these nodes.pull_boundedstays off, because its SGLang source pin does not match this image.--enable-nvidia-megakernelfails at spec import with this SGLang.muse_spark/spec.pydeclaresNumericsKind.TOLERANCEwithtolerances={}, and SGLang'sNumericsrejects that ("a TOLERANCE spec must state its tolerances"). The runs above leave the flag off; the components register through the plugin entry point either way.After the trim (this head), on another GB300 node with dummy weights and the same server arguments:
prefill_moe_xis no longer present).bench_serving(ISL 8192 / OSL 512, concurrency 112): 448 of 448 completed, no tracebacks.Not done yet:
moe_x_kernels/prefill_moe_x(K=64 scale layout).gemm_pick/gemm_ltrules tuned for GB300.Checklist
pre-commit runpasses on the changed files. [Not run for the last commit; pre-commit was not installed where it was made.]test/cover the change. [No new tests.]306ccf6)..github/CODEOWNERSalready covers**/*muse_spark*.🤖 Generated with Claude Code