Skip to content

fix(vllm): support misaligned MXFP8 MoE dimensions - #3630

Merged
terrykong merged 37 commits into
NVIDIA-NeMo:mainfrom
seonjinn:sna/mxfp8-moe-padding
Sep 17, 2026
Merged

terrykong merged 37 commits into
NVIDIA-NeMo:mainfrom
seonjinn:sna/mxfp8-moe-padding

Conversation

@seonjinn

@seonjinn seonjinn commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable FlashInfer TRTLLM MXFP8 MoE for models whose dimensions are valid for MXFP8 but do not meet the kernel's stricter alignment requirements.

The key idea is simple: keep checkpoint/refit weights unchanged, and pad only the tensors used by the MoE kernel.

Why this is needed

FlashInfer TRTLLM requires:

  • hidden size divisible by 512
  • TP-local intermediate size divisible by 128

Nemotron Nano 3 does not meet either requirement:

Dimension TP1 TP2 Kernel requirement
Hidden size 2688 2688 multiple of 512
Local intermediate size 1856 928 multiple of 128

Without padding, MXFP8 rollout fails while initializing the MoE kernel.

How it works

For a TP1 Nano expert:

Canonical checkpoint/refit tensors       FlashInfer execution tensors
hidden:       2688  ------------------>   3072
intermediate: 1856  ------------------>   1920
                    zero-padding only

The forward path follows the same rule:

activation [..., 2688]
  -> pad to [..., 3072]
  -> run FlashInfer MXFP8 MoE with padded W13/W2
  -> crop output back to [..., 2688]

Checkpoint loading and repeated refits still read and write the original 2688/1856 tensors. The padded regions contain zero-valued weights with neutral E8M0 scales, so they do not change the original output.

Implementation

  • derive aligned runtime dimensions from the model and tensor-parallel partition
  • preserve canonical W13/W2 values and scales for checkpoint loading and refit
  • create separate padded runtime weights and scales for FlashInfer
  • pad gated W13 gate/up projections independently
  • reuse padded runtime buffers across refits
  • reject the unsupported padded modular-kernel path with an explicit error
  • install the patch in both legacy and vLLM 0.25.1 Ray executor workers

Validation

  • Lyris GB200, NeMo-RL nightly, vLLM 0.25.1
  • 33 targeted vLLM unit tests passed; Pyrefly reported 0 errors
  • Nemotron Nano 3, BF16 training + all-MXFP8 MoE rollout
  • TP1 and TP2 each completed 2 GRPO steps
  • TP1 refit: 2.68 s / 2.25 s; TP2 refit: 2.10 s / 1.62 s
  • coverage includes padding contracts, gated/non-gated numerical parity, repeated refit, grouped loading, kernel reuse, and Ray worker serialization

Scope

This PR only adds FlashInfer TRTLLM MXFP8 MoE dimension padding. Adaptive 8x4/128x4 scale-layout selection, QKVO quantization, and mixed BF16/MXFP8 layerwise reload are outside this PR.

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@seonjinn seonjinn added the CI:L1 Run doctests, unit tests, and functional tests label Aug 13, 2026
@seonjinn
seonjinn marked this pull request as ready for review August 13, 2026 20:57
@seonjinn
seonjinn requested review from a team as code owners August 13, 2026 20:57
@seonjinn
seonjinn force-pushed the sna/mxfp8-moe-padding branch from de9ab1f to d2f5f6b Compare August 13, 2026 21:48
@seonjinn
seonjinn force-pushed the sna/mxfp8-moe-padding branch from d2f5f6b to aabb197 Compare August 13, 2026 21:52
@seonjinn

Copy link
Copy Markdown
Contributor Author

/review-pr-team self-review

Reviewed tensor/layout correctness, vLLM worker lifecycle, refit behavior, error boundaries, tests, and CI compatibility.

Resolved findings:

  • moved the new tests into the L0 vLLM unit-test collection
  • prevented checkpoint-engine refit from running the whole-model post-load hook twice
  • preserved valid E8M0 scale byte zero instead of rewriting it
  • installed the MXFP8 patch before model loading in vLLM 0.25.1 RayExecutorV2 workers
  • isolated per-executor FP8 configs and added a cloudpickle serialization regression test
  • added gated and non-gated numerical parity coverage for the padded MoE path
  • verified TP1 and TP2 with real Nemotron Nano 3 GRPO runs

Validation at aabb197611026ef7d93c1985c4d609012ed7bdd6:

  • Lyris GB200, vLLM 0.25.1: 33 targeted tests passed
  • Pyrefly: 0 errors
  • Nano TP1: 2 GRPO steps completed
  • Nano TP2: 2 GRPO steps completed

No unresolved high-confidence findings remain from the self-review.

@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test aabb197

Signed-off-by: seonjinn <[email protected]>

# Conflicts:
#	nemo_rl/models/generation/vllm/vllm_backend.py
@seonjinn

Copy link
Copy Markdown
Contributor Author

Contributor self-review refresh for 0440e4f29e8a7bf3b201b85a8408b7eb75d1bc98 after the latest main merge.

The logical-shape preservation, aligned fast path, misaligned MoE padding, checkpoint-engine behavior, and NCCL lifecycle were rechecked. No new source-level findings were identified. Ruff/format/config checks pass locally; Linux vLLM coverage remains delegated to CI.

@guyueh1

guyueh1 commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

/ok to test d0ae775

guyueh1
guyueh1 previously approved these changes Sep 15, 2026
@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test 6ecfdf7

@guyueh1

guyueh1 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

/ok to test dc01362

@guyueh1

guyueh1 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

/ok to test cc5b80d

@guyueh1

guyueh1 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

/ok to test 1314083

@seonjinn

Copy link
Copy Markdown
Contributor Author

@terrykong Could you review this PR ?

@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test f3abda6

@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test 0bd1dc8

@terrykong
terrykong enabled auto-merge (squash) September 17, 2026 06:41
@seonjinn seonjinn added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L1 Run doctests, unit tests, and functional tests labels Sep 17, 2026
@seonjinn
seonjinn force-pushed the sna/mxfp8-moe-padding branch from 0bd1dc8 to 3240185 Compare September 17, 2026 08:54
@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test 3240185

@seonjinn

Copy link
Copy Markdown
Contributor Author

/ok to test 7f1e1de

@terrykong
terrykong merged commit bcf1a56 into NVIDIA-NeMo:main Sep 17, 2026
84 checks passed
@yfw yfw mentioned this pull request Sep 22, 2026
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants