Skip to content

[Qwen4-Exp] Load nvidia/Qwen3.8-Flash-Next-NVFP4 (ModelOpt MIXED_PRECISION: NVFP4 experts, fp8 PLE, fp8 MTP) - #37752

Closed
YAMY1234 wants to merge 2 commits into
sgl-project:qwen4-main-squashed-rebasedfrom
YAMY1234:qwen38-flash-next-nvidia-mixed
Closed

YAMY1234 wants to merge 2 commits into
sgl-project:qwen4-main-squashed-rebasedfrom
YAMY1234:qwen38-flash-next-nvidia-mixed

Conversation

@YAMY1234

@YAMY1234 YAMY1234 commented Sep 3, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Stacked on #37500. nvidia/Qwen3.8-Flash-Next-NVFP4 (ModelOpt export) does not load on the qwen4-main-squashed-rebased branch. Unlike RadixArk/Qwen3.8-Flash-Next-NVFP4, the NVIDIA checkpoint is a ModelOpt MIXED_PRECISION export:

part quant checkpoint metadata
routed experts (48 layers) NVFP4 g16 quantized_layers["model.language_model.layers.N.mlp.experts"]
PLE n-gram table FP8 per-tensor quantized_layers["model.language_model.layers.1.ple.ple_embedding.ngram_embedding"], 128 fp8 shard_N.weight + weight_scale
MTP experts FP8_BLOCK_SCALES g128 quantized_layers["mtp.layers.0.mlp.experts"], weight_scale_inv
everything else bf16 292-entry glob ignore list

config.json carries the quantization_config (quant_method: modelopt) and has no text_config.ple_embedding_dtype.

On the base branch the server dies while loading weights:

ValueError: fp8 PLE auto-switch is unsupported with ple_offload_embedding; set text_config.ple_embedding_dtype="float8_e4m3fn" instead

and with --no-ple-offload-embedding it dies at CUDA-graph capture:

NotImplementedError: Unsupported moe_runner_backend for NVFP4 MoE: MoeRunnerBackend.FLASHINFER_TRTLLM. Use --moe-runner-backend flashinfer_cutlass instead.

Modifications

  • ModelOptMixedPrecisionConfig: resolve model.language_model.* keys against the model.* prefixes Qwen4-Exp modules use; default exclude_modules to [] (ModelOpt may omit ignore, and is_layer_skipped iterates it); map FP8_BLOCK_SCALES to the 128x128 block Fp8LinearMethod / Fp8MoEMethod.
  • Qwen4ExpNGramEmbedding: pick fp8 table storage when the mixed config marks the ngram table FP8 (previously only an fp8 checkpoint or explicit ple_embedding_dtype), so the pinned-host offload path sees fp8 storage up front instead of hitting the auto-switch error.
  • model_overrides/qwen3_moe.py: apply the sm100 flashinfer_trtllm MoE runner override to modelopt_mixed as well. With the runner left on auto, ModelOptNvFp4FusedMoEMethod.create_moe_runner resolves TRTLLM at run time while enable_flashinfer_trtllm_moe was computed as False at init, which is what raised the NotImplementedError above.
  • _mtp_quant_config: keep the mixed config for the MTP head when it lists mtp.* layers (the NVIDIA checkpoint quantizes the MTP experts); previously it was dropped, so the fp8 expert weights would have been loaded into bf16 params.
  • Unit test for the key resolution and the FP8_BLOCK_SCALES MoE mapping in test_modelopt_loader.py.

Accuracy Tests

All runs: GB300 (sm103), TP1, --linear-attn-{prefill,decode}-backend flashinfer --mamba-ssm-dtype bfloat16, container lmsysorg/sglang:nightly-dev-cu13-20260901-07c8f729 with this branch overlaid. GSM8K = sgl-eval, 200 examples, thinking on, max_tokens=16384 (same as test_qwen4_exp_models.py, threshold 0.94). MTP = NEXTN 3/1/4.

