Skip to content

[Feat] moe: Allow SiTU on the CuTe DSL NVFP4 MoE (Kimi-K3 W4A16) - #44148

Merged
ByronHsu merged 9 commits into
sgl-project:mainfrom
ByronHsu:byron/cutedsl-nvfp4-w4a16-situ
Nov 3, 2026
Merged

ByronHsu merged 9 commits into
sgl-project:mainfrom
ByronHsu:byron/cutedsl-nvfp4-w4a16-situ

Conversation

@ByronHsu

@ByronHsu ByronHsu commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Why?

  • Kimi-K3's routed experts use the SiTU activation. Two checks only allowed silu/relu2: the CuTe DSL MoE runner and the ModelOpt NVFP4 activation guard. That blocked K3 from FlashInfer's NVFP4 W4A16 CuTe DSL kernel (NVFP4 weights, BF16 activations).
  • FlashInfer already supports SiTU in this kernel (feat(moe): support GeGLU and SiTU in W4A16 flashinfer-ai/flashinfer#4394, situ_beta / situ_linear_beta).

What?

  • modelopt_quant.py: allow situ on the CuTe DSL v2 NVFP4 path, as already done for TRT-LLM.
  • flashinfer_cutedsl.py:
    • accept situ (FlashInfer selects SiTU through the gated Swiglu path);
    • pass situ_beta / situ_linear_beta (K3's gemm1_alpha / gemm1_clamp_limit) to CuteDslMoEWrapper. Without them the kernel would compute plain SwiGLU.
  • New GPU test test/registered/unit/layers/quantization/test_nvfp4_cutedsl_w4a16_situ_moe.py.
  • Usage is the same as other W4A16 models: --moe-runner-backend flashinfer_cutedsl with SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16=1.
  • Checkpoint requirement (documented, not enforced): gate (w1) and up (w3) must share one weight_scale_2 per expert, because the kernel applies one GEMM1 scale before SiTU's tanh.

Verification?

Before:  K3 NVFP4 + SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16=1 + --moe-runner-backend flashinfer_cutedsl
         -> AssertionError: activation='situ' is unsupported by flashinfer_cutedsl
After:   same command
         -> routed experts run CuTe DSL W4A16 with SiTU fused into GEMM1

Observed on GB300 with the same kernel path on a development branch (5-layer truncated K3 converted to ModelOpt NVFP4, TP4, CUDA graphs), CuTe DSL W4A16 vs Marlin on the same NVFP4 weights:

mean |prompt logprob diff| = 0.026, max = 0.20, first token equal 7/8   (observed)

Reproduce:

SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16=1 \
python -m sglang.launch_server --model-path <Kimi-K3 ModelOpt NVFP4 checkpoint> \
  --quantization modelopt_fp4 --moe-runner-backend flashinfer_cutedsl \
  --tp 4 --trust-remote-code

Test?

  • test_nvfp4_cutedsl_w4a16_situ_moe.py on GB300 with this branch and the upstream pins (flashinfer 0.7.1, torch 2.14.1+cu130, GB300): passed (observed). The test checks two things:
    • CuTe DSL W4A16 SiTU output matches a dequantized torch reference;
    • a SiLU reference does not match (cosine < 0.99), so the test proves SiTU is applied.
  • test_nvfp4_moe_backends.py::TestNvFp4MoeBackends::test_flashinfer_cutedsl (existing SiLU path), same run: passed (observed; 2 passed in 415.95s together with the test above).
  • pre-commit run on the changed files: all hooks passed (observed).
  • CI: pending.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ⏳ Run #41449060368
Latest PR Test (Extra): ❌ Run #41449060314
Latest PR Test (AMD ROCm 10): ⏳ Run #41449060148

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

Kimi-K3's routed experts use SiTU. FlashInfer's CuteDslMoEWrapper applies
SiTU in the GEMM1 epilogue (situ_beta / situ_linear_beta), but SGLang's
CuTe DSL runner and the ModelOpt NVFP4 activation guard only allowed
silu/relu2, so K3 could not run on the NVFP4 W4A16 kernel
(SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16=1).

- modelopt_quant: allow 'situ' on the CuTe DSL v2 NVFP4 path.
- flashinfer_cutedsl: accept 'situ' (FlashInfer's gated Swiglu path) and
  pass gemm1_alpha / gemm1_clamp_limit as situ_beta / situ_linear_beta.
- GPU test: CuTe DSL W4A16 SiTU vs a dequantized torch reference; the
  SiLU reference must differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ByronHsu

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 14, 2026
@ByronHsu ByronHsu changed the title Allow SiTU on the CuTe DSL NVFP4 MoE (Kimi-K3 W4A16) [Feat] moe: Allow SiTU on the CuTe DSL NVFP4 MoE (Kimi-K3 W4A16) Oct 14, 2026
@ByronHsu

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@ByronHsu

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

Resolve the SiTU backend allow-list in modelopt_quant.py: keep upstream's
FlashInfer MegaMoE (sgl-project#44036) and this PR's CuTe DSL v2 standard path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ByronHsu

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

1 similar comment
@ByronHsu

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@ByronHsu

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

ByronHsu and others added 2 commits November 2, 2026 14:18
Pick up main's fix for test_basic_sanity_dspark.py, which was broken on
the Oct 22 main this PR last tested against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pick up sgl-project#47837, which fixes test_linear_parallel_groups.py on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ByronHsu
ByronHsu merged commit 62f9f3f into sgl-project:main Nov 3, 2026
163 of 171 checks passed
Yuxingwang-intel pushed a commit to Yuxingwang-intel/sglang that referenced this pull request Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blackwell SM100/SM120 quant LLM Quantization run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant