Skip to main content
A Loops checkpoint holds either training state or sampler weights. Training state lets a new run continue training where a run stopped. Sampler weights feed a sampler, and you can deploy them as a model. The Python SDK, the Baseten CLI, and the 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.
Both return a future whose result has the checkpoint’s path. To save both kinds and print their paths, run:
The script prints both paths, one for the training state and one for the sampler weights. Sampler weights are saved at 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 its id. The name you saved it under is a separate field, checkpoint_name in API responses and checkpoint_id in the SDK.
To list a run’s checkpoints:Call list_checkpoints() on the training client:
Each line has the checkpoint’s 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