Fuse the DSA (V3.2, GLM-5.x) indexer Q/K paths into single kernels - #27705
Merged
Merged
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
b8zhong
marked this pull request as ready for review
June 10, 2026 03:05
b8zhong
requested review from
1am9trash,
BBuf,
DarkSharpness,
Fridge003,
HaiShaw,
YAMY1234,
ch-wan,
fzyzcjy,
hubertlu-tw,
ispobock and
kkHuang-amd
as code owners
June 10, 2026 03:05
b8zhong
enabled auto-merge (squash)
June 27, 2026 00:09
Fridge003
disabled auto-merge
June 27, 2026 20:34
Fridge003
pushed a commit
that referenced
this pull request
Jun 27, 2026
…27705) Co-authored-by: Brayden Zhong <brayden@radixark.ai> Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
5 tasks
whybeyoung
pushed a commit
to whybeyoung/sglang
that referenced
this pull request
Jul 1, 2026
…oject#29613) Reverts 073de15 (sgl-project#27705 "Fuse the DSA (V3.2, GLM-5.x) indexer Q/K paths into single kernels") and its follow-up b6fceaa (sgl-project#29613). The wk/weights_proj fusion (wk_weights_proj) and the fused-indexer weight loader broke GLM-5.2 block-fp8 checkpoint loading with a weight-shape mismatch during model load on both prefill and decode instances.
smartssw
pushed a commit
to smartssw/sglang
that referenced
this pull request
Jul 6, 2026
…gl-project#27705) Co-authored-by: Brayden Zhong <brayden@radixark.ai> Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
vincentzed
added a commit
to vincentzed/sglang
that referenced
this pull request
Jul 8, 2026
… for DeepSeek-V3.2 The DSA lightning-indexer fused Q/K kernels (PR sgl-project#27705) hardcoded the interleave/GPT-J RoPE pairing (2i, 2i+1), so is_neox_style=True models (DeepSeek-V3.2) were parked on the slow split path by sgl-project#30111 after the wrong rotation corrupted indexer top-k selection (~2.4pt GSM8K drop, 0.955 -> 0.931, sgl-project#30088). Add a compile-time kIsNeox branch to both kernels that pairs dim i with i + rope_dim/2 via a lane shuffle (partner pack lives at lane ^ 8) and loads the cos/sin halves layout with per-element frequency indexing; the cache layout itself is identical between the two conventions. Plumb is_neox through the JIT wrappers and drop the `and not is_neox_style` fusion gate clause. The interleave path is untouched (GLM-5.x byte-identical); Hadamard behavior (kHadamard) and the DeepSeek-V4 native indexer are unchanged. Tests: parametrize the fused-kernel unit tests over is_neox and add a fused-vs-eager NeoX top-k checksum guard (an interleave-only rotation collapses overlap to ~topk/3).
This was referenced Aug 20, 2026
5 tasks
Chronostasys
pushed a commit
to MindLab-Research/sglang
that referenced
this pull request
Aug 24, 2026
…gl-project#27705) Co-authored-by: Brayden Zhong <brayden@radixark.ai> Co-authored-by: Kaixi <kaiximatteoc@nvidia.com>
jakki-amd
pushed a commit
to jakki-amd/sglang
that referenced
this pull request
Sep 9, 2026
…gl-project#27705) Co-authored-by: Brayden Zhong <brayden@radixark.ai> Co-authored-by: Kaixi <kaiximatteoc@nvidia.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.
Note: to completely revert the affects of this PR, we can set
SGLANG_DISABLE_DSA_INDEXER_FUSION=1Changes
Fuse the key projection and the head-gate projection into a single matmul
instead of two.
Fuse the query path — rope, optional Hadamard, fp8 quantization, and
head-gate scaling — into one kernel instead of four separate ops.
Fuse the key path — normalization, rope, optional Hadamard, fp8 quantization,
and the index cache write — into one kernel instead of four. The previous
split path is kept as a fallback for the cases that can't use the fused store
(non-CUDA / NPU, HIP).
Drop the Hadamard rotation for V3.2. It cancels out of the indexer scores, so
removing it doesn't change results — it only affected quantization accuracy,
and V3.2 now quantizes the un-rotated activations directly. It stays available
for the paths that still want it.
Run the key and query paths concurrently. Previously the cache store sat on
the critical path after the key work; folding the store into the key kernel
lets the entire key side overlap the query side.
Note: for the fusion, it seems vLLM has adopt a similar approach: vllm-project/vllm#38928
Checkpoint / weight loading
The fused key+head-gate matmul is bf16, so the loader has to land the key
projection as bf16. How it gets there depends on the checkpoint format (the bf16
result is identical either way):
The NVFP4 checkpoint authors intentionally left the (small) indexer out of
low-bit quantization and pre-dequantized its key projection to bf16, verified it
matches the FP8 checkpoint dequantized exactly. The head-gate projection is bf16
in all of them.
FP4:
Before:

After:


FP8:
Before:

After:

Accuracy Tests
GPQA:
FP4:
Before:
After:
FP8:
Before:
After:
Speed Tests and Profiling
BS = 1: 97.72 -> 107.77 TPS with 0 context (about 10%), with above command on B300.
For B300 + GLM FP8 checkpoint and BS = 128, around 3212.05 -> 3418.63 TPS in decode
CI States
Latest PR Test (Base): ✅ Run #28271629599
Latest PR Test (Extra): ✅ Run #28302367849