Files
prime-rl/skills/configs/SKILL.md
T
cb74ae2beb feat: bump verifiers to 0.2.2.dev7, adopt the multi-agent episode wire (#3104)
* feat: bump verifiers to 0.2.2.dev7, adopt the multi-agent episode wire

Companion to PrimeIntellect-ai/verifiers#1939 (multi-agent api). Re-pins
deps/verifiers to 192fd8ef0 (= 0.2.2.dev7) and deps/pydantic-config to
v0.4.2 (verifiers now requires prime-pydantic-config>=0.4.2).

- Serve wire: the env-server route run_rollout -> run, answering one
  Episode envelope ({id, env, ok, errors, traces}) per env-rollout.
  Env.run returns list[Rollout]; an episode that failed before minting
  any trace raises (the dispatcher synthesizes its error marker), and a
  not-ok episode marks its clean traces failed so a broken episode's
  partial seats are never trained on.
- The episode is the pipeline currency: the dispatcher emits one episode
  (list[Rollout]) per completed task onto out_q (a legacy run_group
  result emits its traces as single-trace episodes), and both sinks
  count episodes - never loose traces - toward group_size and eval epoch
  sizes. episode_id is stamped into info so saved records keep grouping.
- ok is the success sentinel: has_error now reads it, so the dispatcher's
  empty-trajectory promotion also flips ok, and error markers carry it.
- Only the trainable subset becomes training samples: a trace stamped
  untrainable (a multi-agent env's frozen agent) is never tokenized,
  never enters the group advantage, and never ships; it still lands in
  the trace files and observation window.
- Config shape: everything env lives under the env block, following the
  new vf.EnvServerConfig (env.taskset, env.agent.harness, per-agent caps
  under env.agent.*). All checked-in TOMLs migrated; the spawned env
  server receives the picklable env block via env_config_data.
- run_group survives only for v0/legacy bridge envs (a v1 server refuses
  it and always reports requires_group_scoring=False); vf's @group_reward
  removal doesn't touch prime-rl's own Algorithm.score_group.

Verified: tests/unit green (487 passed; config-loading params covered all
migrated TOMLs), ruff clean, and a 3-step reverse-text RL run on 2 GPUs
trains at 0% errors with every saved trace carrying ok, agent.name,
agent.trainable, and a distinct info.episode_id.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore: trim narrative comments to the load-bearing facts

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: count buffered sink progress in episodes; explicit ok=False on cancel markers

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: keep untrainable traces out of the effective views and the derived avg@k

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 16:44:20 -07:00

5.1 KiB

name, description
name description
configs How the prime-rl config system works — TOML files, CLI overrides, composition, and special patterns. Use when creating configs, debugging config errors, or overriding values via CLI.

Configs

prime-rl uses pydantic-config — a Pydantic-based TOML + CLI config system (no tyro). Every entrypoint accepts TOML files via @ and CLI overrides.

Loading and composition

uv run rl @ examples/basic/reverse-text/rl.toml                                  # single TOML
uv run rl @ examples/basic/reverse-text/rl.toml --max-steps 50                   # CLI override
uv run rl @ base.toml @ overlay.toml                                       # left-to-right merge
uv run rl --model @ model.toml --data @ data.toml                          # nested section files
uv run rl @ base.toml --trainer @ trainer.toml --trainer.lr 1e-3           # mixed

Resolution order: CLI > config files (left-to-right) > class defaults. Merging is deep — unset fields in an overlay are preserved from the base.

Naming: CLI uses kebab-case (--model.max-model-len); TOML uses snake_case (max_model_len).

Inspect & validate

uv run rl --help                                  # all fields and defaults
uv run rl @ rl.toml --dry-run --output-dir /tmp/x # write resolved TOML to /tmp/x/configs

Validators

Incompatible combinations (e.g. CP requires flash attention) must raise in a model_validator at resolve time, not at runtime. When renaming a field, emit a deprecation warning with a migration hint — never silently drop.

Special syntax

Booleans — CLI --flag / --no-flag; TOML must be explicit (enforce_eager = true).

None — TOML has no null, use the string "None" (max_model_len = "None"); CLI: --model.max-model-len None.

Lists — TOML uses array of tables; later config files replace lists wholesale, so overlays must include the full desired list:

[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }

CLI: --orchestrator.train.env.0.env.taskset.id reverse-text-v1.

Dicts — TOML uses a section; CLI takes a JSON string: --vllm-extra '{"key1": "value1"}'. This works for plain dict fields only — nested pydantic-model fields (e.g. algo) reject JSON strings; use dotted keys (--orchestrator.algo.type max_rl) or a TOML overlay file.

Discriminated unions — set the type field to pick the variant ([orchestrator.algo] type = "max_rl"). Omit type to keep the default variant.

Algorithms — [orchestrator.algo] type = "grpo" | "max_rl" | "opd" | "opsd" | "sft" | "echo" — the type names the algorithm (credit assignment + loss routing, fused), and each type's class defaults are its vetted setting; any other key you set is your own assembly (e.g. [orchestrator.algo.roles.user] alpha = 0.1 for echo — setting any echo role replaces the whole role table). There is no preset layer, and no config hook that points at user code — a new algorithm is a named class in the repo (subclass Algorithm, register it). Per-env override: [orchestrator.train.env.algo] type = "opd" (the env assembles its own algorithm). prime-rl only hosts the trainable policy; frozen models are inline external endpoints on the algorithm, named where the model is used — [orchestrator.algo.teacher] for opd (the frozen model scored against), [orchestrator.algo.sampling.source] for sft (the model it samples from), each with name + base_url. There is no shared teacher slot. opsd declares no model — it self-distills against the live policy. See docs/algorithms.md.

BaseModel | None fields — bare flag enables defaults; nested override enables and sets:

--model.compile             # enables compile with defaults
--model.compile.fullgraph   # enables and sets fullgraph=true

In TOML, an empty section header ([ckpt]) does the same.

RL trainer token exports

For rollout debugging, enable trainer-side token export with trainer.enable_token_export = true (or --enable-token-export when running the trainer entrypoint directly). It writes one JSONL record per exported sequence. Single-run/fallback exports go under output_dir/token_exports/step_<step>/rank_<rank>.jsonl; multi-run trainer exports with packer metadata go under the owning run directory, output_dir/<run_id>/token_exports/step_<run_step>/rank_<rank>.jsonl. Each record stores aligned per-token arrays for token ids, loss mask, component weight streams (rl/ce/ref_kl), advantages, entropy, mismatch KL, inference/trainer logprobs, importance ratios, probability deltas, and masking diagnostics. It does not decode token text in the trainer.

enable_token_export = true

Leave it unset for normal training. When enabled, it exports every sequence from each exporting rank.

Key files

  • packages/prime-rl-configs/src/prime_rl/ — config classes under configs/; utils/config.py re-exports BaseConfig and cli
  • configs/debug/ — minimal debug configs
  • examples/ — full example configs