Repository navigation
fix(training): reuse Megatron-Core determinism setup under --deterministic - #6271
Merged
Merged
Conversation
2 of 5 tasks
malay-nagda
previously approved these changes
Oct 9, 2026
Contributor
|
/ok to test 2cefe2a |
Contributor
|
Automatic Claude reviews have been retired. To request a pull-request review, post a comment containing: Add |
cuichenx
previously approved these changes
Oct 9, 2026
ZhiyuLi-Nvidia
dismissed stale reviews from cuichenx and malay-nagda
via
October 9, 2026 19:52
c879c5e
Contributor
Author
|
/ok to test c879c5e |
Contributor
Author
|
/ok to test b60f603 |
ZhiyuLi-Nvidia
force-pushed
the
zhiyul/det-reuse-mcore-setup
branch
from
October 12, 2026 08:49
b60f603 to
ec13f2e
Compare
Contributor
Author
|
/ok to test ec13f2e |
Contributor
|
/ok to test 3ef4d9b |
…istic Bridge's --deterministic hand-maintained its own copy of Megatron-Core's determinism rules, and the two had drifted. Delegate to Megatron-Core (megatron/training/determinism.py) so both frameworks enforce the same setup: - ConfigContainer calls apply_determinism_to_args: required option values (cross-entropy fusion, TP comm overlap, MoE aux-loss fusion), env-var validation + defaults, torch deterministic algorithms. - apply_determinism_overrides disables only the MoE aux-loss fusion (fused TopK routing stays on) and exports DETERMINISM_ENV_VAR_DEFAULTS at launch, plus MAMBA_DETERMINISTIC / CAUSAL_CONV1D_DETERMINISTIC. Behavior now follows Megatron-Core: NCCL_ALGO=Tree is rejected, an unset NCCL_ALGO defaults to Ring, a non-deterministic NVTE_ALLOW_NONDETERMINISTIC_ALGO is rejected, and fill_uninitialized_memory is left off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Zhiyu Li <zhiyul@nvidia.com>
…6272) Signed-off-by: Zhiyu Li <zhiyul@nvidia.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Flat perf recipes must assign one inline cfg.env_vars literal (docs/recipe-usage.md, enforced by test_perf_recipe_environment.py). Replace the pop/update on the parent mapping with the full literal, grouped into determinism and other settings. The resulting environment is unchanged. Allow *_deterministic_config recipes to pin NVTE_ALLOW_NONDETERMINISTIC_ALGO=0 in the environment invariant test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Zhiyu Li <zhiyul@nvidia.com>
Megatron-Core's DETERMINISM_ENV_VAR_DEFAULTS on main now includes NCCL_EP_HT_EM_AG_SCAN_MODE=1. Mirror it in the inline determinism section so the recipe environment matches apply_determinism_overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Zhiyu Li <zhiyul@nvidia.com>
ZhiyuLi-Nvidia
force-pushed
the
zhiyul/det-reuse-mcore-setup
branch
from
October 12, 2026 16:57
3ef4d9b to
6a219ba
Compare
Contributor
Author
|
/ok to test 6a219ba |
ZhiyuLi-Nvidia
enabled auto-merge (squash)
October 13, 2026 04:32
cuichenx
approved these changes
Oct 13, 2026
cuichenx
disabled auto-merge
October 13, 2026 16:40
cuichenx
enabled auto-merge (squash)
October 13, 2026 16:40
malay-nagda
approved these changes
Oct 13, 2026
3 of 5 tasks
This branch was successfully deployed
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 Bridge's
--deterministicdelegate to Megatron-Core's determinism setup (megatron/training/determinism.py) instead of a hand-maintained copy that had drifted from it.Changelog
ConfigContainer._validate_and_apply_deterministic_modecallsapply_determinism_to_args: required option values (cross-entropy loss fusion, TP comm overlap, MoE aux-loss fusion), env-var validation and defaults, and torch deterministic algorithms.apply_determinism_overridesdisables only the MoE aux-loss fusion (fused TopK routing stays on, per fix(determinism): Separate the MoE aux-loss fusion flag so --deterministic-mode guards only the op that breaks it NVIDIA/Megatron-LM#6967), exports Megatron-Core'sDETERMINISM_ENV_VAR_DEFAULTSat launch, and pinsMAMBA_DETERMINISTIC/CAUSAL_CONV1D_DETERMINISTIC.test_determinism_utils.py;test_config.pycovers the rejected options, env validation/defaults and the torch state;test_recipe_environment.pyexpects Megatron-Core's string value"0"forNVTE_ALLOW_NONDETERMINISTIC_ALGO.Behavior changes (inherited from Megatron-Core's rules):
NCCL_ALGO=TreeNCCL_ALGORingNVTE_ALLOW_NONDETERMINISTIC_ALGOset to a non-deterministic value--deterministic)torch.utils.deterministic.fill_uninitialized_memoryNo Megatron-LM bump needed: the pinned Megatron-LM already provides
megatron/training/determinism.pyandmoe_router_aux_loss_fusion.Context: this came out of making DeepSeek-V3 MXFP8 on 256 GB300 GPUs bitwise reproducible; a 50-step A/B with this setup (plus kernel-level fixes outside this repo) matched on all 550 logged metric values. A follow-up PR adds the deterministic DSv3 GB300 recipe on top of this change.
GitHub Actions CI
See the CI section in the Contributing doc for how to trigger the CI. A Nvidia developer will need to approve and trigger the CI for external contributors.
Before your PR is "Ready for review"
Pre checks:
Additional Information
test_determinism_utils.py,test_recipe_environment.py,test_config.py::TestConfigContainerValidation), except the GPU-onlytest_native_energon_packing_allows_other_ep_dispatchers_with_fixed_width[flex]which needs a GPU and fails on a CPU node withFound no NVIDIA driver(unrelated to this change).🤖 Generated with Claude Code