Skip to content

test(checkpointing): seed CPU initialization in checkpoint load test - #8263

Merged
balasaajay merged 1 commit into
NVIDIA:mainfrom
cuichenx:chcui/omar-strategy/seed-checkpoint-load-test
Oct 15, 2026
Merged

balasaajay merged 1 commit into
NVIDIA:mainfrom
cuichenx:chcui/omar-strategy/seed-checkpoint-load-test

Conversation

@cuichenx

@cuichenx cuichenx commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What does this PR do?

Seed both model constructions in test_checkpoint_load_without_microbatch_calculator with torch.manual_seed(123).

The fixture seeds CUDA RNGs, but this test initializes its model weights on the CPU. Without an explicit CPU seed, data-parallel ranks can construct different reference weights. The legacy torch checkpoint saves rank 0's replica, so other ranks compare the restored weights against a different reference. Earlier tests can accidentally align CPU RNG states and mask the failure.

This is a two-line, test-only change. The restored model is still zeroed before loading, and the separate pre-load seed of 987 and all weight/output/RNG assertions remain unchanged. No production code or copyright changes.

⚠️ For major changes (either in lines of code or in its impact), please make sure to first share a design doc with the team. If you're unsure what's the best way to do so, contact @NVIDIA/mcore-oncall.

Issue tracking

For PRs from open-source community contributors:

  • New features: a linked issue is required. Please open a feature request and reference it here before submitting the PR.
  • Small updates (bug fixes, minor improvements): a linked issue is recommended and will accelerate the PR review process.

Linked issue: Related to #7792, which introduced this test.

Contribution process

Pre-checks

  • I have added relevant unit tests
  • I have added relevant functional tests
  • If this PR adds or changes a GPU kernel (Triton, jit_fuser/torch.compile, CUDA extension, TE or external-library dispatch, or a scatter/index accumulation), I have added or updated its bit-exact determinism test and registered it in tests/unit_tests/determinism/kernels/manifest.py (guide)
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

Existing unit-test setup is corrected; no new test cases, GPU kernels, or public APIs are added.

  • Independent full-diff review: no findings.
  • Four-GPU isolated regression and all 16 parametrizations: passed on every rank.
  • Ordering robustness: 140 test executions per rank across seven runs (normal, reverse, three seeded shuffles, and normal/shuffled mixed checkpoint-test sequences), all passed on four H100s. Stress runs deliberately set distinct CPU RNG states per rank after fixtures before each target test; recorded hashes confirm the states differ.
  • Negative control on unpatched base 3914483fd: the same adversarial setup reproduces the original weight-equality assertion on ranks 1–3. Fixed head: d0d34b404. Experiment scripts are external to the PR.
  • git diff --check, scoped Black and Ruff checks pass.
  • The full formatting wrapper cannot run on the workstation because Git 2.25.1 is below its required 2.31 minimum.

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"

  1. When your PR is ready, click Ready for Review.
  2. An oncall reviewer is auto-assigned and expert reviewers are notified based on your changes.
    • Some PRs may jump straight to step 2. This is determined by .github/CODEOWNERS.

⚠️ Only mark as ready once merge-conflicts are resolved and the CI is passing.
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, the Final Review label 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 Approved label is applied automatically.

Merge

Any member of mcore-engineers will be able to merge your PR.

@copy-pr-bot

copy-pr-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@cuichenx
cuichenx marked this pull request as ready for review October 15, 2026 17:47
@svcnvidia-nemo-ci
svcnvidia-nemo-ci requested a review from a team October 15, 2026 17:47
@deepakn94
deepakn94 self-requested a review October 15, 2026 17:57
@deepakn94
deepakn94 enabled auto-merge October 15, 2026 17:59
@deepakn94
deepakn94 added this pull request to the merge queue Oct 15, 2026
@balasaajay
balasaajay removed this pull request from the merge queue due to a manual request Oct 15, 2026
@balasaajay
balasaajay added this pull request to the merge queue Oct 15, 2026
@nemo-automation-bot

Copy link
Copy Markdown

🔄 Merge queue validation started!

You can track the progress here: https://github.com/NVIDIA/Megatron-LM/actions/runs/38821466909

@balasaajay
balasaajay removed this pull request from the merge queue due to a manual request Oct 15, 2026
@balasaajay
balasaajay merged commit ee6baa2 into NVIDIA:main Oct 15, 2026
125 checks passed
nemo-autobot-origin Bot pushed a commit to svcnemo-autobot/Megatron-LM that referenced this pull request Oct 16, 2026
Bring in NVIDIA#8263, which seeds the CPU-initialized models in test_checkpoint_load_without_microbatch_calculator. This PR's testmon selection runs those 16 cases alone. Without the seed, the data-parallel ranks build different reference weights, and the H100 unit job hangs in the NCCL barrier of the next case's fixture.

Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>

This branch was successfully deployed

2 active deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants