Repository navigation
[Refactor] kernels: Regroup operators by computation and dissolve ops/muse_spark - #45112
Merged
Merged
Conversation
Relocate the Muse Spark operators added by sgl-project#44665 into the groups that own their computation (README forbids model bundles under ops/). Code is moved with git mv; only import paths, module names and op ids change. - communication: all-gather (+ norm/residual) kernels, TRT-LLM MoE finalize with optional fused TP all-reduce (op, CuTeDSL and Helion backends) - layernorm: norm+gate, post-norm/residual/pre-norm, RMSNorm+NVFP4 quant (+ their JIT/Helion backends and the private launch-config loader) - attention: QK norm + RoPE + KV store (+ Helion) - moe: routing (Triton/JIT) and the Triton post-expert finalize - elementwise: row_sum; gemm: router GEMM - Helion runtime helper -> kernels/jit/utils; triton_sum test oracle -> sglang.test.kernels - op ids: muse_spark.{rms_norm_gate,norm_fp4_quant,qk_norm,post_expert_finalize} -> layernorm.muse_spark_norm_gate, layernorm.muse_spark_rmsnorm_nvfp4_quant, attention.muse_spark_qk_norm_rope_store, communication.muse_spark_moe_finalize_all_reduce Co-Authored-By: Claude Opus 5.5 <[email protected]>
all_gather_matmul / matmul_reduce_scatter and their CUTLASS kernels read and write peer memory (symmetric-memory all-gather, multicast reduce-scatter), so they belong to communication regardless of the GEMM they fuse. Pure git mv; only import paths change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… RoPE+cache store from kvcache to attention Rule 5: kvcache owns ops that read/write KV-cache contents; index/shape/schedule tables for attention kernels belong to attention, and a fused compute+store stays with its compute group. - kvcache/kv_indices.py -> attention/kv_indices.py - kvcache/trtllm_mha_page_table.py -> attention/trtllm_mha_page_table.py - kvcache/trtllm_mha_graph_metadata.py -> attention/trtllm_mha_graph_metadata.py - kvcache/aiter_unified_attention.py -> attention/aiter_unified_page_table.py - kvcache/rope_cache.py -> attention/fused_qk_rope_reshape_and_cache.py Op ids kvcache.<fn> -> attention.<fn> for the ten inventoried entry points. Pure renames (100% similarity); only import paths change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sition in srt Split the runtime-owned parts out of the relocated kernel modules: - communication.muse_spark_all_gather keeps the all-gather kernel and its support predicate; the column-parallel GEMM composition (gemm_local, gemm_ag) and the CustomAllReduceV2 push-capacity reservation move to srt/layers/communication/muse_spark_gemm_ag.py. The kernel is not the K3 communication.gemm_ag (which fuses a fixed-shape TP8 GEMV into the producer), so both stay. - FinalizePushWorkspace (borrows CustomAllReduceV2 buffers, all_gather_object config check) moves to srt/layers/communication/muse_spark_finalize_workspace.py; the kernel op only references it for typing. - The FlashInfer 0.6.17 pin that only the NVFP4 quant Helion backend needs moves from the shared Helion runtime into that op's eligibility check; helion_supported() drops its now-unused op name argument. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…subpackages Relocation only (git mv + import paths): - cutedsl_fp8_paged_mqa_logits.py -> dsa/cutedsl_fp8_paged_mqa_logits.py - dsa_metadata.py -> dsa/metadata.py, dsa_kpool_metadata/ -> dsa/kpool_metadata/ - fused_store_index_cache.py, fused_metadata_copy.py -> dsa/ - deepseek_v4_rope.py -> dsv4/rope.py - dsv4_attn_metadata_kernels.py -> dsv4/attn_metadata_kernels.py - nsa_triton_decode/ -> dsv4/triton_sparse_decode/ - dsv4/elementwise.py -> dsv4/norm_rope.py (no clash with the elementwise group) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…of the vendored fla tree The fla/ tree mirrors flash-linear-attention; these files carry no upstream attribution and come from SGLang PRs (sgl-project#10239, sgl-project#12508, sgl-project#28451, sgl-project#28695, sgl-project#32692, sgl-project#32890, sgl-project#33561, sgl-project#41105), so they move next to the other SGLang linear-attention kernels: - attention/fla/{fused_gdn_gating, fused_kda_conv_recurrent_verify, fused_recurrent_linear_replayssm, fused_sigmoid_gating_recurrent, gdn_replayssm_spec_decode, gdn_replayssm_spec_fold, kda_replayssm_spec_decode}.py -> attention/linear/ - attention/fla/kda_prefill_graph_track.py -> mamba/kda_prefill_track.py (copies conv windows and SSM states into cache pools; no attention math, same as mamba/sconv_tracking.py) Pure renames (100% similarity); only import paths, mock.patch strings and doc paths change. CODEOWNERS gains attention/linear with the fla owners. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e all-gather - FusedPostNormResidualPreNorm no longer imports srt.layers.muse_spark to isinstance-check its modules; the model passes post_norm_is_input_scale / use_residual_gate (the unused pre-norm flag is dropped). - forward_with_ag is removed: the decoder layer calls communication.muse_spark_all_gather_norm_residual directly with the boundary's jit_kernel_kwargs(), which forward_jit shares. - The launch-config loader reads configs/muse_spark/ next to the layernorm ops instead of a nonexistent srt/autotune_configs tree (no data exists, so the defaults stay in effect). - The JIT routing launcher is renamed fused_muse_spark_routing_jit so it no longer shadows the Triton fused_muse_spark_routing; note why the op does not reuse moe.moe_fused_gate (different multiplier/EP-map/softmax/padding semantics and weight rounding). - layernorm.muse_spark_rmsnorm_nvfp4_quant gets a torch forward_native reference (RMSNorm -> bf16 -> per-token NVFP4 with linear e4m3 scales) instead of raising NotImplementedError. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nvfp4_gemm_swiglu_nvfp4_quant (NVFP4 GEMM with a SwiGLU + NVFP4-quant epilogue) and the gfx950 MXFP8 dense GEMM/GEMV modules (native, FlyDSL, aiter, with the native route's tuning table) are GEMMs; move them to ops/gemm with their test. Op id quantization.nvfp4_gemm_swiglu_nvfp4_quant becomes gemm.nvfp4_gemm_swiglu_nvfp4_quant. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Relocation only; moved definitions are byte-identical: - dsa act_quant (fp8, block 128, optional ue8m0 scale) -> quantization/act_quant_triton.py and quantization/act_quant_tilelang.py; get_valid_kv_indices and the TileLang attention kernels stay in dsa/. Drop the attention/nsa triton_kernel/tilelang_kernel re-export shims. - dsv4/fp8_wo_a.py -> quantization/fp8_group_major_quant_ue8m0.py (+ test_fp8_wo_a.py -> ops/quantization/) - dsv4/torch_quant.py -> quantization/fp4_fake_quant.py - dsv4/fp4_indexer quantize_fp4_indexer_tensor and its row helpers -> quantization/fp4_indexer_quant.py; op id attention.quantize_fp4_indexer_tensor -> quantization.quantize_fp4_indexer_tensor Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r groups; drop attention.utils re-exports Verbatim function moves (no body changes): - kvcache/cache_ops.py: concat_and_cast_mha_k_* (MLA K concat/cast), concat_and_cast_q_fp8_pad and absorbed_bmm_concat_cast_q_fp8 (Q8KV8 q-prep) -> attention/mla_qk_prep.py; they build attention inputs, not cache contents. q8kv8_topk_length_from_indices (per-row topk length for the sparse prefill) -> attention/metadata.py. cache_ops.py keeps only reshape_and_cache_flash; its stale trailing DCP-helper comment (those helpers live in attention/dcp_kernels.py) is dropped. - attention/utils.py: reshape_and_cache_shuffle_5d / gather_shuffle_5d_to_linear and their launchers (store/gather for the aiter SHUFFLE-5D KV pool) -> kvcache/shuffle_5d_cache.py. attention/utils.py no longer re-exports pad, kv_indices, cache_ops and the RoPE+store kernel; every importer now names the defining module. The attention.launch_reshape_and_cache_flash spec pointed at that re-export and duplicated kvcache.reshape_and_cache_flash, so it is dropped. Op-id renames: kvcache.concat_and_cast_mha_k_triton -> attention.concat_and_cast_mha_k_triton, attention.launch_reshape_and_cache_shuffle_5d -> kvcache.launch_reshape_and_cache_shuffle_5d. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…htning_backend BailingLinearKernel reshapes the per-layer KV cache, calls lightning_attention and copies the final state back; it is runtime glue with a single user, so it moves verbatim from kernels/ops/attention/linear/lightning_attn.py to srt/layers/attention/linear/lightning_backend.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
quantization/mxfp8_amd_gfx95 held both the MXFP8 / fp8-grid quantizers and two dense linears (dot_scaled_mxfp8_blockscaled_linear and bf16_dequant_blockscaled_linear). Move the linears, unchanged, to gemm/mxfp8_amd_gfx95; the quantizers stay since eight kernel modules import them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tation
- quantization/rmsnorm_fake_quant_amd_gfx95 (RMSNorm onto the fp8 grid)
-> layernorm.
- quantization/minimax_quant_ue8m0 (FP8 quant scattered into the
expert-permuted GEMM input) -> moe, next to its test.
- moe/rocm_moe_utils (pure dequant of dispatched tokens) ->
quantization/rocm_upscale; op ids moe.upscale{,_mxfp4} become
quantization.upscale{,_mxfp4}.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ue8m0_scale and mxfp8_epilogue are MXFP8 quantization device helpers that gemm/dsv4_wo_a and layernorm/hc_combine_norm call; gemm reached them through layernorm/mxfp8_epilogue. Move them to quantization/mxfp8_epilogue and keep rmsnorm_mxfp8 in layernorm as layernorm/rmsnorm_mxfp8. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… test/manual flash_fwd_mla_sm100.py was vendored (sgl-project#31681) from an upstream snapshot (Dao-AILab/flash-attention around 6dba0373b7) that still carried test_mla_kernel / timeit / benchmark_mla_kernel / __main__; upstream dropped them by 940cd9680f and the SGLang copy already diverges (forward_gqa / mValue from sgl-project#42239, stream order from sgl-project#42926). They move verbatim to test/manual/kernels/attention/test_flash_fwd_mla_sm100.py, and the kernel module stops importing the test-only modules (testing.attention_ref, torch.utils.benchmark, time, from_dlpack, dump_kernel_attributes, torch). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…vcache quant_store_kv_mxfp8 quantizes K/V and scatters payload and FA4 scales into the paged cache, and mxfp8_interleave_sf scatters scale factors into the cache layout: both write KV-cache contents. Split the former out of quantization/mxfp8_quant into kvcache/mxfp8_quant_store_kv and move the latter to kvcache; to_mxfp8 stays in quantization. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Relocation only; moved definitions are byte-identical: - dsv4/request_window_copy.py -> kvcache/dsv4_request_window_copy.py (+ test_dsv41_request_window_copy.py -> ops/kvcache/) - dsv4/c128_cleanup.py -> kvcache/dsv4_c128_cleanup.py - dsv4/index_buf_accessor.py (V4 main KV cache writer) -> kvcache/dsv4_main_kv_store.py - dsa/index_buf_accessor.py (indexer K cache get/set) -> kvcache/dsa_index_k_cache.py; drop the attention/nsa index_buf_accessor re-export shim - unified_kv_kernels.runtime store_swa_into_unified / scatter_bf16_into_unified -> kvcache/dsv4_unified_kv_store.py - dsv4/fp4_indexer gather_fp4_index_k -> kvcache/dsv4_fp4_index_k_cache.py Co-Authored-By: Claude Opus 5.5 <[email protected]>
silu_mul_mxfp8, swiglu_oai_mxfp8 and swiglu_oai_mxfp8_deepgemm fuse an
activation with MXFP8 quantization, so they belong to activation. Split
them out of quantization/mxfp8_swizzled_triton into
activation/swiglu_mxfp8_swizzled (the quantizer, its layout helpers and the
indexed scale-shift producer stay), split the test the same way, and
re-register quantization.swiglu_oai_mxfp8{,_deepgemm} as
activation.swiglu_oai_mxfp8{,_deepgemm}. The diffusion facade re-exports
silu_mul_mxfp8 from its new module.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
swiglu_oai_split and swiglu_oai_mxfp8_quant are an activation and an activation + MXFP8 quantization; move moe/minimax_m3_swiglu to activation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s collectives to communication
Relocation only; moved definitions are byte-identical:
- dsv4/fp4_indexer_hip indexer_head_weights (split-K GEMV + scale epilogue)
and its reduce kernels -> gemm/dsv4_indexer_head_weights_hip.py; the fused
index_q_rope_pack_weights_flydsl stays and reuses the reduce block.
- attn_res register_comm / attn_res_fused_pull_rs / attn_res_fused_direct_ag
(NVLS RS / multicast AG fused with the aggregation) ->
communication/attn_res_collective.py; attn_res_fused_tma stays in attention.
Op ids attention.attn_res_fused_{pull_rs,direct_ag} ->
communication.attn_res_fused_{pull_rs,direct_ag}.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
elementwise/elementwise mixed unrelated public ops. Move the two fused RMSNorm kernels (already registered as layernorm.*) to layernorm/fused_rmsnorm and gelu_and_mul_triton to activation/gelu_and_mul_triton; the sigmoid-mul family stays. Co-Authored-By: Claude Opus 5.5 <[email protected]>
elementwise/hc_mix runs the hyper-connection down/up projections as two split-K GEMMs; move it to gemm/hc_mix_splitk beside the persistent Triton gemm/hc_mix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two different ops were both called hc_combine: elementwise.hc_combine (the hyper-connection gated-residual combine) and layernorm.mhc.hc_combine (the DeepSeek-V4 mHC weighted sum over streams). Rename the latter to mhc_combine, matching mhc_pre / mhc_post and the moe_finalize_all_reduce_mhc_combine fusion, and its test file to test_mhc_combine.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
moe/triton_sigmoid_gate_mul (Triton, same-shape and per-row broadcast) and attention/mla_output_gate (Kimi-K3 JIT CUDA) compute the same pointwise gate as elementwise.fused_sigmoid_mul. Move them to elementwise/sigmoid_gate_mul and elementwise/mla_output_gate with their tests; op id attention.kimi_k3_mla_output_gate becomes elementwise.kimi_k3_mla_output_gate. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd Q8KV8 Q prep Relocation only; moved definitions are byte-identical: - dsa/tilelang_kernel dpsk_v4_fp8_attention_fwd (+ dpsk_v4_* kernels and helpers) -> dsv4/tilelang_fp8_attention.py - dsv4 fused_q_indexer_rope_first_quant (DeepSeek-V3.2 only) -> dsa/indexer_q.py, next to dsa/indexer_k.py - dsv4/dequant_k_cache q8kv8_padded_num_heads / cast_q_fp8_for_q8kv8_prefill (Q side) -> sparse_mla_q8kv8_prefill_sm90.py; the DSV4 backend imports them lazily with the kernel, and the backend test stub forwards the real helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The same-shape Triton sigmoid_gate_mul and elementwise.fused_sigmoid_mul compute fp32 x * sigmoid(gate) with one rounding at the store; they are bitwise identical on GPU over bf16/fp16/fp32, 1D/2D/3D shapes, zero rows and inf/nan/denormal inputs. Drop sigmoid_gate_mul, point the HIP callers (qwen3_next, hunyuan_v4) and its test at fused_sigmoid_mul, and move the per-row broadcast variant next to it in elementwise/elementwise. kimi_k3_mla_output_gate stays a separate kernel: it rounds sigmoid(gate) to bf16 before the multiply, so it differs from fused_sigmoid_mul. Co-Authored-By: Claude Opus 5.5 <[email protected]>
swiglu_oai_mxfp8_quant (MiniMax-M3 MoE) and swiglu_oai_mxfp8 differ in 2.5% of payload bytes on GPU (fp32 vs bf16-rounded activation before the quant) and use different scale layouts. hc_mix (split-K) and fused_hc_mix (device-scope atomics) cannot agree bitwise. Keep both of each pair. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…row_scale apply_log_scaling_tau is a per-row scale (out = x * tau[row]) whose fast path already is elementwise.row_scale_bf16; move the Triton fallback and the dispatcher into elementwise/row_scale and register elementwise.apply_log_scaling_tau. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bias_gelu_tanh is an activation (with a bias add); move it from elementwise to activation with its test and benchmark. Its CUDA source stays in jit/csrc/elementwise next to activation.cuh. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s to sglang.test.kernels Relocation only; moved definitions are byte-identical: - dsv4/online_c128_mtp OnlineC128MTPController (+ its runtime dataclasses) -> srt/layers/attention/dsv4/online_c128_mtp.py; the JIT module stays. - dsv4/unified_kv_kernels/env_gate.py (server-config predicates) -> srt/layers/attention/dsv4/unified_kv_gate.py - dsa/hip_gfx950/fused_decode.py (Gfx950FusedIndexer, workspace registry, model-shape gate) -> srt/layers/attention/dsa/gfx950_fused_indexer.py; the hip_gfx950 loader stays and the package no longer re-exports runtime state. - dsa/quant_k_cache _quantize_k_cache_ref -> sglang.test.kernels.dsa_k_cache_reference - dsv4/fp4_indexer_hip read_fp4_index_k_split -> sglang.test.kernels.deepseek_v4.fp4_index_k_reference - dsa/dequant_k_cache gather_dequant_requant_fp8_paged_legacy (+ its kernel), used only as the baseline of benchmark_q8kv8_kv_gather.py -> that benchmark. Co-Authored-By: Claude Opus 5.5 <[email protected]>
kevin-mii
added a commit
to sgl-project/sgl-amd-mono
that referenced
this pull request
Oct 21, 2026
## Motivation sgl-project/sglang#45112 regrouped SGLang's kernels. #17 moved the DeepSeek-V4.1 spec's and draft's reads (`unified_kv_gate`, `mhc_combine`); `check_k1` still imports the old modules, so on SGLang main `test/kernels/test_deepseek_v41_kernels.py` fails at TP2 and TP4 with `ImportError`. ## Modifications `test/kernels/deepseek_v41/check_k1.py`: `fused_k_norm_rope_flashmla` from `attention/dsv4/norm_rope.py`, and `mxfp8_native_amd_gfx95` from `gemm/`. ## Accuracy Tests MI350X, TP4, SGLang main f8fd41c36e, this tree (identical to #17 plus this commit): - `test/unit/`: 120 passed. - `test/kernels/test_deepseek_v41_kernels.py`: 4 passed. - `test/kernels/test_deepseek_v41_k2i.py`: 14 passed. - `test/e2e/test_deepseek_v41_server.py`: 9 passed (GSM8K 0.910 / 0.910). ## Checklist - [x] `pre-commit run --all-files` passes. - [x] Tests under `test/` cover the change. - [x] The SGLang commit or PR this was tested against is named above. - [ ] Accuracy and speed results are attached when kernel or forward code changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
2 tasks done
maeehart
added a commit
to maeehart/sglang
that referenced
this pull request
Oct 21, 2026
…le GEMM from their new module smallm_fp8_blockscale_gfx950 still imports _check, _hip_lib, _hipcc and _Kernel from smallm_moe_gfx950, but sgl-project#45112 moved those helpers to sglang.kernels.jit.utils.hipcc as check_hip, hip_lib, hipcc_path and HipKernel. On gfx950 every block-FP8 linear that takes the small-M path then fails with an ImportError during CUDA graph capture. This imports the helpers from their new module under the names the file already uses.
Closed
2 of 5 tasks
4 of 5 tasks
3 of 5 tasks
6 tasks done
This was referenced Nov 4, 2026
Merged
6 of 7 tasks
This was referenced Nov 10, 2026
This was referenced Nov 20, 2026
This was referenced Nov 24, 2026
3 of 5 tasks
4 of 5 tasks
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
python/sglang/kernels/README.mdsays to classify kernels by the computation they perform, not by the model that first used them, and never to add a model bundle as a top-level group. An audit of current main found that this had drifted:ops/muse_spark/([Feat] kernels: Add muse spark operators and collective GEMM (2/5) #44665) was a model-named top-level group. It contained 22 files mixing norms, routing, GEMMs, collectives and reductions, with no KernelSpecs and no kernel tests. It had been added to_GROUPS, which is the only thing the guard test checked, so the test did not catch it.attention/dsv4/andattention/dsa/had collected quantization kernels, KV-cache stores and copies, a split-K GEMV, collective attention-residual kernels, runtime controllers and config predicates, and test oracles.quantization, RMSNorms inelementwise, attention metadata inkvcache, a forwarding shim inattention/utils.py, and the same computation implemented in two or three groups.This PR fixes all of it in one pass. It writes the classification rules into the README and the
kernel-organizationskill, and makes the guard test enforce the README.Classification rules (README + skill)
attention.layernormactivationgemmmoequantizationholds only pure format conversion: quant, dequant, scale layout, repack.communication, whatever compute it fuses. Workspaces, symmetric buffers and process groups stay insrt/layers/communication/.kvcacheowns ops that read or write KV-cache contents: store, gather, copy, quantize-into-cache, clear rows.attentionowns the index, shape and schedule tables attention kernels consume: page tables, cu_seqlens, kv_indices, schedule metadata.kda_kernels/andcake_kernels/are documented as the agent-generated kernel backends. They are deliberately left in place, and new agent kernels keep landing there.Guard test (
test_kernels_namespace.py):_GROUPS.sglang/kernels/.Both checks fail on main.
Modifications
All relocations are
git mvplus import updates. Every moved function, class and constant was checked to be byte-identical apart from import paths, either by AST comparison or by a normalized diff. Relocation commits are kept apart from semantic commits. No forwarding shims remain: 94 old module paths have zero references anywhere.ops/muse_sparkdissolvedmuse_spark_norm_gate{,_jit,_helion},muse_spark_norm_residual{,_jit},muse_spark_rmsnorm_nvfp4_quant{,_helion},_muse_spark_tuning.muse_spark_qk_norm_rope_store{,_helion}.muse_spark_routing{,_jit},muse_spark_post_expert_finalize_triton.muse_spark_all_gather,muse_spark_all_gather_norm_residualmuse_spark_moe_finalize_all_reduce{,_cutedsl,_helion}cutlass_all_gather_gemm,cutlass_gemm_reduce_scatter,sp_collective_gemm(moved fromgemm)row_sum. gemm:muse_spark_router_gemm. It is kept but still unused; the model only reads itsMAX_TOKENSthreshold.kernels/jit/utils/helion_runtime.py.srt/layers/communication/: the GEMM+all-gather composition and projection workspace,FinalizePushWorkspace, and the SP collective-GEMM symmetric-memory workspace. The SP kernels now take the workspace as an argument.forward_with_agused to route it, and the norm op no longer imports srt model classes.triton_sum→sglang.test.kernels, used as therow_sumbitwise reference.DeepSeek V4 / DSA
quantization:act_quant(Triton and TileLang)fp8_group_major_quant_ue8m0(wasdsv4/fp8_wo_a)fp4_fake_quant(wasdsv4/torch_quant)quantize_fp4_indexer_tensordsa_quant_k_cache(returns new tensors; it never writes the cache)kvcache:gemm:dsv4_indexer_head_weights_hip, a split-K GEMV.communication:attn_res_collective(NVLS pull reduce-scatter, multicast all-gather).OnlineC128MTPController, the unified-KV config gate,Gfx950FusedIndexer.@triton.jitkernels.dsa/dsv4/;nsa_triton_decode/→dsv4/triton_sparse_decode/dsv4/elementwise.py→dsv4/norm_rope.pydsa/indexer_q.py*_dsa/*_dsv4*_kpool_kv_splits_for_stream→kv_splits_for_stream(public)sglang.test.kernels. The deadtriton_create_paged_compress_datais deleted.kvcache ↔ attention, attention subpackages
attention:kv_indices,trtllm_mha_page_table,trtllm_mha_graph_metadata,aiter_unified_page_table,fused_qk_rope_reshape_and_cache, and the MLA Q/K prep fromcache_ops(→mla_qk_prep.py).attention/utils.pyforwarding re-exports removed. 21 importers now import from the defining modules. The shuffle-5D store and gather →kvcache/shuffle_5d_cache.py. Two duplicate inventory specs dropped.attention/fla/: 7 files →attention/linear/, andkda_prefill_graph_track→mamba/.BailingLinearKernel→ its srt backend.flash_fwd_mla_sm100.py) intotest/manual/.srt/layers/attention/minimax_sparse_ops→kernels/ops/attention/minimax_sparse/. Itstests/folder had never been collected and had stale imports; it is now intest/registered, with the slow autotune test nightly. The unusednaive/references are deleted.Other groups
quantization→gemm:nvfp4_gemm_swiglu_nvfp4_quant, the gfx950 MXFP8 GEMV/GEMM (with its tuning JSON),mxfp8_flydsl,mxfp8_aiter, and the MXFP8 blockscaled linears.rmsnorm_fake_quant_amd_gfx95→layernormactivationminimax_quant_ue8m0→moeupscale(dequant) →quantizationquantizationquant_store_kv_mxfp8and the interleaved SF →kvcachediffusion/modulateelementwise: RMSNorms →layernorm;gelu_and_mul_tritonandbias_gelu→activation.hc_mixsplit-K →gemm;router_gate_matvec→gemmsilu_and_mul_clamp/silu_and_mul_contig_post_quant→activation; these also serve dense MLPs.ngram_embedding→embeddingssoftcap_row_argmax→samplingbmm_fp8's implementation moved out of srt intogemm/flashinfer_bmm_fp8.pycommunication/mp.py→srt/distributedmoe/triton_sigmoid_gate_mulmerged intoelementwise.fused_sigmoid_mul: bit-exact over 92 cases on sm_90/sm_100/sm_120.mla_output_gate(rounds the gate to bf16 first), thehc_mixsplit-K vs persistent kernels,swiglu_oai_mxfp8, DSparkSoftmaxTemp,act_quant, the V4 Triton RoPE, the grok/gfx1250 RMSNorms, int8 group quant on ROCm, marlin SiTU.kernels/jit/utils/hipcc.py_jit_*module prefixes removedkv_canary/lplbmhc.hc_combine→mhc_combine(it clashed withelementwise.hc_combine)fp8_cvtandscatter_req_token_idsreference →sglang.test.kernelsmxfp4_marlin_repackdeletedBugs fixed along the way
_is_blackwell()returnedmajor >= 10, but the kernels need tcgen05. The first extend failed with an NVVMunsupported operationon sm_120a. They are now gated to SM10x, and SM120 falls back to Triton; B200 still selects CuTeDSL.forward_nativeraisedNotImplementedError, which BaseFusedOp does not allow. It is now implemented and checked against the JIT kernel.Coordination
#44667 and #44668 (Fridge003) touch
ops/muse_spark/. New locations:ops/muse_spark/…fused_muse_spark_routing.pymoe/muse_spark_routing.pyfused_norm_gate.pylayernorm/muse_spark_norm_gate.pyfused_norm_residual.pylayernorm/muse_spark_norm_residual.pyfused_op_tuning.pylayernorm/_muse_spark_tuning.py(configs inlayernorm/configs/muse_spark/)fused_qk_norm.py/helion_qk_norm.pyattention/muse_spark_qk_norm_rope_store{,_helion}.pyhelion_runtime.pykernels/jit/utils/helion_runtime.pyfi_trtllm_moe_finalize_with_rmsnorm_cutedsl.pycommunication/muse_spark_moe_finalize_all_reduce_cutedsl.pyNotes for the rebase:
FusedPostNormResidualPreNormnow takespost_norm_is_input_scaleanduse_residual_gate, andforward_with_agis gone. Callcommunication.muse_spark_all_gather_norm_residual(..., **op.jit_kernel_kwargs()).FinalizePushWorkspacenow lives insrt/layers/communication/muse_spark_finalize_workspace.py.helion_megakernels/and its tests need a logical group; the guard test rejectsops/muse_sparkandtest/registered/kernels/ops/muse_spark.Validation
sglang.*import and every KernelSpec target finds 0 new unresolved names vs main.pytest --collect-onlyovertest/registered, the diffusion unit tests and the AOT tests shows no new collection errors on H200 or B200. 340 more tests are collected: the new tests plus the MiniMax tests that could not be collected before.sglang.kernels,multimodal_genandsrt.{layers,models,speculative,mem_cache,disaggregation}fails on exactly the same modules as main. These are only the optional helion/aiter/flydsl dependencies, now under their new paths.EADDRINUSE) and pass when run alone.test_collectives(covers the moved attn_res collectives and the gemm all-gather),test_ar_fusion,test_tp_qknorm,test_symm_mem_all_gatherandtest_deterministic_reduce_scatterall pass on both main and this PR.indexed_scale_shift_mxfp8_both directly and through the diffusion facade. Thesigmoid_gate_mulmerge is bit-exact over 92 cases on sm_90, sm_100 and sm_120.test_muse_spark_12_b300_pd.pycovers them.Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ⏳ Run #39347887110
Latest PR Test (Extra): ⏳ Run #39347887019
Latest PR Test (AMD ROCm 10): ⏳ Run #39347887056