Prerequisites
- A source job with checkpointing enabled, or a Loops run with a saved checkpoint.
- The ID of the job that saved the checkpoint, or the name of its project.
- To load a specific checkpoint, the checkpoint’s name. To list a job’s checkpoints, see List and download checkpoints. The checkpoint must show
COMPLETEin theSYNCcolumn, and it must not have expired.
Access downloaded checkpoints
Baseten sets theBT_LOAD_CHECKPOINT_DIR environment variable to the download folder and places each named checkpoint in its own directory, $BT_LOAD_CHECKPOINT_DIR/<checkpoint_name>/. The root checkpoint, ., loads directly into $BT_LOAD_CHECKPOINT_DIR, with no subdirectory. from_latest_checkpoint can resolve to the root checkpoint, so check for both layouts in your code; List and download checkpoints shows the . row. From a multinode source job, Baseten loads only the files that node 0 wrote, at the paths node 0 wrote them.
Choose the checkpoints to load
Setload_checkpoint_config on the job’s Runtime and list the checkpoints to download. Each of the following examples configures the same field; pick the one that matches the source you have.
From the latest checkpoint
config.py
from_latest_checkpoint takes project_name, job_id, or both:
- With
project_name, it loads the latest checkpoint from the project’s most recent job that ran. - With
job_id, it loads the latest checkpoint from that job. - With both, the job must belong to that project.
BasetenCheckpoint.
From a named checkpoint
config.py
from_named_checkpoint requires both the checkpoint’s name and the ID of the job that saved it.
From a Loops run
config.py
target="trainer" loads the full training state, and target="sampler" loads the inference weights. For all parameters, see LoopsCheckpoint.
LoadCheckpointConfig downloads to /tmp/loaded_checkpoints by default, which is the value BT_LOAD_CHECKPOINT_DIR holds. To download somewhere else, set download_folder; for all parameters, see LoadCheckpointConfig.
Use checkpoints in your training code
In your training script, read$BT_LOAD_CHECKPOINT_DIR and pass the latest checkpoint inside it to Trainer.train(). This fragment takes the dataset as an argument and omits loading it:
get_last_checkpoint finds the newest checkpoint-<step> folder. When the loaded checkpoint is the root checkpoint, its files sit directly in $BT_LOAD_CHECKPOINT_DIR, so the fragment uses that folder instead. output_dir is $BT_CHECKPOINT_DIR, the directory Baseten syncs, so the new job saves the checkpoints it writes.
Complete training job configuration
config.py
config.py:
Confirm the job loaded the checkpoint
Stream the new job’s logs:Resuming from checkpoint: <path>, confirms that Baseten downloaded the checkpoint and that your code read it. If the logs show No checkpoint found, starting from scratch, list $BT_LOAD_CHECKPOINT_DIR in your start commands to see what Baseten downloaded. An empty folder means the checkpoint name or job ID didn’t match a synced checkpoint; files without a checkpoint-<step> folder mean your code needs to read the folder directly.
Next steps
- List and download checkpoints: Check a checkpoint’s sync status and keep a local copy.
- Save checkpoints: Write checkpoints your next job can load.
- Deploy a Training Jobs checkpoint: Serve the checkpoint instead of training from it.