Repository navigation
[Checkpoint] clarify initial load and resume behavior - #3732
Conversation
|
Hi @hit-wdy! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
|
checkpoint.resume instead of auto-resuming when the folder exists
checkpoint.resume instead of auto-resuming when the folder existscheckpoint.resume instead of auto-resuming when the folder exists
checkpoint.resume instead of auto-resuming when the folder existsfolder save-only (drop implicit auto-resume)
|
I haven't look into the code yet but just read the proposal. TorchTitan checkpointer was developed to be used in the scenario first and later being evolved to support more options.
Because of 1, you will mostly have to make the saving and loading path to share the same parent folder (without step suffix), defeating the purpose of this design, repurpose the initial_load_path for loading.
I agree the design may sound confusing, which we can discuss how to improve it. However, this design doesn't seem to consider the goal 1 (fault-tolerance checkpoints) as the native feature, but an opt-in feature. |
Two questions before I rework the PR:
For reference, I've summarized the current checkpoint loading flow. |
9a41403 to
0592bcc
Compare
model-only save is only enabled for the last step. The reason be what I mentioned, the checkpoint serves two purposes, fault-tolerance and model publishing. The current design the intermediate-steps checkpoints are always full because they are used for fault-tolerance purpose, only the last step do we consider model-only save. It's nothing to do with HF or not. HF format is only used when we load in the first step, after that we will always load/recover from the intermediate-steps checkpoints, which are NOT HF format.
So, for checkpointing, the original design is to have two simple cases, on and off. For a real production run, it doesn't make sense to not have fault-tolerance or model publishing, so checkpointing is on and it serves for both purposes. For an experimental run, neither are required, so checkpointing is off. What's the use case of the third one, which we save the model but drop the fault-tolerance purpose? I think we should focus optimizing the first-step load configurations and flows. That loading is the |
I fully understand your point. Here's how I read the current load() flow, split by the two cases the os.path.exists(folder) gate creates: My confusion is mainly around case (2c). If I want to start training from the first step and set initial_load_path, but folder happens to exist, how should that be handled? Shouldn't we go through initial_load_path init when the user has explicitly set it, even if folder exists? |
|
That's a good catch. For 2(c), the correct way should be 1) if the step is 1 then error outs, this is an ambiguous case, 2) if the step is > 2, this is correct, the existing folder is used for the fault tolerance purpose, we already load from the initial_load_path, so no hard errors nor warnings should happen. Would this resolve your concern? |
Thanks for the clarification. My understanding is slightly different here: when I explicitly set initial_load_path, I would naturally expect the run to initialize from that path and start training from step 1. In this case, I would not set load_step manually. So I am not sure whether we need to add the extra check based on whether the step is 1 or >2. From the user's perspective, initial_load_path is an explicit signal that this should be treated as an initialization path, not a fault-tolerance resume path. Therefore, even if folder already exists, I think we should still initialize from initial_load_path when it is explicitly provided. I believe this does not break the original design where folder is used for fault tolerance. Intermediate checkpoints in folder can still serve the resume/fault-tolerance purpose, but initial_load_path should take precedence when the user explicitly wants to start a new run from a given model checkpoint. Does this interpretation make sense? |
Why do we design like this? It is not efficient that a user needs to change the command line arguments every time a trainer crashes. So in such a case, it is common that a resume-from-fault run and a fresh run share the same arguments. The way to distinguish the resume-from-fault run and a fresh run is through the training state. So in the 5-step fails case, the trainer should ignore So for your 2.c case, |
Got it. Thank you for the patient explanation! I understand the intended design now. I will update this PR. |
folder save-only (drop implicit auto-resume)folder save-only (drop implicit auto-resume)
0592bcc to
6f1e846
Compare
folder save-only (drop implicit auto-resume)|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Signed-off-by: 1Fire4 <[email protected]>
- Revert initial_load_path config docstring to original wording - Simplify load branch condition to load_step == -1, which subsumes the missing-folder case since load_step stays -1 when the folder does not exist - Remove the ValueError/warnings when initial_* options are set while checkpoint.folder has valid checkpoints; this resume path is the fault-tolerance branch and must silently ignore initial_* options so a job can keep the same arguments across automatic restarts. Document this design with a comment instead.
61a6d91 to
f19a781
Compare
Absorbs 4 upstream commits (checkpoint load/resume clarify pytorch#3732, override kwargs from CLI+config pytorch#3894, [spmd_types] VarlenAttention un-hardcode pytorch#3937, VLLMGenerator readline hang patch pytorch#3950). No conflicts; spmd_types regression verified -- GQA MoE TP+EP+typecheck (12.48->6.82) and DSA GLM-5 TP=2 (12.53->6.82) both clean.
Summary
checkpoint.folderhas no validcheckpoint (
load_step == -1), not only when the folder is missing.FileNotFoundErrorfor an explicit--checkpoint.load_stepwhenthe folder does not exist.
initial_*options are ignored by designfor fault tolerance. Per review, the warnings there were removed and
replaced with a comment.
Motivation
load()chose between initial load and resume solely by whethercheckpoint.folderexists, causing two silent failures:save):
initial_load_path/ HF initial load was silently skipped andtraining started from scratch.
--checkpoint.load_step=Nwith a missing folder wassilently ignored.