Repository navigation
perf(refit): quantize grouped FP8 experts in one cast per group - #4738
Merged
youngeunkwon0405 merged 1 commit intoOct 15, 2026
Merged
youngeunkwon0405 merged 1 commit into
youngeunkwon0405 merged 1 commit into
Conversation
The blockwise FP8 receiver hook quantized grouped MoE experts one expert at a time, launching a dozen small kernels per expert from Python. vLLM drains PP stages sequentially on one thread, so this CPU-bound loop delayed the receives for later stages and left training ranks blocked in their first NCCL send. FP8 blocks never straddle experts (vLLM requires block-aligned per-rank expert shapes), so one cast of the flattened [E * rows, cols] group is bitwise-identical to the per-expert casts. FP8 Qwen3-30B-A3B EP8xPP2 -> TP2 weight sync: 5.04 s -> 2.56 s (main: 2.75 s), KL unchanged. Signed-off-by: Youngeun Kwon <[email protected]>
youngeunkwon0405
merged commit Oct 15, 2026
43a166f
into
codex/refit-source-pre-hooks
10 checks passed
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.
Summary
FP8 refit on this branch was ~1.8x slower than
mainfor MoE models (Qwen3-30B-A3B: 5.04 s vs 2.75 s weight sync). This change restores it tomain's level by quantizing each grouped-expert receive buffer with a singlecast_tensor_to_fp8_blockwisecall instead of one call per expert.Root cause
_blockwise_fp8_receiver_quant_spec.postre-quantized grouped MoE experts one expert at a time in Python (cast_tensor_to_fp8_blockwise+ two copies per expert). For Qwen3-30B-A3B at gen TP2 that is ~18k casts per refit, each launching a dozen small kernels._nccl_reshard_refit_impl, so this CPU-bound loop delayed posting the receives for the second PP stage. The training ranks of that stage sat in their first NCCL send waiting for vLLM to join.main, same container) showed identical GPU compute (dequant/cast, GEMM, copies) and the whole difference inside NCCL kernels with unchanged call counts (SendRecv +3.95 s, AllGather +1.32 s, AllReduce +1.23 s per rank over 2 refits), concentrated on one PP stage's ranks.Change
For grouped experts, cast the flattened
[E * rows, cols]buffer once and reshape the values and scales back to[E, rows, cols]/[E, rows / 128, cols / 128]. Blocks never straddle experts because vLLM requires block-aligned per-rank expert shapes for blockwise FP8, so the result is bitwise-identical to the per-expert casts.Validation
Same container (
nemo_rl.1011), python_impl reshard, FP8 Qwen3-30B-A3B, train EP8xPP2 -> gen TP2:main(66c0925)codex/refit-source-pre-hookstests/unit/models/generation/test_nccl_reshard_backend.py --vllm-only: 54 passed, 4 skipped (CUDA-only MXFP8 tests on a CPU node).🤖 Generated with Claude Code