Skip to content

Support JIT fused A GEMM (MLA down projection) and support GLM-5 hidden size, SM120 - #27397

Merged
Fridge003 merged 11 commits into
mainfrom
brayden/cute-dsl-fused-a-gemm
Jun 27, 2026
Merged

Fridge003 merged 11 commits into
mainfrom
brayden/cute-dsl-fused-a-gemm

Conversation

@b8zhong

@b8zhong b8zhong commented Jun 5, 2026 •

Copy link
Copy Markdown
Collaborator

Modifications

  1. Adopt this kernel to JIT, to support GLM-5 hidden size (6144)
  2. Support SM120, by decreasing the number of stages to fit the SM120 shared memory (99 KB) vs 228 KB on Hopper/Blackwell (since this kernel uses mma.sync for latency instead of tensor core, it's fully compatible)
  3. Rewrite this kernel in cute-dsl. Currently, it's perf is better on SM120, but not on SM100. Maybe migrate it later/on future archs if necessary.

DSL vs the original CUDA changes on SM120:

  1. Instead of ldsm_x4, use _ldmatrix_x2
  2. Eliminate the register spill to GMEM issue (max_number_threads=[256], min_blocks_per_mp=1) by capping the launch bounds on SM120, when tileN is 8
  3. Instead of try_wait, simply use mbarrier_wait.

SM120 Perf Data

K = 6144, N = 2112

M (tokens) DSL (µs) CUDA-JIT (µs) torch (µs) CUDA-JIT ÷ DSL torch ÷ DSL
1 29.50 29.73 34.49 1.01 1.17
2 29.50 29.76 34.08 1.01 1.16
3 29.79 30.53 37.63 1.02 1.26
4 29.63 30.27 36.45 1.02 1.23
5 29.92 30.53 38.27 1.02 1.28
6 29.79 30.88 36.67 1.04 1.23
7 30.37 31.07 38.02 1.02 1.25
8 30.14 30.78 38.69 1.02 1.28
9 30.78 31.62 38.56 1.03 1.25
10 30.40 31.36 39.49 1.03 1.30
11 31.01 31.81 39.07 1.03 1.26
12 30.69 31.33 39.17 1.02 1.28
13 30.88 31.84 39.10 1.03 1.27
14 31.14 32.26 40.32 1.04 1.29
15 30.72 31.90 40.38 1.04 1.31
16 31.10 31.97 40.26 1.03 1.29

K = 7168, N = 2112

M (tokens) DSL (µs) CUDA-JIT (µs) torch (µs) CUDA-JIT ÷ DSL torch ÷ DSL
1 32.67 32.90 38.82 1.01 1.19
2 32.77 32.93 39.30 1.00 1.20
3 32.77 33.09 38.56 1.01 1.18
4 32.86 33.12 39.78 1.01 1.21
5 32.86 33.15 40.90 1.01 1.24
6 32.93 33.22 40.54 1.01 1.23
7 33.09 33.44 41.02 1.01 1.24
8 33.15 33.50 41.44 1.01 1.25
9 33.28 33.66 38.56 1.01 1.16
10 33.44 33.89 38.72 1.01 1.16
11 33.47 33.82 38.82 1.01 1.16
12 33.57 34.18 38.78 1.02 1.16
13 33.73 34.18 38.94 1.01 1.15
14 33.57 34.24 43.65 1.02 1.30
15 33.79 34.34 43.46 1.02 1.29
16 33.82 34.59 45.63 1.02 1.35

SM100 Perf Data

K = 6144, N = 2112

M (tokens) DSL (µs) CUDA-JIT (µs) AOT (µs) torch (µs) CUDA-JIT ÷ DSL AOT ÷ DSL torch ÷ DSL
1 8.38 8.13 — 9.98 0.97 — 1.19
2 8.48 8.13 — 10.02 0.96 — 1.18
3 8.42 8.13 — 10.02 0.97 — 1.19
4 8.38 8.13 — 10.02 0.97 — 1.19
5 8.35 8.10 — 10.02 0.97 — 1.20
6 8.32 8.10 — 10.02 0.97 — 1.20
7 8.35 8.10 — 10.05 0.97 — 1.20
8 8.32 8.13 — 10.05 0.98 — 1.21
9 8.38 8.22 — 10.62 0.98 — 1.27
10 8.42 8.22 — 10.62 0.98 — 1.26
11 8.45 8.26 — 10.66 0.98 — 1.26
12 8.51 8.26 — 10.66 0.97 — 1.25
13 8.45 8.26 — 10.69 0.98 — 1.27
14 8.51 8.22 — 10.72 0.97 — 1.26
15 8.51 8.22 — 10.72 0.97 — 1.26
16 8.58 8.22 — 10.14 0.96 — 1.18

K = 7168, N = 2112

M (tokens) DSL (µs) CUDA-JIT (µs) AOT (µs) torch (µs) CUDA-JIT ÷ DSL AOT ÷ DSL torch ÷ DSL
1 9.38 9.18 9.18 10.91 0.98 0.98 1.16
2 9.34 9.15 9.18 10.98 0.98 0.98 1.17
3 9.34 9.15 9.15 11.01 0.98 0.98 1.18
4 9.44 9.15 9.15 11.01 0.97 0.97 1.17
5 9.44 9.18 9.18 11.01 0.97 0.97 1.17
6 9.47 9.18 9.18 11.01 0.97 0.97 1.16
7 9.54 9.18 9.22 11.04 0.96 0.97 1.16
8 9.54 9.25 9.25 11.04 0.97 0.97 1.16
9 9.51 9.28 9.28 11.59 0.98 0.98 1.22
10 9.57 9.28 9.31 11.58 0.97 0.97 1.21
11 9.54 9.31 9.28 11.62 0.98 0.97 1.22
12 9.57 9.28 9.28 11.62 0.97 0.97 1.21
13 9.60 9.28 9.28 11.65 0.97 0.97 1.21
14 9.66 9.31 9.31 11.68 0.96 0.96 1.21
15 9.76 9.34 9.34 11.68 0.96 0.96 1.20
16 9.82 9.41 9.41 11.17 0.96 0.96 1.14

Speed Tests and Profiling

56.03 -> 57.23 on SM120 on BS = 1 (DSL path)
Before:
Screenshot 2026-06-08 at 11 21 13 AM

After:
Screenshot 2026-06-08 at 11 21 34 AM

before vs after JIT fused A on GLM-5 on SM103

python3 -m sglang.launch_server --model-path nvidia/GLM-5.1-NVFP4 \
  --tp 4 \
  --trust-remote-code \
  --reasoning-parser glm45 \
  --tool-call-parser glm47
for c in 1 2 4 8 12 16; do
  python3 -m sglang.bench_serving --backend sglang --flush-cache \
    --dataset-name random --random-input-len 1 --random-output-len 1024 \
    --random-range-ratio 1.0 --num-prompts $((c * 8)) \
    --max-concurrency $c --output-file res_after.jsonl
done
Concurrency before after (JIT CUDA) delta
1 98.23 98.70 +0.5%
2 184.71 186.90 +1.2%
4 339.55 341.89 +0.7%
8 606.68 611.75 +0.8%
12 846.31 846.00 -0.04%
16 1046.36 1057.55 +1.1%

CI States

Latest PR Test (Base): ❌ Run #28282639269
Latest PR Test (Extra): ❌ Run #28282639236

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@b8zhong b8zhong changed the title Cute-DSL Fused A GEMM [GLM-5] Cute-DSL Fused A GEMM Jun 5, 2026
@b8zhong b8zhong changed the title [GLM-5] Cute-DSL Fused A GEMM Support JIT fused A GEMM (MLA down projection) and support GLM-5 hidden size, SM120 Jun 8, 2026
@b8zhong
b8zhong force-pushed the brayden/cute-dsl-fused-a-gemm branch from 69f0df7 to ce52f63 Compare June 8, 2026 18:12
Add a CuTe DSL fused QKV-A GEMM (cutedsl_dsv3_fused_a_gemm) and the CUDA
JIT variant (dsv3_fused_a_gemm), both ported from TensorRT-LLM dsv3FusedAGemm
for SM90+. Route the DeepSeek-V2/V3 fused-A GEMM to the DSL kernel on SM120
(Blackwell) and the AOT sgl_kernel otherwise. Add unit tests for both kernels
and a merged benchmark comparing DSL vs CUDA JIT vs AOT vs torch.
@b8zhong
b8zhong force-pushed the brayden/cute-dsl-fused-a-gemm branch from ce52f63 to e878ea5 Compare June 8, 2026 18:15
@b8zhong
b8zhong marked this pull request as ready for review June 8, 2026 18:20
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@b8zhong b8zhong self-assigned this Jun 8, 2026
@b8zhong b8zhong added the run-ci CI: run the baseline test suite on this PR label Jun 10, 2026
Brayden Zhong and others added 3 commits June 11, 2026 21:42
CI-registered tests must not ship inside the sglang package; relocate
them under test/registered/jit so the in-package rejection hook passes
and run_suite.py collects them.
Comment thread python/sglang/srt/models/deepseek_v2.py Resolved
@b8zhong
b8zhong enabled auto-merge (squash) June 25, 2026 21:29
@b8zhong

b8zhong commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

#21531 (comment)

@Fridge003
Fridge003 disabled auto-merge June 27, 2026 20:31
@Fridge003
Fridge003 merged commit e4253b3 into main Jun 27, 2026
182 of 197 checks passed
@Fridge003
Fridge003 deleted the brayden/cute-dsl-fused-a-gemm branch June 27, 2026 20:32
Fridge003 pushed a commit that referenced this pull request Jun 27, 2026
@b8zhong

b8zhong commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

To verify this PR has no performance regression in E2E serving, here is even more data on B300. Which looks fine.

Screenshot 2026-06-29 at 6 12 23 AM

Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail deepseek jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants