[Quant] ModelOpt mixed precision: dispatch block-FP8 MoE experts and derive the block size - #38726
Open
zhendonghua wants to merge 2 commits into
Open
zhendonghua wants to merge 2 commits into
zhendonghua wants to merge 2 commits into
Conversation
…derive the block size ModelOptMixedPrecisionConfig had a Linear entry for `FP8_PB_WO` but no FusedMoE entry for any block-FP8 algorithm, and it hard-coded the block size to 128. `nvidia/Qwen3.8-Flash-Next-NVFP4` lists its MTP experts as block-FP8 (`FP8_BLOCK_SCALES` in hf_quant_config.json, the canonical `FP8_PB_WO` in the inline config.json copy), so those experts resolved to "unquantized": the loader cast the fp8 values to bf16 without their block scales and silently skipped `weight_scale_inv`. The server ran, but the draft was numerically wrong (MTP accept length 1.6 instead of ~3). - Treat `FP8_PB_WO` and `FP8_BLOCK_SCALES` as one block-FP8 family for both Linear and FusedMoE, dispatching FusedMoE to `Fp8MoEMethod` with the shared block-FP8 sub-config (mirrors vllm-project/vllm#55513). - Build that sub-config's block size from the checkpoint's `group_size` (default 128) and reject a MIXED_PRECISION map whose block-FP8 layers disagree on it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
6 tasks
zhendonghua
marked this pull request as ready for review
September 9, 2026 20:37
zhendonghua
requested review from
Alisehen,
AniZpZ,
BBuf,
Edwardf0t1,
FlamingoPg,
HaiShaw,
OrangeRedeng,
b8zhong,
ch-wan and
mmangkad
as code owners
September 9, 2026 20:37
Contributor
Author
|
/tag-and-rerun-ci |
Contributor
Author
|
/rerun-failed-ci |
6 tasks
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
ModelOptMixedPrecisionConfighas a Linear entry forFP8_PB_WObut no FusedMoE entry for any block-FP8 algorithm, and it hard-codes the block-FP8 sub-config to[128, 128].nvidia/Qwen3.8-Flash-Next-NVFP4lists its MTP experts (mtp.layers.0.mlp.experts) as block-FP8:FP8_BLOCK_SCALESinhf_quant_config.json, the canonicalFP8_PB_WOin the inlineconfig.jsoncopy (SGLang currently reads the file because the inline copy carries no KV-cache key, but either name can win). Both resolve to "no quant method" for FusedMoE, so the experts are built unquantized: the loader casts the fp8 values to bf16 without their block scales and silently skipsweight_scale_inv. The server starts and target accuracy is unaffected, but the draft is numerically wrong (accept length ~1.6 instead of ~3).Mirrors vllm-project/vllm#55513.
Modifications
_BLOCK_FP8_ALGOS = ("FP8_PB_WO", "FP8_BLOCK_SCALES"); Linear and FusedMoE both dispatch on it, FusedMoE toFp8MoEMethod(self.fp8_pb_wo_config)(block scales viaweight_scale_inv, dynamic activation).group_size(default 128); a MIXED_PRECISION map whose block-FP8 layers disagree raises.Test
test_modelopt_loader.py::TestModelOptMixedPrecisionConfig: both names dispatch toFp8MoEMethodwith[128,128]; block size followsgroup_size; conflicting sizes raise. Verified red on the pre-change code.nvidia/Qwen3.8-Flash-Next-NVFP4, 4x B300, TP4, NEXTN 3/1/4: sgl-eval GSM8K (200, thinking) 0.97, accept length ~3.2-3.6.Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #34401732103
Latest PR Test (Extra): ❌ Run #34401731840
Latest PR Test (AMD ROCm 10): ❌ Run #34401731988