Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
91d4b92597 | ||
|
|
82acb12ed7 | ||
|
|
124f9694a6 | ||
|
|
4308fe3aba | ||
|
|
da53d4c064 | ||
|
|
efe8e7fda8 | ||
|
|
bb23623d6e | ||
|
|
03f12efbaf | ||
|
|
f2ead102d1 | ||
|
|
c698bdeb2a | ||
|
|
6e33f3f82f | ||
|
|
c282262e6e | ||
|
|
289562d2ec |
@@ -174,7 +174,7 @@ jobs:
|
||||
run: |
|
||||
if [ -f .gitmodules ]; then
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/pydantic-config deps/verifiers deps/renderers deps/research-environments
|
||||
git submodule update --init --recursive -- deps/pydantic-config deps/verifiers deps/renderers deps/prime-envs
|
||||
fi
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
with:
|
||||
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
- name: Install dependencies
|
||||
@@ -84,9 +84,6 @@ jobs:
|
||||
- test: reverse_text_moe
|
||||
runner: vm
|
||||
pytest_args: "tests/integration/test_reverse_text_moe.py"
|
||||
- test: reverse_text_multi_run
|
||||
runner: 4xa6000
|
||||
pytest_args: "tests/integration/test_reverse_text_multi_run.py"
|
||||
- test: benchmark_regression
|
||||
runner: 4xa6000
|
||||
pytest_args: "tests/integration/test_benchmark_regression.py"
|
||||
@@ -103,7 +100,7 @@ jobs:
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
- name: Install dependencies
|
||||
|
||||
@@ -79,7 +79,7 @@ jobs:
|
||||
- name: Init public submodules
|
||||
run: |
|
||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
git submodule update --init --recursive -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
with:
|
||||
|
||||
+3
-3
@@ -4,9 +4,9 @@
|
||||
[submodule "renderers"]
|
||||
path = deps/renderers
|
||||
url = git@github.com:PrimeIntellect-ai/renderers.git
|
||||
[submodule "research-environments"]
|
||||
path = deps/research-environments
|
||||
url = git@github.com:PrimeIntellect-ai/research-environments.git
|
||||
[submodule "prime-envs"]
|
||||
path = deps/prime-envs
|
||||
url = git@github.com:PrimeIntellect-ai/prime-envs.git
|
||||
[submodule "pydantic-config"]
|
||||
path = deps/pydantic-config
|
||||
url = https://github.com/PrimeIntellect-ai/pydantic-config
|
||||
|
||||
@@ -95,7 +95,7 @@ cd prime-rl
|
||||
2. Initialize submodules
|
||||
|
||||
```bash
|
||||
git submodule update --init -- deps/verifiers deps/renderers deps/research-environments deps/pydantic-config
|
||||
git submodule update --init -- deps/verifiers deps/renderers deps/prime-envs deps/pydantic-config
|
||||
```
|
||||
|
||||
3. Install [uv](https://docs.astral.sh/uv/)
|
||||
@@ -218,7 +218,7 @@ Check out the [docs](docs) directory for in-depth guides on how to use prime-rl.
|
||||
- [**Training**](docs/training.md) - RL, SFT, evals, checkpointing, observability, rules of thumb
|
||||
- [**Scaling**](docs/scaling.md) - Single-GPU through multi-node, FSDP/EP/CP, SLURM, benchmarking
|
||||
- [**Algorithms**](docs/algorithms.md) - Async/off-policy training, the AIPO loss, advantage and filter plugins, trajectory merging
|
||||
- [**Advanced**](docs/advanced.md) - Custom modeling, multimodal training, LoRA, multi-tenant training
|
||||
- [**Advanced**](docs/advanced.md) - Custom modeling, multimodal training, LoRA
|
||||
- [**Development**](docs/development.md) - Test suite, pre-commit hooks, adding a new model
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -36,7 +36,7 @@ max_completion_tokens = 768
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ seq_len = 8192
|
||||
name = "hendrycks-math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
id = "math-env"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -44,7 +44,7 @@ max_completion_tokens = 512
|
||||
name = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
id = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -25,7 +25,7 @@ group_size = 8
|
||||
name = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
id = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -26,7 +26,7 @@ max_completion_tokens = 384
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 2
|
||||
max_turns = 2
|
||||
min_names_per_turn = 1
|
||||
|
||||
@@ -30,7 +30,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -29,7 +29,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -29,7 +29,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# Env server for the multi-run RL integration test: one per orchestrator, each bound at
|
||||
# its run's base port (the test passes --serve.address).
|
||||
[env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[env.agent.runtime]
|
||||
type = "subprocess"
|
||||
@@ -1,11 +0,0 @@
|
||||
# Inference config for multi-run RL integration test
|
||||
[vllm]
|
||||
model = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
max_model_len = 2048
|
||||
enable_lora = true
|
||||
max_lora_rank = 8
|
||||
max_loras = 4
|
||||
gpu_memory_utilization = 0.7
|
||||
|
||||
[weight_broadcast]
|
||||
type = "filesystem"
|
||||
@@ -1,39 +0,0 @@
|
||||
# Orchestrator config for multi-run RL integration test
|
||||
# model.lora.name and output_dir are set via CLI
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
seq_len = 2048
|
||||
max_steps = 20
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
|
||||
[optim]
|
||||
lr = 3e-5
|
||||
|
||||
[train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[train.source]]
|
||||
name = "reverse-text"
|
||||
|
||||
[train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[ckpt]
|
||||
interval = 10
|
||||
resume_step = -1
|
||||
|
||||
[weight_broadcast]
|
||||
type = "filesystem"
|
||||
|
||||
# PrimeIntellect Qwen3 fine-tune - select its renderer explicitly (the -SFT
|
||||
# suffix misses the MODEL_RENDERER_MAP exact match).
|
||||
[renderer]
|
||||
name = "prime-qwen3"
|
||||
@@ -1,21 +0,0 @@
|
||||
# Trainer config for multi-run RL integration test
|
||||
max_concurrent_runs = 2
|
||||
enable_token_export = true
|
||||
|
||||
[model]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
seq_len = 65536
|
||||
fused_lm_head_token_chunk_size = 8192
|
||||
optim_cpu_offload = false
|
||||
|
||||
[model.lora]
|
||||
rank = 8
|
||||
|
||||
[model.ac]
|
||||
freq = 1
|
||||
|
||||
[model.compile]
|
||||
fullgraph = false
|
||||
|
||||
[weight_broadcast]
|
||||
type = "filesystem"
|
||||
@@ -29,7 +29,7 @@ type = "opd"
|
||||
|
||||
[orchestrator.algo.teacher]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "prime-qwen3"
|
||||
@@ -41,7 +41,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -60,7 +60,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -30,7 +30,7 @@ type = "sft"
|
||||
# sft's teacher IS the model it samples from.
|
||||
[orchestrator.algo.sampling.source]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
|
||||
# The student's renderer tokenizes the teacher's messages into the student's
|
||||
# token space (backfill). Use `prime-qwen3` — it matches this PrimeIntellect
|
||||
@@ -47,7 +47,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -66,7 +66,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -27,7 +27,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -26,7 +26,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -22,7 +22,7 @@ group_size = 16
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ seq_len = 8192
|
||||
name = "hendrycks-math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
id = "math-env"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
@@ -40,7 +40,7 @@ name = "aime2024"
|
||||
group_size = 32
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime24-v1"
|
||||
id = "aime24"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -22,7 +22,7 @@ group_size = 16
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -27,7 +27,7 @@ enforce = true
|
||||
name = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
id = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -22,7 +22,7 @@ group_size = 16
|
||||
name = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
id = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -24,7 +24,7 @@ max_completion_tokens = 64
|
||||
name = "color-codeword"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "color-codeword-v1"
|
||||
id = "color-codeword"
|
||||
images_per_turn = 1
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
|
||||
@@ -28,7 +28,7 @@ alpha = 0.1
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -44,7 +44,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -25,7 +25,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -44,7 +44,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -35,7 +35,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text-grpo"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -47,7 +47,7 @@ type = "subprocess"
|
||||
name = "reverse-text-opd"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -60,7 +60,7 @@ type = "opd"
|
||||
|
||||
[orchestrator.train.source.algo.teacher]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 5
|
||||
@@ -73,7 +73,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -24,7 +24,7 @@ type = "opd"
|
||||
|
||||
[orchestrator.algo.teacher]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
|
||||
# Teacher rolls out over plain chat-completions (no tokens); the renderer backfills them.
|
||||
[orchestrator.renderer]
|
||||
@@ -37,7 +37,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -56,7 +56,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -24,7 +24,7 @@ type = "opd"
|
||||
|
||||
[orchestrator.algo.teacher]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
|
||||
# Teacher rolls out over plain chat-completions (no tokens); the renderer backfills them.
|
||||
[orchestrator.renderer]
|
||||
@@ -37,7 +37,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -56,7 +56,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -25,7 +25,7 @@ max_completion_tokens = 512
|
||||
name = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
id = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.player0.harness]
|
||||
id = "null"
|
||||
@@ -50,7 +50,7 @@ max_completion_tokens = 512
|
||||
name = "kuhn-poker"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
id = "kuhn-poker"
|
||||
|
||||
[orchestrator.eval.source.env.player0.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -33,7 +33,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -52,7 +52,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -25,7 +25,7 @@ type = "sft"
|
||||
# sft's teacher IS the model it samples from.
|
||||
[orchestrator.algo.sampling.source]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
|
||||
# The student's renderer tokenizes the teacher's messages into the student's
|
||||
# token space (backfill). Use `prime-qwen3` — it matches this PrimeIntellect
|
||||
@@ -42,7 +42,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -61,7 +61,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -25,7 +25,7 @@ type = "sft"
|
||||
# sft's teacher IS the model it samples from.
|
||||
[orchestrator.algo.sampling.source]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
|
||||
# The student's renderer tokenizes the teacher's messages into the student's
|
||||
# token space (backfill). Use `prime-qwen3` — it matches this PrimeIntellect
|
||||
@@ -42,7 +42,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -61,7 +61,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -21,7 +21,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text-a"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -33,7 +33,7 @@ type = "subprocess"
|
||||
name = "reverse-text-b"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -52,7 +52,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
+1
Submodule deps/prime-envs added at b30aad3637
Vendored
+1
-1
Submodule deps/renderers updated: 2a7e77eb14...2846a3dcd2
Vendored
-1
Submodule deps/research-environments deleted from b10db7640b
Vendored
+1
-1
Submodule deps/verifiers updated: 29e3a0f7a3...42a6c95de7
+1
-8
@@ -1,6 +1,6 @@
|
||||
# Advanced
|
||||
|
||||
This page covers the specialized features layered on top of the core training stack: our custom model implementations (with EP for MoE families and CP for long-context training), multimodal training, LoRA training, multi-tenant training, and disaggregated prefill/decode inference. For developer-side workflows (adding new model architectures, debugging modeling code at small scale), see [Development](development.md).
|
||||
This page covers the specialized features layered on top of the core training stack: our custom model implementations (with EP for MoE families and CP for long-context training), multimodal training, LoRA training, and disaggregated prefill/decode inference. For developer-side workflows (adding new model architectures, debugging modeling code at small scale), see [Development](development.md).
|
||||
|
||||
## Table of Contents
|
||||
|
||||
@@ -11,7 +11,6 @@ This page covers the specialized features layered on top of the core training st
|
||||
- [Enabling VLM Mode](#enabling-vlm-mode)
|
||||
- [Limitations](#limitations)
|
||||
- [LoRA Training](#lora-training)
|
||||
- [Multi-Tenant Training](#multi-tenant-training)
|
||||
- [Disaggregated Prefill/Decode Inference](#disaggregated-prefilldecode-inference)
|
||||
|
||||
## Custom Modeling
|
||||
@@ -123,12 +122,6 @@ LoRA is supported across SFT and RL. For RL, NCCL weight broadcast is **not** su
|
||||
save_adapter_separately = true
|
||||
```
|
||||
|
||||
LoRA pairs naturally with [multi-tenant training](#multi-tenant-training) — each tenant gets its own adapter and the backbone is shared across all of them in trainer memory.
|
||||
|
||||
## Multi-Tenant Training
|
||||
|
||||
Multi-tenant training lets a single trainer + inference deployment serve many concurrent LoRA "tenants" — each a fully isolated run with its own orchestrator, LoRA adapter, optimizer, scheduler, checkpoints, and progress tracking — sharing the same backbone weights and the same vLLM server. This is the topology behind hosted training on the [Prime Intellect platform (Lab)](https://app.primeintellect.ai). The trainer-side implementation is the `MultiRunManager` singleton, enabled by setting `trainer.max_concurrent_runs > 1`. For the full API surface, see [`src/prime_rl/trainer/runs.py`](https://github.com/PrimeIntellect-ai/prime-rl/blob/main/src/prime_rl/trainer/runs.py).
|
||||
|
||||
## Disaggregated Prefill/Decode Inference
|
||||
|
||||
For large MoE serving, splitting prefill and decode onto separate vLLM groups can substantially improve throughput. Pick the prefill:decode ratio based on workload shape:
|
||||
|
||||
+9
-9
@@ -35,7 +35,7 @@ A training algorithm in `prime-rl` is configured under `[orchestrator.algo]`, wh
|
||||
1. **Sampling** (`algo.sampling`) — how train rollouts are produced: which model generates them. `source` is a [model reference](#model-references): `"policy"` (the live policy, the default) or an inline frozen hosted model. Group sizing stays on the env config (`group_size`).
|
||||
2. **The per-token training signal** — credit assignment and loss routing, fused; the algorithm's own parameters sit directly on `algo`. One mapping from a finalized rollout to per-token *(loss component, weight)* pairs — the credit a token gets and the loss that consumes it are two coordinates of the same output. Group-relative algorithms compute credit on the orchestrator and ship per-token advantage streams; reference-KL algorithms query a reference model at batch-ship time (bounded concurrency) and ship its prefill logprobs for the trainer to evaluate against the live policy. The `type` determines which loss component consumes the action tokens (`rl` / `ce` / `ref_kl`) and what happens to env-provided observation tokens in multi-turn rollouts (masked out by default; `echo` trains on them with weighted CE).
|
||||
|
||||
The trainer is algorithm-blind: the loss is a sum of three components (rl, ce, ref_kl), each normalized by its own global token count; per-token streams ship on the wire (the `rl_weights` / `ce_weights` / `ref_kl_weights` component weights plus the `advantages` stream on each training sample) and the trainer just executes them. Adding an algorithm never touches the dispatcher, packer, or trainer hot path.
|
||||
The trainer is algorithm-blind: the loss is a sum of three components (rl, ce, ref_kl), each normalized by its own global token count; per-token streams ship on the wire (the `rl_weights` / `ce_weights` / `ref_kl_weights` component weights plus the `advantages` stream on each training sample) and the trainer just executes them. Adding an algorithm never touches the dispatcher, batch packing, or trainer hot path.
|
||||
|
||||
### Model References
|
||||
|
||||
@@ -47,7 +47,7 @@ type = "opd"
|
||||
|
||||
[orchestrator.algo.teacher] # opd's teacher: the frozen model it scores against
|
||||
name = "Qwen/Qwen3-32B"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
base_url = "http://localhost:8001/v1"
|
||||
```
|
||||
|
||||
Model *roles* are algorithm-local vocabulary — each algorithm names its reference on the field where the model is actually used, and there is no shared `teacher` slot. `opd` declares a `teacher` field (the frozen model whose reverse KL the policy distills toward); `sft`'s teacher *is* its `sampling.source` (the frozen model it imitates); `opsd` self-distills against the live policy and names no model at all. No role exists outside the algorithm that declares it: the dispatcher, sink, and trainer branch on liveness alone, never on what an algorithm calls a model.
|
||||
@@ -126,7 +126,7 @@ type = "grpo"
|
||||
name = "math" # inherits the top-level grpo
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-v1"
|
||||
id = "math"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -138,7 +138,7 @@ type = "subprocess"
|
||||
name = "terminal"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "terminal-v1"
|
||||
id = "terminal"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
@@ -354,7 +354,7 @@ The solver attempts for A should not be compared with the solver attempts for B:
|
||||
|
||||
For example, if three solvers receive rewards `[1, 1, 0]` on one proposed problem, their average is `2/3` and their advantages are `[1/3, 1/3, -2/3]`. Solver rewards from other proposed problems do not affect those values. The proposers are scored separately according to how useful their problems were for the solvers, then compared with the other proposers in the group.
|
||||
|
||||
Configure which roles are compared within a single proposed problem with `episode_agents`. For `proposer-solver-v1`, that role is `solver`:
|
||||
Configure which roles are compared within a single proposed problem with `episode_agents`. For `proposer-solver`, that role is `solver`:
|
||||
|
||||
```toml
|
||||
[orchestrator.algo]
|
||||
@@ -367,7 +367,7 @@ group_size = 4 # proposed problems per source task
|
||||
env.n = 4 # solver attempts per proposed problem
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "proposer-solver-v1"
|
||||
id = "proposer-solver"
|
||||
|
||||
[orchestrator.train.source.env.proposer.harness]
|
||||
id = "null"
|
||||
@@ -401,7 +401,7 @@ decay = 0.95
|
||||
name = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
id = "kuhn-poker"
|
||||
|
||||
[orchestrator.train.source.env.player0.harness]
|
||||
id = "null"
|
||||
@@ -416,7 +416,7 @@ id = "null"
|
||||
type = "subprocess"
|
||||
```
|
||||
|
||||
Both of `kuhn-poker-v1`'s agents late-bind to the run's own model — shared-policy self-play against a continuously improving opponent. Pin one agent to a frozen endpoint (`env.player1.model = ...`) for asymmetric play; its traces are marked untrainable by the env and never reach the advantage computation. A single-agent env under `rae` degrades to REINFORCE with an EMA baseline.
|
||||
Both of `kuhn-poker`'s agents late-bind to the run's own model — shared-policy self-play against a continuously improving opponent. Pin one agent to a frozen endpoint (`env.player1.model = ...`) for asymmetric play; its traces are marked untrainable by the env and never reach the advantage computation. A single-agent env under `rae` degrades to REINFORCE with an EMA baseline.
|
||||
|
||||
### Authoring an Algorithm
|
||||
|
||||
@@ -481,7 +481,7 @@ Filtered rollouts still appear in W&B distributions, just not in the trainer bat
|
||||
|
||||
## Multi-Turn Trajectories
|
||||
|
||||
Multi-turn rollouts (tool use, browser environments, long conversations) used to be stitched into a single fake "single-turn" sample, which silently corrupted the importance ratio when chat templates didn't roundtrip. Since [`verifiers` v0.1.8](https://github.com/PrimeIntellect-ai/verifiers/releases/tag/v0.1.8), `prime-rl` records each LLM request/response as an independent **trajectory step** and merges them at training time using best-effort interleaving — with [renderers](#renderers) as the mechanism that keeps the merge safe by construction.
|
||||
For multi-turn rollouts (tool use, browser environments, long conversations), `prime-rl` records each LLM request/response as an independent **trajectory step** and merges them at training time using best-effort interleaving — with [renderers](#renderers) as the mechanism that keeps the merge safe by construction.
|
||||
|
||||
### Extension Property
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ name = "gsm8k"
|
||||
ratio = 3 # 75% of batches
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "gsm8k-v1"
|
||||
id = "gsm8k"
|
||||
split = "train"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
@@ -169,7 +169,7 @@ name = "reverse-text"
|
||||
ratio = 1 # default — 25% of batches
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -181,7 +181,7 @@ type = "subprocess"
|
||||
name = "gsm8k-eval"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "gsm8k-v1"
|
||||
id = "gsm8k"
|
||||
split = "test"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ uv run pytest tests/integration/test_reverse_text.py -vvs # one specific scenar
|
||||
| Workflow | Trigger | What runs | Where |
|
||||
|---|---|---|---|
|
||||
| [`cpu_tests.yaml`](https://github.com/PrimeIntellect-ai/prime-rl/blob/main/.github/workflows/cpu_tests.yaml) | every PR + push to `main` | `pytest tests/unit -m "not gpu"`, plus a slim-wheel install check that `prime-rl-configs` imports cleanly without heavy deps (no torch / vllm / transformers / wandb / verifiers / datasets / liger / loguru in `sys.modules`) | `ubuntu-latest` |
|
||||
| [`gpu_tests.yaml`](https://github.com/PrimeIntellect-ai/prime-rl/blob/main/.github/workflows/gpu_tests.yaml) | every non-draft PR + push to `main` | `pytest tests/unit -m gpu`, plus a matrix of named integration scenarios (`reverse_text`, `reverse_text_sft`, `reverse_text_lora`, `reverse_text_moe`, `reverse_text_multi_run`, `reverse_text_rl_opd`, `reverse_text_rl_sft`, `reverse_text_sft_lora`, `alphabet_sort`, `benchmark_regression`) | self-hosted GPU runners (`vm`, `4xa6000`) |
|
||||
| [`gpu_tests.yaml`](https://github.com/PrimeIntellect-ai/prime-rl/blob/main/.github/workflows/gpu_tests.yaml) | every non-draft PR + push to `main` | `pytest tests/unit -m gpu`, plus a matrix of named integration scenarios (`reverse_text`, `reverse_text_sft`, `reverse_text_lora`, `reverse_text_moe`, `reverse_text_rl_opd`, `reverse_text_rl_sft`, `reverse_text_sft_lora`, `alphabet_sort`, `benchmark_regression`) | self-hosted GPU runners (`vm`, `4xa6000`) |
|
||||
| [`nightly_tests.yaml`](https://github.com/PrimeIntellect-ai/prime-rl/blob/main/.github/workflows/nightly_tests.yaml) | 03:00 PST daily + manual `workflow_dispatch` (single-file filter optional) | every file in `tests/nightly/`, one matrix job per file | `research-cluster` |
|
||||
|
||||
The GPU + Nightly workflows skip drafts — open the PR as **Draft** until you're ready to consume CI compute, then mark it ready for review to trigger the GPU matrix.
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ A `prime-rl` RL run is three cooperating processes:
|
||||
|
||||
- **Inference** — vLLM-backed server (or fleet) holding the current policy. The orchestrator drives rollouts through the token-in `/inference/v1/generate` route via the [`renderers`](https://github.com/PrimeIntellect-ai/renderers) package (OpenAI-compatible chat/completions routes are also exposed for external clients). We are trying to stay up-to-date with the latest vLLM features, you can read more about the supported features and deployment options in the dedicated [inference documentation](inference.md).
|
||||
- **Orchestrator** — Lightweight CPU process that owns the data plane across many [`verifiers`](https://github.com/PrimeIntellect-ai/verifiers) training and eval environments. Each env runs in an isolated subprocess with a variable-size pool of env workers for scalability. The orchestrator drives multi-turn rollouts against the inference fleet (tool use, browsers, sandboxes, long horizons) without re-tokenizing across turns, computes advantages, packs the rollouts into training batches, and relays new weights from trainer to inference.
|
||||
- **Trainer** — FSDP2 process group that consumes packed rollouts and steps the optimizer. We ship optimized custom modeling code for many MoE / dense / VLM families that unlocks advanced trainer parallelism — expert parallelism (EP, with DeepEP kernels) and context parallelism (CP) for long-sequence training — plus selective activation checkpointing, FP8 training on Hopper+, LoRA, and multi-tenant training (many concurrent LoRA tenants sharing one trainer + inference deployment). You can read more in the dedicated [training documentation](training.md).
|
||||
- **Trainer** — FSDP2 process group that consumes packed rollouts and steps the optimizer. We ship optimized custom modeling code for many MoE / dense / VLM families that unlocks advanced trainer parallelism — expert parallelism (EP, with DeepEP kernels) and context parallelism (CP) for long-sequence training — plus selective activation checkpointing, FP8 training on Hopper+, and LoRA. You can read more in the dedicated [training documentation](training.md).
|
||||
|
||||
The three processes communicate through configurable transports — by default the trainer↔orchestrator rollout link uses ZMQ, and weight broadcast uses NCCL for synchronous in-memory transfer (falling back to filesystem when LoRA is enabled or no inference server is configured). Swap the rollout link to the local filesystem (`rollout_transport.type = "filesystem"`) if you want rollouts persisted to disk. See [Scaling](scaling.md) for the deployment options.
|
||||
|
||||
@@ -20,7 +20,7 @@ The three processes communicate through configurable transports — by default t
|
||||
curl -sSL https://raw.githubusercontent.com/PrimeIntellect-ai/prime-rl/main/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
The script clones the repo, initializes the [`verifiers`](https://github.com/PrimeIntellect-ai/verifiers) / [`renderers`](https://github.com/PrimeIntellect-ai/renderers) / [`research-environments`](https://github.com/PrimeIntellect-ai/research-environments) submodules, installs `uv`, and runs `uv sync --all-extras`. For manual setup, or troubleshooting, see the [README](https://github.com/PrimeIntellect-ai/prime-rl#setup).
|
||||
The script clones the repo, initializes the [`verifiers`](https://github.com/PrimeIntellect-ai/verifiers) / [`renderers`](https://github.com/PrimeIntellect-ai/renderers) / [`prime-envs`](https://github.com/PrimeIntellect-ai/prime-envs) submodules, installs `uv`, and runs `uv sync --all-extras`. For manual setup, or troubleshooting, see the [README](https://github.com/PrimeIntellect-ai/prime-rl#setup).
|
||||
|
||||
You need at least one NVIDIA GPU (RTX 3090/4090/5090, A100, H100, H200, or B200). Single-GPU runs are supported for debugging; production RL is typically 1× inference node + 1+ trainer nodes.
|
||||
|
||||
@@ -41,5 +41,5 @@ The `rl` entrypoint reads `examples/basic/reverse-text/rl.toml`, splits it into
|
||||
- **[Inference](inference.md)** — vLLM-backed server (or fleet) holding the current policy.
|
||||
- **[Scaling](scaling.md)** — Single-GPU through multi-node clusters via FSDP / EP / CP and SLURM.
|
||||
- **[Algorithms](algorithms.md)** — Async semantics, loss / advantage / filter plugins, trajectory merging.
|
||||
- **[Advanced](advanced.md)** — Custom modeling, multimodal, LoRA, multi-tenant, P/D inference.
|
||||
- **[Advanced](advanced.md)** — Custom modeling, multimodal, LoRA, P/D inference.
|
||||
- **[Development](development.md)** — Test suite, pre-commit hooks, adding a new model.
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ Offloading optimizer states to CPU is enabled by default (`optim_cpu_offload = t
|
||||
optim_cpu_offload = true # already the default
|
||||
```
|
||||
|
||||
Mutually exclusive with `fsdp_cpu_offload`. Also incompatible with `trainer.max_concurrent_runs > 1` (multi-tenant training) — set `optim_cpu_offload = false` for multi-run. Muon doesn't support `fsdp_cpu_offload` but does support `optim_cpu_offload`.
|
||||
Mutually exclusive with `fsdp_cpu_offload`. Muon doesn't support `fsdp_cpu_offload` but does support `optim_cpu_offload`.
|
||||
|
||||
### LM Head Chunking
|
||||
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ The RL entrypoint supports several training algorithms, switched via `[orchestra
|
||||
|---|---|---|
|
||||
| `grpo` (default) | None | Standard group-relative RL |
|
||||
| `max_rl` | None | [MaxRL](https://arxiv.org/abs/2602.02710): GRPO with mean-normalized advantages (maximum-likelihood RL) |
|
||||
| `rae` | None | [SPIRAL](https://arxiv.org/abs/2506.24119)'s role-conditioned advantage estimation: reward minus a per-agent EMA baseline, for multi-agent self-play envs (e.g. `kuhn-poker-v1`) |
|
||||
| `rae` | None | [SPIRAL](https://arxiv.org/abs/2506.24119)'s role-conditioned advantage estimation: reward minus a per-agent EMA baseline, for multi-agent self-play envs (e.g. `kuhn-poker`) |
|
||||
| `hierarchical_grpo` | None | GRPO for proposer-solver envs: compare solvers only with attempts on the same proposed problem, and compare proposers with the other proposals in the group |
|
||||
| `opd` | Required, must be vLLM (needs `prompt_logprobs`) | [On-policy distillation](https://thinkingmachines.ai/blog/on-policy-distillation/): the policy generates rollouts, the trainer minimizes per-token reverse KL to a reference model |
|
||||
| `sft` | Required, any OpenAI-compatible endpoint | Hard-distill: a frozen model generates rollouts, the policy trains on its tokens |
|
||||
|
||||
@@ -109,7 +109,7 @@ idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "openseeker-v1"
|
||||
id = "openseeker"
|
||||
|
||||
[[orchestrator.train.source.env.taskset.task.judges]]
|
||||
id = "reference"
|
||||
@@ -122,7 +122,7 @@ choices = ["A", "B"]
|
||||
# [[orchestrator.train.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -142,7 +142,7 @@ idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "redsearcher-v1" # optional `difficulty` filter (easy/medium/hard)
|
||||
id = "redsearcher" # optional `difficulty` filter (easy/medium/hard)
|
||||
|
||||
[[orchestrator.train.source.env.taskset.task.judges]]
|
||||
id = "reference"
|
||||
@@ -155,7 +155,7 @@ choices = ["A", "B"]
|
||||
# [[orchestrator.train.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -184,7 +184,7 @@ labels = ["glm45air-search"]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "browsecomp-v1"
|
||||
id = "browsecomp"
|
||||
|
||||
[orchestrator.eval.source.env.taskset.task.judge]
|
||||
model = "Qwen/Qwen3-235B-A22B-Instruct-2507"
|
||||
@@ -193,7 +193,7 @@ model = "Qwen/Qwen3-235B-A22B-Instruct-2507"
|
||||
# [[orchestrator.eval.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# v1 RL: GLM-4.5-Air (100B MoE) on the v1 `scaleswe-v1` SWE taskset, rlm harness on a prime sandbox
|
||||
# v1 RL: GLM-4.5-Air (100B MoE) on the v1 `scaleswe` SWE taskset, rlm harness on a prime sandbox
|
||||
# runtime; eval on SWE-Bench Verified. Router replay is enabled (trainer.enable_router_replay replays
|
||||
# the routed-expert decisions returned by inference via enable_return_routed_experts) — GLM-4.5-Air is
|
||||
# a glm4_moe model, which supports routed_experts.
|
||||
@@ -101,7 +101,7 @@ thinking_retention = "all"
|
||||
name = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "scaleswe-v1"
|
||||
id = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
@@ -124,7 +124,7 @@ interval = 20
|
||||
name = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
|
||||
@@ -105,20 +105,20 @@ idle_timeout = "None"
|
||||
labels = ["glm45air-terminal"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "tmax-v1"
|
||||
id = "tmax"
|
||||
|
||||
# # Metric-only monitors (weight 0): rlm harness-mechanics + swe code-usage rubrics, judged by GLM-5.2.
|
||||
# [[orchestrator.train.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.train.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
# path = "deps/prime-envs/rubrics/swe.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -144,19 +144,19 @@ labels = ["glm45air-terminal"]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
# path = "deps/prime-envs/rubrics/swe.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
@@ -178,19 +178,19 @@ labels = ["glm45air-terminal"]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "terminal-bench-2-v1"
|
||||
id = "terminal-bench-2"
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# path = "deps/prime-envs/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
# path = "deps/prime-envs/rubrics/swe.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ clear_thinking = false
|
||||
name = "r2e"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
|
||||
@@ -79,7 +79,7 @@ interval = 20
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
@@ -52,7 +52,7 @@ name = "swe"
|
||||
ratio = 0.3
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
@@ -66,7 +66,7 @@ name = "deepdive"
|
||||
ratio = 0.2
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "deepdive-v1"
|
||||
id = "deepdive"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
@@ -82,7 +82,7 @@ name = "math"
|
||||
ratio = 0.3
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_math_v1"
|
||||
id = "i3_math"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -95,7 +95,7 @@ name = "logic"
|
||||
ratio = 0.2
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_logic_v1"
|
||||
id = "i3_logic"
|
||||
|
||||
[orchestrator.train.source.env.taskset.filter]
|
||||
max = 0.874
|
||||
@@ -111,7 +111,7 @@ name = "code"
|
||||
ratio = 0.2
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_code_v1"
|
||||
id = "i3_code"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -130,7 +130,7 @@ interval = 25
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
@@ -143,7 +143,7 @@ labels = ["intellect-3.1", "swe-bench-verified"]
|
||||
name = "aime2025"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime25-v1"
|
||||
id = "aime25"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -52,7 +52,7 @@ max_off_policy_steps = 16
|
||||
name = "swe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
@@ -68,7 +68,7 @@ interval = 25
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
@@ -85,7 +85,7 @@ truncate_history_thinking = false
|
||||
name = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "scaleswe-v1"
|
||||
id = "scaleswe"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
@@ -106,7 +106,7 @@ interval = 20
|
||||
name = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
|
||||
@@ -52,7 +52,7 @@ max_completion_tokens = 32768
|
||||
name = "math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_math_v1"
|
||||
id = "i3_math"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -67,7 +67,7 @@ interval = 25
|
||||
name = "aime2025"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime25-v1"
|
||||
id = "aime25"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -50,7 +50,7 @@ max_off_policy_steps = 16
|
||||
name = "swe"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
id = "r2e-gym"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
@@ -66,7 +66,7 @@ interval = 25
|
||||
name = "swe-bench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
id = "swebench-verified"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
@@ -38,7 +38,7 @@ max_off_policy_steps = 32
|
||||
[[orchestrator.train.source]]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "general-agent-v1"
|
||||
id = "general-agent"
|
||||
min_tier = 1
|
||||
|
||||
[orchestrator.train.source.env.taskset.task.tools]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 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 `alphabet-sort-v1` taskset.
|
||||
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` taskset.
|
||||
|
||||
> This example runs on a single H100 GPU.
|
||||
|
||||
@@ -9,7 +9,7 @@ In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to sort na
|
||||
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import alphabet_sort_v1"
|
||||
uv run python -c "import alphabet_sort"
|
||||
```
|
||||
|
||||
Start the tmux session:
|
||||
@@ -38,7 +38,7 @@ uv run inference --vllm.enable-lora --vllm.model Qwen/Qwen3-4B-Instruct-2507
|
||||
Evaluate the base model:
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval alphabet-sort-v1 --harness.id null \
|
||||
uv run eval alphabet-sort --harness.id null \
|
||||
-m Qwen/Qwen3-4B-Instruct-2507 \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
@@ -115,7 +115,7 @@ uv run inference --vllm.enable-lora --vllm.model PrimeIntellect/Qwen3-4B-Instruc
|
||||
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval alphabet-sort-v1 --harness.id null \
|
||||
uv run eval alphabet-sort --harness.id null \
|
||||
-m PrimeIntellect/Qwen3-4B-Instruct-AlphabetSort-RL \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
|
||||
@@ -35,7 +35,7 @@ max_completion_tokens = 768
|
||||
name = "alphabet-sort"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
id = "alphabet-sort"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ seq_len = 8192
|
||||
name = "hendrycks-math"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
id = "math-env"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
@@ -38,7 +38,7 @@ name = "aime2024"
|
||||
group_size = 32
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime24-v1"
|
||||
id = "aime24"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -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 on the `reverse-text-v1` taskset. We use a similar setup in our CI 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` 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
|
||||
|
||||
The `reverse-text-v1` taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
The `reverse-text` taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import reverse_text_v1"
|
||||
uv run python -c "import reverse_text"
|
||||
```
|
||||
|
||||
First, let's start a `tmux` session which we will use throughout the experiment.
|
||||
@@ -27,7 +27,7 @@ uv run inference --vllm.model Qwen/Qwen3-0.6B
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval reverse-text-v1 --harness.id null -m Qwen/Qwen3-0.6B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval reverse-text --harness.id null -m Qwen/Qwen3-0.6B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
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!
|
||||
@@ -100,7 +100,7 @@ uv run inference --vllm.model PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval reverse-text-v1 --harness.id null -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval reverse-text --harness.id null -m PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
Way better! Now we get an **average reward of ~0.8**.
|
||||
@@ -213,7 +213,7 @@ kubectl exec -it my-exp-inference-0 -- bash
|
||||
uv run inference --vllm.model /data/outputs/weights/step_20
|
||||
|
||||
# Back in trainer pod, run evaluation
|
||||
uv run eval reverse-text-v1 --harness.id null \
|
||||
uv run eval reverse-text --harness.id null \
|
||||
-m /data/outputs/weights/step_20 \
|
||||
--client.base-url $INFERENCE_URL \
|
||||
-n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
|
||||
@@ -19,7 +19,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -16,7 +16,7 @@ In this example, we demonstrate how to train `Qwen3-4B-Instruct-2507` to answer
|
||||
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import wiki_search_v1"
|
||||
uv run python -c "import wiki_search"
|
||||
```
|
||||
|
||||
Set up the credentials for the configured reference judge:
|
||||
@@ -77,7 +77,7 @@ Evaluate the base model:
|
||||
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval wiki-search-v1 --harness.id null \
|
||||
uv run eval wiki-search --harness.id null \
|
||||
-m Qwen/Qwen3-4B-Instruct-2507 \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
@@ -119,7 +119,7 @@ uv run inference --vllm.enable-lora --vllm.model <user>/Qwen3-4B-Instruct-WikiSe
|
||||
|
||||
```bash
|
||||
# In the `Trainer` pane
|
||||
uv run eval wiki-search-v1 --harness.id null \
|
||||
uv run eval wiki-search --harness.id null \
|
||||
-m <user>/Qwen3-4B-Instruct-WikiSearch-RL \
|
||||
--client.base-url http://localhost:8000/v1 \
|
||||
-n 20 \
|
||||
@@ -135,7 +135,7 @@ The V1 taskset fixes the question bank and searchable corpus. You can replace it
|
||||
```toml
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
taskset = { id = "wiki-search-v1", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
|
||||
taskset = { id = "wiki-search", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
|
||||
harness = { id = "null" }
|
||||
runtime = { type = "subprocess" }
|
||||
```
|
||||
|
||||
@@ -44,7 +44,7 @@ max_completion_tokens = 512
|
||||
name = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
id = "wiki-search"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 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 and, finally, multi-turn RL against the `wordle-v1` taskset 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` 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.
|
||||
|
||||
@@ -9,7 +9,7 @@ In this example, we demonstrate how to train `Qwen3-1.7B` to play Wordle. This w
|
||||
The taskset is included through the Verifiers workspace. After syncing the repository, verify it with:
|
||||
|
||||
```bash
|
||||
uv run python -c "import wordle_v1"
|
||||
uv run python -c "import wordle"
|
||||
```
|
||||
|
||||
Start the pre-layouted `tmux` session which we will use to run all experiments and view logs conveniently
|
||||
@@ -29,7 +29,7 @@ Then, use the `eval` entrypoint to evaluate the model in the `wordle` environmen
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval wordle-v1 --harness.id null -m Qwen/Qwen3-1.7B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval wordle --harness.id null -m Qwen/Qwen3-1.7B --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
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.
|
||||
@@ -103,7 +103,7 @@ uv run inference --vllm.model PrimeIntellect/Qwen3-1.7B-Wordle-RL
|
||||
|
||||
```bash
|
||||
# Run this in the `Trainer` pane
|
||||
uv run eval wordle-v1 --harness.id null -m PrimeIntellect/Qwen3-1.7B-Wordle-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
uv run eval wordle --harness.id null -m PrimeIntellect/Qwen3-1.7B-Wordle-RL --client.base-url http://localhost:8000/v1 -n 20 -r 3 --sampling.max-tokens 1024 --no-push
|
||||
```
|
||||
|
||||
Way better! Our model now wins **~60%** and gets an average reward of **~1.5**.
|
||||
|
||||
@@ -22,7 +22,7 @@ group_size = 16
|
||||
name = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
id = "wordle"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -11,7 +11,7 @@ image:
|
||||
orchestrator:
|
||||
enabled: true
|
||||
autoStart: true
|
||||
command: "uv run orchestrator @ /app/k8s/prime-rl/examples/reverse-text/orch.toml --output-dir /data/outputs/run_default --client.base-url $INFERENCE_URL ; sleep infinity"
|
||||
command: "uv run orchestrator @ /app/k8s/prime-rl/examples/reverse-text/orch.toml --output-dir /data/outputs --client.base-url $INFERENCE_URL ; sleep infinity"
|
||||
resources:
|
||||
requests:
|
||||
memory: "1Gi"
|
||||
|
||||
@@ -17,7 +17,7 @@ max_completion_tokens = 128
|
||||
name = "reverse-text"
|
||||
|
||||
[train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
@@ -59,9 +59,6 @@ spec:
|
||||
fieldPath: metadata.namespace
|
||||
- name: STATEFUL_REPLICAS
|
||||
value: "{{ .Values.orchestrator.replicas }}"
|
||||
- name: HEADLESS_SERVICE
|
||||
value: "{{ .Release.Name }}-orchestrator-headless.{{ .Values.namespace }}.svc.cluster.local"
|
||||
- name: INFERENCE_URL
|
||||
{{- $releaseName := .Release.Name }}
|
||||
{{- $namespace := .Values.namespace }}
|
||||
{{- $port := int .Values.inference.service.port }}
|
||||
@@ -71,6 +68,9 @@ spec:
|
||||
{{- $url := printf "http://%s-inference-%d.%s-inference-headless.%s.svc.cluster.local:%d/v1" $releaseName $i $releaseName $namespace $port }}
|
||||
{{- $urls = append $urls $url }}
|
||||
{{- end }}
|
||||
- name: INFERENCE_URL
|
||||
value: {{ first $urls | quote }}
|
||||
- name: ADMIN_INFERENCE_URLS
|
||||
value: {{ $urls | join "," | quote }}
|
||||
{{- with .Values.orchestrator.env }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
@@ -163,8 +163,6 @@ spec:
|
||||
fieldPath: metadata.namespace
|
||||
- name: STATEFUL_REPLICAS
|
||||
value: "{{ .Values.inference.replicas }}"
|
||||
- name: HEADLESS_SERVICE
|
||||
value: "{{ .Release.Name }}-inference-headless.{{ .Values.namespace }}.svc.cluster.local"
|
||||
{{- with .Values.inference.env }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
@@ -294,13 +292,10 @@ spec:
|
||||
fieldPath: metadata.namespace
|
||||
- name: STATEFUL_REPLICAS
|
||||
value: "{{ .Values.trainer.replicas }}"
|
||||
- name: HEADLESS_SERVICE
|
||||
value: "{{ .Release.Name }}-trainer-headless.{{ .Values.namespace }}.svc.cluster.local"
|
||||
{{- if .Values.trainer.pytorchCudaAllocConf }}
|
||||
- name: PYTORCH_CUDA_ALLOC_CONF
|
||||
value: {{ .Values.trainer.pytorchCudaAllocConf | quote }}
|
||||
{{- end }}
|
||||
- name: INFERENCE_URL
|
||||
{{- $releaseName := .Release.Name }}
|
||||
{{- $namespace := .Values.namespace }}
|
||||
{{- $port := int .Values.inference.service.port }}
|
||||
@@ -310,6 +305,9 @@ spec:
|
||||
{{- $url := printf "http://%s-inference-%d.%s-inference-headless.%s.svc.cluster.local:%d/v1" $releaseName $i $releaseName $namespace $port }}
|
||||
{{- $urls = append $urls $url }}
|
||||
{{- end }}
|
||||
- name: INFERENCE_URL
|
||||
value: {{ first $urls | quote }}
|
||||
- name: ADMIN_INFERENCE_URLS
|
||||
value: {{ $urls | join "," | quote }}
|
||||
{{- with .Values.trainer.env }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
|
||||
@@ -28,9 +28,12 @@ orchestrator:
|
||||
|
||||
# Auto-start configuration (set to false to use sleep infinity for debugging)
|
||||
autoStart: false
|
||||
# Example command - use $INFERENCE_URL directly (comma-separated list of all inference server URLs)
|
||||
command: "" # e.g., 'uv run orchestrator @ /app/k8s/prime-rl/examples/reverse-text/orch.toml --output-dir /data/outputs/run_default --client.base-url $INFERENCE_URL'
|
||||
# $INFERENCE_URL is auto-set to: 'http://<release>-inference-0...:8000/v1,http://<release>-inference-1...:8000/v1,...'
|
||||
# Example command - use $INFERENCE_URL directly (the first inference server URL)
|
||||
command: "" # e.g., 'uv run orchestrator @ /app/k8s/prime-rl/examples/reverse-text/orch.toml --output-dir /data/outputs --client.base-url $INFERENCE_URL'
|
||||
# $INFERENCE_URL is auto-set to 'http://<release>-inference-0...:8000/v1'. With more than one
|
||||
# inference replica, put a router in front and point --client.base-url at it; admin operations
|
||||
# (weight updates, health checks) fan out to every replica via
|
||||
# --client.admin-base-url $ADMIN_INFERENCE_URLS (comma-separated list of all replica URLs).
|
||||
|
||||
resources:
|
||||
requests:
|
||||
|
||||
@@ -58,7 +58,7 @@ class FrozenModelConfig(ClientConfig):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def require_explicit_endpoint(self):
|
||||
if "base_url" not in self.model_fields_set and not self.is_elastic:
|
||||
if "base_url" not in self.model_fields_set:
|
||||
raise ValueError(
|
||||
"a frozen model reference needs base_url — frozen models are externally "
|
||||
"hosted; prime-rl only ever hosts the trainable policy."
|
||||
@@ -246,7 +246,7 @@ class RAEAlgoConfig(BaseAlgoConfig):
|
||||
https://arxiv.org/abs/2506.24119): scalar advantage = reward minus a
|
||||
per-agent EMA baseline of that agent's own rewards, consumed by the ``rl``
|
||||
loss component. The advantage estimator for multi-agent self-play envs
|
||||
(``kuhn-poker-v1`` and friends): in a zero-sum game the group mean is ~0
|
||||
(``kuhn-poker`` and friends): in a zero-sum game the group mean is ~0
|
||||
whatever the policy does, so a group-relative baseline mixes the agents'
|
||||
opposite reward scales — a structural first-mover edge would read as
|
||||
permanent credit. Per-agent baselines measure each agent against its own
|
||||
@@ -274,16 +274,16 @@ class HierarchicalGRPOAlgoConfig(BaseAlgoConfig):
|
||||
|
||||
episode_agents: list[str] = Field(min_length=1)
|
||||
"""Roles compared within one proposed problem. Use ``["solver"]`` for
|
||||
``proposer-solver-v1``."""
|
||||
``proposer-solver``."""
|
||||
|
||||
def validate_env(self, env_config: vf.EnvConfig) -> None:
|
||||
"""Require the proposer-solver structure used by the comparisons."""
|
||||
try:
|
||||
from proposer_solver_v1 import ProposerSolverEnvConfig
|
||||
from proposer_solver import ProposerSolverEnvConfig
|
||||
except ImportError as e:
|
||||
raise ValueError(
|
||||
"algorithm 'hierarchical_grpo' requires a proposer-solver env, but the "
|
||||
"proposer-solver-v1 package is not installed (`uv sync --all-packages`)."
|
||||
"proposer-solver package is not installed (`uv sync --all-packages`)."
|
||||
) from e
|
||||
if not isinstance(env_config, ProposerSolverEnvConfig):
|
||||
raise ValueError(
|
||||
|
||||
@@ -8,9 +8,9 @@ from prime_rl.utils.config import BaseConfig
|
||||
|
||||
|
||||
class EnvServerConfig(BaseConfig):
|
||||
"""``uv run env-server``: what to serve (``[env]``, or ``[legacy]`` for a classic v0
|
||||
env) and how it's hosted (``[serve]``). The ``rl`` launcher writes one of these per
|
||||
train/eval source, with ``serve.address`` set to the source's derived address."""
|
||||
"""``uv run env-server``: what to serve (``[env]``) and how it's hosted (``[serve]``).
|
||||
The ``rl`` launcher writes one of these per train/eval source, with ``serve.address``
|
||||
set to the source's derived address."""
|
||||
|
||||
env: SerializeAsAny[vf.EnvConfig] = vf.SingleAgentEnvConfig()
|
||||
"""The environment — which env, its seed taskset, each agent, its knobs. Narrowed to the selected env's config class by the env id, else the taskset id."""
|
||||
@@ -18,9 +18,6 @@ class EnvServerConfig(BaseConfig):
|
||||
serve: vf.ServeConfig = vf.ServeConfig()
|
||||
"""How it's served: the worker pool, the bind address, each worker's episode bound."""
|
||||
|
||||
legacy: vf.LegacyEnvConfig = vf.LegacyEnvConfig()
|
||||
"""A classic (v0) environment to serve through the bridge instead of ``env``."""
|
||||
|
||||
log: LogConfig = LogConfig()
|
||||
|
||||
output_dir: Path = Path("outputs")
|
||||
@@ -32,35 +29,12 @@ class EnvServerConfig(BaseConfig):
|
||||
"""Narrow ``env`` to the selected env's config class."""
|
||||
return vf.resolve_env_field(data, vf.narrowed_env_annotation(cls))
|
||||
|
||||
@property
|
||||
def is_legacy(self) -> bool:
|
||||
"""Whether this serves the v0 bridge: a legacy id and no v1 taskset."""
|
||||
return self.legacy.id is not None and not self.env.taskset.id
|
||||
|
||||
@property
|
||||
def env_id(self) -> str:
|
||||
"""The served env's identifier: the v1 env's, else the v0 env id."""
|
||||
return self.env.env_id or self.legacy.id or ""
|
||||
return self.env.env_id or ""
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_env(self):
|
||||
# A v0 id next to any v1 env identity leaves one of the two going nowhere, and
|
||||
# which one depends on `is_legacy`: a taskset makes it False, so the v0 env never
|
||||
# loads; a bare `env.id` leaves it True, so the v0 env runs under the v1 name.
|
||||
if self.legacy.id is not None and self.env.env_id:
|
||||
if self.env.taskset.id:
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with "
|
||||
f"the v1 taskset {self.env.taskset.id!r}. Pairing a reusable env with a taskset "
|
||||
f"is env.id = {self.legacy.id!r}; to run the v0 env instead, drop the taskset."
|
||||
)
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with the "
|
||||
f"v1 env.id {self.env.id!r}: the v0 env is what would run, stamped with the v1 "
|
||||
"env's name. Keep whichever one you meant to run."
|
||||
)
|
||||
if not self.env_id:
|
||||
raise ValueError(
|
||||
'no env configured — set env = { taskset = { id = "<id>" } } (v1) or legacy = { id = "<id>" } (v0)'
|
||||
)
|
||||
raise ValueError('no env configured — set env = { taskset = { id = "<id>" } }')
|
||||
return self
|
||||
|
||||
@@ -25,11 +25,6 @@ from prime_rl.configs.trainer import TokenizerConfig
|
||||
from prime_rl.utils.config import BaseConfig
|
||||
|
||||
|
||||
class OptimizerConfig(BaseConfig):
|
||||
lr: float = Field(1e-4, ge=0)
|
||||
"""Learning rate for this run (per-run override for multi-run training)."""
|
||||
|
||||
|
||||
class LoRAConfig(BaseConfig):
|
||||
name: str | None = None
|
||||
"""LoRA adapter name. If None, auto-generated from rank and alpha."""
|
||||
@@ -124,8 +119,7 @@ class EvalSamplingConfig(BaseConfig):
|
||||
|
||||
class EnvConfig(BaseConfig):
|
||||
"""One environment a run pulls from: the verifiers blocks it composes (``env`` — what
|
||||
runs, ``serve`` — how it's hosted, ``legacy`` — a classic v0 env instead) plus this
|
||||
orchestrator's own per-env knobs."""
|
||||
runs, ``serve`` — how it's hosted) plus this orchestrator's own per-env knobs."""
|
||||
|
||||
env: SerializeAsAny[vf.EnvConfig] = vf.SingleAgentEnvConfig()
|
||||
"""The verifiers environment — which env, its seed taskset, each agent, its knobs. Narrowed to the selected env's config class by the env id, else the taskset id."""
|
||||
@@ -133,9 +127,6 @@ class EnvConfig(BaseConfig):
|
||||
serve: vf.ServeConfig = vf.ServeConfig()
|
||||
"""How this source's env server is hosted. The sizing knobs are consumed by the launcher, which writes each source's env-server config with an unset ``address`` filled in as the derived ``tcp://127.0.0.1:<env_server_base_port + index>``. Setting ``address`` marks the server externally managed: the launchers neither write its env-server TOML nor spawn a server for it, and the orchestrator connects to the given address — e.g. a k8s deployment running env servers in their own pods."""
|
||||
|
||||
legacy: vf.LegacyEnvConfig = vf.LegacyEnvConfig()
|
||||
"""A classic (v0) environment to run through the bridge instead of ``env``."""
|
||||
|
||||
name: str | None = None
|
||||
"""Display name for this environment in logs, metrics, and buffer keys. Defaults to the taskset id. Must be unique across all envs in the same group."""
|
||||
|
||||
@@ -148,15 +139,9 @@ class EnvConfig(BaseConfig):
|
||||
"""Narrow ``env`` to the selected env's config class."""
|
||||
return vf.resolve_env_field(data, vf.narrowed_env_annotation(cls))
|
||||
|
||||
@property
|
||||
def is_legacy(self) -> bool:
|
||||
"""A classic (v0) env run through the bridge: a legacy id and no v1 taskset."""
|
||||
return self.legacy.id is not None and not self.env.taskset.id
|
||||
|
||||
@property
|
||||
def env_id(self) -> str:
|
||||
"""The env's identifier: the v1 env's, else the v0 env id."""
|
||||
return self.env.env_id or self.legacy.id or ""
|
||||
return self.env.env_id or ""
|
||||
|
||||
@property
|
||||
def resolved_name(self) -> str:
|
||||
@@ -164,47 +149,14 @@ class EnvConfig(BaseConfig):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_env(self):
|
||||
# A v0 id next to any v1 env identity leaves one of the two going nowhere, and
|
||||
# which one depends on `is_legacy`: a taskset makes it False, so the v0 env never
|
||||
# loads; a bare `env.id` leaves it True, so the v0 env runs under the v1 name.
|
||||
if self.legacy.id is not None and self.env.env_id:
|
||||
if self.env.taskset.id:
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with "
|
||||
f"the v1 taskset {self.env.taskset.id!r}. Pairing a reusable env with a taskset "
|
||||
f"is env.id = {self.legacy.id!r}; to run the v0 env instead, drop the taskset."
|
||||
)
|
||||
raise ValueError(
|
||||
f"legacy.id {self.legacy.id!r} is a classic (v0) env and can't combine with the "
|
||||
f"v1 env.id {self.env.id!r}: the v0 env is what would run, stamped with the v1 "
|
||||
"env's name. Keep whichever one you meant to run."
|
||||
)
|
||||
if not self.env_id:
|
||||
raise ValueError(
|
||||
'no env configured — set env = { taskset = { id = "<id>" } } (v1) or legacy = { id = "<id>" } (v0)'
|
||||
)
|
||||
raise ValueError('no env configured — set env = { taskset = { id = "<id>" } }')
|
||||
if self.resolved_name == "agg":
|
||||
raise ValueError(
|
||||
'Environment name "agg" is reserved for cross-env metric aggregation. Use a different name or id.'
|
||||
)
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_legacy_env_kwargs(self):
|
||||
"""For a v0/legacy env, surface the v1 knobs the legacy bridge applies via
|
||||
``legacy.extra_env_kwargs`` (``env.set_kwargs(...)``): the per-rollout wall-clock
|
||||
timeout and the multi-turn completion-token budget, read off ``env.agent``.
|
||||
(``max_seq_len`` is added per train run in ``OrchestratorConfig.resolve_env_config``,
|
||||
which knows ``seq_len``.)"""
|
||||
if self.is_legacy:
|
||||
agent = getattr(self.env, "agent", None)
|
||||
if agent is not None:
|
||||
if agent.timeout.rollout is not None:
|
||||
self.legacy.extra_env_kwargs["timeout_seconds"] = agent.timeout.rollout
|
||||
if agent.max_output_tokens is not None:
|
||||
self.legacy.extra_env_kwargs["max_total_completion_tokens"] = agent.max_output_tokens
|
||||
return self
|
||||
|
||||
|
||||
class TrainSourceConfig(EnvConfig):
|
||||
sampling: TrainSamplingConfig = TrainSamplingConfig()
|
||||
@@ -338,7 +290,7 @@ class CheckpointConfig(BaseConfig):
|
||||
"""Step to resume the orchestrator from. None starts from scratch; ``-1`` resumes from the latest checkpoint available."""
|
||||
|
||||
wait_for_weights_timeout: int | None = Field(None, ge=1)
|
||||
"""When resuming, wait up to this many seconds for the weight directory to appear. Useful when the orchestrator restarts while the trainer is still saving weights. If None, fail immediately when weights are not found."""
|
||||
"""Wait up to this many seconds for the startup weight directory to appear (the trainer broadcasts the incoming policy — v0 from scratch, v{resume_step} on resume — before the first step). If None, fall back to a default timeout. Raise this for large models on slow shared filesystems."""
|
||||
|
||||
keep_last: int | None = Field(None, ge=1)
|
||||
"""Keep at most this many recent step checkpoints on disk. If None, never clean old checkpoints based on recency."""
|
||||
@@ -461,9 +413,6 @@ class OrchestratorConfig(BaseConfig):
|
||||
``tokenizer.name_or_path`` via ``MODEL_RENDERER_MAP``. RL/OPD roll out through the renderer
|
||||
client; SFT uses it to backfill tokens for its chat-completions teacher."""
|
||||
|
||||
optim: OptimizerConfig = OptimizerConfig()
|
||||
"""Per-run optimizer configuration for multi-run training."""
|
||||
|
||||
eval: EvalConfig | None = None
|
||||
"""Evaluation configuration."""
|
||||
|
||||
@@ -512,11 +461,11 @@ class OrchestratorConfig(BaseConfig):
|
||||
rollout_transport: TransportConfig = ZMQTransportConfig()
|
||||
"""Transport used to ship rollouts from orchestrator to trainer."""
|
||||
|
||||
output_dir: Path = Path("outputs/run_default")
|
||||
"""Directory to write outputs to — checkpoints, weights, rollouts, and logs are written as subdirectories. Should be a persistent directory with enough disk space and unique per experiment running on a single node."""
|
||||
output_dir: Path = Path("outputs")
|
||||
"""Directory to write outputs to — checkpoints, weights, rollouts, and logs are written as subdirectories. Shared with the trainer; should be a persistent directory with enough disk space and unique per experiment running on a single node."""
|
||||
|
||||
tasks_per_minute: int | None = Field(None, ge=1)
|
||||
"""Rate limit per environment worker, in tasks per minute. Recommended for sandbox-backed environments to prevent sandbox-not-ready errors during autoscaling. With multiple workers, the effective total rate is ``workers × this value``. None disables rate limiting."""
|
||||
"""Global rate limit on task dispatch, in tasks per minute. Recommended for sandbox-backed environments to prevent sandbox-not-ready errors during autoscaling. None disables rate limiting."""
|
||||
|
||||
env_server_base_port: int = Field(5000, ge=1, le=65535)
|
||||
"""First port of the env-server port range: the source at position ``i`` (train, then eval) is served at ``tcp://127.0.0.1:<base + i>``. Sources with an explicit ``serve.address`` keep it instead, without shifting the other sources' ports (indices stay positional). Give concurrent runs on one host distinct bases (e.g. one per multi-run orchestrator)."""
|
||||
@@ -539,9 +488,11 @@ class OrchestratorConfig(BaseConfig):
|
||||
seq_len: int = 2048
|
||||
"""Training sequence length. Shorter samples are padded; longer samples are truncated."""
|
||||
|
||||
# TODO(Mika): This should be automatic from the number of ZMQ connections
|
||||
num_train_workers: int = Field(1, ge=1)
|
||||
"""Training workers to use."""
|
||||
"""Trainer data-parallel world size (trainer world size // cp). The orchestrator packs one micro-batch list per DP rank, so this must match the trainer topology. Auto-filled by the ``rl`` entrypoint; set explicitly for standalone orchestrator runs."""
|
||||
|
||||
pad_to_multiple_of: int = Field(1, ge=1)
|
||||
"""Pad each packed micro batch to a multiple of this value (the trainer's cp degree). Auto-filled by the ``rl`` entrypoint; set explicitly for standalone orchestrator runs with cp > 1."""
|
||||
|
||||
max_steps: int | None = None
|
||||
"""Maximum training steps. If None, runs indefinitely."""
|
||||
@@ -703,7 +654,7 @@ class OrchestratorConfig(BaseConfig):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def resolve_env_config(self):
|
||||
"""Set vLLM sampling defaults + legacy env kwargs on each train env from top-level fields."""
|
||||
"""Set vLLM sampling defaults on each train env from top-level fields."""
|
||||
for env in self.train.source:
|
||||
# Policy-sourced rollouts hit our vLLM server; frozen-sourced
|
||||
# rollouts may hit external OAI endpoints that reject these knobs.
|
||||
@@ -712,10 +663,6 @@ class OrchestratorConfig(BaseConfig):
|
||||
env.sampling.extra_body.setdefault("top_k", -1)
|
||||
env.sampling.extra_body.setdefault("min_p", 0.0)
|
||||
env.sampling.extra_body.setdefault("return_token_ids", True)
|
||||
if env.is_legacy:
|
||||
# v0 env: cap per-turn response tokens to the training budget (the legacy
|
||||
# bridge applies legacy.extra_env_kwargs via env.set_kwargs).
|
||||
env.legacy.extra_env_kwargs["max_seq_len"] = self.seq_len
|
||||
return self
|
||||
|
||||
@property
|
||||
|
||||
@@ -222,7 +222,7 @@ class RLConfig(BaseConfig):
|
||||
orchestrator: OrchestratorConfig
|
||||
|
||||
inference: InferenceConfig | None = None
|
||||
"""Inference server configuration. If None, the rl entrypoint will not start an inference server (useful for elastic inference pools or manually started servers)."""
|
||||
"""Inference server configuration. If None, the rl entrypoint will not start an inference server (useful for manually started servers)."""
|
||||
|
||||
env_vars: EnvVars = {}
|
||||
"""Extra environment variables for every launched RL component. Component-specific env_vars override these."""
|
||||
@@ -603,6 +603,7 @@ class RLConfig(BaseConfig):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_deployment(self):
|
||||
self.orchestrator.pad_to_multiple_of = self.trainer.model.cp
|
||||
if self.deployment.type == "single_node": # single-node
|
||||
# set num_train_workers to the number of data replicas
|
||||
non_data_parallel_size = self.trainer.model.cp
|
||||
@@ -625,7 +626,9 @@ class RLConfig(BaseConfig):
|
||||
self.inference.vllm.api_server_count = dp
|
||||
|
||||
elif self.deployment.type == "multi_node": # multi-node
|
||||
self.orchestrator.num_train_workers = self.deployment.num_train_nodes * self.deployment.gpus_per_node
|
||||
self.orchestrator.num_train_workers = (
|
||||
self.deployment.num_train_nodes * self.deployment.gpus_per_node // self.trainer.model.cp
|
||||
)
|
||||
|
||||
if self.deployment.nodes_per_fsdp_group is not None:
|
||||
if self.deployment.num_train_nodes % self.deployment.nodes_per_fsdp_group != 0:
|
||||
@@ -756,7 +759,7 @@ class RLConfig(BaseConfig):
|
||||
if not self.orchestrator.any_policy_sourced and "base_url" not in client.model_fields_set:
|
||||
host = self.inference.server.host or "localhost"
|
||||
port = self.inference.server.port
|
||||
client.base_url = [f"http://{host}:{port}/v1"]
|
||||
client.base_url = f"http://{host}:{port}/v1"
|
||||
if (
|
||||
self.deployment.type == "single_node"
|
||||
and self.inference.router is not None
|
||||
|
||||
@@ -108,23 +108,12 @@ class BaseModelConfig(BaseConfig):
|
||||
"""VLM configuration. Setting this enables vision-language model support."""
|
||||
|
||||
|
||||
class ElasticConfig(BaseConfig):
|
||||
hostname: str
|
||||
"""DNS hostname that resolves to inference server IPs."""
|
||||
|
||||
port: int = 8000
|
||||
"""Port that inference servers listen on."""
|
||||
|
||||
sync_interval: float = 5.0
|
||||
"""Seconds between server discovery checks."""
|
||||
|
||||
|
||||
class ClientConfig(BaseConfig):
|
||||
wait_for_ready_timeout: int = 1800
|
||||
"""Seconds to wait at startup for the inference pool to become ready. Applies to both the static health check and elastic DNS-based discovery."""
|
||||
"""Seconds to wait at startup for the inference pool to become ready."""
|
||||
|
||||
base_url: list[str] = ["http://localhost:8000/v1"]
|
||||
"""Base URLs for the OpenAI API. With more than one URL, the client round-robins (chat) completion requests across all servers. Ignored when ``elastic`` is set."""
|
||||
base_url: str = "http://localhost:8000/v1"
|
||||
"""Base URL for the OpenAI API. For multi-replica deployments, point this at a router in front of the replicas."""
|
||||
|
||||
api_key_var: str = "VLLM_API_KEY"
|
||||
"""Environment variable name containing the API key, resolved via ``os.getenv``. Can be any string when the server is not protected by an API key; the same key is used for every URL."""
|
||||
@@ -142,18 +131,7 @@ class ClientConfig(BaseConfig):
|
||||
"""Skip checking that the model is available in the inference pool. Useful for external APIs or keys that do not expose ``/models``."""
|
||||
|
||||
admin_base_url: list[str] | None = None
|
||||
"""Separate base URLs for admin operations (weight updates, health checks). When set, admin clients bypass routers and hit each server directly — used in disaggregated P/D deployments where the router must not handle admin traffic."""
|
||||
|
||||
elastic: ElasticConfig | None = None
|
||||
"""Elastic inference pool config for DNS-based service discovery. When set, ``base_url`` is ignored and inference servers are discovered dynamically via DNS."""
|
||||
|
||||
router_url: str | None = None
|
||||
"""vllm-router URL for load-aware inference routing. With elastic mode, inference requests go through the router while admin ops still hit discovered pods directly."""
|
||||
|
||||
@property
|
||||
def is_elastic(self) -> bool:
|
||||
"""Check if elastic mode is enabled."""
|
||||
return self.elastic is not None
|
||||
"""Separate base URLs for admin operations (weight updates, health checks). When set, admin clients bypass routers and hit each server directly — used in multi-replica or disaggregated P/D deployments where the router must not handle admin traffic."""
|
||||
|
||||
|
||||
class LogConfig(BaseConfig):
|
||||
|
||||
@@ -625,9 +625,6 @@ class TrainerConfig(BaseConfig):
|
||||
metrics_server: MetricsServerConfig | None = None
|
||||
"""Prometheus metrics server configuration. If set, exposes a ``/metrics`` endpoint for scraping."""
|
||||
|
||||
max_concurrent_runs: int = Field(1, ge=1)
|
||||
"""Maximum number of concurrent runs to allow. If 1, only one run may run at a time."""
|
||||
|
||||
enable_token_export: bool = False
|
||||
"""Opt-in per-token JSONL export for rollout debugging. When enabled, writes token ids and aligned trainer metrics after each forward pass."""
|
||||
|
||||
@@ -702,12 +699,6 @@ class TrainerConfig(BaseConfig):
|
||||
raise ValueError("Muon optimizer does not support FSDP CPU offload")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_optim_cpu_offload_single_run(self):
|
||||
if self.model.optim_cpu_offload and self.max_concurrent_runs > 1:
|
||||
raise ValueError("Optimizer CPU offload is not supported with max_concurrent_runs > 1")
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_lora_broadcast(self):
|
||||
if self.model.lora is not None and self.weight_broadcast.type in ("nccl", "nixl"):
|
||||
|
||||
@@ -33,6 +33,7 @@ REASONING_PARSER_PATTERNS: list[tuple[re.Pattern[str], str]] = [
|
||||
(re.compile(r"^PrimeIntellect/INTELLECT-3"), "deepseek_r1"),
|
||||
(re.compile(r"^nvidia/NVIDIA-Nemotron-3-Super"), "nemotron_v3"),
|
||||
(re.compile(r"^nvidia/NVIDIA-Nemotron-3-Nano"), "nano_v3"),
|
||||
(re.compile(r"^nvidia/NVIDIA-Nemotron-3\.5"), "nano_v3"),
|
||||
(re.compile(r"^stepfun-ai/Step-3\.5"), "step3p5"),
|
||||
# Only Qwen3 Thinking models reason — Instruct/base models do not.
|
||||
(re.compile(r"^Qwen/Qwen3-.*Thinking"), "deepseek_r1"),
|
||||
|
||||
@@ -138,21 +138,7 @@ def propagate_shared_fields(data: Any) -> Any:
|
||||
# pass (the per-rank inference.toml drops slurm, so each rank still runs locally).
|
||||
propagate("slurm", "inference.slurm")
|
||||
|
||||
# output_dir: orchestrator gets a ``/run_default`` subdir so trainer +
|
||||
# orchestrator nest under the same experiment root without colliding.
|
||||
# Conflicts are reported against the *transformed* sub-config value, not
|
||||
# the raw shared path, so the materialized config round-trips cleanly.
|
||||
output_dir = get("output_dir")
|
||||
if output_dir is not None:
|
||||
expected = {
|
||||
"trainer.output_dir": output_dir,
|
||||
"orchestrator.output_dir": f"{output_dir}/run_default",
|
||||
}
|
||||
for sub, expected_value in expected.items():
|
||||
sub_value = get(sub)
|
||||
if sub_value is not None and sub_value != expected_value:
|
||||
conflicts.append(("output_dir", sub))
|
||||
fill(sub, expected_value)
|
||||
propagate("output_dir", "trainer.output_dir", "orchestrator.output_dir")
|
||||
|
||||
# Cascade trainer.tokenizer.chat_template → inference.vllm.chat_template
|
||||
# (vLLM ``--chat-template``). Read trainer's value *after* the shared
|
||||
@@ -243,9 +229,10 @@ def validate_shared_output_dir(
|
||||
trainer: TrainerConfig,
|
||||
orchestrator: OrchestratorConfig,
|
||||
) -> None:
|
||||
if trainer.output_dir != orchestrator.output_dir.parent:
|
||||
if trainer.output_dir != orchestrator.output_dir:
|
||||
raise ValueError(
|
||||
f"Trainer outputs directory ({trainer.output_dir}) and orchestrator outputs directory parent ({orchestrator.output_dir.parent}) are not the same. Please specify the same outputs directory for both."
|
||||
f"Trainer outputs directory ({trainer.output_dir}) and orchestrator outputs directory ({orchestrator.output_dir}) are not the same. "
|
||||
"Please specify the same outputs directory for both (the orchestrator no longer nests under a run_default subdirectory)."
|
||||
)
|
||||
|
||||
|
||||
|
||||
+17
-19
@@ -33,7 +33,7 @@ dependencies = [
|
||||
"setproctitle>=1.3.0",
|
||||
"uvloop>=0.21.0",
|
||||
"torchtitan",
|
||||
"verifiers[harbor]>=0.3.0",
|
||||
"verifiers[harbor]>=0.3.1.dev14",
|
||||
"renderers",
|
||||
"dion",
|
||||
"tilelang>=0.1.8",
|
||||
@@ -128,28 +128,28 @@ override-dependencies = [
|
||||
"openenv-core",
|
||||
]
|
||||
|
||||
# research-environments packages are auto-discovered as workspace members, so new
|
||||
# prime-envs packages are auto-discovered as workspace members, so new
|
||||
# envs there need no per-package registration. verifiers' example envs are opt-in:
|
||||
# only the ones prime-rl trains or tests on are listed, so an upstream example with
|
||||
# conflicting pins can't break the shared lock. Install them with
|
||||
# `uv sync --all-packages`.
|
||||
[tool.uv.workspace]
|
||||
members = [
|
||||
"deps/research-environments/environments/*/*",
|
||||
"deps/verifiers/environments/alphabet_sort_v1",
|
||||
"deps/verifiers/environments/color_codeword_v1",
|
||||
"deps/verifiers/environments/gsm8k_v1",
|
||||
"deps/verifiers/environments/kuhn_poker_v1",
|
||||
"deps/verifiers/environments/proposer_solver_v1",
|
||||
"deps/verifiers/environments/reverse_text_v1",
|
||||
"deps/verifiers/environments/wiki_search_v1",
|
||||
"deps/verifiers/environments/wordle_v1",
|
||||
"deps/prime-envs/environments/*/*",
|
||||
"deps/verifiers/environments/alphabet_sort",
|
||||
"deps/verifiers/environments/color_codeword",
|
||||
"deps/verifiers/environments/gsm8k",
|
||||
"deps/verifiers/environments/kuhn_poker",
|
||||
"deps/verifiers/environments/proposer_solver",
|
||||
"deps/verifiers/environments/reverse_text",
|
||||
"deps/verifiers/environments/wiki_search",
|
||||
"deps/verifiers/environments/wordle",
|
||||
]
|
||||
# tau2-synth-v1 and tau3-bench-v1 pin `tau2` forks/revs that conflict with the
|
||||
# canonical tau2-bench-v1; a workspace shares one lock, so these can't coexist.
|
||||
# tau2-synth and tau3-bench pin `tau2` forks/revs that conflict with the
|
||||
# canonical tau2-bench; a workspace shares one lock, so these can't coexist.
|
||||
exclude = [
|
||||
"deps/research-environments/environments/tool_use/tau2_synth_v1",
|
||||
"deps/research-environments/environments/tool_use/tau3_bench_v1",
|
||||
"deps/prime-envs/environments/tool_use/tau2_synth",
|
||||
"deps/prime-envs/environments/tool_use/tau3_bench",
|
||||
]
|
||||
|
||||
# ModelExpress 0.3.0 publishes protobuf<6 metadata, but its generated proto is
|
||||
@@ -195,10 +195,8 @@ torchao = false
|
||||
|
||||
[tool.uv.sources]
|
||||
prime-rl-configs = { path = "packages/prime-rl-configs", editable = true }
|
||||
# prime-rl depends on the one `verifiers` package (v0 + v1 + the legacy bridge + the built-in v1
|
||||
# harnesses/tasksets, now bundled in verifiers.v1). v0 envs resolve from
|
||||
# deps/{verifiers,research-environments}/environments; v1 tasksets (`-v1`) and the `compact`
|
||||
# example live under deps/{verifiers,research-environments}/environments.
|
||||
# prime-rl consumes `verifiers.v1` (incl. the built-in harnesses/tasksets); env tasksets
|
||||
# live under deps/{verifiers,prime-envs}/environments.
|
||||
verifiers = { path = "deps/verifiers", editable = true }
|
||||
renderers = { path = "deps/renderers", editable = true }
|
||||
prime-pydantic-config = { path = "deps/pydantic-config", editable = true }
|
||||
|
||||
@@ -47,7 +47,7 @@ Incompatible combinations (e.g. CP requires flash attention) must raise in a `mo
|
||||
name = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
@@ -59,7 +59,7 @@ type = "subprocess"
|
||||
name = "reverse-text-eval"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
id = "reverse-text"
|
||||
split = "test"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
@@ -69,7 +69,7 @@ id = "null"
|
||||
type = "subprocess"
|
||||
```
|
||||
|
||||
CLI: `--orchestrator.train.source.0.env.taskset.id reverse-text-v1` or `--orchestrator.eval.source.0.env.taskset.id reverse-text-v1`.
|
||||
CLI: `--orchestrator.train.source.0.env.taskset.id reverse-text` or `--orchestrator.eval.source.0.env.taskset.id reverse-text`.
|
||||
|
||||
**Dicts** — TOML uses a section; CLI takes a JSON string: `--trainer.env-vars '{"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.
|
||||
|
||||
@@ -90,7 +90,7 @@ 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.
|
||||
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 under `output_dir/token_exports/step_<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.
|
||||
|
||||
```toml
|
||||
enable_token_export = true
|
||||
|
||||
@@ -26,10 +26,10 @@ uv sync # core only
|
||||
uv sync --group dev # + pytest, ruff, pre-commit
|
||||
uv sync --all-extras # + extras (flash-attn, flash-attn-cute, …)
|
||||
uv sync --all-extras --all-packages # + all env packages (needed to train on them)
|
||||
uv sync --package prime-rl --package gsm8k-v1 # core + just one env
|
||||
uv sync --package prime-rl --package gsm8k # core + just one env
|
||||
```
|
||||
|
||||
Environment packages are uv **workspace members**. Those under `deps/research-environments/environments/*/*` are auto-discovered — adding a new env there needs no `pyproject.toml` change. verifiers' example envs are enumerated explicitly in `[tool.uv.workspace].members` (only the ones prime-rl trains or tests on) — to use another, add its path to the list. Members are opt-in: a plain `uv sync` / `--all-extras` does not install them (and would remove them if already present — re-run with `--all-packages`, or `--inexact` to keep them). Install all with `--all-packages`, or a subset with repeated `--package <env>` (include `--package prime-rl` to keep the core). If two envs pin conflicting transitive versions (all members share one lock), add the loser to `[tool.uv.workspace].exclude`.
|
||||
Environment packages are uv **workspace members**. Those under `deps/prime-envs/environments/*/*` are auto-discovered — adding a new env there needs no `pyproject.toml` change. verifiers' example envs are enumerated explicitly in `[tool.uv.workspace].members` (only the ones prime-rl trains or tests on) — to use another, add its path to the list. Members are opt-in: a plain `uv sync` / `--all-extras` does not install them (and would remove them if already present — re-run with `--all-packages`, or `--inexact` to keep them). Install all with `--all-packages`, or a subset with repeated `--package <env>` (include `--package prime-rl` to keep the core). If two envs pin conflicting transitive versions (all members share one lock), add the loser to `[tool.uv.workspace].exclude`.
|
||||
|
||||
When bumping a package past the workspace-wide `exclude-newer = "7 days"` window, add it (and any newly-required transitives) to `[tool.uv.exclude-newer-package]` before refreshing `uv.lock`.
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ jq '.rewards' {output_dir}/rollouts/step_42/train/effective/traces.jsonl
|
||||
jq 'select(.ok | not) | {id, env: .info.env_name, runtime}' {output_dir}/rollouts/step_*/train/all/traces.jsonl
|
||||
```
|
||||
|
||||
The batches consumed by the trainer are shipped over ZMQ by default, so nothing binary is written. With `rollout_transport.type = "filesystem"` they land at `{output_dir}/rollouts/step_N/train_rollouts.bin`, next to the trace subtrees.
|
||||
The batches consumed by the trainer are shipped over ZMQ by default, so nothing binary is written. With `rollout_transport.type = "filesystem"` they land at `{output_dir}/rollouts/step_N/rank_<rank>.bin` (one packed micro-batch file per trainer DP rank), next to the trace subtrees.
|
||||
|
||||
### Common failure modes
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ uv run rl @ examples/basic/reverse-text/rl.toml --dry-run
|
||||
- SLURM: single- and multi-node
|
||||
- Environment packages: before launching a config with a non-core verifier env id,
|
||||
verify the package imports under `uv run` (for example
|
||||
`uv run python -c "import importlib.util; print(importlib.util.find_spec('r2e_gym_v1'))"`).
|
||||
If a local env exists under `deps/research-environments/environments/` or
|
||||
`uv run python -c "import importlib.util; print(importlib.util.find_spec('r2e_gym'))"`).
|
||||
If a local env exists under `deps/prime-envs/environments/` or
|
||||
`deps/verifiers/environments/` but does not import, install the env workspace
|
||||
members with `uv sync --all-packages` (all) or `uv sync --package prime-rl
|
||||
--package <env>` (one) — they're auto-discovered, no `pyproject.toml` edit needed.
|
||||
|
||||
@@ -12,21 +12,14 @@ from prime_rl.utils.utils import clean_exit
|
||||
|
||||
@clean_exit
|
||||
def run_server(config: EnvServerConfig):
|
||||
# ``serve.pool`` (static or elastic) sizes the server; a v0/legacy env runs through
|
||||
# the bridge, a v1 env is a native env block — both speak the same serve protocol,
|
||||
# so the orchestrator is agnostic. serve_env applies the logging setup in this process
|
||||
# and in every spawned worker.
|
||||
server_kwargs = (
|
||||
{"env_id": config.env_id, "env_args": config.legacy.args, "extra_env_kwargs": config.legacy.extra_env_kwargs}
|
||||
if config.is_legacy
|
||||
else {"config_data": env_config_data(config.env), "max_concurrent": config.serve.max_concurrent}
|
||||
)
|
||||
# ``serve.pool`` (static or elastic) sizes the server. serve_env applies the logging
|
||||
# setup in this process and in every spawned worker.
|
||||
serve_env(
|
||||
**pool_serve_kwargs(config.serve.pool),
|
||||
legacy=config.is_legacy,
|
||||
address=config.serve.address,
|
||||
log_setup=partial(setup_env_server_logging, config.log.level, config.log.json_logging),
|
||||
**server_kwargs,
|
||||
config_data=env_config_data(config.env),
|
||||
max_concurrent=config.serve.max_concurrent,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ def write_subconfigs(config: RLConfig, output_dir: Path) -> None:
|
||||
|
||||
# One EnvServerConfig TOML per launcher-managed source: `env-server @ <path>` binds
|
||||
# at the source's deterministic address, where the orchestrator connects. The source's
|
||||
# env/serve/legacy blocks carry over; its other knobs (sampling, algo, name, ...) are
|
||||
# env/serve blocks carry over; its other knobs (sampling, algo, name, ...) are
|
||||
# orchestrator-side.
|
||||
for split, source, address in env_servers(config):
|
||||
env_dir = output_dir / ENVS_DIR / split
|
||||
@@ -114,7 +114,6 @@ def write_subconfigs(config: RLConfig, output_dir: Path) -> None:
|
||||
env_server_dict = {
|
||||
"env": source_dict["env"],
|
||||
"serve": {**source_dict.get("serve", {}), "address": address},
|
||||
"legacy": source_dict.get("legacy", {}),
|
||||
"log": {"level": config.orchestrator.log.vf_level, "json_logging": config.orchestrator.log.json_logging},
|
||||
}
|
||||
with open(env_dir / f"{source.resolved_name}.toml", "wb") as f:
|
||||
@@ -170,9 +169,8 @@ def rl_local(config: RLConfig):
|
||||
}
|
||||
|
||||
# Validate client port matches inference server port
|
||||
if config.inference is not None and not config.orchestrator.model.client.is_elastic:
|
||||
base_url = config.orchestrator.model.client.base_url[0]
|
||||
parsed = urlparse(base_url)
|
||||
if config.inference is not None:
|
||||
parsed = urlparse(config.orchestrator.model.client.base_url)
|
||||
client_port = parsed.port
|
||||
expected_port = config.inference.server.port
|
||||
if client_port != expected_port:
|
||||
@@ -238,7 +236,7 @@ def rl_local(config: RLConfig):
|
||||
"No [inference] block configured - the policy inference server will not be started here. "
|
||||
"Every algorithm requires a policy inference pool for evals + weight sync; "
|
||||
"make sure one is running at orchestrator.model.client.base_url "
|
||||
f"({', '.join(config.orchestrator.model.client.base_url)}), otherwise the orchestrator "
|
||||
f"({config.orchestrator.model.client.base_url}), otherwise the orchestrator "
|
||||
"will hang waiting for it."
|
||||
)
|
||||
|
||||
@@ -248,7 +246,7 @@ def rl_local(config: RLConfig):
|
||||
assert algo is not None, "TrainSourceConfig.algo must be resolved before launch (inherit_env_algorithms)"
|
||||
for ref in (algo.sampling.source, getattr(algo, "teacher", None)):
|
||||
if isinstance(ref, FrozenModelConfig):
|
||||
frozen_endpoints.append(f"{ref.name} ({', '.join(ref.base_url)})")
|
||||
frozen_endpoints.append(f"{ref.name} ({ref.base_url})")
|
||||
if frozen_endpoints:
|
||||
endpoints = ", ".join(dict.fromkeys(frozen_endpoints))
|
||||
logger.info(
|
||||
@@ -483,7 +481,6 @@ def write_slurm_script(config: RLConfig, config_dir: Path, script_path: Path) ->
|
||||
is_disaggregated=True,
|
||||
config_dir=config_dir,
|
||||
output_dir=config.output_dir,
|
||||
orchestrator_output_dir=config.orchestrator.output_dir,
|
||||
num_train_nodes=config.deployment.num_train_nodes,
|
||||
num_infer_nodes=infer_deploy.num_nodes * config.deployment.num_infer_replicas,
|
||||
nodes_per_infer_replica=infer_deploy.num_nodes,
|
||||
@@ -524,7 +521,6 @@ def write_slurm_script(config: RLConfig, config_dir: Path, script_path: Path) ->
|
||||
is_disaggregated=False,
|
||||
config_dir=config_dir, # TODO: should prob have each subconfig path separately
|
||||
output_dir=config.output_dir,
|
||||
orchestrator_output_dir=config.orchestrator.output_dir,
|
||||
num_train_nodes=config.deployment.num_train_nodes,
|
||||
num_infer_nodes=config.deployment.total_infer_nodes,
|
||||
nodes_per_infer_replica=config.deployment.infer_nodes_per_replica,
|
||||
|
||||
@@ -65,15 +65,15 @@ async def connect_frozen_pool(
|
||||
(sft), so the rollout carries tokens. Left as plain chat-completions
|
||||
otherwise (opd/opsd read teacher logprobs via prefill, where the train
|
||||
client type is moot)."""
|
||||
from prime_rl.utils.client import setup_inference_pool
|
||||
from prime_rl.utils.client import InferencePool
|
||||
|
||||
get_logger().info(f"Initializing frozen model pool (model={config.name}, base_url={', '.join(config.base_url)})")
|
||||
get_logger().info(f"Initializing frozen model pool (model={config.name}, base_url={config.base_url})")
|
||||
if renderer_config is not None:
|
||||
pool = await setup_inference_pool(
|
||||
pool = InferencePool(
|
||||
config, model_name=config.name, train_client_type="renderer", renderer_config=renderer_config
|
||||
)
|
||||
else:
|
||||
pool = await setup_inference_pool(config, model_name=config.name)
|
||||
pool = InferencePool(config, model_name=config.name)
|
||||
await pool.wait_for_ready(config.name)
|
||||
return pool
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from prime_rl.configs.algorithm import OPDAlgoConfig
|
||||
from prime_rl.orchestrator.algo.base import Algorithm
|
||||
from prime_rl.utils.client import StaticInferencePool
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from prime_rl.orchestrator.types import Rollout
|
||||
@@ -29,13 +28,10 @@ class OPDAlgorithm(Algorithm):
|
||||
def __init__(self, config: OPDAlgoConfig, policy_pool: InferencePool):
|
||||
super().__init__(config, policy_pool)
|
||||
self.teacher = config.teacher
|
||||
self.teacher_pool: StaticInferencePool | None = None # static teacher endpoint, connected in setup()
|
||||
self.teacher_pool: InferencePool | None = None # frozen teacher endpoint, connected in setup()
|
||||
|
||||
async def setup(self) -> None:
|
||||
pool = await self.connect(self.teacher)
|
||||
if not isinstance(pool, StaticInferencePool):
|
||||
raise TypeError("opd teacher must be a static endpoint — prefill scoring needs fixed endpoints")
|
||||
self.teacher_pool = pool
|
||||
self.teacher_pool = await self.connect(self.teacher)
|
||||
|
||||
async def score_rollout(self, rollout: Rollout) -> None:
|
||||
pool = self.teacher_pool
|
||||
|
||||
@@ -15,7 +15,7 @@ class RAEAlgorithm(Algorithm):
|
||||
"""Role-conditioned advantage estimation (SPIRAL, arXiv:2506.24119):
|
||||
credit = reward minus a per-agent EMA baseline of that agent's rewards.
|
||||
|
||||
The advantage estimator for multi-agent self-play envs (kuhn-poker-v1 and
|
||||
The advantage estimator for multi-agent self-play envs (kuhn-poker and
|
||||
friends): in a zero-sum game the group mean is ~0 whatever the policy does,
|
||||
and centering all agents against it mixes their opposite reward scales — a
|
||||
structural first-mover edge would read as permanent credit for one agent.
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
"""RolloutDispatcher: schedules rollouts under a shared permit counter.
|
||||
|
||||
- Capacity (``max_inflight_episodes``) is shared across train + eval. One permit is
|
||||
one episode: for a v1 env one ``run`` request, and a group-scoring task that runs
|
||||
N rollouts in one call reserves N permits (each bridged v0 rollout is its own
|
||||
single-agent episode).
|
||||
one episode: one ``run`` request against an env server.
|
||||
- Optional rate limiting via ``AsyncLimiter(tasks_per_minute, 60)``.
|
||||
- Emit-everything invariant: every dispatched episode eventually reaches
|
||||
``out_q`` exactly once, as a ``list[Rollout]``. Failures
|
||||
@@ -28,7 +26,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import uuid
|
||||
from collections import Counter, defaultdict
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum, auto
|
||||
from typing import Literal
|
||||
@@ -47,7 +45,7 @@ from prime_rl.orchestrator.types import (
|
||||
RolloutKind,
|
||||
)
|
||||
from prime_rl.utils.async_utils import safe_cancel, safe_cancel_all
|
||||
from prime_rl.utils.client import InferencePool, client_identity
|
||||
from prime_rl.utils.client import InferencePool
|
||||
from prime_rl.utils.logger import get_logger
|
||||
|
||||
|
||||
@@ -183,11 +181,11 @@ class RolloutDispatcher:
|
||||
|
||||
@property
|
||||
def inflight_train_count(self) -> int:
|
||||
return sum(m.rollout_count for m in self.inflight.values() if m.kind == "train")
|
||||
return sum(1 for m in self.inflight.values() if m.kind == "train")
|
||||
|
||||
@property
|
||||
def inflight_eval_count(self) -> int:
|
||||
return sum(m.rollout_count for m in self.inflight.values() if m.kind == "eval")
|
||||
return sum(1 for m in self.inflight.values() if m.kind == "eval")
|
||||
|
||||
@property
|
||||
def available_permits(self) -> int:
|
||||
@@ -197,7 +195,7 @@ class RolloutDispatcher:
|
||||
def inflight_by_env(self) -> dict[tuple[RolloutKind, str], int]:
|
||||
counts: dict[tuple[RolloutKind, str], int] = defaultdict(int)
|
||||
for meta in self.inflight.values():
|
||||
counts[(meta.kind, meta.env_name)] += meta.rollout_count
|
||||
counts[(meta.kind, meta.env_name)] += 1
|
||||
return dict(counts)
|
||||
|
||||
@property
|
||||
@@ -356,10 +354,7 @@ class RolloutDispatcher:
|
||||
for gid, group in list(self.groups.items()):
|
||||
if group.kind != kind or group.rollouts_to_schedule <= 0:
|
||||
continue
|
||||
env = envs.get(group.env_name)
|
||||
cost = group.rollouts_to_schedule if env.requires_group_scoring else 1
|
||||
if cost <= self.available_permits:
|
||||
return await self.schedule_group_rollout(gid, group)
|
||||
return await self.schedule_group_rollout(gid, group)
|
||||
|
||||
fresh = self.next_fresh_group(kind, envs)
|
||||
if fresh is None:
|
||||
@@ -370,14 +365,13 @@ class RolloutDispatcher:
|
||||
|
||||
def next_fresh_group(self, kind: RolloutKind, envs) -> GroupState | None:
|
||||
"""Pop the next example from the corresponding source and wrap it in
|
||||
a ``GroupState``. Returns ``None`` if the source is empty or the
|
||||
picked env's permit cost doesn't fit."""
|
||||
a ``GroupState``. Returns ``None`` if the source is empty."""
|
||||
if kind == "train":
|
||||
source = self.train_source
|
||||
else:
|
||||
assert self.eval_source is not None
|
||||
source = self.eval_source
|
||||
example = source.next_example(self.available_permits)
|
||||
example = source.next_example()
|
||||
if example is None:
|
||||
return None
|
||||
|
||||
@@ -388,8 +382,7 @@ class RolloutDispatcher:
|
||||
return GroupState(
|
||||
kind=kind,
|
||||
env_name=env_name,
|
||||
task_idx=example["task_idx"],
|
||||
task=example.get("task"),
|
||||
task=example["task"],
|
||||
rollouts_to_schedule=group_size,
|
||||
target_rollouts=group_size,
|
||||
eval_step=eval_step,
|
||||
@@ -397,7 +390,7 @@ class RolloutDispatcher:
|
||||
)
|
||||
|
||||
async def schedule_group_rollout(self, group_id: uuid.UUID, group: GroupState) -> bool:
|
||||
"""Dispatch one ``run`` / ``run_group`` task for this group.
|
||||
"""Dispatch one ``run`` task for this group.
|
||||
|
||||
Returns False only if we couldn't even schedule one rollout (no clients
|
||||
ready, no permits). Returns True after issuing one task — the caller
|
||||
@@ -405,28 +398,17 @@ class RolloutDispatcher:
|
||||
"""
|
||||
# Train rollouts use the env sampler's pool via the
|
||||
# renderer/token train client. Eval always evaluates the policy and
|
||||
# goes through the eval client (chat-completions) — the same path the
|
||||
# legacy orchestrator used, so eval scores stay comparable.
|
||||
# goes through the eval client (chat-completions) so eval scores stay
|
||||
# comparable.
|
||||
if group.kind == "eval":
|
||||
pool, model_name = self.policy_pool, self.policy.model_name
|
||||
live_sourced = True
|
||||
else:
|
||||
pool, model_name, live_sourced = self._train_pool_for(group.env_name)
|
||||
|
||||
# Pin a single client per group to keep prefix-cache hits
|
||||
if group.pinned_client is None:
|
||||
if group.kind == "eval":
|
||||
client = await pool.get_eval_client()
|
||||
else:
|
||||
load = Counter(
|
||||
client_identity(m.client_config) for m in self.inflight.values() if m.client_config is not None
|
||||
)
|
||||
client = await pool.select_train_client(load)
|
||||
if group_id not in self.groups:
|
||||
return False
|
||||
group.pinned_client = client
|
||||
else:
|
||||
client = group.pinned_client
|
||||
group.pinned_client = pool.eval_client if group.kind == "eval" else pool.train_client
|
||||
client = group.pinned_client
|
||||
|
||||
env_collection = self.train_envs if group.kind == "train" else self.eval_envs
|
||||
if env_collection is None:
|
||||
@@ -440,73 +422,48 @@ class RolloutDispatcher:
|
||||
else:
|
||||
cache_salt = None
|
||||
|
||||
if env.requires_group_scoring:
|
||||
# Legacy-only route (a v1 env never group-scores) — addressed by row.
|
||||
permits = group.rollouts_to_schedule
|
||||
group.rollouts_to_schedule = 0
|
||||
await self.acquire(permits)
|
||||
task: asyncio.Task = asyncio.create_task(
|
||||
env.run_group(
|
||||
client=client,
|
||||
task_idx=group.task_idx,
|
||||
model_name=model_name,
|
||||
group_size=permits,
|
||||
cache_salt=cache_salt,
|
||||
)
|
||||
)
|
||||
else:
|
||||
# A v1 env takes the task itself; the legacy bridge its dataset row.
|
||||
if group.task is not None:
|
||||
addressing = {"task_data": group.task.data.model_dump(mode="json")}
|
||||
else:
|
||||
addressing = {"task_idx": group.task_idx}
|
||||
permits = 1
|
||||
group.rollouts_to_schedule -= 1
|
||||
await self.acquire(permits)
|
||||
task = asyncio.create_task(
|
||||
env.run(
|
||||
client=client,
|
||||
model_name=model_name,
|
||||
cache_salt=cache_salt,
|
||||
**addressing,
|
||||
)
|
||||
group.rollouts_to_schedule -= 1
|
||||
await self.acquire()
|
||||
task = asyncio.create_task(
|
||||
env.run(
|
||||
client=client,
|
||||
model_name=model_name,
|
||||
cache_salt=cache_salt,
|
||||
task_data=group.task.data.model_dump(mode="json"),
|
||||
)
|
||||
)
|
||||
|
||||
self.inflight[task] = InflightRollout(
|
||||
kind=group.kind,
|
||||
env_name=group.env_name,
|
||||
group_id=group_id,
|
||||
policy_version=group.policy_version_at_start,
|
||||
rollout_count=permits,
|
||||
client_config=client,
|
||||
eval_step=group.eval_step,
|
||||
)
|
||||
return True
|
||||
|
||||
async def acquire(self, n: int) -> None:
|
||||
"""Reserve ``n`` permits + rate-limit each one. Caller must precheck
|
||||
``available_permits >= n``; this is not a blocking acquire."""
|
||||
for _ in range(n):
|
||||
if self.rate_limiter is not None:
|
||||
await self.rate_limiter.acquire()
|
||||
self.inflight_permits += 1
|
||||
async def acquire(self) -> None:
|
||||
"""Reserve one permit + rate-limit it. Caller must precheck
|
||||
``available_permits >= 1``; this is not a blocking acquire."""
|
||||
if self.rate_limiter is not None:
|
||||
await self.rate_limiter.acquire()
|
||||
self.inflight_permits += 1
|
||||
|
||||
def release(self, n: int) -> None:
|
||||
self.inflight_permits -= n
|
||||
def release(self) -> None:
|
||||
self.inflight_permits -= 1
|
||||
|
||||
async def handle_completed_rollout(self, task: asyncio.Task) -> None:
|
||||
"""Emit every dispatched episode exactly once to ``out_q``: a ``run``
|
||||
result as one episode, a legacy ``run_group`` result as ``rollout_count``
|
||||
single-trace episodes. Task exceptions synthesize ``rollout_count``
|
||||
error-marker episodes so the sink's count-to-``group_size`` finalization
|
||||
still triggers. Cancelled tasks (popped by ``drop_group``) raise
|
||||
``CancelledError`` and are discarded — ``drop_group`` already emitted
|
||||
their markers.
|
||||
"""Emit every dispatched episode exactly once to ``out_q``. Task
|
||||
exceptions synthesize an error-marker episode so the sink's
|
||||
count-to-``group_size`` finalization still triggers. Cancelled tasks
|
||||
(popped by ``drop_group``) raise ``CancelledError`` and are discarded —
|
||||
``drop_group`` already emitted their markers.
|
||||
"""
|
||||
meta = self.inflight.pop(task, None)
|
||||
if meta is None:
|
||||
return # already handled by drop_group / cancel_inflight_rollouts
|
||||
self.release(meta.rollout_count)
|
||||
self.release()
|
||||
group = self.groups.get(meta.group_id)
|
||||
|
||||
is_synth_exception = False
|
||||
@@ -519,13 +476,12 @@ class RolloutDispatcher:
|
||||
return
|
||||
except Exception as exc:
|
||||
get_logger().warning(f"Rollout task failed in group {meta.group_id} ({meta.env_name}): {exc!r}")
|
||||
task_idx = group.task_idx if group is not None else -1
|
||||
task_idx = group.task.data.idx if group is not None else -1
|
||||
rollouts = [
|
||||
Rollout(
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
)
|
||||
for _ in range(meta.rollout_count)
|
||||
]
|
||||
for r in rollouts:
|
||||
r.record_error(exc)
|
||||
@@ -544,13 +500,7 @@ class RolloutDispatcher:
|
||||
get_logger().warning(
|
||||
f"Rollout failed in group {meta.group_id} ({meta.env_name}) — {r.last_error.type}: {r.last_error.message}"
|
||||
)
|
||||
if meta.rollout_count == 1:
|
||||
# A ``run`` task: the whole result is one episode.
|
||||
await self.emit_episode(meta, group, rollouts)
|
||||
else:
|
||||
# A legacy ``run_group`` task: one single-trace episode per trace.
|
||||
for r in rollouts:
|
||||
await self.emit_episode(meta, group, [r])
|
||||
await self.emit_episode(meta, group, rollouts)
|
||||
|
||||
async def emit_episode(self, meta: InflightRollout, group: GroupState | None, rollouts: list[Rollout]) -> None:
|
||||
"""Stamp prime-rl metadata onto one completed episode and put it on
|
||||
@@ -582,7 +532,7 @@ class RolloutDispatcher:
|
||||
(both in-flight and not-yet-scheduled). Returns the count for
|
||||
off-policy metrics."""
|
||||
group = self.groups.pop(group_id, None)
|
||||
task_idx = group.task_idx if group is not None else -1
|
||||
task_idx = group.task.data.idx if group is not None else -1
|
||||
|
||||
# Sync claim phase: pop matching tasks from ``self.inflight`` and
|
||||
# release their permits in one non-yielding sweep. After this loop
|
||||
@@ -594,26 +544,25 @@ class RolloutDispatcher:
|
||||
if meta.group_id != group_id:
|
||||
continue
|
||||
del self.inflight[task]
|
||||
self.release(meta.rollout_count)
|
||||
self.release()
|
||||
claimed.append((task, meta))
|
||||
|
||||
tasks_to_cancel = [task for task, _ in claimed]
|
||||
inflight_cancelled = sum(meta.rollout_count for _, meta in claimed)
|
||||
inflight_cancelled = len(claimed)
|
||||
last_meta: InflightRollout | None = claimed[-1][1] if claimed else None
|
||||
for _, meta in claimed:
|
||||
for _ in range(meta.rollout_count):
|
||||
trace = Rollout(
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
ok=False,
|
||||
errors=[vf.Error(type="Cancelled", message="Off-policy cancel")],
|
||||
stop_condition="error",
|
||||
)
|
||||
await self.emit_episode(meta, group, [trace])
|
||||
trace = Rollout(
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
ok=False,
|
||||
errors=[vf.Error(type="Cancelled", message="Off-policy cancel")],
|
||||
stop_condition="error",
|
||||
)
|
||||
await self.emit_episode(meta, group, [trace])
|
||||
|
||||
# For non-group-scoring envs, the group may have rollouts that
|
||||
# were never dispatched (``rollouts_to_schedule > 0``). Emit
|
||||
# markers for those too so the sink hits ``target_rollouts``
|
||||
# The group may have rollouts that were never dispatched
|
||||
# (``rollouts_to_schedule > 0``). Emit markers for those too so the
|
||||
# sink hits ``target_rollouts``
|
||||
#
|
||||
# ``last_meta`` can be ``None`` if the only inflight task for this
|
||||
# group completed naturally between ``on_version_pending``'s snapshot
|
||||
@@ -625,7 +574,6 @@ class RolloutDispatcher:
|
||||
env_name=group.env_name,
|
||||
group_id=group_id,
|
||||
policy_version=group.policy_version_at_start,
|
||||
rollout_count=1,
|
||||
eval_step=group.eval_step,
|
||||
)
|
||||
unscheduled_cancelled = group.rollouts_to_schedule
|
||||
@@ -647,7 +595,6 @@ class RolloutDispatcher:
|
||||
env_name=group.env_name,
|
||||
group_id=group_id,
|
||||
policy_version=group.policy_version_at_start if group else 0,
|
||||
rollout_count=1,
|
||||
eval_step=group.eval_step,
|
||||
)
|
||||
if group is not None
|
||||
@@ -668,8 +615,8 @@ class RolloutDispatcher:
|
||||
"""Cancel all in-flight rollouts. Used on shutdown — doesn't emit
|
||||
markers since the sinks are being torn down anyway."""
|
||||
for meta in self.inflight.values():
|
||||
self.metrics.record_cancellation(kind=meta.kind, env_name=meta.env_name, n=meta.rollout_count)
|
||||
self.release(meta.rollout_count)
|
||||
self.metrics.record_cancellation(kind=meta.kind, env_name=meta.env_name)
|
||||
self.release()
|
||||
tasks = list(self.inflight.keys())
|
||||
self.inflight.clear()
|
||||
self.groups.clear()
|
||||
@@ -687,9 +634,9 @@ class RolloutDispatcher:
|
||||
if meta.kind != "train":
|
||||
continue
|
||||
self.inflight.pop(task, None)
|
||||
self.release(meta.rollout_count)
|
||||
self.metrics.record_cancellation(kind="train", env_name=meta.env_name, n=meta.rollout_count)
|
||||
cancelled += meta.rollout_count
|
||||
self.release()
|
||||
self.metrics.record_cancellation(kind="train", env_name=meta.env_name)
|
||||
cancelled += 1
|
||||
train_tasks.append(task)
|
||||
train_group_ids.add(meta.group_id)
|
||||
for gid in train_group_ids:
|
||||
|
||||
@@ -10,9 +10,7 @@ once, and each dispatched episode ships its task's data on the request
|
||||
(``task_data``); the server pydantic-validates it into the taskset's declared
|
||||
``TaskData`` type and runs it. That keeps the server (and every worker in its
|
||||
pool) stateless about data — no per-worker dataset loads, no idx-addressed task
|
||||
cache — and gives the orchestrator real tasks to cycle, shuffle, and filter. Only
|
||||
the legacy (v0) bridge, whose dataset genuinely lives server-side, is still driven
|
||||
by ``task_idx`` (its count comes from ``info``).
|
||||
cache — and gives the orchestrator real tasks to cycle, shuffle, and filter.
|
||||
|
||||
The server answers one ``Episode`` per run request, whose traces we validate into
|
||||
``Trace[WireTaskData]`` — real ``vf.Trace``\\ s (never loose dicts) whose task
|
||||
@@ -41,7 +39,7 @@ from prime_rl.utils.logger import get_logger
|
||||
ROLLOUT_TYPE = Rollout[vf.WireTaskData]
|
||||
|
||||
# Max wait for the env server to answer health. Generous because the launcher spawns
|
||||
# servers concurrently with the orchestrator, and a legacy server loads its dataset
|
||||
# servers concurrently with the orchestrator, and a server imports its env package
|
||||
# before serving.
|
||||
ENV_SERVER_STARTUP_TIMEOUT = 600.0
|
||||
|
||||
@@ -56,12 +54,11 @@ class Env:
|
||||
self.sampling_args: dict = {}
|
||||
self.num_tasks: int | None = 0
|
||||
"""Task count; ``None`` means the taskset is infinite."""
|
||||
self.requires_group_scoring: bool = False
|
||||
self.tasks: Iterator[vf.Task] | None = None
|
||||
"""The env's tasks, client-side; ``None`` for legacy (its dataset lives on the
|
||||
server). A finite taskset is materialized at ``start()`` (``num_tasks`` is its
|
||||
count) and iterated from there; an infinite one streams off its generator.
|
||||
Consumed once — by ``TrainSource`` (train) or ``EvalEnv.start`` (eval)."""
|
||||
"""The env's tasks, client-side, set at ``start()``. A finite taskset is
|
||||
materialized (``num_tasks`` is its count) and iterated from there; an infinite
|
||||
one streams off its generator. Consumed once — by ``TrainSource`` (train) or
|
||||
``EvalEnv.start`` (eval)."""
|
||||
self._env_client: EnvClient | None = None
|
||||
|
||||
@property
|
||||
@@ -75,29 +72,23 @@ class Env:
|
||||
return self._env_client
|
||||
|
||||
async def start(self) -> None:
|
||||
"""Connect to the env server and load the taskset client-side (legacy instead
|
||||
asks the server for ``info`` — its dataset is server-side)."""
|
||||
"""Connect to the env server and load the taskset client-side."""
|
||||
get_logger().debug(f"Connecting {self.name} to env server {self.address}")
|
||||
self._env_client = EnvClient(address=self.address)
|
||||
# The server may still be coming up (the launcher spawns it concurrently with
|
||||
# the orchestrator), so poll until it answers.
|
||||
await self.env_client.wait_for_server_startup(timeout=ENV_SERVER_STARTUP_TIMEOUT)
|
||||
if self.config.is_legacy:
|
||||
info = await self.env_client.info()
|
||||
self.num_tasks = info.num_tasks
|
||||
self.requires_group_scoring = info.requires_group_scoring
|
||||
taskset = vf.load_taskset(self.config.env.taskset)
|
||||
if type(taskset).INFINITE:
|
||||
self.tasks = iter(taskset.load())
|
||||
self.num_tasks = None
|
||||
else:
|
||||
taskset = vf.load_taskset(self.config.env.taskset)
|
||||
if type(taskset).INFINITE:
|
||||
self.tasks = iter(taskset.load())
|
||||
self.num_tasks = None
|
||||
else:
|
||||
# Materialize off the event loop — load() may pull a dataset.
|
||||
materialized = await asyncio.to_thread(lambda: list(taskset.load()))
|
||||
self.tasks = iter(materialized)
|
||||
self.num_tasks = len(materialized)
|
||||
# Materialize off the event loop — load() may pull a dataset.
|
||||
materialized = await asyncio.to_thread(lambda: list(taskset.load()))
|
||||
self.tasks = iter(materialized)
|
||||
self.num_tasks = len(materialized)
|
||||
num_tasks = self.num_tasks if self.num_tasks is not None else "infinite"
|
||||
get_logger().info(f"Env {self.name} ready: num_tasks={num_tasks} group_scoring={self.requires_group_scoring}")
|
||||
get_logger().info(f"Env {self.name} ready: num_tasks={num_tasks}")
|
||||
|
||||
def _sampling(self, cache_salt: str | None) -> vf.SamplingConfig:
|
||||
sampling = {**self.sampling_args}
|
||||
@@ -110,17 +101,13 @@ class Env:
|
||||
client: vf.ClientConfig,
|
||||
model_name: str,
|
||||
cache_salt: str | None,
|
||||
task_data: dict | None = None,
|
||||
task_idx: int | None = None,
|
||||
task_data: dict,
|
||||
) -> list[Rollout]:
|
||||
"""Run one episode; return its typed Traces. A v1 env takes the task itself
|
||||
(``task_data``); the legacy bridge is addressed by dataset row (``task_idx``).
|
||||
A zero-trace episode raises (the dispatcher synthesizes the error marker); a
|
||||
not-``ok`` episode marks its clean traces failed so partial episodes never
|
||||
train."""
|
||||
"""Run one episode; return its typed Traces. A zero-trace episode raises (the
|
||||
dispatcher synthesizes the error marker); a not-``ok`` episode marks its clean
|
||||
traces failed so partial episodes never train."""
|
||||
episode = await self.env_client.run(
|
||||
task_data=task_data,
|
||||
task_idx=task_idx,
|
||||
client=client,
|
||||
model=model_name,
|
||||
sampling=self._sampling(cache_salt),
|
||||
@@ -140,19 +127,6 @@ class Env:
|
||||
rollout.ok = False
|
||||
return rollouts
|
||||
|
||||
async def run_group(
|
||||
self, client: vf.ClientConfig, task_idx: int, model_name: str, group_size: int, cache_salt: str | None
|
||||
) -> list[Rollout]:
|
||||
"""Run a group of rollouts for ``task_idx`` (group-scoring envs); return typed Traces."""
|
||||
wires = await self.env_client.run_group(
|
||||
task_idx=task_idx,
|
||||
n=group_size,
|
||||
client=client,
|
||||
model=model_name,
|
||||
sampling=self._sampling(cache_salt),
|
||||
)
|
||||
return [ROLLOUT_TYPE.model_construct(**dict(wire)) for wire in wires]
|
||||
|
||||
|
||||
class TrainEnv(Env):
|
||||
config: TrainSourceConfig
|
||||
@@ -175,15 +149,11 @@ class EvalEnv(Env):
|
||||
async def start(self) -> None:
|
||||
await super().start()
|
||||
n = self.config.num_examples
|
||||
if self.tasks is None: # legacy: the dataset lives on the server — address it by row
|
||||
count = self.num_tasks if n < 0 else min(n, self.num_tasks)
|
||||
self.examples = [{"task_idx": i} for i in range(count)]
|
||||
return
|
||||
if self.num_tasks is None and n < 0:
|
||||
raise ValueError(f"Eval env {self.name} has an infinite taskset — set num_examples to bound it")
|
||||
# A fixed eval set, pulled off the tasks once and reused every epoch.
|
||||
tasks = list(self.tasks) if n < 0 else list(islice(self.tasks, n))
|
||||
self.examples = [{"task_idx": task.data.idx, "task": task} for task in tasks]
|
||||
self.examples = [{"task": task} for task in tasks]
|
||||
|
||||
|
||||
EnvT = TypeVar("EnvT", bound=Env)
|
||||
|
||||
@@ -63,15 +63,13 @@ class EvalSink:
|
||||
"""One entry per accumulating ``(env, eval_step)`` batch:
|
||||
``(env_name, eval_step, batch_count, expected, buffered)``.
|
||||
``batch_count`` is finalized-group episodes in ``pending_batches``;
|
||||
``buffered`` is partial-group episode arrivals from non-group-scoring envs."""
|
||||
``buffered`` is partial-group episode arrivals."""
|
||||
batch_counts: dict[tuple[str, int], int] = dict(self.pending_batch_episodes)
|
||||
buffered: dict[tuple[str, int], int] = {}
|
||||
for group_id, rollouts in self.pending_groups.items():
|
||||
if not rollouts:
|
||||
continue
|
||||
env_name = rollouts[0].env_name
|
||||
if self.eval_envs.get(env_name).requires_group_scoring:
|
||||
continue
|
||||
bkey = (env_name, rollouts[0].eval_step)
|
||||
buffered[bkey] = buffered.get(bkey, 0) + self.pending_group_episodes.get(group_id, 0)
|
||||
return [
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
"""EvalSource: trigger-driven, finite-per-epoch pull of eval examples.
|
||||
|
||||
The orchestrator pokes ``trigger(step)`` after each ship + once at
|
||||
startup; the dispatcher pulls via ``next_example(available_permits)``
|
||||
until ``bool(source) == False``. Constructed only when eval is
|
||||
configured."""
|
||||
startup; the dispatcher pulls via ``next_example()`` until
|
||||
``bool(source) == False``. Constructed only when eval is configured."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -68,16 +67,10 @@ class EvalSource:
|
||||
self.queue.append(row)
|
||||
return fired
|
||||
|
||||
def next_example(self, available_permits: int) -> dict | None:
|
||||
"""Pop the next eval example if the head's permit cost fits in
|
||||
``available_permits``; otherwise leave it for a later call."""
|
||||
def next_example(self) -> dict | None:
|
||||
"""Pop the next eval example, or ``None`` when the queue is empty."""
|
||||
if not self.queue:
|
||||
return None
|
||||
head = self.queue[0]
|
||||
env = self.eval_envs.get(head["env_name"])
|
||||
cost = env.config.group_size if env.requires_group_scoring else 1
|
||||
if cost > available_permits:
|
||||
return None
|
||||
return self.queue.popleft()
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
|
||||
@@ -271,7 +271,7 @@ class EpisodeMetrics:
|
||||
|
||||
def episodes(self) -> list[list[Rollout]]:
|
||||
"""The subset's rollouts grouped into their episodes. A rollout without an
|
||||
``episode_id`` (legacy envs, synthesized error markers) is its own episode."""
|
||||
``episode_id`` (synthesized error markers) is its own episode."""
|
||||
grouped: dict[str, list[Rollout]] = {}
|
||||
for r in self.rollouts:
|
||||
grouped.setdefault(r.episode_id or r.id, []).append(r)
|
||||
|
||||
@@ -27,7 +27,6 @@ import time
|
||||
import uuid
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import tomli_w
|
||||
import verifiers.v1 as vf
|
||||
from modelexpress import p2p_pb2
|
||||
from modelexpress.client import MxClient
|
||||
@@ -37,7 +36,7 @@ if TYPE_CHECKING:
|
||||
from transformers.tokenization_utils import PreTrainedTokenizer
|
||||
|
||||
from prime_rl.orchestrator.ckpt import CheckpointManager
|
||||
from prime_rl.transport.base import TrainingBatchSender
|
||||
from prime_rl.transport.base import MicroBatchSender
|
||||
from prime_rl.utils.client import InferencePool
|
||||
from prime_rl.utils.monitor.base import Monitor
|
||||
import prime_rl._compat # noqa: F401 — patch ring_flash_attn compat before transitive imports
|
||||
@@ -49,6 +48,7 @@ from prime_rl.orchestrator.eval_sink import EvalSink
|
||||
from prime_rl.orchestrator.eval_source import EvalSource
|
||||
from prime_rl.orchestrator.filters import setup_filters
|
||||
from prime_rl.orchestrator.inference_metrics import InferenceMetricsCollector
|
||||
from prime_rl.orchestrator.packing import BatchPacker
|
||||
from prime_rl.orchestrator.patches import (
|
||||
monkey_patch_chat_completion_logprobs,
|
||||
monkey_patch_oai_iterable_types,
|
||||
@@ -74,10 +74,9 @@ from prime_rl.orchestrator.utils import (
|
||||
from prime_rl.orchestrator.watcher import WeightWatcher
|
||||
from prime_rl.trainer.model import setup_tokenizer
|
||||
from prime_rl.trainer.rl.broadcast.nixl.model_express import ModelExpressSession
|
||||
from prime_rl.transport import TrainingBatch, setup_training_batch_sender
|
||||
from prime_rl.transport import setup_micro_batch_sender
|
||||
from prime_rl.utils.async_utils import EventLoopLagMonitor, EventLoopLagStats, safe_cancel
|
||||
from prime_rl.utils.client import init_nccl_broadcast, init_nixl_broadcast
|
||||
from prime_rl.utils.config import to_toml_dict
|
||||
from prime_rl.utils.heartbeat import Heartbeat
|
||||
from prime_rl.utils.logger import format_time, get_logger, setup_logger
|
||||
from prime_rl.utils.monitor import setup_monitor
|
||||
@@ -129,7 +128,8 @@ class Orchestrator:
|
||||
tokenizer: PreTrainedTokenizer
|
||||
policy_inference: InferencePool
|
||||
monitor: Monitor
|
||||
sender: TrainingBatchSender
|
||||
sender: MicroBatchSender | None
|
||||
packer: BatchPacker
|
||||
train_envs: TrainEnvs
|
||||
train_source: TrainSource
|
||||
train_sink: TrainSink
|
||||
@@ -205,12 +205,6 @@ class Orchestrator:
|
||||
config = self.config
|
||||
set_default_executor()
|
||||
|
||||
# Persist the resolved config alongside the run
|
||||
config_dir = config.output_dir / "control"
|
||||
config_dir.mkdir(parents=True, exist_ok=True)
|
||||
with open(config_dir / "orch.toml", "wb") as f:
|
||||
tomli_w.dump(to_toml_dict(config), f)
|
||||
|
||||
get_logger().info(f"Initializing tokenizer ({config.tokenizer})")
|
||||
self.tokenizer = setup_tokenizer(config.tokenizer)
|
||||
|
||||
@@ -218,8 +212,7 @@ class Orchestrator:
|
||||
# references are external endpoints — each env's Algorithm builds its
|
||||
# own pools in ``setup()`` below.
|
||||
get_logger().info(
|
||||
f"Initializing policy inference pool (base_url={', '.join(config.model.client.base_url)}, "
|
||||
f"model={config.model.name})"
|
||||
f"Initializing policy inference pool (base_url={config.model.client.base_url}, model={config.model.name})"
|
||||
)
|
||||
self.renderer, self.policy_inference = await setup_policy_inference_pool(
|
||||
config=config, tokenizer=self.tokenizer
|
||||
@@ -333,9 +326,6 @@ class Orchestrator:
|
||||
self.model_express.publish()
|
||||
await asyncio.to_thread(self.model_express.set_status, p2p_pb2.SOURCE_STATUS_INITIALIZING)
|
||||
|
||||
get_logger().info(f"Initializing training batch sender ({config.rollout_transport})")
|
||||
self.sender = setup_training_batch_sender(config.output_dir, config.rollout_transport)
|
||||
|
||||
self.lora_name = config.model.lora.name if config.model.lora else None
|
||||
|
||||
self.train_source = TrainSource(self.train_envs)
|
||||
@@ -350,16 +340,31 @@ class Orchestrator:
|
||||
else:
|
||||
get_logger().info("Training from scratch")
|
||||
|
||||
# Sync inference to the incoming policy before the first step when resuming or when using
|
||||
# an in-memory transport, which rendezvouses with the trainer's startup broadcast.
|
||||
if self.resume_step is not None or config.weight_broadcast.type in ("nccl", "nixl"):
|
||||
self.packer = BatchPacker(config)
|
||||
if config.bench:
|
||||
# Bench runs have no trainer: nothing consumes shipped batches, and the
|
||||
# ZMQ sender's READY barrier would block forever.
|
||||
self.sender = None
|
||||
else:
|
||||
get_logger().info(f"Initializing micro batch sender ({config.rollout_transport})")
|
||||
self.sender = setup_micro_batch_sender(
|
||||
config.output_dir, config.num_train_workers, self.progress.step, config.rollout_transport
|
||||
)
|
||||
|
||||
# Sync inference to the incoming policy before the first step, rendezvousing
|
||||
# with the trainer's startup broadcast (v{resume_step} on resume, v0 from
|
||||
# scratch). Bench runs have no trainer, so there is no broadcast to wait for.
|
||||
if not config.bench:
|
||||
sync_version = self.resume_step if self.resume_step is not None else 0
|
||||
if config.weight_broadcast.type == "nixl":
|
||||
weights_path = None
|
||||
else:
|
||||
check_exists = config.weight_broadcast.type == "filesystem"
|
||||
# Without a ckpt block, fall back to a default timeout instead of not waiting at all.
|
||||
wait_timeout = config.ckpt.wait_for_weights_timeout if config.ckpt else STARTUP_WEIGHT_WAIT_TIMEOUT_S
|
||||
# The trainer's startup broadcast is always coming, so wait for it
|
||||
# rather than failing immediately when the directory is not there yet.
|
||||
wait_timeout = (config.ckpt.wait_for_weights_timeout if config.ckpt else None) or (
|
||||
STARTUP_WEIGHT_WAIT_TIMEOUT_S
|
||||
)
|
||||
weights_path = get_weight_dir(
|
||||
config.output_dir, sync_version, check_exists=check_exists, wait_timeout=wait_timeout
|
||||
)
|
||||
@@ -645,7 +650,11 @@ class Orchestrator:
|
||||
records = [r.to_record() for r in effective]
|
||||
await asyncio.to_thread(save_rollouts, records, get_trace_path(config.output_dir, step, "train", "effective"))
|
||||
|
||||
await self.sender.send(TrainingBatch(examples=batch.samples, step=step))
|
||||
pack_start_time = time.perf_counter()
|
||||
micro_batch_grid = await asyncio.to_thread(self.packer.pack, batch.samples)
|
||||
pack_time = time.perf_counter() - pack_start_time
|
||||
if self.sender is not None:
|
||||
await self.sender.send(micro_batch_grid)
|
||||
self.progress.step += 1
|
||||
self.update_dispatch_gate()
|
||||
# Checkpoint the step we just shipped (resume point: continue at step + 1).
|
||||
@@ -679,6 +688,7 @@ class Orchestrator:
|
||||
"progress/total_rollouts": self.progress.total_samples,
|
||||
"progress/total_tasks": self.progress.total_problems,
|
||||
"time/step": step_time,
|
||||
"time/pack": pack_time,
|
||||
"time/save_ckpt": save_ckpt_time,
|
||||
"time/wait_for_policy": self.wait_for_policy_time,
|
||||
"step": step,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
from transformers import AutoConfig
|
||||
|
||||
from prime_rl.configs.orchestrator import OrchestratorConfig
|
||||
from prime_rl.trainer.batch import build_bin_cost, prepare_batch
|
||||
from prime_rl.transport.types import MicroBatch, TrainingSample
|
||||
from prime_rl.utils.logger import get_logger
|
||||
|
||||
|
||||
class BatchPacker:
|
||||
"""Bin-packs a step's training samples into one micro-batch list per trainer DP rank."""
|
||||
|
||||
def __init__(self, config: OrchestratorConfig):
|
||||
self.seq_len = config.seq_len
|
||||
self.num_train_workers = config.num_train_workers
|
||||
self.pad_to_multiple_of = config.pad_to_multiple_of
|
||||
try:
|
||||
model_config = AutoConfig.from_pretrained(
|
||||
config.model.name, trust_remote_code=config.tokenizer.trust_remote_code
|
||||
)
|
||||
except Exception as e:
|
||||
get_logger().warning(
|
||||
f"Could not load model config for {config.model.name} ({e}) - "
|
||||
"packing balances by token count instead of estimated FLOPs"
|
||||
)
|
||||
model_config = None
|
||||
self.bin_cost = build_bin_cost(model_config)
|
||||
|
||||
def pack(self, samples: list[TrainingSample]) -> list[list[MicroBatch]]:
|
||||
return prepare_batch(
|
||||
rollouts=samples,
|
||||
seq_len=self.seq_len,
|
||||
num_train_workers=self.num_train_workers,
|
||||
bin_cost=self.bin_cost,
|
||||
pad_to_multiple_of=self.pad_to_multiple_of,
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user