Skip to content

Fix integrity settings during checkpoint conversion - #6502

Merged
maanug-nv merged 5 commits into
NVIDIA:mainfrom
bvolpato:bvolpato/save-run-config-yaml
Oct 24, 2026
Merged

maanug-nv merged 5 commits into
NVIDIA:mainfrom
bvolpato:bvolpato/save-run-config-yaml

Conversation

@bvolpato

@bvolpato bvolpato commented Aug 13, 2026 •

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

What does this PR do?

Converting a torch_dist checkpoint to torch with --verify-integrity carries that flag into the converted checkpoint's saved arguments, even though integrity checks only support torch_dist.

Clear args.verify_integrity after loading the source and before saving an unsupported output format. Keep it enabled when the target is torch_dist.

This change does not update the run_config.yaml sidecar or the separate tools/checkpoint/convert.py conversion path. The sidecar can still contain the source checkpoint settings.

⚠️ 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: None.

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

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.

Testing

Before this merge, conversion-argument, training, checkpointing, and config checks passed on the pinned CUDA base with one GPU.

After merging main, focused conversion-argument, checkpoint-selection, and config-mapping tests passed in a CPU-only Python container using one Gloo rank. Model-parallel initialization was stubbed, and the container used PyTorch 2.13.0 instead of the pinned CI image. The conversion regression fails against main and passes with this change. It mocks checkpoint loading and saving.

Black, isort, pylint, and Ruff checks passed for the changed test. Python compilation and git diff --check also passed. Mypy was not run.

GPU/NCCL, end-to-end conversion, and multi-GPU tests were not run after the merge. The standard unit-test command requires the CI container and GPUs:

uv run python -m torch.distributed.run --nproc-per-node=8 -m pytest tests/unit_tests

Upstream build, installation, lint, and documentation checks passed for the current head. GPU tests are waiting for a slot in the automated external-contributor queue.

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 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.

@bvolpato
bvolpato marked this pull request as ready for review August 14, 2026 04:31
@bvolpato
bvolpato requested a review from a team as a code owner August 14, 2026 04:31
@bvolpato
bvolpato requested a review from a team August 14, 2026 04:31
@bvolpato
bvolpato requested a review from a team as a code owner August 14, 2026 04:31
@svcnvidia-nemo-ci
svcnvidia-nemo-ci requested a review from a team August 14, 2026 04:31
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Aug 15, 2026
@bvolpato
bvolpato force-pushed the bvolpato/save-run-config-yaml branch from 79ea001 to 930457d Compare August 21, 2026 05:43
@bvolpato
bvolpato requested a review from a team as a code owner August 21, 2026 05:43
@bvolpato

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and resolved the generated uv.lock conflict. Full checkpointing unit suite (22 tests), formatting, lint, and lock checks pass. Ready for CI vetting and review.

@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label Aug 21, 2026
@bvolpato
bvolpato force-pushed the bvolpato/save-run-config-yaml branch from 930457d to e89e2d7 Compare August 22, 2026 03:37
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Aug 23, 2026
@bvolpato

Copy link
Copy Markdown
Contributor Author

@maanug-nv, could you take a look at this PR when you have a chance? It implements #6002 by saving a Bridge-compatible run_config.yaml from the active PretrainConfigContainer. It covers sync and async checkpoint finalization, conversion/upcycling paths, and legacy provider fallback. Your context from the ConfigContainer and ModelBuilder migration would be especially useful.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-maintainers Waiting on maintainers to respond and removed waiting-on-maintainers Waiting on maintainers to respond labels Aug 29, 2026
@bvolpato
bvolpato requested a review from a team as a code owner September 21, 2026 03:51
@bvolpato
bvolpato force-pushed the bvolpato/save-run-config-yaml branch from 49c9348 to 8c6bea8 Compare September 24, 2026 00:44
@bvolpato
bvolpato force-pushed the bvolpato/save-run-config-yaml branch from 8c6bea8 to c592cc4 Compare October 3, 2026 06:09
@bvolpato bvolpato changed the title Save run config with distributed checkpoints Fix converted checkpoint run-config metadata Oct 3, 2026
Comment thread megatron/training/checkpointing.py Resolved
@dimapihtar

Copy link
Copy Markdown
Contributor

Thanks for the PR!

@dimapihtar
dimapihtar requested a review from maanug-nv October 5, 2026 14:01
@dimapihtar

Copy link
Copy Markdown
Contributor

/ok to test c592cc4

@dimapihtar dimapihtar added the Expert Review [deprecated] Apply this label to indicate that your PR is ready for expert review. label Oct 5, 2026
@maanug-nv

Copy link
Copy Markdown
Contributor

/ok to test 2ea74a3

@maanug-nv

Copy link
Copy Markdown
Contributor

/ok to test b3a73de

@maanug-nv

Copy link
Copy Markdown
Contributor

/ok to test 1997dd7

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the Approved All necessary approvals have been made label Oct 23, 2026
@maanug-nv
maanug-nv added this pull request to the merge queue Oct 23, 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/40038856702

@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/40045640221

Merged via the queue into NVIDIA:main with commit 2052769 Oct 24, 2026
148 of 149 checks passed
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Oct 24, 2026
asolergi-nv added a commit to asolergi-nv/Megatron-LM that referenced this pull request Oct 26, 2026
Five commits landed on main since the last merge (0a2f6ee); one of them
conflicts with this branch, NVIDIA#7047 "[DCP V2 3/4] Integrate dynamic CP with
standard train and eval schedules" (ea99fdf). The other four (NVIDIA#8381 CI
test selection, NVIDIA#8269 PR template, NVIDIA#6502 checkpoint conversion integrity,
NVIDIA#7780 gtp scratch lifetime) do not touch this branch's files.

Conflicts, all resolved in this branch's structure:
- megatron/core/datasets/gpt_dataset.py: imports (warnings for the new
  deprecation warning; no `field`, token_dtype_code is a property here).
  NVIDIA#7047's warn-and-rewrite of the deprecated hybrid_context_parallel alias
  landed in validate_without_tokenizer(), which asserts only: it keeps the
  warning and the "not both" error and does not rewrite the alias; the
  SBHD exclusion counts the alias.
- pretrain_gpt.py, pretrain_hybrid.py: NVIDIA#7047 edited the legacy factory and
  rank predicate this branch replaced with argument_utils and
  megatron.training.datasets.providers; this branch's imports and the
  removals stay, NVIDIA#7047's get_batch changes (pg_collection, dynamic_cp)
  merge as they are.
- tools/prepare_cache.py: same; the shared factory maps the new field.

The renamed field through the data section: dynamic_context_parallel joins
CONTAINER_WRITTEN_FIELDS next to the deprecated alias; the container's
cross-section check reads either name against model.transformer's
dynamic_context_parallel and finalize() writes the canonical field and
clears the alias; the standalone factory forwards both from the
arguments, which validate_args already normalizes (NVIDIA#7047). The ownership,
section, provider and Core config tests follow, with cases for the alias;
the frozen legacy factories the provider tests use as their oracle take
the same one-line rename NVIDIA#7047 gave the originals.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>

This branch was previously deployed

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

Labels

Approved All necessary approvals have been made community-request Expert Review [deprecated] Apply this label to indicate that your PR is ready for expert review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants