Repository navigation
fix: preserve fp32 router correction bias during refit - #3540
Merged
Merged
Conversation
Contributor
Author
|
/ok to test 7a849d7 |
2 of 4 tasks
Contributor
Author
|
/ok to test 7a849d7 |
Signed-off-by: fujial-code <[email protected]>
fujial-code
force-pushed
the
jia/preserve-fp32-router-bias
branch
from
August 17, 2026 08:01
7a849d7 to
f5984ab
Compare
Contributor
Author
|
/ok to test f5984ab |
fujial-code
commented
Aug 17, 2026
fujial-code
left a comment
Contributor
Author
There was a problem hiding this comment.
Self-review (/review-pr-team)
Reviewed the rebased two-file change at f5984ab954d97fc6ea460221e55bf68442ab0e31 with parallel RL/design, bug/test, comment/process, and independent devil's-advocate passes. No remaining correctness, mixed-dtype transport, or design findings were identified.
What was verified
- The pinned Automodel implementation creates
e_score_correction_biasin FP32 and documents that BF16 quantization can change expert routing. - The refit payload and
state_dict_infometadata use the same dtype-selection helper after HF state-dict adaptation. - Static inspection found per-tensor dtype support in the IPC, collective, HTTP, and checkpoint-engine refit paths.
Findings resolved before staging this review
- Updated the generator docstring to describe
target_dtypeas the default and document the FP32 router-bias exception. - Applied the Ruff formatting change reported by the previous CI run.
- Rebasing onto current
mainleaves this PR one commit ahead with the same two-file scope. - Added the required
CI:L2label and reauthorized CI for the new SHA.
Verification status
git diff --check: passed.- DCO, title, copyright, and secrets checks: passed or running cleanly on the new SHA.
- The full
CI:L2test matrix is currently queued/running. Local runtime tests were not claimed because the login node has neitheruvnor a working GPU environment. - The existing 50-step plot combines router-FP32 preservation with a stream fence, so it should be treated as preliminary rather than an isolated causal A/B result.
No inline findings remain on the current head. The PR should stay in Draft until the targeted/runtime CI results are available.
Generated by Claude Code
Contributor
Author
|
/ok to test d3974b2 |
yuekaizhang
added a commit
to mferrato/RL
that referenced
this pull request
Aug 26, 2026
PR NVIDIA-NeMo#3540 already preserves the FP32 e_score_correction_bias MoE router buffer during DTensor refit; this PR's more general _keep_in_fp32_modules(_strict) mechanism duplicated that fix. Drop it here to avoid overlapping/conflicting changes and let NVIDIA-NeMo#3540 land the fix; this PR keeps only the non-contiguous top-p logits and keep_top_k: null fixes. This reverts commit a697d80 and commit 9edaf9d. Signed-off-by: Yuekai Zhang <[email protected]>
4 tasks done
yuki-97
approved these changes
Aug 26, 2026
yuki-97
left a comment
Contributor
There was a problem hiding this comment.
LGTM! thanks for the fix! @fujial-code
Contributor
|
/ok to test 8f5336c |
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.
What does this PR do?
Preserve the Nemotron-Nano V3 MoE
e_score_correction_biasbuffer in FP32 during DTensor policy refit instead of unconditionally casting it to the policy dtype (typically BF16).The change keeps the refit payload and its metadata consistent:
dtensor_params_generatorsends the router correction bias in its original FP32 dtype.prepare_refit_infoadvertises FP32 for the same tensor.Why?
e_score_correction_biasis maintained in FP32, but the current refit path casts every tensor toself.dtype. For BF16 policies, that downcast can introduce coarse rounding in the router correction values and change expert routing between the trainer and generation model.This prevents an avoidable FP32-to-BF16 precision loss for the router correction bias in the full-weight refit path.
Experimental context
The plot below shows the 50-step merged-LoRA run with the FP32 router-bias preservation enabled together with a stream fence.
train/gen_kl_errorstarts near the0.002scale, grows after approximately step 18, and reaches a transient peak of approximately0.102around step 26 before returning near its initial scale. The fix prevents the FP32 router correction state from being quantized during each refit, removing that source of precision loss from the merged full-weight sync path.Issues
No linked issue.
Usage
No configuration change is required. FP32 preservation is selected only for tensors whose final fully qualified name is
e_score_correction_biasand whose source dtype is FP32.Testing
git diff --checkpasses.torchorpytest; full Nano V3 regression remains pending.Before this PR is ready for review