Repository navigation
AutoEP + AutoTP folding: Universal Checkpointing under ZeRO-3 - #8848
Draft
pengdurice wants to merge 1 commit into
Draft
pengdurice wants to merge 1 commit into
pengdurice wants to merge 1 commit into
Conversation
Signed-off-by: pengdurice <pengduhit@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AutoEP + AutoTP folding: Universal Checkpointing under ZeRO-3
Part of: #8672 (Q4 2026 roadmap), "Mixture-of-Expert (MoE) Training Scaling and Kernel Development": "AutoEP Performance Optimization & Parallel Folding (AutoEP + AutoTP)" (PoC @tohtana @pengdurice). Follows #8670.
Problem
#8670 makes
ds_to_universalrefuse a folded ZeRO-3 checkpoint: "Universal checkpoint conversion of an AutoEP +AutoTP folded ZeRO-3 checkpoint is not supported yet. Load it with the same topology." So a folded run can only resume
with the same TP size, EP size and number of GPUs.
Three things stood in the way: two in the conversion, one in the load.
alone (
_zero3_rank_from_file). ZeRO-3 files are namedzero_pp_rank_{dp}_mp_rank_{tp}. Under folding the files ofdifferent TP ranks share a data-parallel rank, so they collided. That is why AutoEP + AutoTP folding under ZeRO-3 #8670 refused.
_merge_tp_slice_filesasserts that every pattern in AutoTP's universal info wasused. AutoTP lists the AutoEP expert weights (
experts.w1/w2/w3) amongtp_replicated_parameter_patterns. Thoseweights are merged by the AutoEP step, not by the TP merge, so their patterns are never used and the assertion
fails.
_load_checkpointcompares the folding layout recorded in the model-states file withthe runtime's (
_validate_autoep_folding_checkpoint_metadata). This rejects any other TP size, EP size or anunfolded runtime, although a universal load re-cuts every tensor for the runtime's layout.
Change
deepspeed/checkpoint/ds_to_universal.py:_zero3_tp_dp_ranks_from_file, which the densemerge already uses.
_zero3_rank_from_fileis no longer used and is removed, along with the folding refusal._merge_tp_slice_filesno longer counts a pattern as unused when it only matches parameters excluded from thismerge. The ZeRO-3 path now passes the AutoEP expert names as excluded; the ZeRO-1/2 path already did.
folding each expert slice exists on exactly one rank, and the existing duplicate and completeness checks still
apply.
deepspeed/runtime/engine.py_load_checkpoint: skip the folding-layout check whencheckpoint.load_universalisset. Rigid loads keep it.
load_hp_checkpoint_stateinstage3.pycuts the EP slice,then the TP shard, then the ZeRO partition in the parameter's own group (dense data-parallel or expert
data-parallel). That is what folding needs.
docs/code-docs/source/autoep.rstanddocs/_pages/config-json.md.tests/unit/v1/moe/test_autoep_autotp_sharded_attention.py:TestZero3FoldedCheckpointno longer expects the conversion to be refused.TestZero3FoldedUniversalCheckpoint. A distributed fixture trains a folded TP 2 x EP 2 run on 4 ranks for oneAdamW step, saves, converts, and records every parameter and both Adam states at full size, then the losses and
parameters of the next step. Each target layout loads the universal checkpoint and must restore every recorded
tensor exactly. Targets with the source's 2 data-parallel groups read the same batches, so they must also repeat
the next step. Targets: the same layout, EP 4, TP 4, 8 ranks with TP 4, and AutoEP without AutoTP; each in fp32
and bf16.
ZeRO-1/2 conversion of folded checkpoints is not covered: it stores experts in per-expert files, one per TP rank,
and is still refused in
autoep_universal.py(resolve_expert_ckpt_path).Tests
On master
d371f33ccwith this change, one node of 8 NVIDIA H200 GPUs, torch 2.8.0+cu126 (and masterwithout the change).
tests/unit/v1/moe/test_autoep_autotp_sharded_attention.py(includes the 10 new universal-checkpoint cases)TestTiedOutputHead::test_row_parallel_tied_head_is_refused(2 cases) fails the same on masterd371f33ccwithout this change: the test expects AutoTP to refuse a row-parallel output head tied to the embedding, and master no longer doestests/unit/v1/moe/test_autoep_checkpoint.pytests/unit/checkpoint/test_autotp_uc_checkpoint.pytests/unit/runtime/tensor_parallel/test_autotp_universal_checkpoint.pytests/unit/checkpoint/test_autoep_affine_universal.pytests/unit/checkpoint/test_universal_checkpoint.pyThe failures in these two files do not come from this change. Master
d371f33ccwithout this change gives the samefailing tests:
test_autotp_uc_checkpoint.pyand all 144 intest_universal_checkpoint.pyare "fixture ... not found"for fixtures defined as
DistributedFixtureclasses (affine_resume_checkpoint,baseline_ws2,baseline_ws4).This environment has pytest 9.1.1, which does not recognize the
_pytestfixturefunctionattribute thattests/unit/common.pysets to register those classes as fixtures.test_autotp_uc_checkpoint.py(TestRealCheckpointUniversalConversionTPxPP::test): gloo"Connection closed by peer" in the conversion's worker pool.
On master 5f266e2 (2026-10-15; 1 node of 8 H200, driver 580.126.09, torch 2.8.0+cu126), the failing
tests are the same with and without this change:
test_autoep_autotp_sharded_attention.pyTestTiedOutputHead, 2 cases)test_autoep_checkpoint.pytest_autotp_uc_checkpoint.pytest_autotp_universal_checkpoint.pytest_autoep_affine_universal.pyThe 6 errors are "fixture ... not found" (
affine_resume_checkpoint4,uneven_vocab_checkpoint2) and the failure isgloo "Connection closed by peer" in
TestRealCheckpointUniversalConversionTPxPP::test, on both sides.Further checks (not part of the PR's tests)
A wider version of the new test: 7 target layouts. Besides the 5 above: 8 ranks with TP 2 x EP 4, and AutoEP EP 4
without AutoTP. Run in fp32 and bf16, with the optimizer-offload PR for folding applied, and in 3 offload
combinations: saved and loaded without offload, saved and loaded with offload, saved without and loaded with offload.
All 42 loads restore every parameter and both Adam states exactly. Every target with the source's 2 data-parallel
groups repeats the next step: losses equal, and parameters within 1e-4 relative, leaving out the attention key bias.
In bf16 only the same layout repeats it.
The key bias is left out of the next-step comparison because its true gradient is zero. Its computed gradient is
rounding noise that another layout adds up in another order, and AdamW turns that noise into steps of about lr
(observed differences 6e-4 to 1.5e-3 relative).
Duplicate check
Searched open and recent pull requests on 2026-10-15 ("universal checkpoint", "ds_to_universal", "folding", "AutoEP"): none converts folded ZeRO-3 checkpoints. #8800 plans live expert transfers between placements; #8637 links ZeRO-1/2 fragments.
Proposal
New functionality: per CONTRIBUTING.md it needs an accepted proposal issue first. Draft:
descriptions/r3/peng-autoep-folding-ucp-v1-proposal-issue.md. TODO(user): open the issue, wait for acceptance, then link it here.AI assistance
This change, its tests and this description were prepared with AI assistance (Claude).