Benefits of checkpointing
- Avoid catastrophic out of disk errors: We mount additional storage at the checkpointing directory to help avoid out of disk errors during your training run.
- Maximize GPU utilization: A separate process uploads the checkpoint directory to cloud storage in the background, so your GPUs keep training instead of waiting on uploads.
- Seamless checkpoint management: Uploaded checkpoints are ready to browse, deploy, or load into later jobs.
Enable checkpointing
To enable checkpointing, add aCheckpointingConfig to the Runtime and set enabled to True:
Use the checkpoint directory
Baseten exports the$BT_CHECKPOINT_DIR environment variable in your job. Write your checkpoints to this directory so Baseten can back them up.
Writing a checkpoint to $BT_CHECKPOINT_DIR stages it for upload. A background process syncs the checkpoint directory to cloud storage on a recurring cycle, and a checkpoint becomes durable when its sync completes. If your training script deletes a checkpoint before it syncs, that checkpoint never reaches cloud storage: it doesn’t appear in your checkpoint list, and errors aren’t raised.
Fast checkpoint rotation is the common way to hit this. Rolling-checkpoint setups that keep only the last N checkpoints, and frameworks that write to a temporary path and then rename, can both remove a checkpoint within seconds of writing it. To keep every checkpoint:
- Keep enough checkpoint history that each checkpoint stays on disk through at least one full sync cycle.
- Confirm a checkpoint appears in
baseten train checkpoint listbefore your script deletes it locally.
$BT_CHECKPOINT_DIR, so you can still reclaim disk space during long runs.
Browse checkpoints
Use the CLI to list and interactively explore checkpoint files for a job:.safetensors files. See checkpoint list for all options.
Resume training from a checkpoint
To resume training from a saved checkpoint or initialize a new job from a previous run, configure aLoadCheckpointConfig on the Runtime. Baseten downloads the referenced checkpoints into $BT_LOAD_CHECKPOINT_DIR before your start_commands run:
Expire checkpoints
You can give a checkpoint an expiry so Baseten deletes it for you. A checkpoint without an expiry stays until you delete it. To see when a checkpoint expires, checkexpires_at in List training job checkpoints, or open the job’s checkpoint list in the dashboard.
Set or remove an expiry
Call Set a training job checkpoint TTL with the checkpoint’sid from the list response and ttl_seconds, the number of seconds from now until the checkpoint expires. Use a value from 3600 (1 hour) to 315360000 (10 years), or null to remove the expiry. The response returns the checkpoint with its new expires_at.
Use id, not checkpoint_id. Despite its name, checkpoint_id holds the checkpoint’s name, such as checkpoint-500.
The request fails in these cases:
404: the job has no checkpoint with that ID.409: Baseten hasn’t confirmed that the job’s checkpoint upload finished. If the job just stopped, try again in a few minutes. Most jobs that finished before checkpoint expiry was available never get this confirmation, so their checkpoints can’t expire.
When expired checkpoints are deleted
Baseten deletes expired checkpoints once a day, but only after the job has stopped. If a checkpoint expires while its job is still running, it’s deleted within about a day after the job stops. Baseten keeps an expired checkpoint if:- It has ever been deployed.
- A Loops run or sampler uses it as its base model.
- A training job is still copying it.
- It’s inside the folder of another checkpoint that’s kept.
Serve checkpoints
Serve your model checkpoints using Baseten’s serving infrastructure. Deploy a checkpoint withbaseten train checkpoint deploy, or sync it into a BDN volume and mount the volume in your own config.yaml. See serving checkpoints for deployment details.