Skip to content

fix(ckpt): auto-generate DSv4 pipeline layout on export when run_config lacks it - #4306

Merged
cuichenx merged 2 commits into
NVIDIA-NeMo:mainfrom
Meirtz:fix/dsv4-export-layout-fallback
Jun 12, 2026
Merged

cuichenx merged 2 commits into
NVIDIA-NeMo:mainfrom
Meirtz:fix/dsv4-export-layout-fallback

Conversation

@Meirtz

@Meirtz Meirtz commented Jun 11, 2026

Copy link
Copy Markdown
Member

What

PP>1 export falls back to bridge.generate_pipeline_layout(...) when run_config.yaml cannot provide a usable layout — exactly like the import path already does.

Why (round-trip bug)

import → export of a DeepSeek-V4 checkpoint at PP>1 currently fails with AssertionError: pipeline_model_parallel_layout must be set when using hash MoE layers with pipeline parallelism (PP > 1).

Root cause: by save time the provider's layout has been finalized into a PipelineParallelLayerLayout object, and run_config.yaml serializes it as an instantiation stub — the actual layout data is lost:

pipeline_model_parallel_layout:
  _call_: true
  _target_: megatron.core.transformer.pipeline_parallel_layer_layout.PipelineParallelLayerLayout

The export-side reader only accepts a list, finds the stub, and the provider then asserts. Reproduced on a full DeepSeek-V4-Flash TP1/PP4/EP8 checkpoint (imported with this same script); with the fallback the export proceeds.

A deeper fix would be serializing the layout in its list form in run_config.yaml (checkpointing owners' call); this script-level fallback restores the import→export round trip now.

Notes

  • AI-assisted (Claude); analysis, repro and review by the human author.

🤖 Generated with Claude Code

…ig lacks it

PP>1 export of a DSv4 checkpoint fails with 'pipeline_model_parallel_layout must be set': the import-time provider finalizes the layout into a PipelineParallelLayerLayout object, and run_config.yaml serializes that as an instantiation stub ({_target_: ...}) — the layout data is lost, so the export-side reader (which expects a list) finds nothing. Fall back to the bridge's generate_pipeline_layout, exactly like the import path already does. Reproduced and verified on a full DeepSeek-V4-Flash TP1/PP4/EP8 checkpoint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Lingrui Mei <lmei@nvidia.com>
@yaoyu-33 yaoyu-33 added area:ckpt Checkpoint conversion, loading, export, and save paths bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer labels Jun 11, 2026
@Meirtz
Meirtz requested review from cuichenx and weijiac0619 June 11, 2026 18:39
The script-level provider fallback alone is insufficient:
load_megatron_model rebuilds the provider from the checkpoint's
run_config.yaml, where the layout was serialized as an object stub, so
the PP>1 assert still fired inside build_and_load_model. Pass the
resolved layout through mp_overrides (captured before finalize converts
it to a PipelineParallelLayerLayout) and declare the field in
ModelParallelKwargs. Caught by a 32-GPU GB300 end-to-end run on a
freshly imported DeepSeek-V4-Flash checkpoint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Lingrui Mei <lmei@nvidia.com>
@Meirtz

Meirtz commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

/ok to test 3acf617

@Meirtz

Meirtz commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

Validated end-to-end on 32x GB300 (TP1/PP4/EP8) with real DeepSeek-V4-Flash weights.

The original script-level fallback turned out to be insufficient on its own: load_megatron_model rebuilds the provider from the checkpoint's run_config.yaml, where the layout is the serialized object stub, so the PP>1 assert still fired inside build_and_load_model. The second commit forwards the resolved layout through mp_overrides (and declares the field in ModelParallelKwargs).

Test flow: fresh HF->Megatron import (run_config carries the stub — confirmed before export), then export with no manual repair. The fallback log line fires (Auto-generated pipeline layout for PP=4 (43 layers, 1 MTP)) and the export completes with 69187 tensors / 34167 scales, identical counts to a reference export from a hand-repaired run_config.

@cuichenx
cuichenx merged commit ae87ec3 into NVIDIA-NeMo:main Jun 12, 2026
101 checks passed
cuichenx pushed a commit that referenced this pull request Jun 12, 2026
…ig lacks it (#4306)

Signed-off-by: Lingrui Mei <lmei@nvidia.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit ae87ec3)

This branch was previously deployed

2 inactive deployments
public — 3acf617a Deployed Jun 12, 2026 by copy-pr-bot[bot] via release / finalize / publish-docs #1428
test — 3acf617a Deployed Jun 12, 2026 by copy-pr-bot[bot] via cicd-wait-in-queue #16235
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 needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants