Skip to content

quant: nvfp4_nf3_hybrid — native serving for mixed NVFP4+NF3 MoE checkpoints - #92

Closed
MadeBy561 wants to merge 1 commit into
local-inference-lab:dev/fathomless-firmamentfrom
MadeBy561:quant/nvfp4-nf3-hybrid
Closed

quant: nvfp4_nf3_hybrid — native serving for mixed NVFP4+NF3 MoE checkpoints#92
MadeBy561 wants to merge 1 commit into
local-inference-lab:dev/fathomless-firmamentfrom
MadeBy561:quant/nvfp4-nf3-hybrid

Conversation

@MadeBy561

@MadeBy561 MadeBy561 commented Jul 13, 2026

Copy link
Copy Markdown

Native serving for per-expert mixed-precision MoE checkpoints — the configuration behind
madeby561/GLM-5.2-MXFP8-NVFP4-NF3-Hybrid
(GLM-5.2 753B, all 256 experts/layer on 4× 96 GB SM120): top-64 experts NVFP4, 192-expert
tail NF3 3-bit, both tiers through the b12x W4A16 fused MoE kernel.

How it works: NvFp4Nf3HybridConfig extends the ModelOpt NVFP4 config and activates
automatically when a checkpoint's quantization config carries hybrid_bit_map (per-layer,
per-expert bit widths). Per MoE layer the method builds two prepared weight objects and
issues two preplanned launches sharing one route geometry and one topk_sum — CUDA-graph-safe,
with an M≤8 TC-decode direct-topk path (tc_zero_output=False accumulation on the second
launch). Layers absent from the map (e.g. the MTP head) run uniform NVFP4. An explicit
--quantization choice other than nvfp4_nf3_hybrid is respected — auto-detection only
applies when no quantization is forced.

No environment variables. Tier assignment comes from the checkpoint; scratch sizing from
max_num_batched_tokens. This replaces an out-of-tree runtime graft (site hook +
monkey-patch) that has served this exact configuration in production since 2026-07-05.

Depends on: b12x nf3_2p1 W4A16 layout — local-inference-lab/b12x#31. This PR should not merge
before that one.

Testing:

  • Kernel-side numerical reference battery: b12x#31 tests/test_w4a16_nf3.py, 3/3 green.
  • In-image (v19) import + detection tests passed: the real K64R16 checkpoint's config.json
    auto-selects nvfp4_nf3_hybrid (75-layer hybrid_bit_map read, no flags, no envs).
  • Full zero-graft serving boot (pool, decode coherence incl. M≤8 TC path, MTP acceptance)
    runs later today; results will be posted as a comment.

Co-authored with Claude (Fable 5).

Summary by CodeRabbit

  • New Features
    • Added support for the nvfp4_nf3_hybrid quantization method.
    • Enables hybrid mixture-of-experts models to use NVFP4/MXFP4 formats for selected experts and NF3 for others.
    • Added validation and configuration support for hybrid quantization metadata.
    • Improved runtime handling of hybrid expert execution across supported decode and prefill workloads.

A quantization method for per-expert mixed-precision MoE checkpoints:
high-saliency experts in NVFP4 (or MXFP4), a low-saliency tail in NF3
3-bit, both served through the b12x W4A16 fused MoE kernel as two
preplanned launches per layer sharing one route geometry and one
topk_sum (CUDA-graph-safe; TC-decode direct-topk path at M<=8).

Detection: a modelopt-tagged NVFP4 checkpoint whose quantization config
carries `hybrid_bit_map` (per-layer, per-expert bit widths; 4 = kept,
3 = NF3) selects this method automatically. `kept_format` optionally
switches the kept tier to MXFP4. No environment variables; scratch is
sized from max_num_batched_tokens.

Replaces the out-of-tree runtime graft that has served this
configuration in production since 2026-07-05. Requires b12x with the
nf3_2p1 W4A16 layout (local-inference-lab/b12x#31).

Co-authored-by: Claude (Fable 5) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 750d82ff-2e7b-4cdd-b065-fe2c04c4e81c

📥 Commits

Reviewing files that changed from the base of the PR and between c649d41 and 7721056.

📒 Files selected for processing (3)
  • vllm/config/model.py
  • vllm/model_executor/layers/quantization/__init__.py
  • vllm/model_executor/layers/quantization/nvfp4_nf3_hybrid.py

📝 Walkthrough

Walkthrough

Adds nvfp4_nf3_hybrid quantization detection and dispatch, with configuration parsing, tiered expert weight loading and repacking, shared runtime planning, and execution through NVFP4, NF3, or MXFP4 MoE paths.

Changes

Hybrid quantization support

Layer / File(s) Summary
Method registration and configuration
vllm/config/model.py, vllm/model_executor/layers/quantization/__init__.py, vllm/model_executor/layers/quantization/nvfp4_nf3_hybrid.py
Registers nvfp4_nf3_hybrid, resolves NvFp4Nf3HybridConfig, reads hybrid checkpoint settings, and defines hybrid runtime state.
Tiered weight loading and repacking
vllm/model_executor/layers/quantization/nvfp4_nf3_hybrid.py
Classifies experts into kept and NF3 tiers, loads tier-specific tensors, and repacks them into b12x-compatible formats.
Launch planning and hybrid execution
vllm/model_executor/layers/quantization/nvfp4_nf3_hybrid.py
Caches launch variants, initializes shared buffers, executes kept and NF3 tiers, optionally uses the MXFP4 modular kernel, and sums outputs.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant NvFp4Nf3HybridMoEMethod
  participant HybridSharedRuntime
  participant B12xFusedMoE
  participant MXFP4ModularKernel
  NvFp4Nf3HybridMoEMethod->>HybridSharedRuntime: Ensure buffers and launch plans
  NvFp4Nf3HybridMoEMethod->>B12xFusedMoE: Execute NVFP4 and NF3 tiers
  NvFp4Nf3HybridMoEMethod->>MXFP4ModularKernel: Execute kept MXFP4 tier when configured
  B12xFusedMoE-->>NvFp4Nf3HybridMoEMethod: Return tier outputs
  MXFP4ModularKernel-->>NvFp4Nf3HybridMoEMethod: Return kept-tier output
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding native serving support for nvfp4_nf3_hybrid mixed NVFP4+NF3 MoE checkpoints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@voipmonitor

Copy link
Copy Markdown

Superseded by #104, which rebases the same implementation onto the current dev/fathomless-firmament head and adds focused CPU unit coverage for detection, parsing, validation, and NF3 unpacking. Closing this old-base PR so Luke has one canonical merge target.

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