[FlashInfer v0.6.18] add FlashInfer CuTe DSL NVFP4 W4A16 mode (#35120)

This commit is contained in:
Ziang Li
2026-08-31 18:47:30 -07:00
committed by GitHub
parent 175973d834
commit 9a85473a89
12 changed files with 287 additions and 68 deletions
@@ -14,7 +14,7 @@ from sglang.test.test_utils import (
popen_launch_server,
)
register_cuda_ci(est_time=800, stage="nightly", runner_config="4-gpu-b200")
register_cuda_ci(est_time=1200, stage="nightly", runner_config="4-gpu-b200")
class FlashinferNvFp4OnlineMoeBackendBase:
@@ -124,5 +124,47 @@ class TestFlashinferCuteDSLMoeBackendNvFp4Online(
}
class TestFlashinferCuteDSLMoeBackendNvFp4OnlineW4A16(
FlashinferNvFp4OnlineMoeBackendBase, CustomTestCase
):
backend = "flashinfer_cutedsl"
model = "nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-FP8"
extra_args = [
"--reasoning-parser",
"nemotron_3",
"--tool-call-parser",
"qwen3_coder",
"--speculative-algorithm",
"EAGLE",
"--speculative-num-steps",
"3",
"--speculative-eagle-topk",
"1",
"--speculative-num-draft-tokens",
"4",
"--dp-size",
"4",
"--enable-dp-attention",
"--enable-dp-lm-head",
"--moe-a2a-backend",
"flashinfer",
"--cuda-graph-backend-prefill",
"disabled",
]
eval_args = {"max_tokens": 16000, "temperature": 1.0, "top_p": 0.95}
spec_accept_length_threshold = 2.5
extra_env = {
"FLASHINFER_NVFP4_4OVER6": "1",
"FLASHINFER_NVFP4_4OVER6_ERR_MODE": "MSE",
"FLASHINFER_NVFP4_4OVER6_ERR_USE_FAST_MATH": "1",
"FLASHINFER_NVFP4_4OVER6_E4M3_USE_256": "1",
"SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16": "1",
"SGLANG_FLASHINFER_NVFP4_PER_TOKEN_ACTIVATION": "0",
"SGLANG_FLASHINFER_MOE_FUSED_FINALIZE": "1",
"SGLANG_MOE_NVFP4_DISPATCH": "0",
"SGLANG_FLASHINFER_NUM_MAX_DISPATCH_TOKENS_PER_RANK": "4096",
}
if __name__ == "__main__":
unittest.main()
@@ -1,6 +1,6 @@
from sglang.test.ci.ci_register import register_cuda_ci
register_cuda_ci(est_time=320, stage="extra-b", runner_config="4-gpu-b200")
register_cuda_ci(est_time=420, stage="extra-b", runner_config="4-gpu-b200")
import time
import unittest
@@ -269,5 +269,37 @@ class TestServerUpdateWeightsFromDiskNVFP4CuteDSL(
)
class TestServerUpdateWeightsFromDiskNVFP4W4A16CuteDSL(
UpdateWeightsFromDiskBase, CustomTestCase
):
model = "nvidia/Qwen3-30B-A3B-NVFP4"
decode_payload = {**UpdateWeightsFromDiskBase.decode_payload, "routed_dp_rank": 0}
launch_env = {
"SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16": "1",
"SGLANG_FLASHINFER_NVFP4_PER_TOKEN_ACTIVATION": "0",
"SGLANG_MOE_NVFP4_DISPATCH": "0",
"SGLANG_FLASHINFER_NUM_MAX_DISPATCH_TOKENS_PER_RANK": "4096",
}
backend_test_suites = (
{
"name": "flashinfer_cutedsl_nvfp4_w4a16",
"other_args": (
"--tp-size",
"4",
"--dp-size",
"4",
"--enable-dp-attention",
"--ep-size",
"4",
"--fp4-gemm-backend",
"flashinfer_cutedsl",
"--moe-runner-backend",
"flashinfer_cutedsl",
"--enable-deterministic-inference",
),
},
)
if __name__ == "__main__":
unittest.main()
@@ -31,6 +31,7 @@ def test_flashinfer_prefill_returns_standard_combine_input():
wrapper.run.return_value = expected_output
quant_info = SimpleNamespace(
wrapper=wrapper,
quant_mode="w4a4",
use_per_token_activation=False,
a1_scale=torch.tensor(1.0),
a2_scale=torch.tensor(1.0),
@@ -962,6 +962,20 @@ class TestModelOptMixedPrecisionConfig(CustomTestCase):
)
)
def test_lm_head_guard_accepts_modelopt_fp4_cutedsl_w4a16_runtime_state(self):
lm_head = nn.Module()
lm_head.weight = nn.Parameter(
torch.empty(128, 1024, dtype=torch.uint8), requires_grad=False
)
lm_head.weight_scale_interleaved = nn.Parameter(torch.empty(1))
lm_head.alpha = nn.Parameter(torch.empty(1))
lm_head.input_size_per_partition = 2048
lm_head.output_size_per_partition = 128
quant_method = ModelOptFp4LinearMethod(ModelOptFp4Config())
quant_method.quant_mode = "w4a16"
self.assertTrue(should_apply_lm_head_quant_method(lm_head, quant_method))
def test_lm_head_guard_rejects_stale_modelopt_fp4_method_on_dense_head(self):
lm_head = nn.Module()
lm_head.weight = nn.Parameter(torch.empty(128000, 2048))