Skip to content

Saving and Loading

Weaver provides two save paths:

  • Sampler weight exports: short-lived weights for sampling, evaluation, and RL rollout.
  • Checkpoints: durable training state for experiment recovery and optimizer restore.

Sampler Weight Exports

save_weights_for_sampler()

Export current training weights and return a model path that can be used by a sampling session:

python
model_path = training_client.save_weights_for_sampler(
    name="step-100",
)

print(model_path)

save_weights_and_get_sampling_client()

Export weights and directly return a SamplingClient:

python
sampling_client = training_client.save_weights_and_get_sampling_client(
    name="step-100",
)

result = sampling_client.sample(...)

Common parameters:

ParameterDescription
nameHuman-readable export name.
ttl_secondsWeight lifetime. Defaults to 3600 seconds. Pass None for permanent retention.
waitTrue waits for completion. False returns an OperationHandle.

WARNING

Sampler weights default to a 1-hour TTL because they are intended for frequent rollout and evaluation. Use save_state() when you need durable training recovery.

Creating a SamplingClient

If you already have an exported model_path, create a sampling client manually:

python
sampling_client = service_client.create_sampling_client(
    model_path=model_path,
    base_model="Qwen/Qwen3-8B",
    model_id=training_client.model_id,
)

Or use the convenience alias:

python
sampling_client = service_client.get_sampling_client(
    model_path,
    base_model="Qwen/Qwen3-8B",
)

Saving Checkpoints

save_state()

Save the current model state:

python
checkpoint = training_client.save_state(
    name="step-100",
)

print(checkpoint.path)

Options:

ParameterDescription
nameHuman-readable checkpoint label.
checkpoint_typeweight, weight_and_optimizer, or sampling.
ttl_secondsLifetime. If omitted, weight checkpoints are permanent while sampling checkpoints default to 1 hour.
waitTrue returns types.Checkpoint; False returns an OperationHandle.

Saving Optimizer State

For full resume-from-checkpoint training, including Adam momentum and optimizer statistics:

python
checkpoint = training_client.save_state(
    name="step-100-full",
    checkpoint_type="weight_and_optimizer",
)

Loading Checkpoints

Load Weights Only

python
training_client.load_state(checkpoint, wait=True)

Or use a path:

python
training_client.load_state(
    "weaver://model-id/checkpoints/step-100",
    wait=True,
)

Load Weights and Optimizer

python
training_client.load_state_with_optimizer(
    checkpoint,
    wait=True,
)

Use this for true training resume.

Listing and Managing Checkpoints

python
checkpoints = training_client.list_checkpoints()

for ckpt in checkpoints:
    print(ckpt.name, ckpt.path, ckpt.status, ckpt.expires_at)

Update TTL:

python
# Expire after 24 hours
training_client.set_checkpoint_ttl(checkpoint, ttl_seconds=24 * 3600)

# Make permanent
training_client.set_checkpoint_ttl(checkpoint, ttl_seconds=None)

Common types.Checkpoint fields:

FieldDescription
idServer-generated checkpoint ID.
pathweaver://... path for loading.
nameName provided when saving.
checkpoint_typeCheckpoint type.
statusCurrent status, such as completed.
ttl_secondsLifetime. None means permanent.
created_at / expires_atCreation and expiration timestamps.
  • Frequent rollout: use save_weights_and_get_sampling_client() with the default 1-hour TTL.
  • Periodic evaluation: name sampler exports clearly and extend TTL only when needed.
  • Experiment recovery: use save_state(checkpoint_type="weight_and_optimizer").
  • Final model: use a permanent checkpoint or permanent sampler export before deployment.

Next Steps

Weaver API Documentation