curl examples authenticate with BASETEN_API_KEY. Export your API key first:
Save training state or sampler weights
Save from the training client:save_state()saves the adapter and optimizer state, so a new run can continue training from it.save_weights_for_sampler()publishes the adapter weights for sampling and inference deployment, without optimizer state.
path. To save both kinds and print their paths, run:
bt://loops:<run_id>/sampler_weights/<checkpoint_name>. Use the path that the SDK returns instead of constructing it. In the serverless mode, each sampler save needs a name the run hasn’t used, and the server refuses a repeated name. save_weights_for_sampler() requires a name; save_weights_and_get_sampling_client() picks a unique one when you leave it out.
To have a checkpoint expire, pass ttl_seconds when you save it. See Set a checkpoint expiry.
Loops doesn’t restart a preempted run, such as a run on spot capacity that Baseten reclaims. Save training state during the run so you can continue from the latest save.
List checkpoints
Downloading, expiring, and deleting a checkpoint through the API take itsid. The name you saved it under is a separate field, checkpoint_name in API responses and checkpoint_id in the SDK.
- Python SDK
- Baseten CLI
- REST API
To list a run’s checkpoints:Call Each line has the checkpoint’s
list_checkpoints() on the training client:id, its target, the name it was saved under, and when it was created.After the run ends, list its checkpoints with a ServiceClient instead, replacing <run_id> with the run ID:target is trainer for training state and sampler for sampler weights.Next steps
- Continue training from a checkpoint: Start a new run from saved training state.
- Deploy a checkpoint: Serve sampler weights as a dedicated inference deployment.
- Download checkpoint files: Keep a local copy of a checkpoint.