chore: migrate environment configs to V1 (#3058)
Docker Push / Push CUDA image to Docker (push) Canceled after 0s

This commit is contained in:
Florian Brand
2026-07-17 15:34:42 +02:00
committed by GitHub
parent 188192ce64
commit 5f7e3ffcaa
38 changed files with 189 additions and 245 deletions
+3 -8
View File
@@ -90,20 +90,15 @@ jobs:
assert find_package_resource("templates") is None, "templates should not be in slim wheel"
print("slim install OK — configs import with no heavy deps loaded")
PY
- name: Verify real configs (with [slurm]) parse on slim install
- name: Verify real SFT config (with [slurm]) parses on slim install
run: |
/tmp/slim/bin/python - <<'PY'
from pydantic_config import cli
from prime_rl.configs.sft import SFTConfig
from prime_rl.configs.rl import RLConfig
# Configs that don't pull in a v1 env package parse on the slim
# (prime-rl-configs-only) install: the SFT config has no env sections, and the
# reverse_text RL recipe uses a v0 env id (resolved lazily, not imported at parse).
# RL configs on a v1 taskset can't parse here because vf.EnvServerConfig imports the
# (uninstalled) env package at parse time.
# The slim wheel intentionally excludes taskset packages, so validate a real
# SFT config here. RL recipes are covered by the full config suite.
for cfg_cls, args in [
(SFTConfig, ["@", "examples/reverse_text/slurm_sft.toml"]),
(RLConfig, ["@", "examples/reverse_text/rl.toml", "@", "examples/reverse_text/slurm_rl.toml"]),
]:
cfg = cli(cfg_cls, args=args)
assert cfg.slurm is not None, f"expected [slurm] in {args}"
+5 -5
View File
@@ -17,20 +17,20 @@ group_size = 16
max_completion_tokens = 512
[[orchestrator.train.env]]
id = "alphabet-sort"
name = "alphabet-sort"
args = { min_turns = 2, max_turns = 2 }
taskset = { id = "alphabet-sort-v1", min_turns = 2, max_turns = 2 }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 50
[[orchestrator.eval.env]]
id = "alphabet-sort"
name = "alphabet-sort"
num_examples = 50
group_size = 4
args = { min_turns = 2, max_turns = 2 }
taskset = { id = "alphabet-sort-v1", min_turns = 2, max_turns = 2 }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer]
[inference]
[inference]
+2 -2
View File
@@ -23,9 +23,9 @@ group_size = 8
max_completion_tokens = 384
[[orchestrator.train.env]]
id = "alphabet-sort"
name = "alphabet-sort"
args = { min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, similarity_power = 4, power_per_turn = false }
taskset = { id = "alphabet-sort-v1", min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, task = { similarity_power = 4, power_per_turn = false } }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
@@ -24,7 +24,9 @@ group_size = 16
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
@@ -23,7 +23,9 @@ group_size = 16
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
@@ -27,7 +27,9 @@ name = "r8-1e-4"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
enable_lora = true
@@ -26,7 +26,9 @@ name = "r8-1e-4"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
enable_lora = true
@@ -26,7 +26,9 @@ group_size = 16
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
gpu_memory_utilization = 0.7
@@ -15,7 +15,9 @@ lr = 3e-5
max_completion_tokens = 128
[[train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[ckpt]
interval = 10
@@ -38,7 +38,9 @@ name = "qwen3"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -48,7 +50,9 @@ num_examples = 16
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
@@ -45,7 +45,9 @@ name = "default"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -55,7 +57,9 @@ num_examples = 16
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+4 -3
View File
@@ -1,4 +1,4 @@
# ECHO on the multi-turn alphabet-sort env (bundled with verifiers): GRPO on
# ECHO on the multi-turn alphabet-sort V1 taskset: GRPO on
# action tokens + weighted CE on the env's observation tokens.
# uv run rl @ configs/debug/algorithms/echo.toml
@@ -25,8 +25,9 @@ type = "echo"
alpha = 0.1
[[orchestrator.train.env]]
id = "alphabet-sort"
args = { min_turns = 3, max_turns = 5, power_per_turn = false }
name = "alphabet-sort"
taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 512
+6 -2
View File
@@ -22,7 +22,9 @@ name = "qwen3"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -32,7 +34,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+6 -2
View File
@@ -22,7 +22,9 @@ name = "qwen3"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -32,7 +34,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+7 -3
View File
@@ -32,12 +32,14 @@ name = "qwen3"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text-grpo"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text-opd"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.env.algo]
type = "opd"
@@ -54,7 +56,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+6 -2
View File
@@ -34,7 +34,9 @@ name = "qwen3"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -44,7 +46,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+6 -2
View File
@@ -34,7 +34,9 @@ name = "qwen3"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -44,7 +46,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 1e-4
+6 -2
View File
@@ -30,7 +30,9 @@ name = "qwen3"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -40,7 +42,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+6 -2
View File
@@ -39,7 +39,9 @@ name = "default"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -49,7 +51,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
@@ -39,7 +39,9 @@ name = "default"
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -49,7 +51,9 @@ num_examples = 128
max_completion_tokens = 128
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 1e-4
+9 -5
View File
@@ -18,12 +18,14 @@ name = "qwen3"
# -- multi train envs --
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text-train-1"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text-train-2"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
# -- multi eval envs --
@@ -33,12 +35,14 @@ num_examples = 16
group_size = 4
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text-eval-1"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[[orchestrator.eval.env]]
id = "reverse-text"
name = "reverse-text-eval-2"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
interval = 5
[trainer.optim]
@@ -48,4 +52,4 @@ lr = 3e-6
gpu_memory_utilization = 0.5
[inference.model]
max_model_len = 128
max_model_len = 128
+2 -2
View File
@@ -41,6 +41,6 @@ port = 8000
sync_interval = 5.0
[[orchestrator.train.env]]
id = "alphabet-sort"
name = "alphabet-sort"
args = { min_turns = 3, max_turns = 5, power_per_turn = false }
taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
harness = { id = "null", runtime = { type = "subprocess" } }
+7 -13
View File
@@ -6,16 +6,10 @@ In this example, we demonstrate how to train `Qwen3-0.6B` to answer math problem
## Setup
Install the environment:
The `gsm8k-v1` taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
```bash
prime env install primeintellect/math-env
```
Verify installation:
```bash
uv run python -c "import math_env"
uv run python -c "import gsm8k_v1"
```
Start the tmux session:
@@ -37,8 +31,8 @@ Evaluate the base model:
```bash
# In the `Trainer` pane
uv run vf-eval math-env \
-a '{"dataset_name": "openai/gsm8k", "dataset_subset": "main"}' \
uv run vf-eval gsm8k-v1 \
-a '{"split": "test"}' \
-m PrimeIntellect/Qwen3-0.6B \
-b http://localhost:8000/v1 \
-n 20 \
@@ -74,10 +68,10 @@ uv run inference --model.name <user>/Qwen3-0.6B-GSM8K-RL
```bash
# In the `Trainer` pane
uv run vf-eval math-env \
-a '{"dataset_name": "openai/gsm8k", "dataset_subset": "main"}' \
uv run vf-eval gsm8k-v1 \
-a '{"split": "test"}' \
-m <user>/Qwen3-0.6B-GSM8K-RL \
-b http://localhost:8000/v1 \
-n 20 \
-t 2048
```
```
+4 -10
View File
@@ -6,16 +6,10 @@ In this example, we demonstrate how to train `Qwen/Qwen3-4B-Instruct-2507` to an
## Setup
Install the environment:
The taskset is included through the research-environments workspace. After syncing the repository, verify it with:
```bash
prime env install primeintellect/math-env
```
Verify installation:
```bash
uv run python -c "import math_env"
uv run python -c "import math_env_v1"
```
Start the tmux session:
@@ -37,7 +31,7 @@ Evaluate the base model:
```bash
# In the `Trainer` pane
uv run vf-eval math-env \
uv run vf-eval math-env-v1 \
-a '{"dataset_name": "PrimeIntellect/Hendrycks-Math", "dataset_subset": "default"}' \
-m Qwen/Qwen3-4B-Instruct-2507 \
-b http://localhost:8000/v1 \
@@ -54,4 +48,4 @@ Train with the config file:
uv run rl @ configs/hendrycks_math/rl.toml \
--wandb.project your-project-name \
--wandb.name your-run-name
```
```
-43
View File
@@ -1,43 +0,0 @@
# math-python
## Setup
CLone `verifiers`
```bash
cd ~ && curl -sSL https://raw.githubusercontent.com/PrimeIntellect-ai/verifiers/main/scripts/install.sh | bash && cd -
```
Install the environment as local packages
```bash
uv pip install -e ~/verifiers/environments/math_python
```
This will automatically install the environment, and a pinned verifiers commit (`71006c`) which includes necessary changes to the PythonEnv.
## Eval
Get a quick vibe-check of the model
```bash
vllm serve Qwen/Qwen3-4B-Instruct-2507 --enable-auto-tool-choice --tool-call-parser hermes --max-model-len 8192
```
```bash
uv run --no-sync vf-eval math-python -n 16 -r 1 -c -1 -v -m Qwen/Qwen3-4B-Instruct-2507 -b http://localhost:8000/v1 -a '{"dataset_name": "PrimeIntellect/Hendrycks-Math", "dataset_subset": "default"}' -t 512
```
## RL
Again, make sure to have installed the environment as local packages from verifiers
```bash
uv pip install -e ~/verifiers/environments/math_python
```
Then, run RL in debug mode (small batch size, limited turns, 2 GPUs, etc.)
```bash
uv run --no-sync rl @ configs/math_python/math_python.toml --log.level debug
```
-29
View File
@@ -1,29 +0,0 @@
max_steps = 300
seq_len = 4096
[wandb]
project = "math-python-debug"
name = "math-python"
[model]
name = "Qwen/Qwen3-4B-Instruct-2507"
[orchestrator]
batch_size = 512
group_size = 16
[orchestrator.train.sampling]
max_completion_tokens = 512
[[orchestrator.train.env]]
id = "math-python"
args = { sandbox_client_max_workers = 128, sandbox_timeout_minutes = 10, sandbox_memory_gb = 1, sandbox_disk_size_gb = 1, pip_install_packages = "numpy sympy" }
[trainer] # Default trainer config
[inference]
api_server_count = 4
[inference.model]
tool_call_parser = "hermes"
max_model_len = 4096
+3 -1
View File
@@ -34,7 +34,9 @@ oversampling_factor = 2.0
max_completion_tokens = 512
[[orchestrator.train.env]]
id = "wiki-search"
name = "wiki-search"
taskset = { id = "wiki-search-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference.model]
tool_call_parser = "hermes"
+4 -4
View File
@@ -1,6 +1,5 @@
# Wordle (classic v0 TextArena env) on 2 GPUs (1 trainer + 1 inference), run via the
# legacy bridge. The Wordle-SFT model plays a full ~6-turn game per rollout; the bridge
# serves each multi-turn rollout to the orchestrator as a vf.Trace.
# Wordle on 2 GPUs (1 trainer + 1 inference). The Wordle-SFT model plays a
# full ~6-turn game per rollout.
max_steps = 200
seq_len = 8192
@@ -23,8 +22,9 @@ batch_size = 128
group_size = 8
[[orchestrator.train.env]]
id = "wordle"
name = "wordle"
taskset = { id = "wordle-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 1024
+9 -7
View File
@@ -148,26 +148,28 @@ Training environments are an array of tables — set one per env, optionally wit
```toml
[[orchestrator.train.env]]
id = "math-env"
name = "gsm8k"
args = { dataset_name = "openai/gsm8k", dataset_subset = "main" }
taskset = { id = "gsm8k-v1", split = "train" }
harness = { id = "null", runtime = { type = "subprocess" } }
ratio = 3 # 75% of batches
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
ratio = 1 # default — 25% of batches
[[orchestrator.eval.env]]
id = "math-env"
name = "gsm8k-eval"
args = { dataset_name = "openai/gsm8k", dataset_subset = "main" }
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.
`args` is forwarded verbatim to the environment's `load_environment(**args)`.
Fields in `taskset` configure the V1 taskset. `harness` selects how its tasks are run.
The same `id` can appear multiple times across train and eval (or with different `args`) — useful for evaluating on a held-out split of the env you're training on, or comparing two configurations of the same env side by side. When `id` is reused, set a distinct `name` on each entry; `name` defaults to `id` and must be unique across all envs in the same group.
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
+7 -11
View File
@@ -1,19 +1,15 @@
# Alphabet Sort
In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to sort names alphabetically using LoRA. Unlike other examples, this task doesn't require SFT warmup as the base model already understands the conversation format. We proceed directly to multi-turn RL against the [`primeintellect/alphabet-sort`](https://app.primeintellect.ai/dashboard/environments/primeintellect/alphabet-sort) environment.
In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to sort names alphabetically using LoRA. Unlike other examples, this task doesn't require SFT warmup as the base model already understands the conversation format. We proceed directly to multi-turn RL against the `alphabet-sort-v1` taskset.
> This example runs on a single H100 GPU.
## Setup
Install the environment:
```bash
prime env install primeintellect/alphabet-sort
```
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
Verify installation:
```bash
uv run python -c "import alphabet_sort"
uv run python -c "import alphabet_sort_v1"
```
Start the tmux session:
@@ -42,12 +38,12 @@ uv run inference --enable-lora --model.name Qwen/Qwen3-4B-Instruct-2507
Evaluate the base model:
```bash
# In the `Trainer` pane
uv run vf-eval alphabet-sort \
uv run vf-eval alphabet-sort-v1 \
-m Qwen/Qwen3-4B-Instruct-2507 \
-b http://localhost:8000/v1 \
-n 20 \
--max-tokens 768 \
--env-args '{"min_turns": 3, "max_turns": 3, "min_names_per_turn": 1, "max_names_per_turn": 4, "similarity_power": 8, "power_per_turn": false}'
--env-args '{"min_turns": 3, "max_turns": 3, "min_names_per_turn": 1, "max_names_per_turn": 4, "task": {"similarity_power": 8, "power_per_turn": false}}'
```
We got an **average reward of ~0.26** across 20×3 rollouts. The model achieves **0% perfect attempts** (no rollouts score 1.0) and **0% perfect examples** (no examples have all 3 rollouts at 1.0). The model shows high variance and struggles on most examples, with the high similarity power (8) heavily penalizing even small errors, and the scores aren't different for most attempts.
@@ -118,12 +114,12 @@ uv run inference --enable-lora --model.name PrimeIntellect/Qwen3-4B-Instruct-Alp
```bash
# In the `Trainer` pane
uv run vf-eval alphabet-sort \
uv run vf-eval alphabet-sort-v1 \
-m PrimeIntellect/Qwen3-4B-Instruct-AlphabetSort-RL \
-b http://localhost:8000/v1 \
-n 20 \
--max-tokens 768 \
--env-args '{"min_turns": 3, "max_turns": 3, "min_names_per_turn": 1, "max_names_per_turn": 4, "similarity_power": 8, "power_per_turn": false}'
--env-args '{"min_turns": 3, "max_turns": 3, "min_names_per_turn": 1, "max_names_per_turn": 4, "task": {"similarity_power": 8, "power_per_turn": false}}'
```
Way better! Our model now gets an **average reward of ~0.81** with **73% perfect attempts** (44/60 rollouts score 1.0) and **65% perfect examples** (13/20 examples have all 3 rollouts at 1.0).
+3 -3
View File
@@ -32,8 +32,8 @@ group_size = 8
max_completion_tokens = 768
[[orchestrator.train.env]]
id = "alphabet-sort"
name = "alphabet-sort"
args = { min_turns = 3, max_turns = 5, power_per_turn = false }
taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
harness = { id = "null", runtime = { type = "subprocess" } }
[inference] # Default inference config
[inference] # Default inference config
+7 -7
View File
@@ -1,15 +1,15 @@
# Reverse Text
We demonstrate how to train `Qwen3-0.6B` to reverse a small chunk of text. We will use a SFT warmup to learn the skill of text reversal on longer documents and then a quick RL run to reverse smaller chunks of text in the [`reverse-text`](https://app.primeintellect.ai/dashboard/environments/primeintellect/reverse-text) environment. We use a similar setup in our CI at the moment and for development.
We demonstrate how to train `Qwen3-0.6B` to reverse a small chunk of text. We will use a SFT warmup to learn the skill of text reversal on longer documents and then a quick RL run on the `reverse-text-v1` taskset. We use a similar setup in our CI and for development.
> The commands in this example were designed to be run on 2 GPUs (one trainer and one inference GPU). It is possible to run on less or more GPUs using different deployment strategies. If you run on a different setup, you may need to adjust the start commands.
## Setup
We keep the `reverse-text` in our lock file because we use it frequently in our CI and for development. If you have synced the environment, you should already have it installed. To verify, run
The `reverse-text-v1` taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
```bash
uv run python -c "import reverse_text"
uv run python -c "import reverse_text_v1"
```
First, let's start a `tmux` session which we will use throughout the experiment.
@@ -27,7 +27,7 @@ uv run inference --model.name Qwen/Qwen3-0.6B
```bash
# Run this in the `Trainer` pane
uv run vf-eval reverse-text -m Qwen/Qwen3-0.6B -b http://localhost:8000/v1 -n 20 --max-tokens 1024
uv run vf-eval reverse-text-v1 -m Qwen/Qwen3-0.6B -b http://localhost:8000/v1 -n 20 --max-tokens 1024
```
This is of course just a quick vibe check and no full-fledged evaluation, but we can see that the model struggles with this task. In this specific instance, we got an **average reward of ~0.05** across the 20x3 rollouts. Let's do some training!
@@ -102,7 +102,7 @@ uv run inference --model.name PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL
```bash
# Run this in the `Trainer` pane
uv run vf-eval reverse-text -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL -b http://localhost:8000/v1 -n 20 --max-tokens 1024
uv run vf-eval reverse-text-v1 -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL -b http://localhost:8000/v1 -n 20 --max-tokens 1024
```
Way better! Now we get an **average reward of ~0.8**.
@@ -215,7 +215,7 @@ kubectl exec -it my-exp-inference-0 -- bash
uv run inference --model.name /data/outputs/weights/step_20
# Back in trainer pod, run evaluation
uv run vf-eval reverse-text \
uv run vf-eval reverse-text-v1 \
-m /data/outputs/weights/step_20 \
-b $INFERENCE_URL \
-n 20 --max-tokens 1024
@@ -236,4 +236,4 @@ kubectl delete pvc prime-rl-shared-data
- Kubernetes services for component communication
- Auto-start capability with proper networking configured
See the [K8s deployment guide](../../k8s/README.md) for more details on scaling, distributed training, and advanced configurations.
See the [K8s deployment guide](../../k8s/README.md) for more details on scaling, distributed training, and advanced configurations.
+3 -1
View File
@@ -16,7 +16,9 @@ group_size = 16
max_completion_tokens = 128
[[orchestrator.train.env]]
id = "reverse-text"
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+23 -48
View File
@@ -4,8 +4,8 @@ In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to answer
- **Single-file configuration**: All training settings (trainer, orchestrator, and inference) are specified in a single `rl.toml` file
- **LoRA training**: Efficient fine-tuning using LoRA (Low-Rank Adaptation) on attention and MLP layers
- **Multi-turn tool use**: The model learns to use tools across multiple turns via `ToolEnv` via native function calling
- **Locally-hosted storage**: Uses ChromaDB for vector search and OpenAI embeddings for retrieval
- **Multi-turn tool use**: The model learns to use V1 tools across multiple turns through native function calling
- **Locally-hosted storage**: Uses ChromaDB and its local embedding model for retrieval
- **LLM judges**: Uses an LLM judge to evaluate answer quality alongside tool execution metrics
- **Online difficulty buffer**: Uses difficulty-based sampling to ensure rollouts have strictly non-zero advantages
@@ -13,19 +13,13 @@ In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to answer
## Setup
Install the environment:
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
```bash
prime env install primeintellect/wiki-search
uv run python -c "import wiki_search_v1"
```
Verify installation:
```bash
uv run python -c "import wiki_search"
```
Set up your OpenAI API key for the judge and embedding models:
Set up the credentials for the configured reference judge:
```bash
export OPENAI_API_KEY=your_api_key_here
@@ -46,19 +40,16 @@ The wiki-search environment requires the model to answer trivia questions by:
3. **Reading** specific sections to extract answers
4. **Answering** the question correctly and coherently
The environment provides three tools:
- `search_pages(query)`: Performs embedding-based search over Wikipedia page titles, returning the top 10 relevant pages
- `view_sections(page_id)`: Lists all sections available in a Wikipedia page
- `read_section(section_id)`: Retrieves the content of a specific section
The taskset provides three tools:
- `wiki_search_pages(query)`: Performs embedding-based search over Wikipedia page titles, returning the top 10 relevant pages
- `wiki_view_sections(page_id)`: Lists all sections available in a Wikipedia page
- `wiki_read_section(section_id)`: Retrieves the content of a specific section
The corpus is indexed in ChromaDB using OpenAI embeddings (`text-embedding-3-small` by default). On first run, the environment automatically builds the index from the `willcb/rare-wiki-pages` dataset, storing it locally in `.chroma_db`.
The corpus is indexed in ChromaDB using its local embedding model. On first run, the taskset builds the index from `willcb/rare-wiki-pages` and stores it under `~/.cache/wiki_search` by default.
## Scoring
The environment uses a composite rubric combining:
1. **ToolRubric**: Evaluates tool execution success and format adherence
2. **JudgeRubric**: An LLM judge (default: `gpt-4.1-mini`) evaluates whether the final answer is both correct and coherent
The taskset uses a reference-answer judge (default: `openai/gpt-5.4-nano`) to evaluate whether the final answer is both correct and coherent.
The judge compares the model's response against the ground truth answer and returns a binary score (1.0 for correct and coherent, 0.0 otherwise).
@@ -70,7 +61,7 @@ Key configuration highlights:
- **LoRA training**: Rank 8, alpha 32 for efficient fine-tuning
- **Tool calling**: Uses Hermes parser for automatic tool selection with Qwen3-4B-Instruct-2507
- **Multi-turn**: Up to 10 turns per episode (configurable via environment args)
- **Multi-turn**: Tool calls and results are carried across turns by the V1 harness
- **Online difficulty buffer**: Uses difficulty-based sampling with 2x oversampling
## Baseline Evaluation
@@ -86,12 +77,11 @@ Evaluate the base model:
```bash
# In the `Trainer` pane
uv run vf-eval wiki-search \
uv run vf-eval wiki-search-v1 \
-m Qwen/Qwen3-4B-Instruct-2507 \
-b http://localhost:8000/v1 \
-n 20 \
--max-tokens 512 \
--env-args '{"judge_model": "gpt-4.1-mini", "judge_base_url": "https://api.openai.com/v1", "judge_api_key_var": "OPENAI_API_KEY", "embed_model": "text-embedding-3-small", "embed_base_url": "https://api.openai.com/v1", "embed_api_key_var": "OPENAI_API_KEY"}'
--max-tokens 512
```
## RL Training
@@ -127,42 +117,27 @@ uv run inference --enable-lora --model.name <user>/Qwen3-4B-Instruct-WikiSearch-
```bash
# In the `Trainer` pane
uv run vf-eval wiki-search \
uv run vf-eval wiki-search-v1 \
-m <user>/Qwen3-4B-Instruct-WikiSearch-RL \
-b http://localhost:8000/v1 \
-n 20 \
--max-tokens 512 \
--env-args '{"judge_model": "gpt-4.1-mini", "judge_base_url": "https://api.openai.com/v1", "judge_api_key_var": "OPENAI_API_KEY", "embed_model": "text-embedding-3-small", "embed_base_url": "https://api.openai.com/v1", "embed_api_key_var": "OPENAI_API_KEY"}'
--max-tokens 512
```
## Environment Arguments
## Taskset Configuration
The wiki-search environment supports several configuration options:
| Argument | Type | Default | Description |
| --- | ---- | ------- | ----------- |
| `max_turns` | int | `10` | Maximum number of tool-use turns per episode |
| `judge_model` | str | `"gpt-4.1-mini"` | Judge model name |
| `judge_base_url` | str | `"https://api.openai.com/v1"` | Judge provider base URL |
| `judge_api_key_var` | str | `"OPENAI_API_KEY"` | Environment variable for judge API key |
| `embed_model` | str | `"text-embedding-3-small"` | Embedding model name |
| `embed_base_url` | str | `"https://api.openai.com/v1"` | Embedding provider base URL |
| `embed_api_key_var` | str | `"OPENAI_API_KEY"` | Environment variable for embedding API key |
| `corpus_dataset` | str | `"willcb/rare-wiki-pages"` | HuggingFace dataset ID containing Wikipedia pages |
| `corpus_split` | str | `"train"` | Dataset split to load |
| `chroma_db_dir` | str | `".chroma_db"` | Path to ChromaDB index directory |
You can pass these via the `--env-args` flag in `vf-eval` or configure them in your `rl.toml`:
The V1 taskset fixes the question bank and searchable corpus. You can replace its reference judge in `rl.toml`:
```toml
[[orchestrator.train.env]]
id = "primeintellect/wiki-search"
args = { max_turns = 5, judge_model = "gpt-4.1" }
name = "wiki-search"
taskset = { id = "wiki-search-v1", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
harness = { id = "null", runtime = { type = "subprocess" } }
```
## Notes
- The first run will build the ChromaDB index, which may take a minute or two
- Ensure `OPENAI_API_KEY` is set in your environment for both judge and embedding calls
- The ChromaDB index is stored locally in `.chroma_db` and persists across runs
- Ensure the selected judge's API credentials are available in your environment
- The ChromaDB index persists under `~/.cache/wiki_search`; set `WIKI_SEARCH_CACHE` to move it
- Tool calling requires `enable_auto_tool_choice = true` and a compatible parser (Hermes is recommended)
+3 -1
View File
@@ -45,7 +45,9 @@ type = "zero_advantage"
enforce = true
[[orchestrator.train.env]]
id = "wiki-search"
name = "wiki-search"
taskset = { id = "wiki-search-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[ckpt] # Checkpoint at the end of training
+5 -11
View File
@@ -1,21 +1,15 @@
# Wordle
In this example, we demonstrate how to train `Qwen3-1.7B` to play Wordle. This will require a SFT warmup to learn the format of the environment and, finally, multi-turn RL against the [`wordle`](https://app.primeintellect.ai/dashboard/environments/will/wordle) environment to improve performance.
In this example, we demonstrate how to train `Qwen3-1.7B` to play Wordle. This will require a SFT warmup to learn the format and, finally, multi-turn RL against the `wordle-v1` taskset to improve performance.
> The commands in this example were designed to be run on 2 GPUs (one trainer and one inference GPU). It is possible to run on less or more GPUs using different deployment strategies. If you run on a different setup, you may need to adjust the start commands.
## Setup
First, let's install the environment using the `prime` (`uv tool install prime`)
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
```bash
prime env install will/wordle
```
Verify your installation by trying to import the environment.
```bash
uv run python -c "import wordle"
uv run python -c "import wordle_v1"
```
Start the pre-layouted `tmux` session which we will use to run all experiments and view logs conveniently
@@ -35,7 +29,7 @@ Then, use the `vf-eval` entrypoint to evaluate the model in the `wordle` environ
```bash
# Run this in the `Trainer` pane
uv run vf-eval wordle -m Qwen/Qwen3-1.7B -b http://localhost:8000/v1 -n 20 -t 1024
uv run vf-eval wordle-v1 -m Qwen/Qwen3-1.7B -b http://localhost:8000/v1 -n 20 -t 1024
```
We got an **average reward of ~0.2** across the 20x3 rollouts. From the summary, we can see that the most of the reward is coming from format and partial rewards. In fact, the model does not guess the correct word within any game, leading to a win rate of **0%**. Looking at some samples, it is evident repeatedly submitting guesses in the wrong format and is not able to revise its strategy from the environment feedback. Let's do some SFT warmup to get the model to learn the format of the environment.
@@ -111,7 +105,7 @@ uv run inference --model.name PrimeIntellect/Qwen3-1.7B-Wordle-RL
```bash
# Run this in the `Trainer` pane
uv run vf-eval wordle -m PrimeIntellect/Qwen3-1.7B-Wordle-RL -b http://localhost:8000/v1 -n 20 --max-tokens 1024
uv run vf-eval wordle-v1 -m PrimeIntellect/Qwen3-1.7B-Wordle-RL -b http://localhost:8000/v1 -n 20 --max-tokens 1024
```
Way better! Our model now wins **~60%** and gets an average reward of **~1.5**.
+2 -1
View File
@@ -19,8 +19,9 @@ batch_size = 1024
group_size = 16
[[orchestrator.train.env]]
id = "wordle"
name = "wordle"
taskset = { id = "wordle-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 1024
+5 -3
View File
@@ -41,11 +41,13 @@ Incompatible combinations (e.g. CP requires flash attention) must raise in a `mo
**Lists** — TOML uses array of tables; later config files replace lists wholesale, so overlays must include the full desired list:
```toml
[[orchestrator.env]]
id = "reverse-text"
[[orchestrator.train.env]]
name = "reverse-text"
taskset = { id = "reverse-text-v1" }
harness = { id = "null", runtime = { type = "subprocess" } }
```
CLI: `--env.0.id reverse-text --env.1.id math-env`.
CLI: `--orchestrator.train.env.0.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.