Use Verifiers' shared sampling config and resolution path for evaluation
and rollout dispatch. Parameter names, provider options, source
defaults, and agent overrides follow the same rules in native Verifiers
and Prime-RL. Training retains its strict config for the distribution
the trainer replays.
## Sampling flow
```mermaid
flowchart TD
T["Train source and agent config<br/>TrainSamplingConfig and replay bounds"] --> V["Validate live-policy sampling<br/>Source owns the distribution"]
V --> S["Shared Verifiers SamplingConfig<br/>Normalize aliases and extra_body"]
V --> A["AgentConfig.sampling<br/>Sparse overrides across config transport"]
E["Eval source and agent config"] --> S
E --> A
S --> R["RunRequest to env server"]
A --> M["Verifiers resolve_agent<br/>Shared merge_defaults"]
R --> M
M --> P["Provider request<br/>Non-null resolved parameters"]
M --> C["Trace<br/>Complete resolved sampling"]
```
## Shared parameters
Verifiers normalizes `max_tokens` / `max_completion_tokens` and flattens
`extra_body` before merging each override layer. Source values replace
group defaults; agent values replace inherited sampling. An explicit
null clears an inherited parameter.
Within one sampling block, top-level values take precedence over
`extra_body`. A typed training `top_k=20`, or the automatic replay bound
of `512`, therefore takes precedence over `extra_body.top_k=-1`. With no
typed `top_k`, the disabled sentinel remains effective.
Prime-RL carries `vf.SamplingConfig` through dispatch and converts
`TrainSamplingConfig` once. Source defaults and agent overrides use
Verifiers' `merge_defaults`; duplicate eval schemas and
sampling-dictionary converters are removed. Request-specific cache salts
are copied onto the shared config.
Unresolved agent overrides remain sparse across env-server config
boundaries. `resolve_agent` materializes the sampling used for
generation, and traces record the complete resolved config. Provider
dialects and the renderer client omit nulls when constructing requests.
## Training ownership
Live-policy sources validate their sampling when the config loads.
Unsupported source parameters, including `frequency_penalty`, are
rejected before generation.
The source owns the distribution replayed by the trainer. Every agent in
a live-policy source, including non-trainable roles, may override only
`max_tokens`, `reasoning_effort`, and `chat_template_kwargs`.
Distribution parameters belong on the source, even when an agent would
repeat the same value. Policy logprobs remain enabled. Evaluation and
frozen-model sources retain general agent overrides.
This removes the post-rollout sampling comparison from `TrainSink`.
## Dependency
Pins Verifiers `2cb0a6d`, the merged commit for [Verifiers
#2762](https://github.com/PrimeIntellect-ai/verifiers/pull/2762), for
shared sampling normalization and resolution. This includes merging
per-call judge sampling overrides before constructing SDK requests,
preserving unrelated configured provider parameters. The lockfile
updates `prime-tunnel` to `0.1.14` to meet the merged dependency's
minimum.
Before publishing packages outside this source checkout, release that
Verifiers change and raise the `verifiers` minimum in both `prime-rl`
and `prime-rl-configs`. The current `>=0.3.2.dev158` package constraints
do not guarantee these semantics.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes how sampling is resolved and validated for all rollouts;
mis-merged configs or rejected agent overrides could break existing
TOMLs, though unit tests cover the main inheritance and policy rules.
>
> **Overview**
> **Unifies rollout sampling** on Verifiers' shared `SamplingConfig` and
merge rules instead of Prime-RL–specific eval schemas and
`to_sampling_args()` dict builders.
>
> Eval sources and group defaults now use `vf.SamplingConfig`;
train/eval env wrappers carry a typed `SamplingConfig` through to the
env server (including per-request `cache_salt` via `model_copy`). Policy
train sources get **load-time validation**: the source owns distribution
parameters (`temperature`, `top_p`, etc.), while agents may only
override `max_tokens`, `reasoning_effort`, and
`chat_template_kwargs`—frozen-model and eval paths stay permissive.
`TrainSink` reads temperature from `env.config.sampling` instead of a
resolved args dict.
>
> **Docs** describe alias normalization (`max_tokens` /
`max_completion_tokens`), `extra_body` merging, and live-policy override
limits. **Tests** cover inherited sampling merges and policy sampling
rejection cases. Lockfile bumps `prime-tunnel` to `0.1.14`.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
671a5aa9857a39a4d44fa7902f1c89021b8fd380. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
13 KiB
Configuration
Every prime-rl entrypoint uses pydantic-config: TOML files for reproducible base configs, CLI flags for one-off overrides.
AI agents working in this repo: the equivalent runbook is at
skills/configs/SKILL.md, with extra runtime hints (where config classes live, validator conventions) that aren't surfaced here.
Table of Contents
Sources and Precedence
Field values come from three sources — Pydantic defaults, TOML files (passed with @), and CLI flags. They're layered in this order, with later sources winning:
- Defaults declared on the Pydantic model.
- TOML files passed with
@, left to right — later files override earlier ones. - CLI flags in dotted, kebab-case form (
--model.name).
TOML Composition
The @ token introduces a TOML file. Multiple @ arguments compose left-to-right, deep-merged — unset fields in an overlay keep the base value:
uv run rl @ examples/basic/reverse-text/rl.toml # one file
uv run rl @ base.toml @ overlay.toml # left to right
uv run rl --trainer @ trainer.toml --orchestrator @ orch.toml # per-section
uv run rl @ base.toml --trainer @ trainer.toml # mixed
Mind the space:
@ path/to/x.toml, not@path/to/x.toml.
CLI Overrides
CLI flags mirror the TOML tree using dots:
--max-steps 50 # top-level
--model.name Qwen/Qwen3-4B # nested
--trainer.optim.lr 1e-5 # double-nested
--inference.vllm.tensor-parallel-size 4
Field names are snake_case in TOML (
max_model_len) and kebab-case on the CLI (--max-model-len).
A renamed field keeps no alias for its old name: the old spelling fails as an unknown key rather than being silently translated.
Inspecting and Validating
uv run rl --help # full schema
uv run rl @ rl.toml --dry-run --output-dir /tmp --run.name check # write resolved configs (JSON) to /tmp/check/configs
Syntax
Booleans
CLI uses paired flags: bare --flag sets True, --no-flag sets False. TOML must be explicit:
uv run rl @ rl.toml --clean # True
uv run rl @ rl.toml --no-clean # False
clean = true
Lists
CLI accepts space-separated values or a JSON literal. TOML uses an array literal. Both forms target the same field:
uv run rl @ rl.toml --trainer.model.lora.target-modules q_proj k_proj v_proj
uv run rl @ rl.toml --trainer.model.lora.target-modules '["q_proj", "k_proj", "v_proj"]'
[trainer.model.lora]
target_modules = ["q_proj", "k_proj", "v_proj"]
Overlay TOMLs replace lists wholesale — an overlay that wants to add one item must still spell out the full list. For arrays of tables, see Environments.
Dicts
CLI takes a JSON literal. TOML uses a table. CLI dicts deep-merge with TOML dicts — CLI keys win on conflict but don't wipe the file's keys:
uv run rl @ rl.toml --orchestrator.train.source.0.args \
'{"dataset_name": "openai/gsm8k", "dataset_subset": "main"}'
[[orchestrator.train.source]]
args.dataset_name = "openai/gsm8k"
args.dataset_subset = "main"
Optional Sub-Configs
Many sub-configs are typed SomeConfig | None. Two patterns enable them:
- Bare flag with defaults:
--model.compileor, in TOML, an empty section[model.compile]. The sub-config materializes with all-default values. - Enable and set fields together:
--model.compile.fullgraph(CLI) or any populated[model.compile]table (TOML).
To disable a sub-config that's on by default, use --no-<name> on the CLI or assign the string "None" in TOML (see None). This is how [ckpt], [model.lora], [model.compile], [trainer.wandb], etc. are turned on and off.
None
TOML has no null. Use the string "None", which the loader coerces:
[inference.vllm]
max_model_len = "None"
On the CLI: --inference.vllm.max-model-len None.
Discriminated Unions
Loss, advantage, optimizer, scheduler, weight broadcast transport, and several others are discriminated unions. Set the type field to pick a variant:
[trainer.optim]
type = "muon"
lr = 1e-5
mu = 0.95
Omit type to keep the default variant.
Environments
Training and evaluation sources are arrays of tables. Set one source per environment; training sources can optionally carry sampling weights:
[[orchestrator.train.source]]
name = "gsm8k"
ratio = 3 # 75% of batches
env.taskset.id = "gsm8k"
env.taskset.split = "train"
env.agent.harness.id = "null"
env.agent.runtime.type = "subprocess"
[[orchestrator.train.source]]
name = "reverse-text"
ratio = 1 # default — 25% of batches
env.taskset.id = "reverse-text"
env.agent.harness.id = "null"
env.agent.runtime.type = "subprocess"
[[orchestrator.eval.source]]
name = "gsm8k-eval"
env.taskset.id = "gsm8k"
env.taskset.split = "test"
env.agent.harness.id = "null"
env.agent.runtime.type = "subprocess"
Each source group — [orchestrator.train], [orchestrator.eval], the [eval] block of sft and the top level of eval — holds defaults for its sources. Every field that a group and its sources both have is a default: env, sampling, select and group_size, plus algo on the train group and interval on the eval groups of a training run. Each source inherits the fields that its group sets. One rule applies to all of them: nested blocks merge key by key, a source's own values win, and a block whose type (e.g. of algo) differs from the group's is the source's alone.
Sampling parameters use Verifiers' shared normalization: max_tokens and max_completion_tokens name the same limit, and extra_body parameters merge like top-level parameters. Agent overrides apply after source defaults; an explicit null clears an inherited parameter. Resolved sampling is recorded on each trace.
For live-policy training, set distribution parameters (temperature, top_p, top_k) on the source's sampling block. Every agent in that source, including non-trainable roles, may override only max_tokens, reasoning_effort, and chat_template_kwargs. These rules are checked when loading the config; evaluation and frozen-model sources allow general agent sampling overrides.
[orchestrator.train]
group_size = 16
[orchestrator.train.algo]
type = "grpo"
[[orchestrator.train.source]]
env.taskset.id = "math"
group_size = 32 # this source's own value wins over the group's 16
[orchestrator.eval.env]
retries.rules = [
{type = "ProviderError", max_retries = 3},
{type = "SandboxError", max_retries = 3},
]
timeout.episode = 7200
[orchestrator.eval.select] # evaluate 128 tasks of each taskset
limit = 128
The group env block holds only the knobs that every env and taskset has: retries, timeout, max_concurrent_agents, interception, and taskset.task and taskset.system_prompt. Ids and agents stay on each source. select picks which tasks of a source's taskset run: include/exclude by task idx/ids/keys/names, then shuffle, skip and limit, in that order.
ratio is a training-source field: it defaults to 1 (equal weight per env), and values are relative weights normalized to probabilities across envs. Eval sources of a training run carry interval instead, the step interval at which they fire; a standalone eval has neither.
Everything environment lives under the env block (verifiers' [env] shape): env.taskset configures the v1 taskset, and each agent is a field on the env — env.agent.harness selects how the single-agent env's tasks are run, and per-run caps are per-agent (env.agent.max_turns, env.agent.timeout, env.agent.max_output_tokens). A multi-agent env declares its own seats (env.<role>.*).
The same taskset can appear multiple times across train and eval (or with different settings) — useful for evaluating on a held-out split or comparing two configurations side by side. When it is reused, set a distinct name on each entry; name defaults to the taskset id and must be unique across all envs in the same group.
Environment Variables
OS environment variables exported into launched component process(es). In rl configs, top-level [env_vars] applies to trainer, inference, and orchestrator:
[env_vars]
HF_HUB_OFFLINE = "1"
TOKENIZERS_PARALLELISM = "false"
Component-specific tables layer on top:
[trainer.env_vars]
NCCL_DEBUG = "INFO"
PYTORCH_CUDA_ALLOC_CONF = "expandable_segments:False"
[inference.env_vars]
VLLM_USE_DEEP_GEMM = "1"
[orchestrator.env_vars]
PRIME_LOG_LEVEL = "debug"
The rl launcher applies these the same way in both single-node and multi-node (SLURM) runs. Precedence, low to high:
- The launcher's own defaults — your
env_varsoverride these. - Your top-level
[env_vars]. - Your
[component.env_vars]. - Orchestration-critical vars the launcher always sets last —
CUDA_VISIBLE_DEVICES(GPU partitioning) andWANDB_SHARED_*(the single shared W&B run) — these cannot be overridden fromenv_vars.
For standalone sft and inference configs, [env_vars] applies to that entrypoint's process(es). For disaggregated P/D inference, the role-specific deployment.{prefill,decode}_env_vars layer on top of any shared inference env vars.
Examples
The shipped end-to-end examples in examples/ are the canonical, kept-up-to-date references — the rest of the repo's TOMLs (under configs/) are CI- and debug-internal and may drift. Each basic example directory has its own README with the full launch story; the advanced examples are config-only.
Basic (1–8 GPUs):
- Reverse Text —
Qwen3-0.6Breversing a chunk of text. Tiny single-turn SFT + RL; runs on a single consumer GPU in minutes. - Wordle —
Qwen3-1.7Bplaying Wordle. Multi-turn SFT + RL; 2–4 H100s. - Alphabet Sort —
Qwen3-4B-Instruct-2507sorting names alphabetically. Multi-turn LoRA RL without SFT warmup; one H100. - Wiki Search —
Qwen3-4B-Instruct-2507answering trivia by searching a Wikipedia corpus. Multi-turn with tool use. - Hendrycks Sanity —
Qwen3-1.7Bon a filtered MATH subset. Useful for algorithm ablations.
Advanced (32–2048 GPUs, SLURM):
- Qwen3-30B-A3B —
Qwen3-30B-A3Bon math, SWE, and tool use. - GLM-4.5-Air —
GLM-4.5-Airon search, SWE, and terminal; includes a variant that trains the 100B+ MoE on only two nodes. - Nemotron-3-Super —
Nemotron-3-Super-120Bhybrid-Mamba MoE on SWE at 131k context. - MiniMax-M2.5 SWE —
MiniMax-M2.5on agentic SWE. - INTELLECT-3.1 — reproduces our INTELLECT-3.1 training run.
- High-throughput GLM-5 — large-scale
GLM-5/GLM-5.3inference with P/D disaggregation and FP8.
Worked Example: Compose, Override, Dry-Run
Start from a shipped base config, override two fields on the CLI, and dry-run:
uv run rl @ examples/basic/reverse-text/rl.toml \
--monitors.wandb.name my-experiment \
--trainer.optim.lr 5e-6 \
--output-dir /tmp/reverse-dry \
--run.name check \
--dry-run
Then inspect the resolved config:
ls /tmp/reverse-dry/check/configs/latest/resolved/
# rl.json trainer.json orchestrator.json inference.json
Each per-process JSON contains the final, validated configuration that the run
uses. This is also what each standalone process reads. For example, the trainer
reads configs/latest/resolved/trainer.json.
configs/latest/command.txt records the shell-safe launch command and its CLI
overrides. Each launch also remains under configs/attempt_<n>/. To compare
configs, dry-run a known-good base and your overlay. Then diff the two attempts.