basetenlabs/rl-rollouts
Python
Captured source
source ↗basetenlabs/rl-rollouts
Description: Baseten managed rollouts: qualified deployment configs and checkpoint publisher.
Language: Python
Stars: 1
Forks: 0
Open issues: 0
Created: 2026-10-23T00:53:09Z
Pushed: 2026-10-29T01:35:30Z
Default branch: main
Fork: no
Archived: no
README:
RL Rollouts: client guide
Your rollout deployment serves a model whose weights follow your trainer. You publish checkpoints to an Amazon S3 or Google Cloud Storage (GCS) bucket you own and request each one; every replica applies the new weights in place and keeps serving. You never redeploy to change weights.
How it works
1. You upload a full checkpoint (an *anchor*) once, then a small delta after each training step. 2. When a snapshot is completely uploaded, you send a hot-load request naming it. 3. Each replica prepares the update, pauses briefly for a delta (seconds to about a minute for a new anchor), swaps weights and resumes, keeping in-flight requests. Full-anchor preparation can slow serving for several minutes. 4. Every response reports which policy produced it, so your trainer can track off-policy samples.
Deploy
We enable BIS and your folder's accelerator (B200, B300, GB300 or H100) on your Baseten workspace. Then, from this folder:
1. Install the Baseten CLI (v1.2.0+) and run baseten auth login --with-api-key --profile with your API key on stdin. 2. Create these workspace secrets (Settings → Secrets) with exactly these names:
rl_checkpoint_reader: `{"aws_access_key_id": "...", "aws_secret_access_key": "...",
"aws_region": ""} (aws_region is required), static keys (a session token would expire) that can list and read your prefix. S3: an IAM user's keys. GCS: an HMAC key (access ID and secret) from gcloud storage hmac create SA_EMAIL for a service account with roles/storage.objectViewer on the bucket, and "aws_region": "us-east-1"`.
rl_bdn_partition: any random string you generate, e.g.openssl rand -hex 32.hf_access_token, only if the push asks for it: a Hugging Face read token.
3. Pick a folder: glm-5.3-flash/b200-8/ or deepseek-v4.1-flash-mxfp4/b200-8/ (B200:8), glm-5.2/b300-8/ (B300:8), kimi-k3/gb300-8/ (MXFP4; in development, not yet acceptance-qualified) or kimi-k3-nvfp4/gb300-8/ (two GB300:4 nodes) or qwen3.5-9b/h100-1/ (H100). In its config.yaml, set BUCKET (the line marked EDIT) to s3://bucket/prefix or gs://bucket/prefix, ideally near the deployment region. Edit nothing else: config changes depart from the documented recipe. 4. Publish an anchor and name it in [STARTUP_SNAPSHOT](#hot-load-api), then baseten model push --dir --override-name --profile --wait. 5. Call https://model-MODEL_ID.api.baseten.co/deployment/DEPLOYMENT_ID/sync/v1/chat/completions (Authorization: Api-Key , model = the config's served_model_name); see [RL fields](rl-api.md).
Bucket layout
s3://your-bucket/your-run/ ├── STARTUP_SNAPSHOT # what a new deployment loads first ├── step000001/ # full anchor │ ├── snapshot_info.json │ ├── model-00001-of-000NN.safetensors ... │ ├── model.safetensors.index.json │ ├── config.json │ └── tokenizer files / chat template └── step000002/ # delta against step000001 ├── snapshot_info.json └── model-*.safetensors # compressed deltas, not ordinary weights
snapshot_info.json for a full anchor:
{"identity": "step000001", "snapshot_type": "full", "policy_version": 1}For a delta, name its exact parent and the anchor the chain started from:
{"identity": "step000002", "snapshot_type": "incremental", "policy_version": 2,
"incremental_snapshot_metadata": {
"previous_snapshot_identity": "step000001",
"base_full_snapshot_identity": "step000001",
"compression_format": "arc_v2", "checksum_format": "alder32"}}policy_version is your label and is echoed back in responses. Ancestry comes only from previous_snapshot_identity, never from step numbers.
Hot-load API
Once a snapshot is completely uploaded, request it (Authorization: Bearer ):
POST https://model-MODEL_ID.api.baseten.co/deployment/DEPLOYMENT_ID/sync/hot_load/v1/models/hot_load
{"identity": "step000002", "incremental_snapshot_metadata": {"compression_format": "arc_v2", "checksum_format": "alder32"}}Omit incremental_snapshot_metadata for an anchor; other keys are ignored. 200 {}: replicas will load it (the newest request wins; resending the current target changes nothing). 400: the request or snapshot is invalid, and nothing changed. 503: not accepted (no replica could check it, or it could not be saved); retry. Replicas that missed a request, restart or are added load the newest one saved in their cluster. GET the same URL returns replicas and excluded_replicas. Each replica has replica_id (its name in Baseten's logs), readiness (false while it swaps), current_snapshot_identity and a loading_state with target_snapshot_identity and a stage: loading, done, or error with a reason (errors list first). Poll until every replica is done (check stage, not just readiness); there is no deadline. After an error, resend once the cause is fixed, or request an anchor. Replicas with no target yet are in excluded_replicas, each with a reason. STARTUP_SNAPSHOT holds a request body, e.g. {"identity": "step000001"} (publish_checkpoint.py startup writes it). Replicas no request has reached load it, rechecking every 10 s until it names a loadable snapshot.
Delta format (arc_v2)
A delta shard is a normal .safetensors file whose entries are not weights. Each entry is a 1-D uint8 tensor named after the weight it updates, holding
zstd_compress( parent_tensor_bytes XOR new_tensor_bytes )
The file's safetensors metadata maps each tensor name to the decimal Adler-32 checksum of the new tensor's bytes. Shape and dtype come from the parent. Tensors you omit keep their parent values. It needs: safetensors for the container, python-zstandard for compression and Python's `zlib.adler32` for checksums. For background on the same idea in an open-source RL framework, see slime's delta weight sync; its files are not interchangeable with this...
Excerpt shown — open the source for the full document.