Skip to content

perf(refit): quantize grouped FP8 experts in one cast per group - #4738

Merged
youngeunkwon0405 merged 1 commit into
codex/refit-source-pre-hooksfrom
claude/codex/refit-source-pre-hooks
Oct 15, 2026
Merged

youngeunkwon0405 merged 1 commit into
codex/refit-source-pre-hooksfrom
claude/codex/refit-source-pre-hooks

Conversation

@youngeunkwon0405

Copy link
Copy Markdown
Contributor

Summary

FP8 refit on this branch was ~1.8x slower than main for MoE models (Qwen3-30B-A3B: 5.04 s vs 2.75 s weight sync). This change restores it to main's level by quantizing each grouped-expert receive buffer with a single cast_tensor_to_fp8_blockwise call instead of one call per expert.

Root cause

  • _blockwise_fp8_receiver_quant_spec.post re-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.
  • vLLM drains PP stages sequentially on one Python thread in _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.
  • nsys of the training ranks (A/B vs 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:

weight sync (mean, range) train-side misc broadcast KL
main (66c0925) 2.75 s (2.59-2.93) 1.88 s 0.0075
codex/refit-source-pre-hooks 5.04 s (4.83-5.36) 3.38 s 0.0077
this PR 2.56 s (2.38-2.92) 1.90 s 0.0076
  • tests/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

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]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 15, 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.

@youngeunkwon0405
youngeunkwon0405 merged commit 43a166f into codex/refit-source-pre-hooks Oct 15, 2026
10 checks passed
@youngeunkwon0405
youngeunkwon0405 deleted the claude/codex/refit-source-pre-hooks branch October 15, 2026 08:11
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.

1 participant