## Summary
- Rename the orchestrator config field `max_off_policy_steps` to
`max_staleness`. Update every config and example that sets it.
- Define two staleness levels and use them in code, metrics, and docs:
- **Token staleness**: the policy version a batch trains on minus the
policy version that sampled the token. Tokens without a policy label
(Dynamo engines) take their rollout's dispatch version, which is the
same rule the masking uses.
- **Rollout staleness**: the max token staleness of the rollout. It
splits into **in-flight** staleness (weight updates between the oldest
token and completion) and **in-queue** staleness (weight updates while
the rollout waits to ship).
- Replace `episode_staleness` and `token_policy_ages` with one
`rollout_staleness` helper that returns both levels.
- Rename the per-step metrics from `off_policy/*` to `staleness/*`:
- `staleness/token/mean`, `staleness/token/masked`
- `staleness/rollout/{mean,max}`
- `staleness/rollout/in_flight/{mean,max}`,
`staleness/rollout/in_queue/{mean,max}`
- `staleness/rollout/dropped`
- Remove the live `dispatcher/off_policy/{mean,max}` gauge. The
per-batch staleness metrics replace it.
- Change the console step log from `Max Off-Policy` to `Max Staleness`.
- Docs: add the token and rollout staleness definitions to
`docs/algorithms.md` (section renamed to "Async Training & Staleness").
List the staleness metrics in `docs/training.md`. Update `docs/ipo.md`,
the README, the `monitor-run` skill, and the dashboard producer regex.
## Breaking
- `orchestrator.max_off_policy_steps` is now
`orchestrator.max_staleness`. Configs that use the old name fail
validation. Migration: rename the key.
- Metric renames (update W&B panels and alerts):
| Old | New |
|---|---|
| `off_policy/{mean,max}` | `staleness/rollout/{mean,max}` |
| `off_policy/in_flight/{mean,max}` |
`staleness/rollout/in_flight/{mean,max}` |
| `off_policy/in_queue/{mean,max}` |
`staleness/rollout/in_queue/{mean,max}` |
| `off_policy/token/mean` | `staleness/token/mean` |
| `off_policy/token/max` | removed: equal to `staleness/rollout/max` |
| `off_policy/token/masked` | `staleness/token/masked` |
| `off_policy/dropped` | `staleness/rollout/dropped` |
| `dispatcher/off_policy/{mean,max}` | removed: use the per-batch
`staleness/rollout/*` |
- Value changes:
- Rollout staleness now comes from token policy labels, not from the
dispatch version. A rollout whose first token was sampled after a weight
update now reports a lower value.
- Token staleness now counts unlabelled tokens at their dispatch
version. Before, it skipped them.
- Frozen-sourced rollouts are left out of the staleness stats. Before,
they counted as 0.
## Verification
- `uv run pytest tests/unit/orchestrator`: 132 passed.
`test_token_policy_ages.py` is now `test_rollout_staleness.py` and
covers the token and rollout levels and the in-flight/in-queue split.
- `OrchestratorConfig(max_staleness=16)` validates, and
`OrchestratorConfig(max_off_policy_steps=16)` raises `ValidationError`.
- I did not run `tests/unit/test_configs.py` to completion. It fails
locally because the taskset packages (`reverse_text`, `gsm8k`,
`scaleswe`, …) are not installed. Every failure is a
`ModuleNotFoundError` for a taskset package.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Breaking config and metric renames affect existing runs and
monitoring; staleness computation changes may shift reported values
without changing masking logic tied to `max_staleness`.
>
> **Overview**
> Renames the orchestrator knob **`max_off_policy_steps`** to
**`max_staleness`** everywhere (config schema, example/advanced TOMLs,
docs). Behavior is unchanged: it still caps how old a sampled token can
be before masking or dropping queued samples; rollouts are not cancelled
for staleness.
>
> **Staleness model and metrics** are tightened and renamed.
**`rollout_staleness`** replaces separate **`episode_staleness`** /
**`token_policy_ages`** helpers: rollout staleness is the **max token
staleness** (from engine `weight_versions`, with unlabeled tokens using
dispatch version), split into in-flight vs in-queue. Shipped-batch
logging and W&B-style keys move from **`off_policy/*`** to
**`staleness/token/*`** and **`staleness/rollout/*`**; live
**`dispatcher/off_policy/{mean,max}`** gauges are removed. Console logs
say **Max Staleness** instead of Max Off-Policy.
>
> Docs and ops surfaces (**`algorithms.md`**, **`training.md`**, IPO
ablation copy, **`monitor-run`** skill, dashboard orch key regex) use
the new vocabulary. **Breaking:** old config key fails validation;
dashboards/alerts must remap metrics (including removed
**`off_policy/token/max`** and dispatcher off-policy gauges). Reported
staleness values can shift slightly because rollout stats are
token-label-based and frozen-sourced rollouts are omitted from
aggregates.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c569e1512817bfd292ad14efc768ec7d1a76acf8. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
GLM-4.5-Air
RL on zai-org/GLM-4.5-Air — a 100B MoE — at 131k context, across three agentic domains: web search, SWE, and terminal. Rollouts run in sandboxes (Prime Intellect Sandboxes by default — see Requirements for using your own), driven either by the rlm agent harness (with its search skill, or ipython-only) or a plain bash harness. All three configs share the same recipe: GRPO with a linear length penalty on input tokens (and turns, for SWE/terminal), the custom MoE trainer implementation with cp = 4 (ulysses) context parallelism, router replay, NCCL weight broadcast, checkpoints every 50 steps (keep_last = 1), and evals every 20 steps (including step 0). The SWE configs also ship budget variants: swe-4-node.toml (1 train + 3 infer) and swe-2-node.toml — train a 100B+ MoE on only two nodes. Both are thin overlays on a shared swe-budget.toml base: the base holds the recipe, the overlay the topology, batch size, and per-run identity.
| Config | Trains on | Evals on | Topology |
|---|---|---|---|
search.toml |
openseeker + redsearcher (search QA, rlm harness + search skill) |
browsecomp (500 examples) |
2 train + 4 infer nodes |
swe.toml |
scaleswe (bash harness) |
swebench-verified |
2 train + 4 infer nodes |
swe-budget.toml + swe-4-node.toml |
scaleswe (bash harness) |
swebench-verified |
1 train + 3 infer nodes |
swe-budget.toml + swe-2-node.toml |
scaleswe (bash harness) |
swebench-verified |
1 train + 1 infer node |
terminal.toml |
tmax (per-task Docker image, rlm ipython harness) |
swebench-verified + terminal-bench-2 (avg@4) |
2 train + 4 infer nodes |
ipo-ablation/ base.toml + ipo.toml / icepop.toml |
scaleswe (bash harness), no router replay, max staleness 64 |
swebench-verified |
2 train + 4 infer nodes |
The ipo-ablation/ configs reproduce the IPO vs IcePop loss ablation in docs/ipo.md.
Inference serves the bf16 checkpoint as-is (no quantization), with tensor_parallel_size = 8 (plus expert parallelism on swe.toml). search.toml, swe.toml, and terminal.toml train with Muon on 2 trainer nodes. The budget variants instead fit the trainer on a single node with full optimizer offload and the stateless sign-SGD optimizer; swe-2-node.toml cuts the batch size to 64 (4 groups of 16) to match the throughput of its single inference replica. They don't parse standalone: compose them left-to-right over swe-budget.toml (uv run rl @ swe-budget.toml @ swe-2-node.toml). Search answers are scored by a reference judge (Qwen/Qwen3-235B-A22B-Instruct-2507).
Requirements
- A Slurm cluster with 8-GPU nodes and a shared filesystem. This guide assumes the shared filesystem is mounted at
/shared— adjust to your own path. - Sandboxes. Rollout and eval agents run in sandboxes. These configs are wired for Prime Intellect Sandboxes by default. Install the
primeCLI separately and log in. Each config'sslurm.pre_run_commandthen cleans up the run's orphaned sandboxes by label before launch:
uv tool install prime
prime login # or: prime config set-api-key <your-key>
To run on your own infrastructure instead, swap env.agent.runtime on each source for a runtime your environments support (e.g. a local Docker backend) and drop the slurm.pre_run_command cleanup line.
-
Environment variables, exported in the shell you launch from — the launcher passes its environment to every component:
HF_TOKEN—zai-org/GLM-4.5-Airis a gated model.WANDB_API_KEY— every config logs to W&B ([monitors.wandb]).SERPER_API_KEY— search envs only; forwarded into the agent sandbox for thesearchskill (harness.forward_env).
Setup
Clone prime-rl onto the shared filesystem and install everything, including the environments — they are opt-in uv workspace members, so --all-packages is required:
git clone https://github.com/PrimeIntellect-ai/prime-rl.git /shared/prime-rl
cd /shared/prime-rl
git submodule update --init -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
uv sync --all-extras --all-packages
Tweak before launching
[slurm] partitionis set toall— override with--slurm.partition <your-partition>, or edit the config.--output-dirdefaults tooutputs/next to the checkout; on a cluster, point it at the shared filesystem.- Validate the full config without submitting a job by appending
--dry-run: it writes<run_dir>/launcher/rl.sbatchplus the resolved per-process configs, and exits.
Start the run
The rl entrypoint submits an sbatch job whenever the config has a [slurm] table — there is no separate launcher. From the shared checkout:
uv run rl @ examples/advanced/glm-4.5-air/swe.toml \
--output-dir /shared/outputs/glm45air \
--run.name glm45air-swe
Swap swe.toml for search.toml or terminal.toml to run the other domains. For SWE on a smaller budget, compose a budget variant over its base: uv run rl @ examples/advanced/glm-4.5-air/swe-budget.toml @ examples/advanced/glm-4.5-air/swe-2-node.toml trains the 100B+ MoE on only two nodes. Pass --run.name: the run directory is <output_dir>/<run_name> and you need a stable name to resume later (unset, it auto-generates as <envs>--<model>--<short-id>).
Monitor with the dashboard
Start the local run dashboard on the head node — it only reads the run directories, so it is safe to point at a live run while the job is training:
uv run dashboard /shared/outputs/glm45air # serves http://localhost:7788
If the head node is remote, forward the port from your laptop and open http://localhost:7788 in a browser:
ssh -L 7788:localhost:7788 <head-node>
Pick the run (<run_name> from the launch) and you get five views:
- Metrics — the W&B-style overview, read from the run's
metrics.jsonl. Watchreward/{all,env}/meantrend upward over steps, andseq_len/*+is_truncated/*for rollout health. - Configs — the launch TOML next to the merged, resolved per-process configs the run actually started with.
- Trace — a per-episode rollout viewer with per-token overlays (advantage, entropy, sampling mismatch, loss/content masks), showing the transcript, a wall-clock timeline of the rollout, a terminal replay of model and tool activity, and a semantic graph of the model-call chain.
- Logs — the merged component logs (trainer, orchestrator, inference), also on disk under
<run_dir>/logs/. - Reports — markdown reports written to
<run_dir>/reports/, if any tooling produces them.
Pass several output directories to track parallel experiments side by side (uv run dashboard /shared/outputs/a /shared/outputs/b); a taken port automatically bumps to the next free one. SLURM stdout/stderr and the generated sbatch script land in <run_dir>/launcher/.
Checkpoint, resume, export
Checkpoints land in <run_dir>/checkpoints/step_<N> every 50 steps (keep_last = 1). To resume, re-run the same command with --resume (latest checkpoint) or --resume.step <N>, the same --run.name / --output-dir, and a --max-steps at least the target final step:
uv run rl @ examples/advanced/glm-4.5-air/swe.toml \
--output-dir /shared/outputs/glm45air \
--run.name glm45air-swe \
--resume --max-steps 1000
Trainer checkpoints are DCP-sharded; export HF-format weights with:
uv run python tools/convert_dcp_to_bf16.py /shared/outputs/glm45air/glm45air-swe/checkpoints/step_100
See Training for the full knobs and metrics reference, and Scaling for SLURM and multi-node details.