> ## Documentation Index
> Fetch the complete documentation index at: https://docs.baseten.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Publish checkpoints for RL Rollouts

> Publish full anchors and compressed deltas to your bucket with publish_checkpoint.py, choose the snapshot new replicas load first, and check a delta before you upload it.

Your trainer publishes weights to your Amazon S3 or Google Cloud Storage (GCS) bucket as snapshots. A full checkpoint, called an anchor, starts a chain. Each later snapshot is a delta: the compressed changes from the previous snapshot. A rollout deployment [loads a snapshot](https://docs.baseten.co/rl-rollouts/load-weights.md) when you request it.

`publish_checkpoint.py` in the [RL Rollouts repository](https://github.com/basetenlabs/rl-rollouts) is a reference publisher. It writes snapshots in the layout that deployments read, and you decide how your training loop calls it.

## Prerequisites

* The repository cloned, with the publisher's Python dependencies installed: `boto3`, `numpy`, `safetensors`, and `zstandard`.
* Publisher credentials and `ROLLOUT_BUCKET` set in your environment. See [Configure publisher access](https://docs.baseten.co/rl-rollouts/deploy.md) in Deploy RL Rollouts.
* Checkpoints that meet your model's [checkpoint requirements](https://github.com/basetenlabs/rl-rollouts/blob/main/docs/checkpoints.md#best-practices), such as its quantization layout.

## Publish an anchor

**To publish a full checkpoint as an anchor**:

Replace `<hf_checkpoint_dir>` with your checkpoint's local directory, then run:

```sh theme={"system"}
python publish_checkpoint.py full --dir "<hf_checkpoint_dir>" \
  --bucket "$ROLLOUT_BUCKET" --identity step000001 --policy-version 1
```

`--identity` names the snapshot's directory in your bucket, and `--policy-version` is the integer label that rollouts report. The publisher uploads every shard, then `snapshot_info.json`, and prints each file it uploads.

Publish a new anchor occasionally, for example when a chain of deltas gets long or a large share of the weights changed. Loading an anchor takes longer than loading a delta, and serving can slow while it prepares.

## Publish a delta

**To publish the changes since the previous snapshot**:

Replace `<parent_hf_dir>` with the exact weights you published as the previous snapshot, and `<new_hf_dir>` with the new export, which must have the same tensor names, shapes, and dtypes. Then run:

```sh theme={"system"}
python publish_checkpoint.py delta --parent "<parent_hf_dir>" --new "<new_hf_dir>" \
  --bucket "$ROLLOUT_BUCKET" --previous step000001 --base step000001 \
  --identity step000002 --policy-version 2
```

`--previous` names the parent snapshot, and `--base` names the anchor that started the chain. The publisher diffs `--parent` against `--new`, so point `--parent` at the exact bytes you published for the previous snapshot, after quantization, not at your trainer's master weights.

The publisher encodes the delta with `arc_v2` compression and `alder32` checksums. Send both formats in the `incremental_snapshot_metadata` of the [hot-load request](https://docs.baseten.co/rl-rollouts/load-weights.md#request-a-snapshot).

To check a delta without uploading anything, pass `--dry-run`:

```sh theme={"system"}
python publish_checkpoint.py delta --parent "<parent_hf_dir>" --new "<new_hf_dir>" \
  --bucket "$ROLLOUT_BUCKET" --previous step000001 --base step000001 \
  --identity step000002 --policy-version 2 --dry-run
```

The publisher builds and verifies the delta, prints each file it would upload and the hot-load request body, and writes nothing.

## Choose the startup snapshot

`STARTUP_SNAPSHOT` in your bucket names the snapshot that a new deployment loads first. A replica that no hot-load request has reached also loads it.

**To set the startup snapshot**:

```sh theme={"system"}
python publish_checkpoint.py startup --bucket "$ROLLOUT_BUCKET" --identity step000001
```

The command confirms the selection:

```text theme={"system"}
STARTUP_SNAPSHOT names step000001
```

## Rules for published snapshots

* **Publish every file before you request a snapshot.** The publisher uploads `snapshot_info.json` last, and a replica rejects an incomplete snapshot.
* **Never change a published snapshot.** Publish a new identity instead. The publisher refuses an identity that already exists.
* **Keep the anchor and every later delta.** Replicas that restart rebuild from them. Delete only snapshots from older chains.

## Next steps

* [Load new weights](https://docs.baseten.co/rl-rollouts/load-weights.md): Request a published snapshot and check that every replica loaded it.
* [Training loops](https://github.com/basetenlabs/rl-rollouts/blob/main/docs/training-loops.md): Publish from Miles or Slime without re-encoding deltas.
