Conversation
Signed-off-by: Zhan Rongrui <me@zrr.dev>
4 tasks
morirun
reviewed
Sep 17, 2026
morirun
left a comment
There was a problem hiding this comment.
温和核对(Draft):
- 把可复现 L2 norm 收成
get_reproducible_grad_norm_bins+ReproducibleL2Norm,并经use_accuracy_compatible and clip_grad > 0门控,方向清楚;非 L2 直接ValueError也合理。 clip_grad_by_total_norm_fp32在缺multi_tensor_scale_tensor_impl时回退到clip_coeff.item()的路径值得留着,避免 accuracy 路径在部分构建上硬断言。- 请确认空
grads_for_norm与grad_stats_parallel_group is None时与旧get_grad_norm_fp32行为一致(当前空列表走device=None的 zeros,看起来有兜底)。 - 与 PFCCLab/ms-swift#14 是配对变更:合并顺序或版本门槛最好在说明里写清,避免下游先合后炸。
当前 alignment_model_accuracy 红,Draft 状态下先把该检查或依赖说明对齐即可。不代推。
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?
Make positive-threshold gradient clipping reproducible under the existing accuracy-compatible mode. Accumulate device-computed FP32 squares in integer bins across the existing dense/expert ownership groups, then round once before taking the square root. A missing fused tensor-scale kernel uses the existing local scaling implementation.
Keep the existing configuration names and optimizer-selection behavior, including
norm_accuracy_compatible,router_accuracy_compatible,dsa_accuracy_compatible, andnative_unfused_adamw. Read the existingUSE_ACCURACY_COMPATIBLEmode; no switch unification or model-path rewrite is included. Ordinary mode and zero-threshold clipping retain their existing norm path.Validation: 14 focused tests passed on each of two GPU ranks, covering FP32 rounding, non-finite values, partition/layout invariance, dense/expert ownership groups, actual clipping, disabled clipping, and a native optimizer update. Black/isort and diff checks passed. Pylint returned zero with an existing
bad-builtinsconfiguration warning. Full remote precision CI has not passed; the paired local results and installation blocker are detailed below.The companion Swift change must preserve the requested clipping threshold. This PR does not change CI workflows, dependency sources, model case scripts, or comparison tolerances.
Paired local validation uses Megatron
6b4771e50, Swiftd3d0b1a87, and Fleetd889f0a1: the original GLM52 CI profile passed 100 bitwise-identical loss steps and 187 identical canonical checkpoint tensors; the acceptance-profile native entrypoints separately passed 100 steps with strict loss, provenance and checkpoint oracles. Both sides also match their prior local baselines. The original two-rank GLM45 10-step regression withclip_grad=1.0passed all 40 raw per-token/final-loss hash records and both same-side baseline comparisons.These runs use local Paddle
3.4.0.post20260808+733f3454aa0and Torch2.12.1+cu129; they do not establish remote CI equivalence. The current PR precision job failed before model execution because Fleet develop cannot resolve its pinned Paddle3.4.0.post20260907+4d8f64b7049. The dependency-index fix is in Fleet NVIDIA#1961. Evidence:experiments/ops/restore-pair-20260916/{ci-terminal,terminal}.jsonandexperiments/ops/restore-pair-regression-20260916/glm45-pair-r0/{protocol,source-binding,comparison}.json.Companion PR: PFCCLab/ms-swift#14.
Issue tracking
For PRs from open-source community contributors:
Related: #17, #20 and PaddleFleet #1961.
Contribution process
Pre-checks
Code review
Feel free to message or comment @NVIDIA/mcore-oncall to help accelerate your merge into main. The less complex your PR is, the faster it will be approved and merged!
All PRs start as draft. If you open a non-draft PR, it will be automatically converted to draft.
Step 1: Mark PR as "Ready for Review"
.github/CODEOWNERS.Final Review might get declined if these requirements are not fulfilled.
Step 2: Final Review
For PRs that change
megatron/core, once all expert reviewers have approved, theFinal Reviewlabel is applied automatically and final reviewers are assigned.For PRs outside
megatron/core, this step is skipped.Step 3: Approved
Once all required reviewers have approved, the
Approvedlabel is applied automatically.Merge
Any member of mcore-engineers will be able to merge your PR.