checkpoint source PLE offload MTP startup GSM8K (200) accept len
nvidia/Qwen3.8-Flash-Next-NVFP4 base branch (#37500 head 593134d) on off fails to load (fp8 PLE auto-switch is unsupported with ple_offload_embedding) - -
nvidia/Qwen3.8-Flash-Next-NVFP4 base branch on on fails to load (same error) - -
nvidia/Qwen3.8-Flash-Next-NVFP4 this PR on off 904 s 0.965 -
nvidia/Qwen3.8-Flash-Next-NVFP4 this PR off off 904 s 0.975 -
nvidia/Qwen3.8-Flash-Next-NVFP4 this PR on on 1024 s 0.970 3.04
nvidia/Qwen3.8-Flash-Next-NVFP4 this PR off on 1024 s 0.965 3.02
RadixArk/Qwen3.8-Flash-Next-NVFP4 (regression check) this PR on off 624 s 0.970 -
RadixArk/Qwen3.8-Flash-Next-NVFP4 (regression check) base branch on on 664 s (5-shot smoke only) -

All runs finished with stop_rate 1.0 (0.995 on one run) and error_rate 0.0; the same code path was also exercised on a synthetic copy of the RadixArk checkpoint rewritten to the NVIDIA MIXED_PRECISION metadata (0.965-0.975, MTP accept 3.03).

Unit tests: pytest test/registered/unit/model_loader/test_modelopt_loader.py -k MixedPrecision -> 14 passed.

Checklist

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #33821513388
Latest PR Test (Extra): ❌ Run #33821513119
Latest PR Test (AMD ROCm 7.2): ❌ Run #33821513209

…PLE and fp8 MTP

nvidia/Qwen3.8-Flash-Next-NVFP4 is exported by ModelOpt as MIXED_PRECISION:
routed experts NVFP4, the PLE n-gram table FP8 (shard_N.weight + weight_scale),
MTP experts FP8_BLOCK_SCALES (weight_scale_inv), quantized_layers keyed
model.language_model.* and no text_config.ple_embedding_dtype. Four things kept
it from loading on this branch:

- ModelOptMixedPrecisionConfig could not match model.language_model.* keys to
  the model.* prefixes Qwen4-Exp modules use, and iterated exclude_modules=None.
- Qwen4ExpNGramEmbedding only picked fp8 storage for an fp8 checkpoint or an
  explicit ple_embedding_dtype, so the fp8 shards hit the offload auto-switch
  ValueError; it now resolves the table's quant_algo from the mixed config.
- The sm100 Qwen MoE override skipped modelopt_mixed, leaving the runner on
  auto; ModelOptNvFp4FusedMoEMethod then resolved trtllm at run time but had
  enable_flashinfer_trtllm_moe=False and raised Unsupported moe_runner_backend.
- _mtp_quant_config dropped the mixed config for the MTP head, and the mixed
  config had no FP8_BLOCK_SCALES mapping; both now route the MTP experts to
  the 128x128 block Fp8MoEMethod.
Comment thread python/sglang/srt/models/qwen3_5_mtp.py Resolved
@YAMY1234
YAMY1234 force-pushed the qwen38-flash-next-nvidia-mixed branch from 66d242d to 056877d Compare September 4, 2026 00:07
…stub test

- qwen3_moe override: only default modelopt_mixed to flashinfer_trtllm when the
  mixed config's expert layers are NVFP4/FP8; W4A16_NVFP4 experts go to marlin
  (or reject an explicit non-marlin runner), mirroring the Nemotron override.
- test_shared_experts_fusion_gates: the modelopt_mixed stub now carries
  quantized_layers; add the positive mtp.* case.
@YAMY1234
YAMY1234 force-pushed the qwen38-flash-next-nvidia-mixed branch from 056877d to 4369675 Compare September 4, 2026 00:22
Jiminator pushed a commit that referenced this pull request Sep 5, 2026
…PLE and fp8 MTP

nvidia/Qwen3.8-Flash-Next-NVFP4 is exported by ModelOpt as MIXED_PRECISION:
routed experts NVFP4, the PLE n-gram table FP8 (shard_N.weight + weight_scale),
MTP experts FP8_BLOCK_SCALES (weight_scale_inv), quantized_layers keyed
model.language_model.* and no text_config.ple_embedding_dtype. Four things kept
it from loading on this branch:

- ModelOptMixedPrecisionConfig could not match model.language_model.* keys to
  the model.* prefixes Qwen4-Exp modules use, and iterated exclude_modules=None.
- Qwen4ExpNGramEmbedding only picked fp8 storage for an fp8 checkpoint or an
  explicit ple_embedding_dtype, so the fp8 shards hit the offload auto-switch
  ValueError; it now resolves the table's quant_algo from the mixed config.
- The sm100 Qwen MoE override skipped modelopt_mixed, leaving the runner on
  auto; ModelOptNvFp4FusedMoEMethod then resolved trtllm at run time but had
  enable_flashinfer_trtllm_moe=False and raised Unsupported moe_runner_backend.
- _mtp_quant_config dropped the mixed config for the MTP head, and the mixed
  config had no FP8_BLOCK_SCALES mapping; both now route the MTP experts to
  the 128x128 block Fp8MoEMethod.

Ported from #37752 (base qwen4-main-squashed-rebased) onto qwen4-main-squashed:
- The sm100 Qwen MoE runner override lives inline in arg_groups/overrides.py
  on this branch (model_overrides/qwen3_moe.py does not exist here yet).
- This branch's ModelOptMixedPrecisionConfig has no fp8_pb_wo_config, so a
  128x128 block Fp8Config (fp8_block_config) is added for FP8_BLOCK_SCALES.
- Comments trimmed.

(cherry picked from commit 7bc5bec)
Jiminator pushed a commit that referenced this pull request Sep 5, 2026
…stub test

- qwen3_moe override: only default modelopt_mixed to flashinfer_trtllm when the
  mixed config's expert layers are NVFP4/FP8; W4A16_NVFP4 experts go to marlin
  (or reject an explicit non-marlin runner), mirroring the Nemotron override.
- test_shared_experts_fusion_gates: the modelopt_mixed stub now carries
  quantized_layers; add the positive mtp.* case.

Ported from #37752 onto qwen4-main-squashed: the override and its test target
arg_groups/overrides.py instead of model_overrides/qwen3_moe.py.

(cherry picked from commit 4369675)
@Qiaolin-Yu
Qiaolin-Yu deleted the branch sgl-project:qwen4-main-squashed-rebased September 8, 2026 20:56
@Qiaolin-Yu Qiaolin-Yu closed this Sep 8, 2026
Jiminator pushed a commit to Jiminator/sglang that referenced this pull request Sep 8, 2026
Restore the original sgl-project#38121/sgl-project#37752 MTP and sm100 runner gates, which are still absent from main. Deployment testing found that dropping the mixed MTP config loads FP8 expert values without their intended quantization method and reduces draft acceptance.

Co-authored-by: Yangmin Li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

quant LLM Quantization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants