Skip to content

NVFP4: load a checkpoint's FP8 linears as FP8 - #49922

Draft
IlyasMoutawwakil wants to merge 4 commits into
nvfp4-expertsfrom
nvfp4-fp8-linears
Draft

IlyasMoutawwakil wants to merge 4 commits into
nvfp4-expertsfrom
nvfp4-fp8-linears

Conversation

@IlyasMoutawwakil

@IlyasMoutawwakil IlyasMoutawwakil commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Depends on #49851, the NVFP4 PR. This PR targets its branch.

ModelOpt exports often mix NVFP4 layers with FP8 ones. #49851 loads those FP8 layers dequantized to the model dtype. This PR loads them as they ship, with the same finegrained-kernels it already uses for NVFP4.

What

  • FP8Linear loads three FP8 layer formats next to the NVFP4 ones:
    • fp8: one weight scale per tensor, and the checkpoint's static input_scale for the activations.
    • fp8_per_block: one weight scale per 128x128 block (ModelOpt FP8_PB_WO). Activations are quantized at run time, as vLLM does.
    • mxfp8: one scale per 32 values.
  • quantized_layers takes these formats. The ModelOpt and MXFP8 readers map their layers to them instead of to "dequantize".
  • Tensor parallelism shards FP8Linear like a linear. A per-tensor scale is replicated, and a block scale is split with its weight.
  • A per-tensor FP8 layer that ships no input_scale raises when loading.

Why

Dequantizing keeps a bf16 copy of every FP8 layer. Loading them as FP8 halves their memory and keeps the checkpoint's numerics, at about the same speed.

Results

Each forward is captured in a CUDA graph and timed as replays, without torch.compile. Decode replays one step with a static cache. B200, bf16 model dtype.

nvidia/Muse-Glimmer-30B-NVFP4, one GPU. It mixes 180 per-tensor FP8 layers with 213 weight-only NVFP4 layers.

Dequantized (#49851) FP8 (this PR)
Memory 28.79 GiB 22.98 GiB (-20%)
Prefill, 2048 tokens 172.0 ms 164.2 ms (-4.5%)
Prefill, 8192 tokens 766.5 ms 742.7 ms (-3.1%)
Decode, batch 1 20.39 ms/token 19.70 ms/token (-3.4%)
Decode, batch 16 25.91 ms/token 25.06 ms/token (-3.3%)
Cosine to the full bf16 model's logits 0.99860 0.99854

MiniMax-M3.1-Flash, 4 GPUs with tp_size=4, ep_size=4. Its NVFP4 experts sit next to MXFP8 attention, indexer, shared expert and dense layers.

Dequantized (#49851) FP8 (this PR)
Memory per GPU 67.84 GiB 62.58 GiB (-7.8%)
Prefill, 2048 tokens 285.7 ms 282.9 ms (-1.0%)
Prefill, 8192 tokens 2870.3 ms 2861.5 ms (-0.3%)
Decode, batch 1 35.52 ms/token 38.60 ms/token (+8.7%)
Decode, batch 16 49.24 ms/token 49.87 ms/token (+1.3%)

MiniMax's batch-1 decode is slower because finegrained-kernels' MXFP8 GEMM at one token reads its weights at about a third of bf16 cuBLAS's bandwidth. That is a kernel issue to fix there. In prefill the FP8 GEMMs are about 1.9x faster than bf16, but they are a small part of this model's runtime.

Tests

  • The ModelOpt fixture mixes per-tensor and per-block FP8 layers, and the MXFP8 fixture has MXFP8 linears. Both load as FP8 and match their dequantized model.
  • A per-tensor FP8 layer without its input_scale raises.

🤖 Generated with Claude Code

IlyasMoutawwakil and others added 2 commits October 23, 2026 05:08
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

A converter pattern only ends at a name boundary. `experts.down_proj` also claimed a shared expert's
`shared_experts.down_proj.weight`, so MiniMax-M3.1-Flash failed to load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: nvfp4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants