Skip to content

fix(ckpt): reject unowned export metadata at every PP size - #5585

Merged
cuichenx merged 3 commits into
mainfrom
pruprakash/fix_ckpt_automapping_pp_skip_unowned_param
Oct 9, 2026
Merged

cuichenx merged 3 commits into
mainfrom
pruprakash/fix_ckpt_automapping_pp_skip_unowned_param

Conversation

@pruprakash

@pruprakash pruprakash commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Reject missing export metadata with the mapped parameter name at every pipeline-parallel size. An invalid all-ranks-unowned AutoMapping task now raises instead of silently returning an empty export at PP1; PP2 retains its error and identifies the parameter. Both normal and quantized export entry points use the same check.

The original NemotronH failure no longer reproduces on main after #5262 and #6343. This revision replaces the original allow_missing proposal, which would have hidden an invalid PP2 task. Mapping validation is not a universal ownership guarantee: cached parameter names and caller-supplied tasks still make a clear error useful.

Changelog

  • Enforce the existing object-broadcast ownership requirement at PP1 and include the parameter name in the PP2 error.
  • Remove the empty-export guards and misleading dense-layer/MoE comment.
  • Test missing ownership, valid remote ownership and repeated export, both export entry points, valid False/0 metadata, and missing expert-count metadata.

Validation

  • 454 focused and adjacent unit tests passed; two MXFP8 tests require newer GPU hardware and were skipped.
  • Current-main and candidate NemotronH PP1/PP2 round trips and separate cold exports: complete 29-key output including embedding, correct shapes/dtypes, finite tensors, exact round-trip values, rank agreement, repeat equality, strict HF reload and identical finite/nonconstant HF logits.
  • Real distributed controls: valid parameters arrive from either owning rank; deliberately invalid all-unowned tasks fail with the parameter name at PP1 and PP2 in the candidate. The original proposal returned empty output for the invalid PP2 case.
  • Full repository pre-commit checks and diff checks pass. Strict local typing retains the same existing errors as main; it is not claimed clean.

The semantic fixture is a deterministic tiny random HF NemotronH checkpoint, not pretrained full-model weights. The forward comparison is HF before/after conversion, not Megatron forward parity. Quantized-entry ownership checks do not qualify quantized payload numerics.

Related: NVBug6612509.

Megatron-to-HF export crashed at pipeline_model_parallel_size > 1 with
"Object must exist on at least one PP rank" whenever a Megatron parameter
had no HF counterpart, so every rank reached AutoMapping.megatron_to_hf
with megatron_module=None. The graceful-skip path for that case was
already written but unreachable: broadcast_obj_from_pp_rank raised before
it could return None, while at PP=1 it short-circuits and the parameter is
skipped correctly.

Adds a unit test covering the change (red-green verified).
Detected by: megatron-bridge QA

Signed-off-by: Pruthviraj Prakash <pruprakash@nvidia.com>
@copy-pr-bot

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

@claude

claude Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

LGTM - clean, well-tested fix.

The asymmetric allow_missing usage in megatron_to_hf (owner passes it implicitly False, non-owners pass True) is safe: all_gather_object gives every rank the same ownership list, so the allow_missing branch is only reached when no rank owns the object - in which case all ranks are non-owners and all pass allow_missing=True. When any rank owns it, src_rank is found everywhere and the broadcast runs symmetrically. No collective divergence. The change correctly turns the old ValueError into a graceful {} export for Megatron params with no HF counterpart on any PP rank (e.g. MoE modules on dense layers via moe_layer_freq).

Suggested test cases (all present in this PR):

  • test_megatron_to_hf_skips_param_no_pp_rank_owns - unowned param exports as {} and nothing is broadcast
  • test_megatron_to_hf_uses_type_broadcast_by_owning_pp_rank - non-owning rank still receives the parallelism type from the owner
  • test_broadcast_obj_from_pp_rank_raises_when_unowned_by_default - default (allow_missing=False) still raises when no rank owns the object

No perf tests impacted.

@pruprakash

Copy link
Copy Markdown
Contributor Author

/ok to test 49d95e2

@pruprakash pruprakash added bug Something isn't working area:ckpt Checkpoint conversion, loading, export, and save paths needs-review PR is ready for code review and waiting on a reviewer qa_rcca_done labels Aug 14, 2026
@pruprakash
pruprakash requested a review from yaoyu-33 August 14, 2026 19:47
@yaoyu-33 yaoyu-33 added full-test-suite needs-more-tests Requires additional L0 and L1 test coverage before merge labels Aug 15, 2026
@pruprakash pruprakash self-assigned this Aug 24, 2026
Merge current main into the existing PR and replace silent skipping with a parameter-named error. Preserve valid remote-owner broadcasts and cover both AutoMapping export entry points.

Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
@cuichenx cuichenx changed the title fix(ckpt): skip export of parameters no PP rank owns fix(ckpt): reject unowned export metadata at every PP size Oct 8, 2026
@cuichenx

cuichenx commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Reassessed against current main, including #6343. The historical NemotronH failure no longer reproduces: PP1/PP2 round trips and independent cold exports preserve all 29 expected keys, and strict HF reload produces identical finite, nonconstant logits on a tiny random checkpoint.

The locally rebased allow_missing change did turn a deliberately invalid PP2 task into an empty export. I replaced it with a parameter-named error at both PP1 and PP2, including the quantized API entry, and removed the misleading MoE comment. #5262 validates mappings and checkpoint keys, but cached names and supplied conversion tasks mean that is not a universal ownership guarantee.

Validation: 454 focused/adjacent tests passed (two hardware-specific MXFP8 skips), real distributed valid-owner and invalid-owner controls passed, 11 final regression cases passed, and repository hooks passed. Independent review approved the final change. This is small-model HF round-trip evidence, not pretrained-model or Megatron-forward parity coverage.

@cuichenx

cuichenx commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

/ok to test fb24c1e

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Automatic Claude reviews have been retired. To request a pull-request review, post a comment containing:

/review

Add model=claude to use a Claude reviewer (the default is model=codex). mode=light|strict selects the review depth; for example, /review model=claude mode=strict. Comment /review help for all options.

@cuichenx
cuichenx merged commit 14d0737 into main Oct 9, 2026
157 checks passed
@cuichenx
cuichenx deleted the pruprakash/fix_ckpt_automapping_pp_skip_unowned_param branch October 9, 2026 00:12
@qiaochuz-nv

Copy link
Copy Markdown

Retrospective QA-fix tracking issue: #6399. It records the fix authored by @pruprakash and delivered by this merged PR.

This branch was successfully deployed

1 active and 1 inactive (outdated) deployments
test — fb24c1e2 Deployed Oct 8, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #22632
public — 49d95e2f Deployed Aug 14, 2026 by copy-pr-bot[bot] via release / finalize / publish-docs #4601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ckpt Checkpoint conversion, loading, export, and save paths bug Something isn't working full-test-suite needs-more-tests Requires additional L0 and L1 test coverage before merge needs-review PR is ready for code review and waiting on a reviewer qa_rcca_done

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants