Files
prime-rl/docs/configuration.md
T
691dd4ef14 chore: overhaul public configs/ and examples/ (#3085)
* chore: overhaul public configs/ and examples/

Restructure the public configs/ and examples/ trees for clarity.

- examples/: split into basic/ (core-env tutorials) and advanced/
  (folder-per-model: qwen3-30b-a3b, glm-4.5-air, glm-5.2, minimax-m2.5,
  nemotron-3-super, intellect-3.1), each with a README; drop multinode/
  and the example screenshots.
- configs/: add basic/ (small 2-GPU dev mirrors of the core envs, one folder
  + README each, validated at 1 step); rename debug/algorithms -> debug/algo;
  move debug/{rl,sft} -> debug/fake/{rl,sft}.toml; remove stale/internal
  configs (gsm8k, nemotron_*, hendrycks_math, general_agent, elastic,
  debug/v1, debug/{infer,orch,multimodal}.toml, debug/{hendrycks_sanity,moe,multi_env}).
- Remove the k8s/ Helm chart and its docs.
- Repoint README, docs/, nightly tests, and CI to the new paths; lowercase
  prime-rl throughout docs and READMEs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore: drop per-model READMEs in examples/advanced

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(k8s): keep Helm chart, refresh reverse-text example configs

Keep the k8s/ Helm chart (undo its removal earlier in this branch) and bring
its reverse-text example back in sync with the current config layout.

The chart invoked examples/reverse_text/rl/{orch,infer,train}.toml — a split
config layout flattened into a single rl.toml months ago (#1859), so the
shipped example had pointed at non-existent files. Add current, validated
orch/infer/train configs under k8s/prime-rl/examples/reverse-text/ (split from
examples/basic/reverse_text/rl.toml), point the chart and docs at them, and
COPY k8s/ into the CUDA image so /app/k8s/... resolves at runtime.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(configs): hyphenate all directory names in configs/, examples/, k8s/

Normalize directory naming to hyphens, matching the model dirs and logical
ids (reverse-text-v1, prime-rl). Renames the env/task dirs that still used
underscores:

  examples/basic/{reverse_text,alphabet_sort,wiki_search,hendrycks_sanity}
  configs/basic/{reverse_text,alphabet_sort,wiki_search,hendrycks_sanity}
  configs/ci/integration/reverse_text{,_lora,_moe,_multi_run,_rl_opd,_rl_sft,_sft,_sft_lora}

to the same names with hyphens, and updates every path reference (README,
docs, skills, nightly + integration test path args, the cpu_tests
config-import check). Python test files/modules and *.toml filenames keep
underscores.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(examples): eval CLI migration, SLURM cleanup, batch sizes, glm-5.2 layout

- Migrate every eval command in examples/basic READMEs from `vf-eval` to the v1
  `eval` CLI (pydantic-config): `-b` -> `--client.base-url`, `--max-tokens`/`-t`
  -> `--sampling.max-tokens`, `--env-args` -> `--args`, plus `-r 3` (v1 defaults
  to 1 rollout; these READMEs report 20x3), `--harness.id null` (these envs train
  with the null harness), and `--no-push`. Drop the now-dead vf-eval skip in
  tests/unit/test_configs.py.
- Remove all SLURM overlays (slurm_rl.toml, slurm_sft.toml) from examples/basic.
  Move the slim-wheel SFT+[slurm] parse fixture to configs/ci/slim_sft.toml and
  repoint cpu_tests.yaml; drop the SLURM section from the hendrycks-sanity README
  and the SLURM line from the start-run skill.
- Tune basic example batch/group sizes: alphabet-sort 256/16, wordle 512/16
  (wiki-search already 512/16).
- Restructure examples/advanced/glm-5.2: inference configs ->
  infer/{pd,pd-llmd}.toml, RL configs -> {swe,swe-llmd}.toml; repoint docs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs: fix outdated docs/skills/configs surfaced by v1 audit

Swept docs/, skills/, READMEs, and config TOMLs for outdated content (special
focus on v0->v1 drift). Verified every fix against current code.

docs/
- configuration.md: repoint 5 dead Basic example links to examples/basic/<hyphen>;
  scope the "each dir has a README" claim to basic (advanced dirs are config-only).
- algorithms.md: opd reference-model field is `teacher` not `model`; renderer names
  `glm-5`/`glm-4.5` (were invalid `glm5`/`glm4.5`); rewrite the per-env algorithm
  example in the v1 taskset/harness form (was the v0 bare-`id` form).
- development.md: drop invalid `--data.type null` (SFT DataConfig has no such type).
- inference.md: fix "Dissagregation" typo + dead P/D anchor.
- overview.md: token-in route is `/inference/v1/generate`.

skills/
- monitor-run: correct the metric tables to the real
  {scope}/{subset}/<metric>/<stat> scheme (num_total_tokens, has_error,
  time/wait_for_policy, dispatcher/*); the old seq_len / errored_rollouts /
  scheduler/* / generate_completions names never existed.
- install: drop the deep-gemm mention (no such section) from the description.

READMEs
- examples/README.md: basic runs on 1-8 GPUs (not 2); hyphenate env names.
- configs/README.md: drop stale "standalone entrypoint configs"; hyphenate.
- wiki-search: eval inference uses `--model.*` (not `--inference.model.*`) and drops
  the auto-derived `enable_auto_tool_choice` flag; "native V1 tools" not "MCP".
- reverse-text: fix dead sft/train.toml path -> sft.toml.
- hyphenate configs/basic/* README headings.

configs/
- qwen3-30b-a3b/tool.toml: move `min_tier` into the taskset (was under a v0
  `[...env.args]` block a v1 taskset never reads); group_size alias.
- glm-5.2/swe-llmd.toml: rollouts_per_example -> group_size.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(configs): use prime-qwen3 renderer for reverse-text (was default)

The reverse-text configs run PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT, whose
`-SFT` suffix misses MODEL_RENDERER_MAP's exact-match lookup and so fell back to
the DefaultRenderer. reverse-text is single-turn and always sends a system
prompt ([system, user, assistant]); the prime-qwen3 renderer is token-for-token
identical to the model's apply_chat_template for that shape (verified via
render_ids parity), and unlike the stock qwen3 renderer it does not inject an
empty <think></think> block. Switch the 7 standard + 3 distill reverse-text
configs to prime-qwen3.

Kept `default` where no hand-coded renderer fits (each errors on the model's
tokenizer): hendrycks-sanity (DeepSeek-R1-Distill-Qwen-1.5B), reverse-text-moe
(samsja/mini-glm-moe), intellect-3.1 (INTELLECT-3-Base).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(configs): use prime-qwen3 (not qwen3) for PrimeIntellect Qwen3 configs

The stock `qwen3` renderer injects an empty <think></think> block the
PrimeIntellect Qwen3 template never emits, so it mismatches these models'
apply_chat_template — single-turn for reverse-text, and every multi-turn shape
for wordle (verified via render_ids parity) — corrupting training tokenization.

- configs/basic/wordle/rl.toml: qwen3 + thinking_retention="all" -> prime-qwen3,
  matching the tutorial examples/basic/wordle (which already uses prime-qwen3).
- configs/debug/algo/{echo,grpo,max_rl,self_distill,mixed_grpo_opd,opd,opd_lora}.toml
  and configs/ci/integration/reverse-text-rl-opd/start.toml: qwen3 -> prime-qwen3
  (all run PrimeIntellect/Qwen3-0.6B-Reverse-Text-{SFT,RL}).

prime-qwen3 handles the PI template's think retention natively, so the explicit
thinking_retention="all" is dropped.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(k8s): use prime-qwen3 renderer in reverse-text orch config

The k8s reverse-text orchestrator config was split from the reverse-text example
before that example migrated to prime-qwen3, and the renderer migration was
scoped to configs/ and examples/ — so this one kept the stale `default`. Align
it with the source (PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT → prime-qwen3).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(k8s): drop redundant renderer comment in reverse-text orch config

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 10:59:06 -07:00

11 KiB
Raw Blame History

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, the trainer-side enable_token_export flag) 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:

  1. Defaults declared on the Pydantic model.
  2. TOML files passed with @, left to right — later files override earlier ones.
  3. 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.parallel.tp 4

Field names are snake_case in TOML (max_model_len) and kebab-case on the CLI (--max-model-len).

Renamed fields keep their old name as a validation alias — e.g. rollouts_per_example is still accepted in TOML and CLI after being renamed to group_size. Mixing the two names across sources is safe.

Inspecting and Validating

uv run rl --help                                       # full schema
uv run rl @ rl.toml --dry-run --output-dir /tmp/check  # write resolved 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-output-dir       # True
uv run rl @ rl.toml --no-clean-output-dir    # False
clean_output_dir = 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 (e.g. environments), see Environments.

Dicts

CLI takes a JSON literal. TOML uses a table or inline-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.env.0.args \
  '{"dataset_name": "openai/gsm8k", "dataset_subset": "main"}'
[[orchestrator.train.env]]
args = { dataset_name = "openai/gsm8k", dataset_subset = "main" }

Optional Sub-Configs

Many sub-configs are typed SomeConfig | None. Two patterns enable them:

  • Bare flag with defaults: --model.compile or, 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.model]
max_model_len = "None"

On the CLI: --inference.model.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 ([[orchestrator.train.env]])

Training environments are an array of tables — set one per env, optionally with sampling weights:

[[orchestrator.train.env]]
name = "gsm8k"
taskset = { id = "gsm8k-v1", split = "train" }
harness = { id = "null", runtime = { type = "subprocess" } }
ratio = 3  # 75% of batches

[[orchestrator.train.env]]
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
ratio = 1  # default — 25% of batches

[[orchestrator.eval.env]]
name = "gsm8k-eval"
taskset = { id = "gsm8k-v1", split = "test" }
harness = { id = "null", runtime = { type = "subprocess" } }

ratio defaults to 1 (equal weight per env); values are relative weights normalized to probabilities across envs.

Fields in taskset configure the V1 taskset. harness selects how its tasks are run.

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]
PI_USAGE_BASE_URL = "https://..."

The rl launcher applies these the same way in both single-node and multi-node (SLURM) runs. Precedence, low to high:

  1. The launcher's own defaults — your env_vars override these.
  2. Your top-level [env_vars].
  3. Your [component.env_vars].
  4. Orchestration-critical vars the launcher always sets last — CUDA_VISIBLE_DEVICES (GPU partitioning) and WANDB_SHARED_* (the single shared W&B run) — these cannot be overridden from env_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.6B reversing a chunk of text. Tiny single-turn SFT + RL; runs on a single consumer GPU in minutes.
  • Wordle — Qwen3-1.7B playing Wordle. Multi-turn SFT + RL; 2–4 H100s.
  • Alphabet Sort — Qwen3-4B-Instruct-2507 sorting names alphabetically. Multi-turn LoRA RL without SFT warmup; one H100.
  • Wiki Search — Qwen3-4B-Instruct-2507 answering trivia by searching a Wikipedia corpus. Multi-turn with tool use.
  • Hendrycks Sanity — DeepSeek-R1-Distill-Qwen-1.5B on a filtered MATH subset. Useful for algorithm ablations.

Advanced (32–2048 GPUs, SLURM):

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 \
  --wandb.name my-experiment \
  --trainer.optim.lr 5e-6 \
  --output-dir /tmp/reverse-dry \
  --dry-run

Then inspect the resolved config:

ls /tmp/reverse-dry/configs/
# rl.toml  trainer.toml  orchestrator.toml  inference.toml

Each per-process TOML reflects the final, validated configuration that the actual run would consume — exactly what each process sees when started standalone (uv run trainer @ /tmp/reverse-dry/configs/trainer.toml, etc.). This is the easiest way to bisect a misbehaving config: dry-run a known-good base, dry-run your overlay, diff the two.