Conversation
ziang-and
force-pushed
the
agent/cutedsl-nvfp4-w4a16-dense
branch
from
August 19, 2026 06:34
d7959d0 to
e48dd82
Compare
Contributor
Author
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
@HumansAnd
Extend the opt-in
SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16mode from #35120 to serialized ModelOpt NVFP4 dense linear layers selected by--fp4-gemm-backend flashinfer_cutedsl. Dense weights remain NVFP4 while activations and outputs remain BF16.Stack and dependency contract:
d01db73b433ce975ee055fe21499d31d72571098; [FlashInfer v0.6.18] add FlashInfer CuTe DSL NVFP4 W4A16 mode #35120 must merge first. Review the dense-only commit range in this stack comparison. After [FlashInfer v0.6.18] add FlashInfer CuTe DSL NVFP4 W4A16 mode #35120 lands, this branch will be rebased onto currentmainso the upstream PR contains only the dense integration. Dense commit:d7959d0ca0ddc47326ddd1a05f2fd41dbf1864b2.94f6ae8ee90fa4d99c8fe91729da57e89fdc6997. This integration intentionally has no compatibility fallback for earlier FlashInfer APIs.v0.6.17and does not contain the full required chain, so this PR must remain gated on a later stable release.nightly-v0.6.18-20260818at0751be928d24187bd39a0dde45ce96418bc03ddf, whose ancestry includes [Fix] usetorch.catinstead oftorch.concatto prevent entering theAutogradbackends. #4466. The published Python wheel reports build commit02647e81072fe23da164fdf5e179adf78e03a2ec, the immediate pre-[Fix] usetorch.catinstead oftorch.concatto prevent entering theAutogradbackends. #4466 parent, so validation installs the requested nightly Python/cubin/cu130-JIT package set and overlays the exact tag source. This ensures the run exercises [Fix] usetorch.catinstead oftorch.concatto prevent entering theAutogradbackends. #4466 rather than treating the release tag alone as sufficient evidence.Modifications
ModelOptNvFp4A16LinearMethodweight-only path. When the environment variable andflashinfer_cutedsldense backend are both selected, regular serialized non-AWQ ModelOpt NVFP4 linear layers use this method; all existing W4A4 selections remain unchanged when the opt-in is off or another dense backend is selected.prepare_bf16_fp4_weights(..., backend="cute-dsl")API, then invokemm_bf16_fp4(..., backend="cute-dsl", out_dtype=torch.bfloat16)through a registered SGLang custom op with a fake implementation for compile/graph tracing. This folds the new kernel into the existing A16 linear backbone rather than adding a parallel wrapper./update_weights_from_diskcan therefore reload the original checkpoint tensors and rebuild the derived runtime state without invalidating existing parameter identities when shape and dtype are unchanged.uint8weight plus MMA-layout scale/global-alpha attributes in addition to the existing Marlinint32representation; this does not add model-specific LM-head handling.TestServerUpdateWeightsFromDiskNVFP4W4A16CuteDSLfrom [FlashInfer v0.6.18] add FlashInfer CuTe DSL NVFP4 W4A16 mode #35120 rather than adding another test class. Its--fp4-gemm-backend flashinfer_cutedslplusSGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16=1now exercises the dense W4A16 path alongside the existing MoE path.Accuracy Tests
Environment:
lmsysorg/sglang:nightly-dev-cu13-20260818-c0b6474bsha256:51e576f02368480c055c7aadb67590d82b172e2392123ce4cf4cc8251b2d8caf590.48.01; TP4/DP4/EP4 with DP attention and FlashInfer A2A3.12.3, PyTorch2.13.0+cu130, CUDA13.0,nvidia-cutlass-dsl==4.6.2nvidia/Qwen3-30B-A3B-NVFP42538ded2a4edb247b4d2b4a8ba24e44bd4c017c3d01db73b433ce975ee055fe21499d31d72571098; tested dense head:d7959d0ca0ddc47326ddd1a05f2fd41dbf1864b2nightly-v0.6.18-20260818at0751be928d24187bd39a0dde45ce96418bc03ddfflashinfer-python==0.6.18.dev20260818,flashinfer-cubin==0.6.18.dev20260818, andflashinfer-jit-cache==0.6.18.dev20260818+cu130(cp39-abi3,manylinux_2_28_x86_64), with the five [Fix] usetorch.catinstead oftorch.concatto prevent entering theAutogradbackends. #4466 runtime files overlaid from the exact tag source because the published Python wheel predates the mergeFlashInfer package and exact-tag runtime setup
Wheel SHA-256 values, in Python/cubin/cu130-JIT order:
23ed75e3af20e704f4bbdcc7e3e1d9471620ab5a16443b3e7bc28477a2244c3c,430eff3b305be5aabc7345b5c19b88f4dada61749e278bd801a6173728de157b, ande26092488089a0ab87b1e3360a03e3faa6a2b9b653d59eaf5f287830af5b25cb.Command:
This registered test launches deterministic inference with BF16 dense activations and outputs using
--fp4-gemm-backend flashinfer_cutedsl,--moe-runner-backend flashinfer_cutedsl, and--moe-a2a-backend flashinfer. It performs both disk-reload variants (flush_cache=trueandfalse) across weight/CUDA-graph release and resume, then requires unchanged decode text and token IDs and token logprobs within1e-4. Decode CUDA-graph capture completed all 52 batch sizes through 512, and runtime decode used CUDA graphs.The CuTe DSL dense runner does not emit its op key in this deterministic configuration. Dense-path provenance was therefore checked from the resolved SGLang implementation: this env/backend pair selects
ModelOptNvFp4A16LinearMethod, whose prepare/apply path calls the two FlashInfer W4A16 APIs above. The runtime-overlay manifest records matching exact-tag source and installed hashes for all five #4466 files.Unittest and timing tail (the full server log is identified below):
GPU-validation log:
/hai-workspace/sglang-w4a16-dense-validation/logs/d7959d0ca-w4a16-dense-002.log, SHA-256744304b54ab3d525ecc0b10a1b496e90dd6ce41d4bda9a18d0dea437c3d881c9.Static validation:
Both commands passed; the pre-commit run included the repository's selected Ruff checks, Black, isort, codespell, and Python AST checks.
Scope notes:
Speed Tests and Profiling
No independent speed claim is made here. This PR only routes SGLang's existing A16 linear method to FlashInfer's public dense W4A16 API; FlashInfer #4466 owns the kernel microbenchmarks. The C2 run above is a correctness and disk-reload test, not a serving benchmark.
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #32223961782
Latest PR Test (Extra): ❌ Run #32223961598