mirror of
https://github.com/NVIDIA/Model-Optimizer.git
synced 2026-12-06 04:57:17 +08:00
### What does this PR do? **Problem:** A native checkpoint restore can validate a layout derived from saved tensor metadata but later apply the earlier, deferred layout instead. **Fix:** Carry the checked layout through rank agreement and apply it afterward. Modules without a checked layout retain the deferred callback path. This treats layout values as opaque and works before the GGML changes in the next slice. ### Testing - Source-isolated red/green proof: upstream fails the checked-layout case; the fix passes both checked/deferred cases. Ruff, format and syntax pass. - Native Megatron CI: both checked/deferred regression cases passed ([job log](https://github.com/NVIDIA/Model-Optimizer/actions/runs/47456979207/job/145477291200)); no GPU run was performed locally. ### Before your PR is ready for review Backward compatible; no new dependencies or third-party code; scoped regressions included. Internal restoration fix; no new feature changelog. Claude approval not requested. ### Additional information Part **[1/4]** of the generic exporter stack. Merge **#3734 → #3735 → #3736 → #3727 → #3730**, retargeting each successor after its predecessor merges. Each slice depends only on earlier PRs. Announcement #3726 remains gated on two human approvals after the exporter stack lands. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved restoration of sharded extra state so checked checkpoint layouts are applied consistently. Other deferred layouts continue to use their existing handling. * Restoration now checks saved tensor metadata and layout agreement before applying layouts, and clears the restore flag when complete. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Hung-Yueh Chiang <hungyuehc@nvidia.com>