Repository navigation
Universal Checkpointing: read AutoEP ZeRO-3 optimizer files one at a time - #8844
Draft
pengdurice wants to merge 1 commit into
Draft
pengdurice wants to merge 1 commit into
pengdurice wants to merge 1 commit into
Conversation
…time 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.
Universal Checkpointing: read AutoEP ZeRO-3 optimizer files one at a time
Problem
ds_to_universalconverts a ZeRO-3 AutoEP checkpoint in two parts. The dense parameters go through the usualextract-and-merge path, which reads one optimizer file per worker and writes fragments to
tmp/. The routed expertsgo through
_consolidate_zero3_autoep_expert_states, which first loads every rank's optimizer file into one dict(
optim_states_by_rank) and then keeps a copy of every expert fragment in memory until all of them are merged.Together those files hold every optimizer state of the model: fp32 (or bf16) master weights plus both Adam moments.
For a large MoE model that is more than one host has:
The H200 nodes this was found on have 2 TiB of host memory, so the conversion cannot finish for either model.
Change
_consolidate_zero3_autoep_expert_statesreads one rank's optimizer file at a time. Each expert fragment it finds iswritten to
<output>/tmp/autoep_expert_fragments/(one file per parameter, optimizer state, EP rank and partitionrank) and the rank's file is released before the next one is read. The merge then loads, for one parameter and one
state at a time, only that parameter's fragments. Peak host memory becomes one optimizer file plus one full expert
tensor, instead of all optimizer files.
The checks are unchanged: missing ranks, duplicate or missing expert-data-parallel partitions, shape mismatches and
placement disagreements raise the same errors. The temporary fragments live under
<output>/tmp, which the converteralready uses for the dense fragments and removes at the end.
Tests
tests/unit/checkpoint/test_autoep_affine_universal.py(calls the function directly; CPU)tests/unit/v1/moe/test_autoep_checkpoint.py(AutoEP ZeRO-3 save, convert, load at other layouts; GPU)Hardware for the GPU tests: 1 node of 8 H200 (driver 580.126.09), torch 2.8.0+cu126, pytest 9.1.1.
pre-commit run --filespasses on the changed file.Not measured: the peak host memory of a full-size conversion before and after. The bound follows from the code:
before, every rank's optimizer file is loaded at once (for MiniMax-M3 with fp32 master weights and fp32 Adam states,
4.65 TiB in total, more than the 2 TiB of the H200 hosts this was found on); after, one rank's file plus one
parameter's fragments.
Duplicate check
Searched open and recent pull requests on 2026-10-15 ("universal checkpoint", "ds_to_universal", "AutoEP
checkpoint"): #8800 plans live expert transfers between placements and #8637 links ZeRO-1/2 fragments; neither
changes how
ds_to_universalreads the ZeRO-3 AutoEP optimizer files.Compatibility
AI assistance
This change, its tests and this description were prepared with AI assistance (Claude).