Convert Train Weights to Sampler
In PyTRIO, the two persistent checkpoint types serve different purposes (see Save Weights):
| Type | Created by | Contains | Typical use case |
|---|---|---|---|
| Train | save_state | Model weights + optimizer state | Resume training |
| Sampler | save_weights_for_sampler | Model weights only | Inference & sampling, OpenAI API, Download adapters |
A Train checkpoint cannot be passed directly to create_sampling_client or the OpenAI-compatible API for inference. If you only saved a Train checkpoint during training, you can load its model weights and re-save them with save_weights_for_sampler to produce a Sampler weight without running any additional training.
Get the Train Checkpoint Path
Find the checkpoint labeled Train on the Weights page in the Web UI and copy its path:

If you just saved the checkpoint in your script, you can also use the path returned by save_state(...).result().path.
Convert to Sampler Weights
Use create_training_client_from_state to load only the model weights from the Train checkpoint (skipping optimizer state), then call save_weights_for_sampler to save them as Sampler weights:
import pytrio as trio
service_client = trio.ServiceClient()
# 1. Load only the model weights from the Train checkpoint (without optimizer state)
training_client = service_client.create_training_client_from_state(
path="YOUR_TRAIN_CHECKPOINT_PATH",
)
# 2. Save as Sampler weights
result = training_client.save_weights_for_sampler(
name="my-sampler-weights",
).result()
print("Sampler path:", result.path)
print("Model:", result.model)
print("Size (bytes):", result.size)TIP
Use create_training_client_from_state rather than create_training_client_from_state_with_optimizer. Exporting Sampler weights only needs the model weights, so skipping optimizer state makes loading lighter.
Once saved, a new Sampler entry appears in the Web UI Weights page, and result.path is ready for inference.
Async Usage
In async code, use create_training_client_from_state_async and save_weights_for_sampler_async:
import asyncio
import pytrio as trio
async def convert_train_to_sampler(train_path: str, sampler_name: str) -> str:
service_client = trio.ServiceClient()
training_client = await service_client.create_training_client_from_state_async(
path=train_path,
)
future = await training_client.save_weights_for_sampler_async(
name=sampler_name,
)
result = await future
return result.path
sampler_path = asyncio.run(
convert_train_to_sampler(
train_path="YOUR_TRAIN_CHECKPOINT_PATH",
sampler_name="my-sampler-weights",
)
)
print("Sampler path:", sampler_path)Temporary Inference Only (Without Persisting Weights)
If you only want to run a quick test or evaluation on a Train checkpoint without keeping a persistent Sampler weight in your account, call save_weights_and_get_sampling_client:
import pytrio as trio
service_client = trio.ServiceClient()
training_client = service_client.create_training_client_from_state(
path="YOUR_TRAIN_CHECKPOINT_PATH",
)
# Save to a temporary archive and immediately get a SamplingClient loaded with those weights
sampling_client = training_client.save_weights_and_get_sampling_client()Temporary weights do not appear on the Web UI Weights page and are cleaned up automatically after some time.
Use the Converted Sampler Weights
After obtaining result.path, you can use it anywhere Sampler weights are accepted:
- SDK inference: Pass it to
service_client.create_sampling_client(base_model=..., model_path=result.path), or calltraining_client.create_sampling_client(model_path=result.path)on the active training client. See Inference. - OpenAI-compatible API: Pass
result.pathas themodelparameter. See OpenAI API. - Local download and deployment: Copy the new
Samplercheckpoint ID from the Web UI, follow Download Adapters to fetch the LoRA adapter, and see Local Weight Deployment to run it with Transformers or vLLM.
Notes
- Original Train checkpoint stays intact: Conversion creates a new
Samplerweight without modifying or deleting the originalTraincheckpoint, so you can still use it to resume training. - Conversion is one-way:
Samplerweights do not include optimizer state and are only for inference or download, not resume training. Keep the originalTraincheckpoint if you may want to continue training later. - Optional expiration (
ttl_seconds): If the convertedSamplerweight is only needed for short-term evaluation, passttl_seconds(in seconds) to expire it automatically;None(default) keeps it permanently. - Naming rules: The
nameargument tosave_weights_for_samplerfollows the Checkpoint Name Rules.