Repository navigation
[checkpoint] Reseed EMA after a model-only or EMA-excluded load on any backend - #5141
Conversation
|
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@claude review this PR |
|
Claude finished @tianyu-l's task in 1m 51s —— View job Review: reseed EMA in
|
|
@David-Wu1119 could you address
|
…y backend CheckpointManager (DCP) reseeds the EMA from the just-loaded weights when the EMA itself was not restored (a model-only load such as a seed step-0 or initial_load_path checkpoint, or exclude_from_loading=["ema"]), as docs/checkpoint.md describes. TorchCheckpointingManager did not, so its EMA kept tracking the discarded random initialization. Move the reseed from CheckpointManager._load_checkpoint into BaseCheckpointManager.load so both backends share it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
c5f7d2a to
4ea0cb8
Compare
|
@claude review again |
|
Claude finished @tianyu-l's task in 46s —— View job Re-review: reseed EMA in
|
|
@David-Wu1119 could you fix? |
_states_to_load always includes MODEL (model_only returns it, and Config.__post_init__ rejects it in exclude_from_loading), so the reseed condition only needs EMA in self.states and EMA not in states. Add tests for a step-5 resume with exclude_from_loading=["ema"] (reseeded) and a full resume (the restored EMA is not reseeded), and note why the step-0 test loads model-only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@tianyu-l sorry for missing this earlier. Fixed in 61fd246:
|
CheckpointManager(DCP) reseeds the EMA from the just-loaded weights when the EMA itself was not restored: a model-only load (a seedstep-0checkpoint, orinitial_load_pathwith the defaultinitial_load_model_only=True) orexclude_from_loading=["ema"].docs/checkpoint.mddescribes this, andtest_model_only_load_reseeds_ema_from_loaded_weights/test_exclude_ema_honored_even_when_data_is_presentpin it. The reseed lives inCheckpointManager._load_checkpoint, soTorchCheckpointingManagernever does it: after those loads its EMA keeps tracking the random initialization the model just discarded, and the EMA's cold-start warning does not fire.Loading a seed checkpoint, then resuming a step-5 checkpoint with
exclude_from_loading=["ema"](CPU, both backends on the same model):Change
Move the reseed from
CheckpointManager._load_checkpointintoBaseCheckpointManager.load, right after_load_checkpoint, so every backend gets it. The old condition also requiredMODEL in states, to keep TorchFT's per-replica dataloader-only load from reseeding; that load calls_load_checkpointdirectly rather thanload(), and insideload()the states always includeMODEL(model_onlyreturns it andConfig.__post_init__rejects it inexclude_from_loading), so that check can no longer be false and was removed.Test plan
test_model_only_load_reseeds_ema_from_loaded_weightsintests/unit_tests/cpu/components/checkpointer/test_torch_checkpointing.pyloads a step-0 checkpoint with an EMA attached and checks the EMA is reseeded. It fails on main.test_ema_excluded_from_resume_is_reseeded(step-5 resume withexclude_from_loading=["ema"]; fails on main) andtest_full_resume_keeps_restored_ema(a full resume restores the EMA and does not reseed it).TestBaseCheckpointManagerTracing._managerbuilds aMock(spec=BaseCheckpointManager)and sets the instance attributesload()reads; it now also setsstates = {}.test_torch_checkpointing.pyandtest_checkpoint.pyon the rebased branch: 115 passed (CPU, torch nightly, locally). The twotest_hf_load_*tests fail locally with and without this change because macOS has noos.O_DIRECT.EMA==loaded weights Trueafter both loads.🤖 Generated with Claude Code