Repository navigation
[Quantization] ModelOpt MXFP8: small-M linear opts + env exclude-modules - #46852
Closed
puririshi98 wants to merge 1 commit into
Closed
puririshi98 wants to merge 1 commit into
puririshi98 wants to merge 1 commit into
Conversation
Three opt-in additions for ModelOpt MXFP8 serving, all inert by default: * VLLM_MODELOPT_EXTRA_EXCLUDE_MODULES: append comma-separated fnmatch patterns to the checkpoint's exclude_modules so operators can keep specific modules in BF16 without re-exporting the checkpoint. * VLLM_MXFP8_BF16_FALLBACK_SMALL_M: cache a BF16-dequantized copy of the MXFP8 linear weight and use a plain matmul at M < 128, avoiding FlashInfer mm_mxfp8's 128-row tile padding in the small-batch regime. * VLLM_MXFP8_TRITON_SMALLM: a Triton MXFP8 GEMM for M < 128 that handles small batch natively instead of padding to mm_mxfp8's 128-row tile; takes precedence over the BF16 fallback when both are set. Each path ships an allclose correctness test under tests/kernels/quantization/. Signed-off-by: Rishi Puri <riship@nvidia.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
puririshi98
requested review from
AndreasKaratzas,
WoosukKwon,
mgoin,
pavanimajety,
robertgshaw2-redhat,
tlrmchlsmth,
yewentao256 and
zyongye
as code owners
June 26, 2026 17:46
Member
|
This seems silly to me. Why can you just add a swap ab case to the cutlass kernel for small M? |
Contributor
Author
|
Closing this. After digging into the actual code path (prompted by @mgoin's swap-A/B question), the small-M optimization this PR was adding isn't needed in vLLM. - vLLM main never pads M, the padding I was working around only ever existed in an specific fork |
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.
Summary
Three small, opt-in additions for ModelOpt MXFP8 serving on Blackwell (sm_100), all inert by default — with none of the env vars set, behaviour is identical to current
main:VLLM_MODELOPT_EXTRA_EXCLUDE_MODULES— append comma-separatedfnmatchwildcard patterns to theexclude_moduleslist parsed from the checkpoint, so operators can keep specific Linear/MoE modules in BF16 (e.g. small projections where per-call quantize overhead dominates) without re-exporting the checkpoint. Patterns flow through the existingis_layer_excluded()path. (vllm/model_executor/layers/quantization/modelopt.py)VLLM_MXFP8_BF16_FALLBACK_SMALL_M— at decode-time batch sizes (M < 128), FlashInfer's CUTLASSmm_mxfp8pads M up to a 128-row tile and discards the rest, wasting most of the GEMM. When enabled,process_weights_after_loadingcaches a BF16-dequantized copy of the weight (via the existingdequant_mxfp8_to_bf16) andapply_weightsdoes a plain BF16 matmul for M < 128. Roughly doubles this layer's weight memory, hence opt-in. (vllm/model_executor/kernels/linear/mxfp8/flashinfer.py)VLLM_MXFP8_TRITON_SMALLM— a dedicated Triton MXFP8 GEMM that handles M < 128 natively without the 128-row tile padding. Caches the un-swizzled[N, K/32]weight scale for row-major indexing; takes precedence over the BF16 fallback when both are set. (newvllm/model_executor/kernels/linear/mxfp8/triton_smallm.py+ wiring)All three env vars are registered in
vllm/envs.py. The change is purely additive (+397 lines, 6 files, no deletions).Not a duplicate
Searched open PRs (
modelopt exclude_modules,mxfp8 small M,mxfp8 triton,EXTRA_EXCLUDE_MODULES). No open PR adds an env-based exclude-modules override, a small-M BF16 fallback, or a small-M Triton GEMM for the FlashInfer CUTLASS MXFP8 linear kernel. Nearest neighbours are distinct: #45875 tunes tile sizes for the MXFP8 MTP path; the ROCm / MiniMax-M3 MXFP8 PRs target AMD gfx, not the sm_100 CUTLASS linear path.Test plan
Adds one allclose correctness test per numerical path under
tests/kernels/quantization/:test_mxfp8_smallm_gemm.py— Triton kernel vs a dequantize-then-matmul reference, M ∈ {1, 16, 17, 32, 64, 127}, N/K ∈ {128, 256} (CUDA-gated).test_mxfp8_bf16_fallback.py— small-M BF16 fallback vs reference (sm_100-gated).The allclose equivalences these tests assert were validated on an sm_100 (Blackwell) device — 28/28 pass across both paths (M ∈ {1,16,17,32,64,127}, N/K ∈ {128,256}, rtol/atol 3e-2). The committed pytest files encode the same checks; please run them in CI / on a Blackwell node before merge.
Based on work reviewed by @TomerBN-Nvidia