Guide

Save Weights

PyTRIO provides three ways to save current training results. Choose the API based on what you want to do next.

MethodWhat it savesTypical use case
save_weights_for_samplerModel weights without optimizer stateLater inference, sampling, download, or deployment
save_stateModel weights plus optimizer state, as a full checkpointResume training from a checkpoint
save_weights_and_get_sampling_clientTemporary model weights, then returns a SamplingClient that has loaded themSample from the latest policy inside a training loop

Save Weights for Inference

Use save_weights_for_sampler when you only need the current LoRA weights and do not need optimizer state:

result = training_client.save_weights_for_sampler(name="sampler").result()
print(result.path)

The saved weights are persisted under your account, visible in the Web UI's Weights page, and can be used for later inference or sampling.

Save a Train Checkpoint

Use save_state when you need to save both model weights and optimizer state for later resume training:

result = training_client.save_state(name="train").result()
print(result.path)

name may only contain ASCII letters, digits, periods, underscores, and hyphens, and must not exceed 200 characters; spaces are replaced with hyphens and over-long names are shortened automatically. See Checkpoint Name Rules for the full rules.

Checkpoints saved this way appear with the Train type in the Web UI. They take more storage than Sampler weights because they include optimizer state:

Use Train checkpoints for resume training, and use Sampler weights for sampling. Pick the API that matches your next step.

Save Temporary Sampling Weights

save_weights_and_get_sampling_client saves the current model weights to a temporary archive and immediately returns a SamplingClient that has loaded those weights:

sampling_client = training_client.save_weights_and_get_sampling_client()
sampling_client.sample(...)

Temporary weights do not appear in the Web UI's Weights page, and they are deleted automatically after some time.

This is useful for reinforcement learning workflows where the training loop needs to keep sampling from the latest policy without keeping every intermediate weight snapshot.

Was this documentation helpful?

On this page