Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef42886edc | ||
|
|
ed05a1418d | ||
|
|
1ef8f1a843 | ||
|
|
e229a286f2 | ||
|
|
2ffe374e02 | ||
|
|
bbb90a1b41 | ||
|
|
9f0d41e23d | ||
|
|
e0638c7eb6 | ||
|
|
0b583306eb | ||
|
|
d612e23c1d | ||
|
|
d135ed4c90 | ||
|
|
1fd2d732c2 | ||
|
|
6a9969e61a |
@@ -32,11 +32,22 @@ group_size = 8
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 768
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "alphabet-sort"
|
||||
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
[orchestrator.train.source.env.taskset.task]
|
||||
power_per_turn = false
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
|
||||
@@ -19,11 +19,19 @@ batch_size = 128
|
||||
group_size = 8
|
||||
seq_len = 8192
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "hendrycks-math"
|
||||
env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.model]
|
||||
seq_len = 16384
|
||||
|
||||
@@ -22,11 +22,17 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -40,11 +40,17 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
env.taskset = { id = "wiki-search-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
|
||||
@@ -21,11 +21,17 @@ name = "PrimeIntellect/Qwen3-1.7B-Wordle-SFT"
|
||||
batch_size = 128
|
||||
group_size = 8
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "wordle"
|
||||
env.taskset = { id = "wordle-v1" }
|
||||
env.player.harness = { id = "null" }
|
||||
env.player.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.player.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 1024
|
||||
|
||||
@@ -22,11 +22,25 @@ group_size = 8
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 384
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "alphabet-sort"
|
||||
env.taskset = { id = "alphabet-sort-v1", min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, task = { similarity_power = 4, power_per_turn = false } }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
min_turns = 2
|
||||
max_turns = 2
|
||||
min_names_per_turn = 1
|
||||
max_names_per_turn = 3
|
||||
|
||||
[orchestrator.train.source.env.taskset.task]
|
||||
similarity_power = 4
|
||||
power_per_turn = false
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
|
||||
|
||||
@@ -26,11 +26,17 @@ name = "r8-1e-4"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
enable_lora = true
|
||||
|
||||
@@ -25,11 +25,17 @@ name = "r8-1e-4"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
enable_lora = true
|
||||
|
||||
@@ -25,11 +25,17 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.7
|
||||
|
||||
@@ -14,11 +14,17 @@ lr = 3e-5
|
||||
[train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[train.env]]
|
||||
[[train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[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
|
||||
|
||||
@@ -37,11 +37,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -50,11 +56,17 @@ num_examples = 16
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -43,11 +43,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -56,11 +62,17 @@ num_examples = 16
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -23,11 +23,17 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
|
||||
|
||||
@@ -22,11 +22,17 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference]
|
||||
|
||||
|
||||
@@ -18,11 +18,22 @@ name = "Qwen/Qwen3-4B-Instruct-2507"
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "alphabet-sort"
|
||||
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
[orchestrator.train.source.env.taskset.task]
|
||||
power_per_turn = false
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 768
|
||||
|
||||
@@ -18,22 +18,36 @@ batch_size = 512
|
||||
group_size = 8
|
||||
seq_len = 8192
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "hendrycks-math"
|
||||
env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 50
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "aime2024"
|
||||
env.taskset = { id = "aime24-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
group_size = 32
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime24-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer]
|
||||
|
||||
[trainer.model]
|
||||
|
||||
@@ -18,11 +18,17 @@ name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-SFT"
|
||||
batch_size = 128
|
||||
group_size = 16
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
@@ -23,11 +23,17 @@ oversampling_factor = 2.0
|
||||
type = "zero_advantage"
|
||||
enforce = true
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
env.taskset = { id = "wiki-search-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
@@ -18,11 +18,17 @@ name = "PrimeIntellect/Qwen3-1.7B-Wordle-SFT"
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "wordle"
|
||||
env.taskset = { id = "wordle-v1" }
|
||||
env.player.harness = { id = "null" }
|
||||
env.player.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.player.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 1024
|
||||
|
||||
@@ -20,11 +20,18 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 64
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "color-codeword"
|
||||
env.taskset = { id = "color-codeword-v1", images_per_turn = 1 }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "color-codeword-v1"
|
||||
images_per_turn = 1
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer]
|
||||
|
||||
|
||||
@@ -24,11 +24,22 @@ type = "echo"
|
||||
[orchestrator.algo.roles.user]
|
||||
alpha = 0.1
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "alphabet-sort"
|
||||
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
[orchestrator.train.source.env.taskset.task]
|
||||
power_per_turn = false
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
@@ -21,11 +21,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -34,11 +40,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -21,11 +21,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -34,11 +40,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -31,22 +31,34 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text-grpo"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text-opd"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.env.algo]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.source.algo]
|
||||
type = "opd"
|
||||
|
||||
[orchestrator.train.env.algo.teacher]
|
||||
[orchestrator.train.source.algo.teacher]
|
||||
name = "PrimeIntellect/Qwen3-0.6B-Reverse-Text-RL"
|
||||
base_url = ["http://localhost:8001/v1"]
|
||||
|
||||
@@ -57,11 +69,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -33,11 +33,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -46,11 +52,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -33,11 +33,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -46,11 +52,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-4
|
||||
|
||||
+32
-12
@@ -21,13 +21,23 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "kuhn-poker"
|
||||
env.taskset = { id = "kuhn-poker-v1" }
|
||||
env.player0.harness = { id = "null" }
|
||||
env.player0.runtime = { type = "subprocess" }
|
||||
env.player1.harness = { id = "null" }
|
||||
env.player1.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
|
||||
[orchestrator.train.source.env.player0.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.player0.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.source.env.player1.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.player1.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -36,13 +46,23 @@ num_examples = 16
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 512
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "kuhn-poker"
|
||||
env.taskset = { id = "kuhn-poker-v1" }
|
||||
env.player0.harness = { id = "null" }
|
||||
env.player0.runtime = { type = "subprocess" }
|
||||
env.player1.harness = { id = "null" }
|
||||
env.player1.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
|
||||
[orchestrator.eval.source.env.player0.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.player0.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval.source.env.player1.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.player1.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -29,11 +29,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -42,11 +48,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -38,11 +38,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -51,11 +57,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -38,11 +38,17 @@ name = "prime-qwen3"
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 1
|
||||
@@ -51,11 +57,17 @@ num_examples = 128
|
||||
[orchestrator.eval.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 1e-4
|
||||
|
||||
Vendored
+1
-1
Submodule deps/renderers updated: bdb96b0c84...d4707862ac
Vendored
+1
-1
Submodule deps/research-environments updated: 6a2dee6fcd...21a284618f
Vendored
+1
-1
Submodule deps/verifiers updated: d0bb0ffe53...dd2950909b
+113
-20
@@ -17,6 +17,7 @@ This page covers the math and the configurable algorithmic components: the algor
|
||||
- [Custom Loss](#custom-loss)
|
||||
- [Advantage](#advantage)
|
||||
- [Default Advantage](#default-advantage)
|
||||
- [Hierarchical GRPO](#hierarchical-grpo)
|
||||
- [Self-Play Advantage (RAE)](#self-play-advantage-rae)
|
||||
- [Authoring an Algorithm](#authoring-an-algorithm)
|
||||
- [Reference Scoring](#reference-scoring)
|
||||
@@ -69,6 +70,7 @@ type = "grpo" # the default
|
||||
| `grpo` | policy | `rl` on actions | Standard group-relative RL. |
|
||||
| `max_rl` | policy | `rl` on actions | MaxRL ([arXiv:2602.02710](https://arxiv.org/abs/2602.02710)): GRPO's centered reward normalized by the group **mean** instead of the standard deviation — the gradient is unbiased for the order-`group_size` truncation of the maximum-likelihood objective, upweighting hard examples like `1/p`. |
|
||||
| `rae` | policy | `rl` on actions | RAE (SPIRAL, [arXiv:2506.24119](https://arxiv.org/abs/2506.24119)): reward minus a per-agent EMA baseline of that agent's own rewards — the estimator for multi-agent self-play envs, where the group mean would mix the agents' opposite reward scales. See [Self-Play Advantage](#self-play-advantage-rae). |
|
||||
| `hierarchical_grpo` | policy | `rl` on actions | GRPO for proposer-solver envs. Solvers are compared only with attempts on the same proposed problem; proposers are compared with the other proposals in the group. See [Hierarchical GRPO](#hierarchical-grpo). |
|
||||
| `opd` | policy | `ref_kl` on actions | On-policy distillation ([Thinking Machines](https://thinkingmachines.ai/blog/on-policy-distillation/)): the policy samples, per-token reverse KL against a reference model as the gradient signal. Needs a `teacher`. |
|
||||
| `sft` | *(the teacher)* | `ce` on actions | Hard distillation: a frozen model generates rollouts, the policy trains with CE on its tokens. Needs a frozen `sampling.source` (the teacher it samples from). |
|
||||
| `opsd` | policy | `ref_kl` on actions | SDFT ([arXiv:2601.19897](https://arxiv.org/abs/2601.19897)): the model is its own reference, conditioned on an expert demonstration. The teacher *is* the live policy (the paper's setting, no extra deployment) — no model to configure. |
|
||||
@@ -98,7 +100,9 @@ Echo also takes an optional user-supplied token filter that narrows the role sel
|
||||
```toml
|
||||
[orchestrator.algo.filter]
|
||||
import_path = "my_module.drop_warnings"
|
||||
kwargs = { patterns = ["WARNING"] }
|
||||
|
||||
[orchestrator.algo.filter.kwargs]
|
||||
patterns = ["WARNING"]
|
||||
```
|
||||
|
||||
```python
|
||||
@@ -118,19 +122,33 @@ Both components resolve per environment. Each env inherits `[orchestrator.algo]`
|
||||
[orchestrator.algo]
|
||||
type = "grpo"
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
name = "math"
|
||||
taskset = { id = "math-v1" }
|
||||
harness = { id = "null" }
|
||||
runtime = { type = "subprocess" }
|
||||
# inherits the top-level grpo
|
||||
[[orchestrator.train.source]]
|
||||
name = "math" # inherits the top-level grpo
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "terminal"
|
||||
taskset = { id = "terminal-v1" }
|
||||
harness = { id = "bash" }
|
||||
runtime = { type = "subprocess" }
|
||||
algo = { type = "echo" } # this env runs its own algorithm
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "terminal-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
# this env runs its own algorithm
|
||||
[orchestrator.train.source.algo]
|
||||
type = "echo"
|
||||
```
|
||||
|
||||
### The Algorithm Classes
|
||||
@@ -143,6 +161,7 @@ At runtime, each env's resolved config builds two objects: a `Sampler` (`prime_r
|
||||
| `echo` | `EchoAlgorithm` | `score_rollout`: weighted ce on observation tokens; `score_group`: group-norm credit (inherited) |
|
||||
| `max_rl` | `MaxRLAlgorithm` | `score_group`: mean-normalized group credit |
|
||||
| `rae` | `RAEAlgorithm` | `score_group`: per-agent EMA-baseline credit |
|
||||
| `hierarchical_grpo` | `HierarchicalGRPOAlgorithm` | `score_group`: GRPO baseline per episode for solvers, per group for the proposer |
|
||||
| `opd` | `OPDAlgorithm` | `score_rollout`: own-context prefill under the teacher |
|
||||
| `opsd` | `OPSDAlgorithm` | `score_rollout`: demo-conditioned prefill under the live policy |
|
||||
| `sft` | `SFTDistillAlgorithm` | `score_group`: group-norm credit (feeds filters) |
|
||||
@@ -179,7 +198,7 @@ $$
|
||||
\mathcal{L} = \frac{\sum \mathcal{L}_{rl}}{N_{rl}} + \frac{\sum \mathcal{L}_{ce}}{N_{ce}} + \frac{\sum \mathcal{L}_{ref\_kl}}{N_{ref\_kl}}
|
||||
$$
|
||||
|
||||
- `rl` — the configured RL loss (`[trainer.loss]`): DPPO + KL by default, or a [custom loss](#custom-loss). Fed by the advantage-assigning algorithms (`grpo`, `max_rl`, `rae`, and `echo`'s action tokens).
|
||||
- `rl` — the configured RL loss (`[trainer.loss]`): DPPO + KL by default, or a [custom loss](#custom-loss). Fed by the advantage-assigning algorithms (`grpo`, `max_rl`, `rae`, `hierarchical_grpo`, and `echo`'s action tokens).
|
||||
- `ce` — masked NLL. Used for frozen-model tokens (`sft`) and env-observation tokens (`echo`).
|
||||
- `ref_kl` — the per-token reverse KL to a reference model ($\log \pi_{\text{ref}} - \log \pi$) as the policy-gradient signal, importance-ratio corrected with a one-sided trust region (`opd`, `opsd`). Requires `ref_logprobs` from a [reference scoring](#reference-scoring); the scoring model must be a vLLM server (it's the only one that exposes `prompt_logprobs`).
|
||||
|
||||
@@ -250,7 +269,9 @@ Wire it up:
|
||||
[trainer.loss]
|
||||
type = "custom"
|
||||
import_path = "my_module.ppo_clip_loss"
|
||||
kwargs = { clip_eps = 0.2 }
|
||||
|
||||
[trainer.loss.kwargs]
|
||||
clip_eps = 0.2
|
||||
```
|
||||
|
||||
The dataclasses:
|
||||
@@ -282,6 +303,7 @@ The per-token training signal is set by `algo.type` and the [algorithm](#the-alg
|
||||
| `grpo` | `rl` | Group-norm: reward minus per-group baseline, optional length penalty. |
|
||||
| `max_rl` | `rl` | Mean-normalized group credit (maximum-likelihood RL). |
|
||||
| `rae` | `rl` | Reward minus a per-agent EMA baseline (SPIRAL's role-conditioned advantage estimation) — for multi-agent self-play envs. |
|
||||
| `hierarchical_grpo` | `rl` | GRPO for proposer-solver envs: solvers are compared within one proposed problem, while proposers are compared across proposals. |
|
||||
| `echo` | `rl` + `ce` | Group-norm on action tokens, plus weighted CE on env-provided tokens selected by message role (each role's `alpha` is its ECHO λ), optionally narrowed by a user filter. |
|
||||
| `opd` | `ref_kl` | On-policy distillation: per-token reverse KL to a reference model (`teacher`, an inline frozen hosted model), evaluated in the trainer from shipped reference logprobs. No credit — rollouts keep `advantages = None` (advantage-based filters never fire) and ship no advantage stream; `group_size` only fans out sampling. |
|
||||
| `opsd` | `ref_kl` | SDFT: per-token reverse KL to a demo-conditioned reference. No credit — rollouts keep `advantages = None` (advantage-based filters never fire) and ship no advantage stream. |
|
||||
@@ -303,6 +325,67 @@ type = "grpo"
|
||||
type = "linear"
|
||||
```
|
||||
|
||||
### Hierarchical GRPO
|
||||
|
||||
GRPO gives each rollout its reward minus the average reward of comparable rollouts. In an ordinary single-agent group, every rollout answers the same task, so one group average is enough.
|
||||
|
||||
A proposer-solver env is different. Starting from one source task, it produces several proposed problems, then runs several solver attempts on each problem:
|
||||
|
||||
```text
|
||||
one source task
|
||||
├── proposed problem A
|
||||
│ ├── proposer trace
|
||||
│ ├── solver attempt 1
|
||||
│ └── solver attempt 2
|
||||
└── proposed problem B
|
||||
├── proposer trace
|
||||
├── solver attempt 1
|
||||
└── solver attempt 2
|
||||
```
|
||||
|
||||
The solver attempts for A should not be compared with the solver attempts for B: the two problems may have very different difficulty. Proposer and solver rewards should not be compared either: they measure different jobs.
|
||||
|
||||
`hierarchical_grpo` therefore chooses the average separately for each role:
|
||||
|
||||
| Trace | Compared with | Why |
|
||||
|---|---|---|
|
||||
| Solver | Other solver attempts on the same proposed problem | They attempted the same problem. |
|
||||
| Proposer | Other proposer traces in the group | They started from the same source task and proposed alternatives. |
|
||||
|
||||
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`:
|
||||
|
||||
```toml
|
||||
[orchestrator.algo]
|
||||
type = "hierarchical_grpo"
|
||||
episode_agents = ["solver"]
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "proposer-solver"
|
||||
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"
|
||||
|
||||
[orchestrator.train.source.env.proposer.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.proposer.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.source.env.solver.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.solver.runtime]
|
||||
type = "subprocess"
|
||||
```
|
||||
|
||||
`group_size` controls how many problems are proposed from each source task. `env.n` controls how many solvers attempt each proposed problem. If a comparison contains only one trace—for example, a solver when `env.n = 1`—its advantage is zero and the zero-advantage filter removes it.
|
||||
|
||||
This algorithm is accepted only for proposer-solver envs. Use the env's `train_proposer` and `train_solver` settings if you want to train only one role.
|
||||
|
||||
### Self-Play Advantage (RAE)
|
||||
|
||||
Group-relative baselines assume the group is exchangeable attempts by one agent. A multi-agent self-play env breaks that: one episode yields one trace per agent, all trainable, and in a zero-sum game the rewards sum to ~0 whatever the policy does — the group mean carries no information, and centering against it converts any structural asymmetry (a first-mover edge) into permanent credit for one agent.
|
||||
@@ -314,13 +397,23 @@ Group-relative baselines assume the group is exchangeable attempts by one agent.
|
||||
type = "rae"
|
||||
decay = 0.95
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "kuhn-poker"
|
||||
env.taskset = { id = "kuhn-poker-v1" }
|
||||
env.player0.harness = { id = "null" }
|
||||
env.player0.runtime = { type = "subprocess" }
|
||||
env.player1.harness = { id = "null" }
|
||||
env.player1.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "kuhn-poker-v1"
|
||||
|
||||
[orchestrator.train.source.env.player0.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.player0.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.source.env.player1.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.player1.runtime]
|
||||
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.
|
||||
|
||||
+44
-21
@@ -17,7 +17,7 @@ Every `prime-rl` entrypoint uses [`pydantic-config`](https://github.com/PrimeInt
|
||||
- [Optional Sub-Configs](#optional-sub-configs)
|
||||
- [None](#none)
|
||||
- [Discriminated Unions](#discriminated-unions)
|
||||
- [Environments](#environments-orchestratortrainenv)
|
||||
- [Environments](#environments)
|
||||
- [Environment Variables](#environment-variables)
|
||||
- [Examples](#examples)
|
||||
|
||||
@@ -55,7 +55,7 @@ CLI flags mirror the TOML tree using dots:
|
||||
|
||||
> Field names are snake_case in TOML (`max_model_len`) and kebab-case on the CLI (`--max-model-len`).
|
||||
|
||||
> Renamed fields keep their old name as a validation alias — e.g. `rollouts_per_example` is still accepted in TOML and CLI after being renamed to `group_size`. Mixing the two names across sources is safe.
|
||||
> A renamed field keeps no alias for its old name: the old spelling fails as an unknown key rather than being silently translated.
|
||||
|
||||
## Inspecting and Validating
|
||||
|
||||
@@ -93,20 +93,23 @@ uv run rl @ rl.toml --trainer.model.lora.target-modules '["q_proj", "k_proj", "v
|
||||
target_modules = ["q_proj", "k_proj", "v_proj"]
|
||||
```
|
||||
|
||||
Overlay TOMLs **replace** lists wholesale — an overlay that wants to add one item must still spell out the full list. For arrays of tables (e.g. environments), see [Environments](#environments-orchestratortrainenv).
|
||||
Overlay TOMLs **replace** lists wholesale — an overlay that wants to add one item must still spell out the full list. For arrays of tables, see [Environments](#environments).
|
||||
|
||||
### Dicts
|
||||
|
||||
CLI takes a JSON literal. TOML uses a table or inline-table. CLI dicts deep-merge with TOML dicts — CLI keys win on conflict but don't wipe the file's keys:
|
||||
CLI takes a JSON literal. TOML uses a table. CLI dicts deep-merge with TOML dicts — CLI keys win on conflict but don't wipe the file's keys:
|
||||
|
||||
```bash
|
||||
uv run rl @ rl.toml --orchestrator.train.env.0.args \
|
||||
uv run rl @ rl.toml --orchestrator.train.source.0.args \
|
||||
'{"dataset_name": "openai/gsm8k", "dataset_subset": "main"}'
|
||||
```
|
||||
|
||||
```toml
|
||||
[[orchestrator.train.env]]
|
||||
args = { dataset_name = "openai/gsm8k", dataset_subset = "main" }
|
||||
[[orchestrator.train.source]]
|
||||
|
||||
[orchestrator.train.source.args]
|
||||
dataset_name = "openai/gsm8k"
|
||||
dataset_subset = "main"
|
||||
```
|
||||
|
||||
### Optional Sub-Configs
|
||||
@@ -142,30 +145,50 @@ mu = 0.95
|
||||
|
||||
Omit `type` to keep the default variant.
|
||||
|
||||
### Environments (`[[orchestrator.train.env]]`)
|
||||
### Environments
|
||||
|
||||
Training environments are an array of tables — set one per env, optionally with sampling weights:
|
||||
Training and evaluation sources are arrays of tables. Set one source per environment; training sources can optionally carry sampling weights:
|
||||
|
||||
```toml
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "gsm8k"
|
||||
env.taskset = { id = "gsm8k-v1", split = "train" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
ratio = 3 # 75% of batches
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "gsm8k-v1"
|
||||
split = "train"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
ratio = 1 # default — 25% of batches
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.eval.source]]
|
||||
name = "gsm8k-eval"
|
||||
env.taskset = { id = "gsm8k-v1", split = "test" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "gsm8k-v1"
|
||||
split = "test"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
```
|
||||
|
||||
`ratio` defaults to `1` (equal weight per env); values are relative weights normalized to probabilities across envs.
|
||||
|
||||
+18
-8
@@ -174,11 +174,17 @@ Every deployment fronts its vLLM engines with a single global router — it list
|
||||
```toml
|
||||
[inference.router] # or [router] for the standalone inference entrypoint
|
||||
type = "llm-d" # "vllm-router" (default) or "llm-d"
|
||||
# llm-d-only knobs (all optional):
|
||||
scorers = { "prefix-cache-scorer" = 3.0, "active-request-scorer" = 2.0 } # base, applied to every profile
|
||||
prefill_scorer_overrides = { "queue-scorer" = 2.0, "kv-cache-utilization-scorer" = 2.0 } # merged onto the P/D prefill profile
|
||||
decode_scorer_overrides = {} # merged onto the P/D decode profile
|
||||
non_cached_tokens = 16 # below this many non-cached prompt tokens, skip remote prefill (P/D)
|
||||
non_cached_tokens = 16 # llm-d only: below this many non-cached prompt tokens, skip remote prefill (P/D)
|
||||
|
||||
# llm-d only: base scorer weights, applied to every profile
|
||||
[inference.router.scorers]
|
||||
"prefix-cache-scorer" = 3.0
|
||||
"active-request-scorer" = 2.0
|
||||
|
||||
# llm-d only: merged onto the P/D prefill profile (decode_scorer_overrides for decode)
|
||||
[inference.router.prefill_scorer_overrides]
|
||||
"queue-scorer" = 2.0
|
||||
"kv-cache-utilization-scorer" = 2.0
|
||||
```
|
||||
|
||||
- **`vllm-router`** (default) — our fork of [vllm-router](https://github.com/PrimeIntellect-ai/router). Knob: `policy`. The only backend supported for single-node (local) deployments.
|
||||
@@ -255,8 +261,12 @@ For configuring various knobs with environment variables, we enable you to confi
|
||||
[inference.deployment]
|
||||
type = "disaggregated"
|
||||
|
||||
prefill_env_vars = {"VLLM_ENABLE_MOE_DP_CHUNK"="0", "VLLM_DEEP_GEMM_WARMUP"="skip"}
|
||||
decode_env_vars = {"VLLM_DEEP_GEMM_WARMUP"="skip"}
|
||||
[inference.deployment.prefill_env_vars]
|
||||
"VLLM_ENABLE_MOE_DP_CHUNK" = "0"
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
|
||||
[inference.deployment.decode_env_vars]
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
```
|
||||
|
||||
These are role-specific and layer on top of [`env_vars`](configuration.md#environment-variables) shared by all inference processes regardless of role.
|
||||
@@ -283,6 +293,6 @@ enable_router_replay = true # this will also auto-set the inference.enable_retur
|
||||
enable_return_routed_experts = true
|
||||
```
|
||||
|
||||
This however is not free, it adds a significant overhead to the HTTP requests as this payload can grow quite large. We reccomend increasing `orchestrator.*.env.num_workers` to allow for more parallelization on the verifiers side.
|
||||
This however is not free, it adds a significant overhead to the HTTP requests as this payload can grow quite large. We reccomend sizing up the env-server pool (`orchestrator.*.source.serve.pool`) to allow for more parallelization on the verifiers side.
|
||||
|
||||
Currently this feature is also not supported with CPU KV cache offload, which can have negative impact on the inference throughput.
|
||||
|
||||
+5
-4
@@ -59,9 +59,9 @@ A condensed view of the knobs you'll most often tune. For trainer-side paralleli
|
||||
| `orchestrator.batch_size` | Tasks per trainer step. |
|
||||
| `orchestrator.group_size` | Rollouts generated per task. |
|
||||
| `orchestrator.max_off_policy_steps` | How many distinct policies may have contributed to one rollout before it's discarded (default 8). The main off-policy dial on long agentic rollouts — bump for throughput, lower for tighter on-policyness. Watch `errored_rollouts` and `mismatch_kl/all/mean` when tuning. |
|
||||
| `[orchestrator.algo]` | Training algorithm — its `type` names it (`grpo` default, `max_rl`, `rae`, `opd`, `opsd`, `sft`, `echo`). See [Algorithms](#algorithms). |
|
||||
| `[[orchestrator.train.env]]` | Training environments. List multiple tables for multi-env training; weight them via `ratio`. See [Configuration § Environments](configuration.md#environments-orchestratortrainenv). |
|
||||
| `[[orchestrator.eval.env]]` + `orchestrator.eval.interval` | Eval environments and cadence (default every 100 steps). |
|
||||
| `[orchestrator.algo]` | Training algorithm — its `type` names it (`grpo` default, `max_rl`, `rae`, `hierarchical_grpo`, `opd`, `opsd`, `sft`, `echo`). See [Algorithms](#algorithms). |
|
||||
| `[[orchestrator.train.source]]` | Training sources. List multiple tables for multi-env training; weight them via `ratio`. See [Configuration § Training sources](configuration.md#training-sources-orchestratortrainsource). |
|
||||
| `[[orchestrator.eval.source]]` + `orchestrator.eval.interval` | Eval environments and cadence (default every 100 steps). |
|
||||
|
||||
**Monitoring:**
|
||||
|
||||
@@ -90,6 +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`) |
|
||||
| `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 |
|
||||
| `opsd` | None — the live policy is its own reference (no deployment) | [SDFT](https://arxiv.org/abs/2601.19897): the model is its own reference conditioned on expert demonstrations |
|
||||
@@ -216,7 +217,7 @@ Checkpointing is split across processes because the orchestrator and trainer can
|
||||
| Process | What's saved | Where |
|
||||
|---|---|---|
|
||||
| Trainer | FSDP-sharded model (DCP), optimizer, scheduler, progress | `<output_dir>/checkpoints/step_N/trainer/` |
|
||||
| Orchestrator | Step counter, total tokens / samples / problems | `<output_dir>/checkpoints/step_N/orchestrator/` |
|
||||
| Orchestrator | Progress, per-env data state | `<output_dir>/checkpoints/step_N/orchestrator/` |
|
||||
| Inference | _nothing_ — re-pushed from the latest checkpoint on restart | n/a |
|
||||
| Trainer (HF weights) | HF-compatible weight snapshot for serving | `<output_dir>/weights/step_N/` |
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ type = "muon"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_rollouts = 512
|
||||
max_inflight_episodes = 512
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "glm-4.5"
|
||||
@@ -93,15 +93,25 @@ num_turns_weight = 0.0
|
||||
# openseeker/redsearcher pre-plug a `reference` judge; declaring `judges` here replaces that
|
||||
# entry wholesale (keep `name`/`question_field`/`choices` in sync with the taskset defaults —
|
||||
# the plugged BC-style prompt is replaced by the reference judge's stock prompt).
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "openseeker"
|
||||
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072] }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] }
|
||||
|
||||
[orchestrator.train.env.env.taskset]
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
skills = ["search"]
|
||||
forward_env = ["SERPER_API_KEY"]
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "openseeker-v1"
|
||||
|
||||
[[orchestrator.train.env.env.taskset.task.judges]]
|
||||
[[orchestrator.train.source.env.taskset.task.judges]]
|
||||
id = "reference"
|
||||
name = "correct"
|
||||
model = "Qwen/Qwen3-235B-A22B-Instruct-2507"
|
||||
@@ -109,22 +119,32 @@ question_field = "question"
|
||||
choices = ["A", "B"]
|
||||
|
||||
# # Metric-only monitor (weight 0): rlm harness-mechanics rubric, judged by GLM-5.2.
|
||||
# [[orchestrator.train.env.env.taskset.task.judges]]
|
||||
# [[orchestrator.train.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "redsearcher"
|
||||
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072] }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] }
|
||||
|
||||
[orchestrator.train.env.env.taskset]
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
skills = ["search"]
|
||||
forward_env = ["SERPER_API_KEY"]
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "redsearcher-v1" # optional `difficulty` filter (easy/medium/hard)
|
||||
|
||||
[[orchestrator.train.env.env.taskset.task.judges]]
|
||||
[[orchestrator.train.source.env.taskset.task.judges]]
|
||||
id = "reference"
|
||||
name = "correct"
|
||||
model = "Qwen/Qwen3-235B-A22B-Instruct-2507"
|
||||
@@ -132,7 +152,7 @@ question_field = "question"
|
||||
choices = ["A", "B"]
|
||||
|
||||
# # Metric-only monitor (weight 0): rlm harness-mechanics rubric, judged by GLM-5.2.
|
||||
# [[orchestrator.train.env.env.taskset.task.judges]]
|
||||
# [[orchestrator.train.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
@@ -144,19 +164,33 @@ choices = ["A", "B"]
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "browsecomp"
|
||||
num_examples = 500 # full set is 1266; cap eval at 500
|
||||
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = 98304 }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] }
|
||||
env.agent.timeout = { rollout = 3600 }
|
||||
|
||||
[orchestrator.eval.env.env.taskset]
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
skills = ["search"]
|
||||
forward_env = ["SERPER_API_KEY"]
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-search"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "browsecomp-v1"
|
||||
task = { judge = { model = "Qwen/Qwen3-235B-A22B-Instruct-2507" } }
|
||||
|
||||
[orchestrator.eval.source.env.taskset.task.judge]
|
||||
model = "Qwen/Qwen3-235B-A22B-Instruct-2507"
|
||||
|
||||
# # Metric-only monitor (weight 0): rlm harness-mechanics rubric, judged by GLM-5.2.
|
||||
# [[orchestrator.eval.env.env.taskset.task.judges]]
|
||||
# [[orchestrator.eval.source.env.taskset.task.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
|
||||
@@ -82,7 +82,7 @@ type = "muon"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_rollouts = 512
|
||||
max_inflight_episodes = 512
|
||||
|
||||
[orchestrator.algo]
|
||||
type = "grpo"
|
||||
@@ -97,11 +97,21 @@ num_turns_weight = 0.1
|
||||
name = "glm-4.5"
|
||||
thinking_retention = "all"
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "scaleswe"
|
||||
env.taskset = { id = "scaleswe-v1" }
|
||||
env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072] }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "scaleswe-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-swe"]
|
||||
|
||||
[orchestrator.prime_monitor]
|
||||
|
||||
@@ -110,12 +120,24 @@ env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels =
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swebench-verified"
|
||||
env.taskset = { id = "swebench-verified-v1" }
|
||||
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] }
|
||||
env.agent.timeout = { rollout = 3600 }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-swe"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
# --- Inference ---
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ type = "muon"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_rollouts = 512
|
||||
max_inflight_episodes = 512
|
||||
|
||||
[orchestrator.renderer]
|
||||
name = "glm-4.5"
|
||||
@@ -91,23 +91,31 @@ num_turns_weight = 0.1
|
||||
|
||||
# --- Train: tmax (per-task Docker image in a prime sandbox, rlm ipython) ---
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "tmax"
|
||||
env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072] }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] }
|
||||
|
||||
[orchestrator.train.env.env.taskset]
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-terminal"]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "tmax-v1"
|
||||
|
||||
# # Metric-only monitors (weight 0): rlm harness-mechanics + swe code-usage rubrics, judged by GLM-5.2.
|
||||
# [[orchestrator.train.env.env.taskset.judges]]
|
||||
# [[orchestrator.train.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.train.env.env.taskset.judges]]
|
||||
# [[orchestrator.train.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
@@ -119,47 +127,67 @@ id = "tmax-v1"
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swebench-verified"
|
||||
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] }
|
||||
env.agent.timeout = { rollout = 3600 }
|
||||
|
||||
[orchestrator.eval.env.env.taskset]
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-terminal"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
|
||||
# [[orchestrator.eval.env.env.taskset.judges]]
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.eval.env.env.taskset.judges]]
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "terminal-bench-2"
|
||||
group_size = 4 # avg@4
|
||||
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] }
|
||||
env.agent.timeout = { rollout = 3600 }
|
||||
|
||||
[orchestrator.eval.env.env.taskset]
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["glm45air-terminal"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "terminal-bench-2-v1"
|
||||
|
||||
# [[orchestrator.eval.env.env.taskset.judges]]
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "rlm"
|
||||
# path = "deps/research-environments/rubrics/rlm.toml"
|
||||
# model = "zai-org/GLM-5.2"
|
||||
# weight = 0.0
|
||||
|
||||
# [[orchestrator.eval.env.env.taskset.judges]]
|
||||
# [[orchestrator.eval.source.env.taskset.judges]]
|
||||
# id = "rubric"
|
||||
# name = "swe"
|
||||
# path = "deps/research-environments/rubrics/swe.toml"
|
||||
|
||||
@@ -35,16 +35,32 @@ prefill_nodes_per_replica = 2
|
||||
num_prefill_replicas = 4
|
||||
decode_nodes_per_replica = 8
|
||||
num_decode_replicas = 1
|
||||
prefill_env_vars = {"VLLM_ENABLE_MOE_DP_CHUNK"="0", "VLLM_DEEP_GEMM_WARMUP"="skip", "UCX_RCACHE_MAX_UNRELEASED"="1024"}
|
||||
decode_env_vars = {"VLLM_DEEP_GEMM_WARMUP"="skip", "UCX_RCACHE_MAX_UNRELEASED"="1024"}
|
||||
|
||||
[deployment.prefill_env_vars]
|
||||
"VLLM_ENABLE_MOE_DP_CHUNK" = "0"
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
[deployment.decode_env_vars]
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
[router]
|
||||
type = "llm-d"
|
||||
scorers = { "prefix-cache-scorer" = 3.0 }
|
||||
prefill_scorer_overrides = { "queue-scorer" = 4.0, "active-request-scorer" = 5.0 }
|
||||
decode_scorer_overrides = { "active-request-scorer" = 5.0, "kv-cache-utilization-scorer" = 4.0, "queue-scorer" = 3.0 }
|
||||
non_cached_tokens = 128
|
||||
|
||||
[router.scorers]
|
||||
"prefix-cache-scorer" = 3.0
|
||||
|
||||
[router.prefill_scorer_overrides]
|
||||
"queue-scorer" = 4.0
|
||||
"active-request-scorer" = 5.0
|
||||
|
||||
[router.decode_scorer_overrides]
|
||||
"active-request-scorer" = 5.0
|
||||
"kv-cache-utilization-scorer" = 4.0
|
||||
"queue-scorer" = 3.0
|
||||
|
||||
[slurm]
|
||||
job_name = "glm5.2-16node-llmd"
|
||||
partition = "all"
|
||||
|
||||
@@ -28,23 +28,44 @@ prefill_nodes_per_replica = 2
|
||||
num_prefill_replicas = 4
|
||||
decode_nodes_per_replica = 8
|
||||
num_decode_replicas = 1
|
||||
|
||||
# skip warmup for faster start in cost of some jit overhead early
|
||||
# ucx needs to be set else random segfaults, vllm can't autoset before importing for some reason
|
||||
prefill_env_vars = {"VLLM_ENABLE_MOE_DP_CHUNK"="0", "VLLM_DEEP_GEMM_WARMUP"="skip", "UCX_RCACHE_MAX_UNRELEASED"="1024"}
|
||||
decode_env_vars = {"VLLM_DEEP_GEMM_WARMUP"="skip", "UCX_RCACHE_MAX_UNRELEASED"="1024"}
|
||||
[inference.deployment.prefill_env_vars]
|
||||
"VLLM_ENABLE_MOE_DP_CHUNK" = "0"
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
[inference.deployment.decode_env_vars]
|
||||
"VLLM_DEEP_GEMM_WARMUP" = "skip"
|
||||
"UCX_RCACHE_MAX_UNRELEASED" = "1024"
|
||||
|
||||
# gives the most KV cache while keeping decent throughput, KV cache increase comes in from lower deep-ep LL static buffers
|
||||
prefill_vllm_overrides = {"enable_dbo"=true}
|
||||
decode_vllm_overrides = {"max_num_batched_tokens"=96, "max_num_seqs"=96}
|
||||
[inference.deployment.prefill_vllm_overrides]
|
||||
"enable_dbo" = true
|
||||
|
||||
[inference.deployment.decode_vllm_overrides]
|
||||
"max_num_batched_tokens" = 96
|
||||
"max_num_seqs" = 96
|
||||
|
||||
|
||||
[inference.router]
|
||||
type = "llm-d"
|
||||
scorers = { "prefix-cache-scorer" = 3.0 } # need some prefix-cache routing, however due to shared mooncake pool do low prio
|
||||
|
||||
prefill_scorer_overrides = { "queue-scorer" = 4.0, "active-request-scorer" = 5.0 } # prefill creates queues quite heavily, queue scorer to 4.0, active request at 5.0 is needed due to burstiness of early pipeline RL fill
|
||||
decode_scorer_overrides = { "active-request-scorer" = 5.0, "kv-cache-utilization-scorer" = 4.0, "queue-scorer" = 3.0 } # decode doesn't really create queue, it fills in KV cache fast, give 4.0
|
||||
non_cached_tokens = 128 # if <128 tokens, skip prefill go to decode immediately
|
||||
|
||||
[inference.router.scorers] # need some prefix-cache routing, however due to shared mooncake pool do low prio
|
||||
"prefix-cache-scorer" = 3.0
|
||||
|
||||
[inference.router.prefill_scorer_overrides] # prefill creates queues quite heavily, queue scorer to 4.0, active request at 5.0 is needed due to burstiness of early pipeline RL fill
|
||||
"queue-scorer" = 4.0
|
||||
"active-request-scorer" = 5.0
|
||||
|
||||
[inference.router.decode_scorer_overrides] # decode doesn't really create queue, it fills in KV cache fast, give 4.0
|
||||
"active-request-scorer" = 5.0
|
||||
"kv-cache-utilization-scorer" = 4.0
|
||||
"queue-scorer" = 3.0
|
||||
|
||||
[slurm]
|
||||
job_name = "glm5-llmd"
|
||||
partition = "all" # FILL IN: set to your cluster's partition
|
||||
@@ -81,7 +102,7 @@ weight_decay = 0.0
|
||||
[orchestrator]
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_inflight_rollouts = 2048
|
||||
max_inflight_episodes = 2048
|
||||
max_off_policy_steps = 8 # 16/32 can be better, 8 is more CPU stable
|
||||
|
||||
[orchestrator.model]
|
||||
@@ -93,14 +114,23 @@ clear_thinking = false
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
temperature = 1.0
|
||||
extra_body = {chat_template_kwargs = {clear_thinking = false}}
|
||||
|
||||
[orchestrator.train.sampling.extra_body.chat_template_kwargs]
|
||||
clear_thinking = false
|
||||
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "r2e"
|
||||
env.taskset = { id = "r2e-gym-v1" }
|
||||
env.agent.harness = { id = "rlm" }
|
||||
env.agent.runtime = { type = "prime", labels = ["glm5-llmd"] }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["glm5-llmd"]
|
||||
|
||||
[inference]
|
||||
enable_expert_parallel = true
|
||||
|
||||
@@ -71,11 +71,18 @@ name = "zai-org/GLM-5-FP8"
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swe-bench-verified"
|
||||
env.taskset = { id = "swebench-verified-v1" }
|
||||
env.agent.harness = { id = "bash" }
|
||||
env.agent.runtime = { type = "prime", labels = ["glm5-pd-disag", "swe-bench-verified"] }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["glm5-pd-disag", "swe-bench-verified"]
|
||||
|
||||
[[orchestrator.post_batch_filters]]
|
||||
type = "gibberish"
|
||||
|
||||
@@ -47,40 +47,77 @@ weight_decay = 0.01
|
||||
batch_size = 2048
|
||||
oversampling_factor = 2
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "swe"
|
||||
ratio = 0.3
|
||||
env.taskset = { id = "r2e-gym-v1" }
|
||||
env.agent.harness = { id = "bash" }
|
||||
env.agent.runtime = { type = "prime", labels = ["intellect-3.1", "swe"] }
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["intellect-3.1", "swe"]
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "deepdive"
|
||||
ratio = 0.2
|
||||
env.taskset = { id = "deepdive-v1" }
|
||||
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"] }
|
||||
env.agent.runtime = { type = "prime", labels = ["intellect-3.1", "deepdive"] }
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "deepdive-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
skills = ["search"]
|
||||
forward_env = ["SERPER_API_KEY"]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["intellect-3.1", "deepdive"]
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "math"
|
||||
ratio = 0.3
|
||||
env.taskset = { id = "i3_math_v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_math_v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "logic"
|
||||
ratio = 0.2
|
||||
env.taskset = { id = "i3_logic_v1", filter = { max = 0.874 } }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_logic_v1"
|
||||
|
||||
[orchestrator.train.source.env.taskset.filter]
|
||||
max = 0.874
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.train.source]]
|
||||
name = "code"
|
||||
ratio = 0.2
|
||||
env.taskset = { id = "i3_code_v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_code_v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.pre_batch_filters]]
|
||||
type = "zero_advantage"
|
||||
@@ -89,17 +126,30 @@ enforce = true
|
||||
[orchestrator.eval]
|
||||
interval = 25
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swe-bench-verified"
|
||||
env.taskset = { id = "swebench-verified-v1" }
|
||||
env.agent.harness = { id = "bash" }
|
||||
env.agent.runtime = { type = "prime", labels = ["intellect-3.1", "swe-bench-verified"] }
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["intellect-3.1", "swe-bench-verified"]
|
||||
|
||||
[[orchestrator.eval.source]]
|
||||
name = "aime2025"
|
||||
env.taskset = { id = "aime25-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime25-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference.parallel]
|
||||
tp = 8
|
||||
|
||||
@@ -49,20 +49,34 @@ oversampling_factor = 2
|
||||
max_off_policy_steps = 16
|
||||
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "swe"
|
||||
env.taskset = { id = "r2e-gym-v1" }
|
||||
env.agent.harness = { id = "bash" }
|
||||
env.agent.runtime = { type = "prime", labels = ["minimax-swe", "swe"] }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["minimax-swe", "swe"]
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 25
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swe-bench-verified"
|
||||
env.taskset = { id = "swebench-verified-v1" }
|
||||
env.agent.harness = { id = "bash" }
|
||||
env.agent.runtime = { type = "prime", labels = ["minimax-swe", "swe-bench-verified"] }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["minimax-swe", "swe-bench-verified"]
|
||||
|
||||
[inference.parallel]
|
||||
tp = 8
|
||||
|
||||
@@ -66,7 +66,7 @@ type = "adamw"
|
||||
batch_size = 256
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
max_inflight_rollouts = 1536
|
||||
max_inflight_episodes = 1536
|
||||
|
||||
[orchestrator.algo]
|
||||
type = "grpo"
|
||||
@@ -81,23 +81,45 @@ num_turns_weight = 0.1
|
||||
name = "nemotron-3"
|
||||
truncate_history_thinking = false
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "scaleswe"
|
||||
env.taskset = { id = "scaleswe-v1" }
|
||||
env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072] }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "scaleswe-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = [65536, 131072]
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["nemotron-3-super-swe"]
|
||||
|
||||
[orchestrator.prime_monitor]
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 20
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swebench-verified"
|
||||
env.taskset = { id = "swebench-verified-v1" }
|
||||
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
|
||||
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] }
|
||||
env.agent.timeout = { rollout = 3600 }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "rlm"
|
||||
summarize_at_tokens = 98304
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
vm = true
|
||||
idle_timeout = "None"
|
||||
labels = ["nemotron-3-super-swe"]
|
||||
|
||||
[orchestrator.eval.source.env.agent.timeout]
|
||||
rollout = 3600
|
||||
|
||||
[inference]
|
||||
enable_expert_parallel = true
|
||||
|
||||
@@ -48,20 +48,32 @@ max_off_policy_steps = 8
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 32768
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "math"
|
||||
env.taskset = { id = "i3_math_v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "i3_math_v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 25
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "aime2025"
|
||||
env.taskset = { id = "aime25-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime25-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference.parallel]
|
||||
tp = 8
|
||||
|
||||
@@ -46,20 +46,34 @@ batch_size = 512
|
||||
oversampling_factor = 2
|
||||
max_off_policy_steps = 16
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "swe"
|
||||
env.taskset = { id = "r2e-gym-v1" }
|
||||
env.agent.harness = { id = "bash" }
|
||||
env.agent.runtime = { type = "prime", labels = ["qwen30b-swe", "swe"] }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "r2e-gym-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["qwen30b-swe", "swe"]
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 25
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "swe-bench-verified"
|
||||
env.taskset = { id = "swebench-verified-v1" }
|
||||
env.agent.harness = { id = "bash" }
|
||||
env.agent.runtime = { type = "prime", labels = ["qwen30b-swe", "swe-bench-verified"] }
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "swebench-verified-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "bash"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "prime"
|
||||
labels = ["qwen30b-swe", "swe-bench-verified"]
|
||||
|
||||
[inference.parallel]
|
||||
tp = 8
|
||||
|
||||
@@ -35,10 +35,20 @@ batch_size = 512
|
||||
group_size = 16
|
||||
max_off_policy_steps = 32
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
env.taskset = { id = "general-agent-v1", task = { tools = { colocated = true } }, min_tier = 1 }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "modal" }
|
||||
[[orchestrator.train.source]]
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "general-agent-v1"
|
||||
min_tier = 1
|
||||
|
||||
[orchestrator.train.source.env.taskset.task.tools]
|
||||
colocated = true
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "modal"
|
||||
|
||||
[inference]
|
||||
gpu_memory_utilization = 0.85
|
||||
|
||||
@@ -31,10 +31,21 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 768
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "alphabet-sort"
|
||||
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "alphabet-sort-v1"
|
||||
min_turns = 3
|
||||
max_turns = 5
|
||||
|
||||
[orchestrator.train.source.env.taskset.task]
|
||||
power_per_turn = false
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[inference] # Default inference config
|
||||
|
||||
@@ -16,22 +16,36 @@ batch_size = 512
|
||||
group_size = 8
|
||||
seq_len = 8192
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "hendrycks-math"
|
||||
env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "math-env-v1"
|
||||
dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B"
|
||||
dataset_subset = "default"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.eval]
|
||||
interval = 50
|
||||
|
||||
[[orchestrator.eval.env]]
|
||||
[[orchestrator.eval.source]]
|
||||
name = "aime2024"
|
||||
env.taskset = { id = "aime24-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
group_size = 32
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "aime24-v1"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.model]
|
||||
seq_len = 16384
|
||||
|
||||
|
||||
@@ -15,11 +15,17 @@ group_size = 16
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[trainer.optim]
|
||||
lr = 3e-6
|
||||
|
||||
@@ -133,7 +133,7 @@ uv run eval wiki-search-v1 --harness.id null \
|
||||
The V1 taskset fixes the question bank and searchable corpus. You can replace its reference judge in `rl.toml`:
|
||||
|
||||
```toml
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
taskset = { id = "wiki-search-v1", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
|
||||
harness = { id = "null" }
|
||||
|
||||
@@ -44,11 +44,17 @@ max_completion_tokens = 512
|
||||
type = "zero_advantage"
|
||||
enforce = true
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "wiki-search"
|
||||
env.taskset = { id = "wiki-search-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wiki-search-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[ckpt] # Checkpoint at the end of training
|
||||
|
||||
|
||||
@@ -18,11 +18,17 @@ name = "PrimeIntellect/Qwen3-1.7B-Wordle-SFT"
|
||||
batch_size = 512
|
||||
group_size = 16
|
||||
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "wordle"
|
||||
env.taskset = { id = "wordle-v1" }
|
||||
env.player.harness = { id = "null" }
|
||||
env.player.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "wordle-v1"
|
||||
|
||||
[orchestrator.train.source.env.player.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.player.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[orchestrator.train.sampling]
|
||||
max_completion_tokens = 1024
|
||||
|
||||
@@ -13,10 +13,17 @@ name = "reverse-text"
|
||||
[train.sampling]
|
||||
max_completion_tokens = 128
|
||||
|
||||
[[train.env]]
|
||||
[[train.source]]
|
||||
name = "reverse-text"
|
||||
taskset = { id = "reverse-text-v1" }
|
||||
harness = { id = "null", runtime = { type = "subprocess" } }
|
||||
|
||||
[train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[renderer]
|
||||
name = "prime-qwen3"
|
||||
|
||||
@@ -7,10 +7,10 @@ requires-python = "~=3.12.0"
|
||||
dependencies = [
|
||||
"pydantic>=1.10.13",
|
||||
"prime-pydantic-config>=0.4.2",
|
||||
"renderers>=0.1.8",
|
||||
"renderers>=0.1.9.dev10",
|
||||
"tomli>=2.2.1",
|
||||
"tomli-w>=1.2.0",
|
||||
"verifiers>=0.2.1",
|
||||
"verifiers>=0.2.2.dev73",
|
||||
]
|
||||
|
||||
[build-system]
|
||||
|
||||
@@ -35,6 +35,7 @@ executes them.
|
||||
|
||||
from typing import Annotated, Any, ClassVar, Literal, TypeAlias
|
||||
|
||||
import verifiers.v1 as vf
|
||||
from pydantic import Field, model_validator
|
||||
from renderers import AutoRendererConfig, RendererConfig
|
||||
|
||||
@@ -188,6 +189,13 @@ class BaseAlgoConfig(BaseConfig):
|
||||
)
|
||||
return self
|
||||
|
||||
def validate_env(self, env_config: vf.EnvConfig) -> None:
|
||||
"""Raise if this algorithm cannot run on the env it is configured for,
|
||||
given that env's resolved config. Most algorithms read only the rollouts
|
||||
and their rewards, so they run on any env and the base does nothing;
|
||||
override where the credit assignment encodes an env's episode structure.
|
||||
Called once per train env after algorithm inheritance resolves."""
|
||||
|
||||
|
||||
class GRPOAlgoConfig(BaseAlgoConfig):
|
||||
type: Literal["grpo"] = "grpo"
|
||||
@@ -253,6 +261,39 @@ class RAEAlgoConfig(BaseAlgoConfig):
|
||||
memory — a restart re-warms them over ~1/(1 − decay) traces per agent."""
|
||||
|
||||
|
||||
class HierarchicalGRPOAlgoConfig(BaseAlgoConfig):
|
||||
type: Literal["hierarchical_grpo"] = "hierarchical_grpo"
|
||||
"""GRPO for proposer-solver envs.
|
||||
|
||||
Agents in ``episode_agents`` are compared with same-role attempts on the
|
||||
same proposed problem. Other agents are compared with the same role across
|
||||
proposals generated from one source task. This keeps rewards from different
|
||||
problems and different roles out of the same average."""
|
||||
|
||||
action_loss_type: ClassVar[ActionLossType] = "rl"
|
||||
|
||||
episode_agents: list[str] = Field(min_length=1)
|
||||
"""Roles compared within one proposed problem. Use ``["solver"]`` for
|
||||
``proposer-solver-v1``."""
|
||||
|
||||
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
|
||||
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`)."
|
||||
) from e
|
||||
if not isinstance(env_config, ProposerSolverEnvConfig):
|
||||
raise ValueError(
|
||||
f"algorithm 'hierarchical_grpo' needs a proposer-solver env, but this env resolved to "
|
||||
f"{type(env_config).__name__}. It compares solver attempts on the same proposed "
|
||||
"problem and proposers across proposals. Use 'grpo' for a flat env or 'rae' for "
|
||||
"multi-agent self-play."
|
||||
)
|
||||
|
||||
|
||||
class OPDAlgoConfig(BaseAlgoConfig):
|
||||
type: Literal["opd"] = "opd"
|
||||
"""On-policy distillation: the per-token signal is the reverse KL to
|
||||
@@ -326,7 +367,14 @@ class SFTAlgoConfig(BaseAlgoConfig):
|
||||
|
||||
|
||||
AlgoConfig: TypeAlias = Annotated[
|
||||
GRPOAlgoConfig | EchoAlgoConfig | MaxRLAlgoConfig | RAEAlgoConfig | OPDAlgoConfig | OPSDAlgoConfig | SFTAlgoConfig,
|
||||
GRPOAlgoConfig
|
||||
| EchoAlgoConfig
|
||||
| MaxRLAlgoConfig
|
||||
| RAEAlgoConfig
|
||||
| HierarchicalGRPOAlgoConfig
|
||||
| OPDAlgoConfig
|
||||
| OPSDAlgoConfig
|
||||
| SFTAlgoConfig,
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
"""The training algorithm: sampling plus the per-token training signal (credit
|
||||
@@ -336,6 +384,7 @@ its class defaults are the vetted setting.
|
||||
- ``grpo`` — policy group sampling, group-relative advantage, RL loss (the default).
|
||||
- ``max_rl`` — GRPO with mean-normalized advantages (maximum-likelihood RL).
|
||||
- ``rae`` — reward minus a per-agent EMA baseline (SPIRAL), for multi-agent self-play envs.
|
||||
- ``hierarchical_grpo`` — GRPO for proposer-solver envs: solvers are compared within one proposed problem and proposers across proposals. Needs ``episode_agents``.
|
||||
- ``opd`` — on-policy distillation: policy samples, per-token reverse KL against a reference model. Needs ``teacher``.
|
||||
- ``opsd`` — SDFT: policy samples, demo-conditioned reverse KL against the live policy (the teacher is the policy itself).
|
||||
- ``sft`` — a frozen model samples, the policy trains with CE on its tokens. Needs a frozen ``sampling.source``.
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import warnings
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Any, Literal, TypeAlias
|
||||
|
||||
import verifiers.v1 as vf
|
||||
from pydantic import AliasChoices, Field, model_validator
|
||||
from pydantic import Field, SerializeAsAny, model_validator
|
||||
from renderers import AutoRendererConfig, RendererConfig
|
||||
|
||||
from prime_rl.configs.algorithm import (
|
||||
@@ -54,9 +53,7 @@ class TrainSamplingConfig(BaseConfig):
|
||||
temperature: float = Field(1.0, ge=0, le=2.0)
|
||||
"""Sampling temperature."""
|
||||
|
||||
max_completion_tokens: int | None = Field(
|
||||
None, validation_alias=AliasChoices("max_completion_tokens", "max_tokens")
|
||||
)
|
||||
max_completion_tokens: int | None = None
|
||||
"""Maximum output tokens per turn. If None, generates until max context length or EOS."""
|
||||
|
||||
# Strictly speaking, extra_body is not a sampling parameter, but it is the
|
||||
@@ -79,18 +76,6 @@ class TrainSamplingConfig(BaseConfig):
|
||||
|
||||
return args
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _deprecate_max_tokens(cls, data: Any) -> Any:
|
||||
if isinstance(data, dict) and "max_tokens" in data and "max_completion_tokens" not in data:
|
||||
warnings.warn(
|
||||
"'max_tokens' is deprecated, use 'max_completion_tokens' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
class EvalSamplingConfig(BaseConfig):
|
||||
temperature: float | None = Field(None, ge=0, le=2.0)
|
||||
@@ -105,9 +90,7 @@ class EvalSamplingConfig(BaseConfig):
|
||||
min_p: float | None = Field(None, ge=0)
|
||||
"""Min-p sampling threshold. None defers to the inference server default."""
|
||||
|
||||
max_completion_tokens: int | None = Field(
|
||||
None, validation_alias=AliasChoices("max_completion_tokens", "max_tokens")
|
||||
)
|
||||
max_completion_tokens: int | None = None
|
||||
"""Maximum output tokens per turn. None defers to the inference server default."""
|
||||
|
||||
reasoning_effort: Literal["minimal", "low", "medium", "high"] | None = None
|
||||
@@ -138,40 +121,53 @@ class EvalSamplingConfig(BaseConfig):
|
||||
|
||||
return args
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _deprecate_max_tokens(cls, data: Any) -> Any:
|
||||
if isinstance(data, dict) and "max_tokens" in data and "max_completion_tokens" not in data:
|
||||
warnings.warn(
|
||||
"'max_tokens' is deprecated, use 'max_completion_tokens' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return data
|
||||
|
||||
|
||||
class EnvConfig(vf.EnvServerConfig):
|
||||
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."""
|
||||
class ServingConfig(vf.ServingConfig):
|
||||
"""Verifiers' serving block with ``address`` back to optional. Verifiers defaults it
|
||||
to the address its own ``serve`` CLI binds; here the question is whether to spawn a
|
||||
server or connect to one already running, and that answer has to survive the
|
||||
resolved config being written to a file and read back — so it must be a *value*
|
||||
(``None``), not field-set metadata, which a round-trip drops."""
|
||||
|
||||
address: str | None = None
|
||||
"""ZMQ address of an external env server (e.g. ``tcp://host:5000``). When set, the orchestrator connects to this server instead of spawning one; when None, a subprocess env server is spawned automatically. The ``pool`` sizes the spawned server."""
|
||||
"""ZMQ address of an external env server (e.g. ``tcp://host:5000``). When set, the orchestrator connects to that server instead of spawning one; when None, it spawns a subprocess env server on a free port. ``pool`` sizes the spawned server."""
|
||||
|
||||
|
||||
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."""
|
||||
|
||||
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."""
|
||||
|
||||
serve: ServingConfig = ServingConfig()
|
||||
"""How the env server is run: ``serve.pool`` sizes the spawned server, ``serve.address`` points at an external one instead, and ``serve.max_concurrent`` bounds one worker's episodes in flight (unset = unbounded; the dispatcher's ``max_inflight_episodes`` is the run's bound)."""
|
||||
|
||||
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."""
|
||||
|
||||
ratio: float = Field(1.0, gt=0)
|
||||
"""Sampling weight for this environment in the buffer. Relative weights are normalized to probabilities across envs (e.g. [1, 1] and [0.5, 0.5] are equivalent). Defaults to 1, i.e. equal weight per env."""
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _migrate_num_workers(cls, data):
|
||||
"""Back-compat: the removed ``num_workers`` maps onto ``pool`` — an int becomes a
|
||||
fixed ``static`` pool, ``"auto"`` falls through to the default ``elastic`` pool. An
|
||||
explicit ``pool`` always wins."""
|
||||
if isinstance(data, dict) and "num_workers" in data:
|
||||
num_workers = data.pop("num_workers")
|
||||
if "pool" not in data and num_workers != "auto":
|
||||
data["pool"] = {"type": "static", "num_workers": num_workers}
|
||||
return data
|
||||
def _resolve_env(cls, data):
|
||||
"""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 ""
|
||||
|
||||
@property
|
||||
def resolved_name(self) -> str:
|
||||
@@ -179,9 +175,24 @@ class EnvConfig(vf.EnvServerConfig):
|
||||
|
||||
@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 id = "<id>" (v0/legacy)'
|
||||
'no env configured — set env = { taskset = { id = "<id>" } } (v1) or legacy = { id = "<id>" } (v0)'
|
||||
)
|
||||
if self.resolved_name == "agg":
|
||||
raise ValueError(
|
||||
@@ -192,25 +203,25 @@ class EnvConfig(vf.EnvServerConfig):
|
||||
@model_validator(mode="after")
|
||||
def resolve_legacy_env_kwargs(self):
|
||||
"""For a v0/legacy env, surface the v1 knobs the legacy bridge applies via
|
||||
``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``.)"""
|
||||
``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.extra_env_kwargs["timeout_seconds"] = agent.timeout.rollout
|
||||
self.legacy.extra_env_kwargs["timeout_seconds"] = agent.timeout.rollout
|
||||
if agent.max_output_tokens is not None:
|
||||
self.extra_env_kwargs["max_total_completion_tokens"] = agent.max_output_tokens
|
||||
self.legacy.extra_env_kwargs["max_total_completion_tokens"] = agent.max_output_tokens
|
||||
return self
|
||||
|
||||
|
||||
class TrainEnvConfig(EnvConfig):
|
||||
class TrainSourceConfig(EnvConfig):
|
||||
sampling: TrainSamplingConfig = TrainSamplingConfig()
|
||||
"""Per-env sampling overrides. Unset fields inherit from the group-level train sampling config."""
|
||||
|
||||
group_size: int = Field(1, ge=1, validation_alias=AliasChoices("group_size", "rollouts_per_example"))
|
||||
group_size: int = Field(1, ge=1)
|
||||
"""Rollouts generated per example for GRPO group-relative advantages.
|
||||
Inherits from ``orchestrator.group_size`` when unset."""
|
||||
|
||||
@@ -220,14 +231,14 @@ class TrainEnvConfig(EnvConfig):
|
||||
this env its own algorithm."""
|
||||
|
||||
|
||||
class EvalEnvConfig(EnvConfig):
|
||||
class EvalSourceConfig(EnvConfig):
|
||||
sampling: EvalSamplingConfig = EvalSamplingConfig()
|
||||
"""Per-env sampling overrides. Unset fields inherit from the group-level eval sampling config."""
|
||||
|
||||
num_examples: int = -1
|
||||
"""Eval examples to sample from the dataset. ``-1`` uses all available examples."""
|
||||
|
||||
group_size: int = Field(1, ge=1, validation_alias=AliasChoices("group_size", "rollouts_per_example"))
|
||||
group_size: int = Field(1, ge=1)
|
||||
"""Rollouts generated per example. Used for pass@k estimation (e.g. ``group_size=8`` enables pass@1 through pass@8)."""
|
||||
|
||||
interval: int = Field(100, ge=1)
|
||||
@@ -235,8 +246,8 @@ class EvalEnvConfig(EnvConfig):
|
||||
|
||||
|
||||
class TrainConfig(BaseConfig):
|
||||
env: list[TrainEnvConfig] = Field(default_factory=list)
|
||||
"""Training environments."""
|
||||
source: list[TrainSourceConfig] = Field(default_factory=list)
|
||||
"""Training sources."""
|
||||
|
||||
sampling: TrainSamplingConfig = TrainSamplingConfig()
|
||||
"""Shared training sampling configuration."""
|
||||
@@ -246,7 +257,7 @@ class TrainConfig(BaseConfig):
|
||||
"""Resolve per-env overrides: inherit group-level sampling (the worker ``pool``
|
||||
is configured per env, defaulting to elastic)."""
|
||||
group_sampling = self.sampling.model_dump()
|
||||
for env in self.env:
|
||||
for env in self.source:
|
||||
if "sampling" not in env.model_fields_set:
|
||||
env.sampling = TrainSamplingConfig(**group_sampling)
|
||||
else:
|
||||
@@ -256,7 +267,7 @@ class TrainConfig(BaseConfig):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_unique_env_names(self):
|
||||
env_names = [env.resolved_name for env in self.env]
|
||||
env_names = [env.resolved_name for env in self.source]
|
||||
duplicates = [n for n in env_names if env_names.count(n) > 1]
|
||||
if duplicates:
|
||||
raise ValueError(
|
||||
@@ -266,8 +277,8 @@ class TrainConfig(BaseConfig):
|
||||
|
||||
|
||||
class EvalConfig(BaseConfig):
|
||||
env: list[EvalEnvConfig] = Field(default_factory=list)
|
||||
"""Evaluation environments."""
|
||||
source: list[EvalSourceConfig] = Field(default_factory=list)
|
||||
"""Evaluation sources."""
|
||||
|
||||
sampling: EvalSamplingConfig = Field(default_factory=EvalSamplingConfig)
|
||||
"""Shared eval sampling configuration; can differ from training sampling."""
|
||||
@@ -275,7 +286,7 @@ class EvalConfig(BaseConfig):
|
||||
num_examples: int = -1
|
||||
"""Default eval examples per environment. ``-1`` uses all. Can be overridden per env."""
|
||||
|
||||
group_size: int = Field(1, ge=1, validation_alias=AliasChoices("group_size", "rollouts_per_example"))
|
||||
group_size: int = Field(1, ge=1)
|
||||
"""Default rollouts per example. Can be overridden per env."""
|
||||
|
||||
interval: int = Field(100, ge=1)
|
||||
@@ -290,33 +301,33 @@ class EvalConfig(BaseConfig):
|
||||
"""Resolve per-env overrides: inherit group-level sampling, num_examples,
|
||||
group_size, and interval (the worker ``pool`` is configured per env, default elastic)."""
|
||||
group_sampling = self.sampling.model_dump()
|
||||
for env in self.env:
|
||||
if "sampling" not in env.model_fields_set:
|
||||
env.sampling = EvalSamplingConfig(**group_sampling)
|
||||
for source in self.source:
|
||||
if "sampling" not in source.model_fields_set:
|
||||
source.sampling = EvalSamplingConfig(**group_sampling)
|
||||
else:
|
||||
merged = group_sampling | env.sampling.model_dump(exclude_unset=True)
|
||||
env.sampling = EvalSamplingConfig(**merged)
|
||||
if "num_examples" not in env.model_fields_set:
|
||||
env.num_examples = self.num_examples
|
||||
if "group_size" not in env.model_fields_set:
|
||||
env.group_size = self.group_size
|
||||
if "interval" not in env.model_fields_set:
|
||||
env.interval = self.interval
|
||||
merged = group_sampling | source.sampling.model_dump(exclude_unset=True)
|
||||
source.sampling = EvalSamplingConfig(**merged)
|
||||
if "num_examples" not in source.model_fields_set:
|
||||
source.num_examples = self.num_examples
|
||||
if "group_size" not in source.model_fields_set:
|
||||
source.group_size = self.group_size
|
||||
if "interval" not in source.model_fields_set:
|
||||
source.interval = self.interval
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_non_empty_envs(self):
|
||||
if not self.env:
|
||||
def validate_non_empty_sources(self):
|
||||
if not self.source:
|
||||
raise ValueError(
|
||||
"EvalConfig must define at least one env. Either drop the "
|
||||
"EvalConfig must define at least one source. Either drop the "
|
||||
"[orchestrator.eval] block entirely (to disable eval) or "
|
||||
"add a [[orchestrator.eval.env]] block."
|
||||
"add a [[orchestrator.eval.source]] block."
|
||||
)
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_unique_env_names(self):
|
||||
env_names = [env.resolved_name for env in self.env]
|
||||
env_names = [source.resolved_name for source in self.source]
|
||||
duplicates = [n for n in env_names if env_names.count(n) > 1]
|
||||
if duplicates:
|
||||
raise ValueError(
|
||||
@@ -437,7 +448,7 @@ class OrchestratorConfig(BaseConfig):
|
||||
algo: AlgoConfig = GRPOAlgoConfig()
|
||||
"""Training algorithm: sampling plus the per-token training signal (credit
|
||||
assignment and loss routing, fused — its ``type`` names the algorithm).
|
||||
Defaults to ``grpo``. Override per env via ``[[orchestrator.train.env]]``'s
|
||||
Defaults to ``grpo``. Override per source via ``[[orchestrator.train.source]]``'s
|
||||
``algo``."""
|
||||
|
||||
model: ModelConfig = ModelConfig()
|
||||
@@ -456,11 +467,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."""
|
||||
|
||||
pool_size: int | None = Field(None, ge=1)
|
||||
"""Number of renderer slots shared across concurrent rollouts. Bump
|
||||
for long multi-turn prompts where client-side jinja tokenization
|
||||
serializes."""
|
||||
|
||||
optim: OptimizerConfig = OptimizerConfig()
|
||||
"""Per-run optimizer configuration for multi-run training."""
|
||||
|
||||
@@ -525,12 +531,12 @@ class OrchestratorConfig(BaseConfig):
|
||||
"""Tokens to train on per step (token-based batching). Set this OR ``batch_size``."""
|
||||
|
||||
oversampling_factor: float | None = Field(None, gt=0)
|
||||
"""Rollout-mode batching only. Multiplier used to derive ``max_inflight_rollouts`` from ``batch_size`` when ``max_inflight_rollouts`` is unset. Values below 1.0 intentionally cap in-flight rollout capacity below ``batch_size``."""
|
||||
"""Rollout-mode batching only. Multiplier used to derive ``max_inflight_episodes`` from ``batch_size`` when ``max_inflight_episodes`` is unset. Values below 1.0 intentionally cap in-flight episode capacity below ``batch_size``."""
|
||||
|
||||
max_inflight_rollouts: int | None = Field(None, ge=1)
|
||||
"""Maximum number of rollouts kept in-flight. Required for token-based batching. With ``batch_size`` set, defaults to ``batch_size * oversampling_factor`` (or ``batch_size`` when ``oversampling_factor`` is unset)."""
|
||||
max_inflight_episodes: int | None = Field(None, ge=1)
|
||||
"""Maximum number of episodes kept in-flight — one episode is one agent run at a time, whatever the env's agents are. Required for token-based batching. With ``batch_size`` set, defaults to ``batch_size * oversampling_factor`` (or ``batch_size`` when ``oversampling_factor`` is unset)."""
|
||||
|
||||
group_size: int = Field(1, ge=1, validation_alias=AliasChoices("group_size", "rollouts_per_example"))
|
||||
group_size: int = Field(1, ge=1)
|
||||
"""Output sequences returned per example during training."""
|
||||
|
||||
seq_len: int = 2048
|
||||
@@ -552,33 +558,6 @@ class OrchestratorConfig(BaseConfig):
|
||||
heartbeat: HeartbeatConfig | None = None
|
||||
"""BetterStack heartbeat configuration for monitoring training progress."""
|
||||
|
||||
@model_validator(mode="before")
|
||||
@classmethod
|
||||
def _env_to_train(cls, data: Any) -> Any:
|
||||
"""Allow [[env]] and [sampling] as shorthand for [train] with [[train.env]] and [train.sampling]."""
|
||||
if not isinstance(data, dict):
|
||||
return data
|
||||
if "env" in data or "sampling" in data:
|
||||
train = data.setdefault("train", {})
|
||||
if isinstance(train, dict):
|
||||
if "env" in data:
|
||||
warnings.warn(
|
||||
"'[[orchestrator.env]]' is deprecated, use '[[orchestrator.train.env]]' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
train.setdefault("env", data.pop("env"))
|
||||
if "sampling" in data:
|
||||
warnings.warn(
|
||||
"'[orchestrator.sampling]' is deprecated, use '[orchestrator.train.sampling]' instead. "
|
||||
"Auto-translating for now, but this will be removed in a future release.",
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
train.setdefault("sampling", data.pop("sampling"))
|
||||
return data
|
||||
|
||||
@model_validator(mode="after")
|
||||
def auto_setup_tokenizer(self):
|
||||
if self.tokenizer.name is None:
|
||||
@@ -617,31 +596,23 @@ class OrchestratorConfig(BaseConfig):
|
||||
def inherit_env_algorithms(self):
|
||||
"""Envs without their own algorithm inherit the top-level one.
|
||||
Declared before any validator that reads ``algo``."""
|
||||
for env_cfg in self.train.env:
|
||||
for env_cfg in self.train.source:
|
||||
if env_cfg.algo is None:
|
||||
env_cfg.algo = self.algo.model_copy(deep=True)
|
||||
return self
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_env_algorithms(self):
|
||||
"""Let each algorithm reject environments it cannot score correctly."""
|
||||
for env_cfg in self.train.source:
|
||||
assert env_cfg.algo is not None # resolved by inherit_env_algorithms
|
||||
env_cfg.algo.validate_env(env_cfg.env)
|
||||
return self
|
||||
|
||||
@property
|
||||
def any_policy_sourced(self) -> bool:
|
||||
"""True when at least one train env samples rollouts from the live policy."""
|
||||
return any(env.algo is not None and env.algo.sampling.source == "policy" for env in self.train.env)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_pool_size(self):
|
||||
"""``pool_size`` sizes the renderer-client pool for policy-sourced
|
||||
sampling. Reject it when that path never runs — no train env samples
|
||||
from the policy — so callers don't silently pass it and wonder why
|
||||
it's ignored."""
|
||||
if self.pool_size is None:
|
||||
return self
|
||||
if not self.any_policy_sourced:
|
||||
raise ValueError(
|
||||
f"orchestrator.pool_size={self.pool_size!r} is set but no train env samples "
|
||||
"from the policy — the renderer-client sampling pool never runs (the renderer "
|
||||
"is still used for client-side tokenization). Remove pool_size."
|
||||
)
|
||||
return self
|
||||
return any(env.algo is not None and env.algo.sampling.source == "policy" for env in self.train.source)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_renderer_auto_resolves(self):
|
||||
@@ -691,29 +662,29 @@ class OrchestratorConfig(BaseConfig):
|
||||
if has_token_batch:
|
||||
if self.oversampling_factor is not None:
|
||||
raise ValueError("oversampling_factor can only be set when batch_size is set")
|
||||
if self.max_inflight_rollouts is None:
|
||||
raise ValueError("max_inflight_rollouts must be set when token_batch_size is set")
|
||||
if self.max_inflight_episodes is None:
|
||||
raise ValueError("max_inflight_episodes must be set when token_batch_size is set")
|
||||
else:
|
||||
assert self.batch_size is not None
|
||||
if self.batch_size % self.group_size != 0:
|
||||
raise ValueError("Batch size must be divisible by the number of samples per problem")
|
||||
oversampling_factor = self.oversampling_factor if self.oversampling_factor is not None else 1.0
|
||||
resolved_max_inflight_rollouts = max(
|
||||
resolved_max_inflight_episodes = max(
|
||||
self.group_size,
|
||||
int(self.batch_size * oversampling_factor),
|
||||
)
|
||||
if self.max_inflight_rollouts is not None and self.oversampling_factor is not None:
|
||||
expected_max_inflight_rollouts = resolved_max_inflight_rollouts
|
||||
if self.max_inflight_rollouts != expected_max_inflight_rollouts:
|
||||
raise ValueError("max_inflight_rollouts conflicts with oversampling_factor * batch_size")
|
||||
if self.max_inflight_rollouts is None:
|
||||
self.max_inflight_rollouts = resolved_max_inflight_rollouts
|
||||
if self.max_inflight_episodes is not None and self.oversampling_factor is not None:
|
||||
expected_max_inflight_episodes = resolved_max_inflight_episodes
|
||||
if self.max_inflight_episodes != expected_max_inflight_episodes:
|
||||
raise ValueError("max_inflight_episodes conflicts with oversampling_factor * batch_size")
|
||||
if self.max_inflight_episodes is None:
|
||||
self.max_inflight_episodes = resolved_max_inflight_episodes
|
||||
|
||||
if self.max_inflight_rollouts is not None and self.max_inflight_rollouts < self.group_size:
|
||||
raise ValueError("max_inflight_rollouts must be at least the number of rollouts per example")
|
||||
if self.max_inflight_episodes is not None and self.max_inflight_episodes < self.group_size:
|
||||
raise ValueError("max_inflight_episodes must be at least the number of rollouts per example")
|
||||
|
||||
# Propagate the top-level ``group_size`` into each train env that didn't set its own.
|
||||
for env_cfg in self.train.env:
|
||||
for env_cfg in self.train.source:
|
||||
if "group_size" not in env_cfg.model_fields_set:
|
||||
env_cfg.group_size = self.group_size
|
||||
|
||||
@@ -736,7 +707,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."""
|
||||
for env in self.train.env:
|
||||
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.
|
||||
assert env.algo is not None
|
||||
@@ -746,6 +717,6 @@ class OrchestratorConfig(BaseConfig):
|
||||
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 extra_env_kwargs via env.set_kwargs).
|
||||
env.extra_env_kwargs["max_seq_len"] = self.seq_len
|
||||
# bridge applies legacy.extra_env_kwargs via env.set_kwargs).
|
||||
env.legacy.extra_env_kwargs["max_seq_len"] = self.seq_len
|
||||
return self
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ dependencies = [
|
||||
"torchaudio",
|
||||
"torchdata>=0.11.0",
|
||||
"transformers==5.6.2",
|
||||
"vllm>=0.24.0",
|
||||
"vllm>=0.26.0",
|
||||
"mooncake-transfer-engine>=0.3.10.post2",
|
||||
"wandb>=0.26.1",
|
||||
"wandb-workspaces>=0.4.3",
|
||||
@@ -33,7 +33,7 @@ dependencies = [
|
||||
"setproctitle>=1.3.0",
|
||||
"uvloop>=0.21.0",
|
||||
"torchtitan",
|
||||
"verifiers[harbor]>=0.2.1",
|
||||
"verifiers[harbor]>=0.2.2.dev73",
|
||||
"renderers",
|
||||
"dion",
|
||||
"tilelang>=0.1.8",
|
||||
@@ -200,8 +200,8 @@ vllm-router = [
|
||||
{ url = "https://github.com/PrimeIntellect-ai/router/releases/download/v0.1.26/vllm_router-0.1.26-cp38-abi3-manylinux_2_28_aarch64.whl", marker = "platform_machine == 'aarch64'" },
|
||||
]
|
||||
vllm = [
|
||||
{ url = "https://github.com/vllm-project/vllm/releases/download/v0.24.0/vllm-0.24.0+cu129-cp38-abi3-manylinux_2_28_x86_64.whl", marker = "platform_machine == 'x86_64'" },
|
||||
{ url = "https://github.com/vllm-project/vllm/releases/download/v0.24.0/vllm-0.24.0+cu129-cp38-abi3-manylinux_2_28_aarch64.whl", marker = "platform_machine == 'aarch64'" },
|
||||
{ url = "https://github.com/vllm-project/vllm/releases/download/v0.26.0/vllm-0.26.0+cu129-cp38-abi3-manylinux_2_28_x86_64.whl", marker = "platform_machine == 'x86_64'" },
|
||||
{ url = "https://github.com/vllm-project/vllm/releases/download/v0.26.0/vllm-0.26.0+cu129-cp38-abi3-manylinux_2_28_aarch64.whl", marker = "platform_machine == 'aarch64'" },
|
||||
]
|
||||
deep-ep = [
|
||||
{ url = "https://github.com/PrimeIntellect-ai/prime-rl/releases/download/v0.5.0/deep_ep-1.2.1+29d31c0-cp312-cp312-linux_x86_64.whl", marker = "platform_machine == 'x86_64'" },
|
||||
|
||||
+28
-7
@@ -30,10 +30,12 @@ uv run rl @ rl.toml --dry-run --output-dir /tmp/x # write resolved TOML to /tmp/
|
||||
|
||||
## Validators
|
||||
|
||||
Incompatible combinations (e.g. CP requires flash attention) must raise in a `model_validator` at resolve time, not at runtime. When renaming a field, emit a deprecation warning with a migration hint — never silently drop.
|
||||
Incompatible combinations (e.g. CP requires flash attention) must raise in a `model_validator` at resolve time, not at runtime. When renaming a field, remove the old spelling: no `validation_alias`, no auto-translating `mode="before"` validator. The old key then fails as an unknown key, which is the signal. An alias that stays forever is worse than a break — it never gets retired, and a key whose *meaning* changed silently misconfigures the run.
|
||||
|
||||
## Special syntax
|
||||
|
||||
**No inline tables** — checked-in configs use `[section]` headers, never `key = { ... }`. Expand `env.taskset = { id = "..." }` to a full-path header (`[orchestrator.train.source.env.taskset]` — subtable headers after a `[[...]]` entry attach to that entry).
|
||||
|
||||
**Booleans** — CLI `--flag` / `--no-flag`; TOML must be explicit (`enforce_eager = true`).
|
||||
|
||||
**None** — TOML has no null, use the string `"None"` (`max_model_len = "None"`); CLI: `--model.max-model-len None`.
|
||||
@@ -41,20 +43,39 @@ Incompatible combinations (e.g. CP requires flash attention) must raise in a `mo
|
||||
**Lists** — TOML uses array of tables; later config files replace lists wholesale, so overlays must include the full desired list:
|
||||
|
||||
```toml
|
||||
[[orchestrator.train.env]]
|
||||
[[orchestrator.train.source]]
|
||||
name = "reverse-text"
|
||||
env.taskset = { id = "reverse-text-v1" }
|
||||
env.agent.harness = { id = "null" }
|
||||
env.agent.runtime = { type = "subprocess" }
|
||||
|
||||
[orchestrator.train.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
|
||||
[orchestrator.train.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.train.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
|
||||
[[orchestrator.eval.source]]
|
||||
name = "reverse-text-eval"
|
||||
|
||||
[orchestrator.eval.source.env.taskset]
|
||||
id = "reverse-text-v1"
|
||||
split = "test"
|
||||
|
||||
[orchestrator.eval.source.env.agent.harness]
|
||||
id = "null"
|
||||
|
||||
[orchestrator.eval.source.env.agent.runtime]
|
||||
type = "subprocess"
|
||||
```
|
||||
|
||||
CLI: `--orchestrator.train.env.0.env.taskset.id reverse-text-v1`.
|
||||
CLI: `--orchestrator.train.source.0.env.taskset.id reverse-text-v1` or `--orchestrator.eval.source.0.env.taskset.id reverse-text-v1`.
|
||||
|
||||
**Dicts** — TOML uses a section; CLI takes a JSON string: `--vllm-extra '{"key1": "value1"}'`. This works for plain `dict` fields only — nested pydantic-model fields (e.g. `algo`) reject JSON strings; use dotted keys (`--orchestrator.algo.type max_rl`) or a TOML overlay file.
|
||||
|
||||
**Discriminated unions** — set the `type` field to pick the variant (`[orchestrator.algo] type = "max_rl"`). Omit `type` to keep the default variant.
|
||||
|
||||
**Algorithms** — `[orchestrator.algo] type = "grpo" | "max_rl" | "rae" | "opd" | "opsd" | "sft" | "echo"` — the type names the algorithm (credit assignment + loss routing, fused), and each type's class defaults are its vetted setting; any other key you set is your own assembly (e.g. `[orchestrator.algo.roles.user] alpha = 0.1` for echo — setting any echo role replaces the whole role table). There is no preset layer, and no config hook that points at user code — a new algorithm is a named class in the repo (subclass `Algorithm`, register it). Per-env override: `[orchestrator.train.env.algo] type = "opd"` (the env assembles its own algorithm). prime-rl only hosts the trainable policy; frozen models are inline external endpoints on the algorithm, named where the model is used — `[orchestrator.algo.teacher]` for opd (the frozen model scored against), `[orchestrator.algo.sampling.source]` for sft (the model it samples from), each with `name` + `base_url`. There is no shared `teacher` slot. opsd declares no model — it self-distills against the live policy. See `docs/algorithms.md`.
|
||||
**Algorithms** — `[orchestrator.algo] type = "grpo" | "max_rl" | "rae" | "hierarchical_grpo" | "opd" | "opsd" | "sft" | "echo"` — the type names the algorithm (credit assignment + loss routing, fused), and each type's class defaults are its vetted setting; any other key you set is your own assembly (e.g. `[orchestrator.algo.roles.user] alpha = 0.1` for echo — setting any echo role replaces the whole role table). `hierarchical_grpo` is only valid with a proposer-solver env: it compares solvers with attempts on the same proposed problem and proposers with other proposals in the group. There is no preset layer, and no config hook that points at user code — a new algorithm is a named class in the repo (subclass `Algorithm`, register it). Per-source override: `[orchestrator.train.source.algo] type = "opd"` (the source assembles its own algorithm). prime-rl only hosts the trainable policy; frozen models are inline external endpoints on the algorithm, named where the model is used — `[orchestrator.algo.teacher]` for opd (the frozen model scored against), `[orchestrator.algo.sampling.source]` for sft (the model it samples from), each with `name` + `base_url`. There is no shared `teacher` slot. opsd declares no model — it self-distills against the live policy. See `docs/algorithms.md`.
|
||||
|
||||
**`BaseModel | None` fields** — bare flag enables defaults; nested override enables and sets:
|
||||
|
||||
|
||||
@@ -89,17 +89,25 @@ grep -E "WARNING|ERROR" {output_dir}/logs/envs/{train,eval}/*.log
|
||||
|
||||
All metrics print to the console log (and W&B when configured).
|
||||
|
||||
**Progress** — orchestrator log. Rollout metrics are keyed `{scope}/{subset}/<metric>/<stat>`: `scope` is `train/agg` (all train envs) or `train/<env>` (`eval/<env>` for eval); `subset` is `all` (every rollout) or `effective` (post-filter).
|
||||
**Progress** — orchestrator log. Rollout metrics mirror the episode/trace hierarchy, at two levels:
|
||||
|
||||
- `{scope}/{subset}/<metric>/<stat>` — episode-level facts only: the token/turn/branch counts, summed over an episode's traces.
|
||||
- `{scope}/{subset}/<agent>/<metric>/<stat>` — every trace-level metric (reward, truncation, errors, timing, env metrics, filter verdicts, eval scores), keyed by agent name so seats never mix. Flat over that agent's traces: one sample is one trace, so an in-episode fan-out like n solvers contributes n samples.
|
||||
|
||||
`scope` is `train/agg` (all train envs) or `train/<env>` (`eval/<env>` for eval); `subset` is `all` (every rollout) or `effective` (post-filter). Single-agent envs have one agent — usually `agent` — and one trace per episode, so both levels agree; multi-agent envs name each seat (`proposer`, `solver`, `judge`, …).
|
||||
|
||||
| Metric | Description |
|
||||
|--------|-------------|
|
||||
| `train/agg/all/reward/mean` | mean training reward (per env: `train/<env>/all/reward/mean`) |
|
||||
| `train/agg/all/num_total_tokens/mean` | avg tokens per rollout (also `num_input_tokens`, `num_output_tokens`) |
|
||||
| `train/agg/all/num_turns/mean` | avg turns per rollout (multi-turn only) |
|
||||
| `train/agg/all/is_truncated/mean` | fraction truncated |
|
||||
| `train/agg/all/has_error/mean` | fraction errored (per-type under `train/agg/all/error/<type>`; also `dispatcher/errored/{train,eval}`) |
|
||||
| `train/<env>/all/metrics/<name>/mean` | env-specific metrics (e.g. pass rate) |
|
||||
| `eval/<env>/all/{avg@k,pass@k}` | eval scores when configured |
|
||||
| `train/agg/effective/<agent>/reward/mean` | mean training reward for that agent (per env: `train/<env>/effective/<agent>/reward/mean`) |
|
||||
| `train/agg/effective/num_total_tokens/mean` | avg tokens per episode, summed over its agents (also `num_input_tokens`, `num_output_tokens`) |
|
||||
| `train/agg/effective/num_turns/mean` | avg turns per episode, summed over its agents |
|
||||
| `train/<env>/effective/<agent>/num_turns/mean` | avg turns for that agent alone (also token counts, `num_branches`) |
|
||||
| `train/agg/effective/<agent>/is_truncated/mean` | fraction of that agent's rollouts truncated |
|
||||
| `train/agg/all/<agent>/has_error/mean` | fraction of that agent's rollouts errored (per-type under `train/agg/all/<agent>/error/<type>`; also `dispatcher/errored/{train,eval}`) |
|
||||
| `train/agg/all/<agent>/is_trainable/mean` | fraction carrying a training signal — 0.0 for a frozen seat like a judge (also `is_filtered`, `filters/<name>`) |
|
||||
| `train/<env>/effective/<agent>/metrics/<name>/mean` | env-specific metrics for that agent (e.g. pass rate) |
|
||||
| `train/<env>/effective/<agent>/timing/agent/model/mean` | model vs harness share of that agent's phase |
|
||||
| `eval/<env>/effective/<agent>/{avg@k,pass@k}` | eval scores for that agent, when configured |
|
||||
|
||||
**Stability** — trainer log:
|
||||
|
||||
|
||||
@@ -205,9 +205,9 @@ def rl_local(config: RLConfig):
|
||||
)
|
||||
|
||||
frozen_endpoints: list[str] = []
|
||||
for env in config.orchestrator.train.env:
|
||||
for env in config.orchestrator.train.source:
|
||||
algo = env.algo
|
||||
assert algo is not None, "TrainEnvConfig.algo must be resolved before launch (inherit_env_algorithms)"
|
||||
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)})")
|
||||
@@ -487,8 +487,10 @@ def rl_slurm(config: RLConfig):
|
||||
write_config(config, config_dir, exclude={"slurm", "dry_run", "clean_output_dir"})
|
||||
logger.info(f"Wrote config to {config_dir / RL_TOML}")
|
||||
|
||||
train_env_names = [env.resolved_name for env in config.orchestrator.train.env]
|
||||
eval_env_names = [env.resolved_name for env in config.orchestrator.eval.env] if config.orchestrator.eval else []
|
||||
train_env_names = [env.resolved_name for env in config.orchestrator.train.source]
|
||||
eval_env_names = (
|
||||
[source.resolved_name for source in config.orchestrator.eval.source] if config.orchestrator.eval else []
|
||||
)
|
||||
|
||||
log_message = format_log_message(
|
||||
log_dir=log_dir,
|
||||
@@ -502,8 +504,10 @@ def rl_slurm(config: RLConfig):
|
||||
write_subconfigs(config, config_dir)
|
||||
logger.info(f"Wrote subconfigs to {config_dir}")
|
||||
|
||||
train_env_names = [env.resolved_name for env in config.orchestrator.train.env]
|
||||
eval_env_names = [env.resolved_name for env in config.orchestrator.eval.env] if config.orchestrator.eval else []
|
||||
train_env_names = [env.resolved_name for env in config.orchestrator.train.source]
|
||||
eval_env_names = (
|
||||
[source.resolved_name for source in config.orchestrator.eval.source] if config.orchestrator.eval else []
|
||||
)
|
||||
|
||||
has_infer = config.deployment.infer_nodes_per_replica > 0
|
||||
log_message = format_log_message(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Prime-RL extensions to vLLM's `/inference/v1/generate` handler.
|
||||
|
||||
vLLM 0.22 ships a generic tokens-in / tokens-out handler at
|
||||
``vllm.entrypoints.serve.disagg.serving.ServingTokens`` that already covers
|
||||
vLLM ships a generic tokens-in / tokens-out handler at
|
||||
``vllm.entrypoints.scale_out.token_in_token_out.serving.ServingTokens`` that covers
|
||||
prefix-cache salting, lora dispatch, multimodal features, prompt logprobs,
|
||||
priority, ``data_parallel_rank`` header routing and server-side ``max_tokens``
|
||||
defaulting. We subclass it for the bits still missing from the upstream handler:
|
||||
@@ -37,12 +37,12 @@ from vllm.entrypoints.openai.engine.protocol import (
|
||||
RequestResponseMetadata,
|
||||
UsageInfo,
|
||||
)
|
||||
from vllm.entrypoints.serve.disagg.protocol import (
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.protocol import (
|
||||
GenerateRequest,
|
||||
GenerateResponse,
|
||||
GenerateResponseChoice,
|
||||
)
|
||||
from vllm.entrypoints.serve.disagg.serving import ServingTokens
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.serving import ServingTokens
|
||||
from vllm.entrypoints.serve.utils.api_utils import get_max_tokens
|
||||
from vllm.outputs import RequestOutput
|
||||
from vllm.sampling_params import RequestOutputKind, SamplingParams
|
||||
@@ -176,7 +176,7 @@ class PrimeRlServingTokens(ServingTokens):
|
||||
request: GenerateRequest,
|
||||
raw_request: Request | None = None,
|
||||
) -> PrimeRlGenerateResponse | ErrorResponse | AsyncGenerator[str, None]:
|
||||
# Mirrors upstream ``ServingTokens.serve_tokens`` (vllm 0.22). Diffs:
|
||||
# Mirrors upstream ``ServingTokens.serve_tokens``. Diffs:
|
||||
# (a) inject ``data_parallel_rank`` from the inbound header into
|
||||
# ``engine_client.generate``; (b) default ``sampling_params.max_tokens``
|
||||
# to ``max_model_len - prompt_len`` when the caller didn't set it; and
|
||||
@@ -200,10 +200,11 @@ class PrimeRlServingTokens(ServingTokens):
|
||||
# Build the engine input — features-aware (MM) or text-only fallback.
|
||||
# Identical to upstream so we keep tracking it.
|
||||
if features := request.features:
|
||||
from vllm.entrypoints.serve.disagg.mm_serde import decode_mm_kwargs_item
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.mm_serde import decode_mm_kwargs_item
|
||||
from vllm.inputs import mm_input
|
||||
from vllm.multimodal.inputs import (
|
||||
MultiModalKwargsItem,
|
||||
MultiModalKwargsItems,
|
||||
PlaceholderRange,
|
||||
)
|
||||
|
||||
@@ -220,13 +221,13 @@ class PrimeRlServingTokens(ServingTokens):
|
||||
mm_kwargs[modality] = [None] * len(hashes)
|
||||
engine_input = mm_input(
|
||||
prompt_token_ids=request.token_ids,
|
||||
mm_kwargs=mm_kwargs, # type: ignore[arg-type]
|
||||
mm_kwargs=MultiModalKwargsItems(mm_kwargs),
|
||||
mm_hashes=features.mm_hashes,
|
||||
mm_placeholders=mm_placeholders,
|
||||
cache_salt=request.cache_salt,
|
||||
)
|
||||
else:
|
||||
(engine_input,) = await self.openai_serving_render.preprocess_completion(
|
||||
(engine_input,) = await self.online_renderer.preprocess_completion(
|
||||
request,
|
||||
prompt_input=request.token_ids,
|
||||
prompt_embeds=None,
|
||||
|
||||
@@ -5,8 +5,9 @@ is — a bundle of sampling and the per-token training signal. This package
|
||||
turns the signal half into runtime objects (the sampling half is the env's
|
||||
:class:`~prime_rl.orchestrator.sampler.Sampler`):
|
||||
|
||||
- one module per algorithm (``grpo``, ``echo``, ``max_rl``, ``rae``, ``opd``,
|
||||
``opsd``, ``sft``) — each named class owns its scoring hooks
|
||||
- one module per algorithm (``grpo``, ``echo``, ``max_rl``, ``rae``,
|
||||
``hierarchical_grpo``, ``opd``, ``opsd``, ``sft``) — each named class owns
|
||||
its scoring hooks
|
||||
(``score_rollout`` / ``score_group``) and declares what it needs (loss
|
||||
component, a "teacher", ...). One instance per env, built by
|
||||
:func:`build_algorithm`. A new credit-assignment scheme is a new named class:
|
||||
@@ -31,6 +32,7 @@ from typing import TYPE_CHECKING
|
||||
from prime_rl.orchestrator.algo.base import Algorithm, connect_frozen_pool
|
||||
from prime_rl.orchestrator.algo.echo import EchoAlgorithm
|
||||
from prime_rl.orchestrator.algo.grpo import GRPOAlgorithm
|
||||
from prime_rl.orchestrator.algo.hierarchical_grpo import HierarchicalGRPOAlgorithm
|
||||
from prime_rl.orchestrator.algo.max_rl import MaxRLAlgorithm
|
||||
from prime_rl.orchestrator.algo.opd import OPDAlgorithm
|
||||
from prime_rl.orchestrator.algo.opsd import OPSDAlgorithm
|
||||
@@ -50,6 +52,7 @@ ALGORITHM_CLASSES: dict[str, type[Algorithm]] = {
|
||||
"echo": EchoAlgorithm,
|
||||
"max_rl": MaxRLAlgorithm,
|
||||
"rae": RAEAlgorithm,
|
||||
"hierarchical_grpo": HierarchicalGRPOAlgorithm,
|
||||
"opd": OPDAlgorithm,
|
||||
"opsd": OPSDAlgorithm,
|
||||
"sft": SFTDistillAlgorithm,
|
||||
@@ -71,6 +74,7 @@ __all__ = [
|
||||
"Algorithm",
|
||||
"EchoAlgorithm",
|
||||
"GRPOAlgorithm",
|
||||
"HierarchicalGRPOAlgorithm",
|
||||
"MaxRLAlgorithm",
|
||||
"OPDAlgorithm",
|
||||
"OPSDAlgorithm",
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import defaultdict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from prime_rl.configs.algorithm import HierarchicalGRPOAlgoConfig
|
||||
from prime_rl.orchestrator.algo.base import Algorithm
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from prime_rl.orchestrator.types import Rollout
|
||||
from prime_rl.utils.client import InferencePool
|
||||
|
||||
|
||||
class HierarchicalGRPOAlgorithm(Algorithm):
|
||||
"""GRPO for proposer-solver envs.
|
||||
|
||||
Solver rewards are compared only with other attempts on the same proposed
|
||||
problem. Proposer rewards are compared with the other proposals generated
|
||||
from the same source task. Keeping those comparisons separate avoids
|
||||
treating different problem difficulties or different agent roles as
|
||||
interchangeable.
|
||||
|
||||
``episode_agents`` lists the roles, normally ``solver``, that are compared
|
||||
within one episode. Other roles are compared across the full rollout group.
|
||||
A comparison group with one trace produces zero advantage."""
|
||||
|
||||
def __init__(self, config: HierarchicalGRPOAlgoConfig, policy_pool: InferencePool):
|
||||
super().__init__(config, policy_pool)
|
||||
self.episode_agents = set(config.episode_agents)
|
||||
|
||||
async def score_group(self, group: list[Rollout]) -> None:
|
||||
peers: dict[tuple[str, str | None], list[Rollout]] = defaultdict(list)
|
||||
for rollout in group:
|
||||
episode_scoped = rollout.agent.name in self.episode_agents
|
||||
key = (rollout.agent.name, rollout.episode_id if episode_scoped else None)
|
||||
peers[key].append(rollout)
|
||||
for members in peers.values():
|
||||
baseline = sum(rollout.reward for rollout in members) / len(members)
|
||||
for rollout in members:
|
||||
rollout.assign_advantages(rollout.reward - baseline)
|
||||
@@ -32,10 +32,10 @@ class RAEAlgorithm(Algorithm):
|
||||
def __init__(self, config: RAEAlgoConfig, policy_pool: InferencePool):
|
||||
super().__init__(config, policy_pool)
|
||||
self.decay = config.decay
|
||||
self.baselines: dict[str | None, float] = defaultdict(float)
|
||||
self.baselines: dict[str, float] = defaultdict(float)
|
||||
|
||||
async def score_group(self, group: list[Rollout]) -> None:
|
||||
for rollout in group:
|
||||
baseline = self.baselines[rollout.agent_name]
|
||||
baseline = self.baselines[rollout.agent.name]
|
||||
rollout.assign_advantages(rollout.reward - baseline)
|
||||
self.baselines[rollout.agent_name] = self.decay * baseline + (1.0 - self.decay) * rollout.reward
|
||||
self.baselines[rollout.agent.name] = self.decay * baseline + (1.0 - self.decay) * rollout.reward
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""Checkpoint manager for ``Progress``. Layout:
|
||||
"""Checkpoint manager for the orchestrator state (``Progress`` counters +
|
||||
``TrainSource`` data position). Layout:
|
||||
``<output_dir>/checkpoints/step_N/orchestrator/progress.pt``."""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -13,6 +14,7 @@ from pathlib import Path
|
||||
import torch
|
||||
|
||||
from prime_rl.configs.orchestrator import CheckpointConfig
|
||||
from prime_rl.orchestrator.train_source import TrainSource
|
||||
from prime_rl.orchestrator.types import Progress
|
||||
from prime_rl.utils.logger import format_time, get_logger
|
||||
from prime_rl.utils.pathing import get_ckpt_dir, get_step_path
|
||||
@@ -26,7 +28,7 @@ class CheckpointManager:
|
||||
def get_ckpt_path(self, step: int) -> Path:
|
||||
return get_step_path(self.ckpt_dir, step) / "orchestrator"
|
||||
|
||||
def save(self, progress: Progress, step: int) -> None:
|
||||
def save(self, progress: Progress, train_source: TrainSource, step: int) -> None:
|
||||
ckpt_path = self.get_ckpt_path(step)
|
||||
ckpt_path.mkdir(parents=True, exist_ok=True)
|
||||
start = time.perf_counter()
|
||||
@@ -35,7 +37,7 @@ class CheckpointManager:
|
||||
fd, tmp_name = tempfile.mkstemp(dir=ckpt_path, prefix="progress.pt.", suffix=".tmp")
|
||||
try:
|
||||
with os.fdopen(fd, "wb") as f:
|
||||
torch.save({"progress": progress}, f)
|
||||
torch.save({"progress": progress, "train_source": train_source.state_dict()}, f)
|
||||
os.replace(tmp_name, ckpt_path / "progress.pt")
|
||||
except BaseException:
|
||||
with contextlib.suppress(OSError):
|
||||
@@ -45,7 +47,7 @@ class CheckpointManager:
|
||||
f"Orchestrator checkpoint saved to {ckpt_path} in {format_time(time.perf_counter() - start)}"
|
||||
)
|
||||
|
||||
def load(self, progress: Progress, step: int) -> None:
|
||||
def load(self, progress: Progress, train_source: TrainSource, step: int) -> None:
|
||||
ckpt_path = self.get_ckpt_path(step)
|
||||
state_file = ckpt_path / "progress.pt"
|
||||
if not state_file.exists():
|
||||
@@ -53,7 +55,7 @@ class CheckpointManager:
|
||||
get_logger().debug(f"Loading checkpoint from {state_file}")
|
||||
start = time.perf_counter()
|
||||
if self.config.skip_progress:
|
||||
get_logger().info("Skipping progress loading from checkpoint")
|
||||
get_logger().info("Skipping progress and data position loading from checkpoint")
|
||||
else:
|
||||
with open(state_file, "rb") as f:
|
||||
state = torch.load(f, weights_only=False)
|
||||
@@ -61,6 +63,16 @@ class CheckpointManager:
|
||||
for key, value in asdict(saved).items():
|
||||
if hasattr(progress, key):
|
||||
setattr(progress, key, value)
|
||||
train_source.load_state_dict(state["train_source"])
|
||||
for name, position in state["train_source"]["envs"].items():
|
||||
if name not in train_source.base_rows:
|
||||
continue
|
||||
rows = train_source.base_rows[name]
|
||||
num_tasks = len(rows) if rows is not None else "infinite"
|
||||
get_logger().info(
|
||||
f"Resumed data position for env {name} - epoch={position['epoch']}, "
|
||||
f"cursor={position['cursor']}/{num_tasks}"
|
||||
)
|
||||
get_logger().debug(f"Orchestrator checkpoint loaded in {format_time(time.perf_counter() - start)}")
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
"""RolloutDispatcher: schedules rollouts under a shared permit counter.
|
||||
|
||||
- Capacity (``max_inflight_rollouts``) is shared across train + eval.
|
||||
A group-scoring task that runs N rollouts in one call reserves N permits.
|
||||
- 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).
|
||||
- Optional rate limiting via ``AsyncLimiter(tasks_per_minute, 60)``.
|
||||
- Emit-everything invariant: every dispatched env-rollout eventually reaches
|
||||
``out_q`` exactly once, as one episode (a ``list[Rollout]``). Failures
|
||||
- Emit-everything invariant: every dispatched episode eventually reaches
|
||||
``out_q`` exactly once, as a ``list[Rollout]``. Failures
|
||||
(env error, empty trajectory, task exception, off-policy cancel) carry
|
||||
``trace.error`` set; sinks decide drop / partial-train policy.
|
||||
``trace.last_error`` set; sinks decide drop / partial-train policy.
|
||||
- ``DispatcherMode.PREFER_TRAIN`` / ``PREFER_EVAL`` controls which kind to
|
||||
schedule next. Transitions are level-triggered (driven by the eval
|
||||
source's emptiness), so in-flight rollouts of the opposite kind drain
|
||||
@@ -129,7 +131,7 @@ class RolloutDispatcher:
|
||||
eval_source: EvalSource | None,
|
||||
policy_pool: InferencePool,
|
||||
policy: Policy,
|
||||
max_inflight_rollouts: int,
|
||||
max_inflight_episodes: int,
|
||||
tasks_per_minute: float | None,
|
||||
max_off_policy_steps: int,
|
||||
) -> None:
|
||||
@@ -143,7 +145,7 @@ class RolloutDispatcher:
|
||||
self.eval_source = eval_source
|
||||
self.max_off_policy_steps = max_off_policy_steps
|
||||
|
||||
self.max_inflight = max_inflight_rollouts
|
||||
self.max_inflight = max_inflight_episodes
|
||||
self.inflight_permits = 0
|
||||
self.rate_limiter: AsyncLimiter | None = (
|
||||
AsyncLimiter(tasks_per_minute, time_period=60) if tasks_per_minute else None
|
||||
@@ -493,7 +495,7 @@ class RolloutDispatcher:
|
||||
self.inflight_permits -= n
|
||||
|
||||
async def handle_completed_rollout(self, task: asyncio.Task) -> None:
|
||||
"""Emit every dispatched env-rollout exactly once to ``out_q``: a ``run``
|
||||
"""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
|
||||
@@ -519,11 +521,14 @@ class RolloutDispatcher:
|
||||
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
|
||||
rollouts = [
|
||||
Rollout(task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)))
|
||||
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.capture_error(exc)
|
||||
r.record_error(exc)
|
||||
is_synth_exception = True
|
||||
|
||||
for r in rollouts:
|
||||
@@ -535,9 +540,9 @@ class RolloutDispatcher:
|
||||
get_logger().warning(f"Empty trajectory in group {meta.group_id} ({meta.env_name})")
|
||||
if r.has_error:
|
||||
self.metrics.record_error(kind=meta.kind, env_name=meta.env_name)
|
||||
if not is_synth_exception and r.error is not None:
|
||||
if not is_synth_exception and r.last_error is not None:
|
||||
get_logger().warning(
|
||||
f"Rollout failed in group {meta.group_id} ({meta.env_name}) — {r.error.type}: {r.error.message}"
|
||||
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.
|
||||
@@ -599,6 +604,7 @@ class RolloutDispatcher:
|
||||
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",
|
||||
@@ -626,6 +632,7 @@ class RolloutDispatcher:
|
||||
for _ in range(unscheduled_cancelled):
|
||||
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",
|
||||
|
||||
@@ -13,18 +13,18 @@ from prime_rl.utils.utils import clean_exit
|
||||
@clean_exit
|
||||
def run_server(config: EnvServerConfig):
|
||||
env = config.env
|
||||
address = env.address or "tcp://127.0.0.1:5000"
|
||||
# The env's ``pool`` (static or elastic) sizes the server; a v0/legacy env runs through
|
||||
address = env.serve.address or "tcp://127.0.0.1:5000"
|
||||
# The env's ``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": env.env_id, "env_args": env.args, "extra_env_kwargs": env.extra_env_kwargs}
|
||||
{"env_id": env.env_id, "env_args": env.legacy.args, "extra_env_kwargs": env.legacy.extra_env_kwargs}
|
||||
if env.is_legacy
|
||||
else {"config_data": env_config_data(env.env)}
|
||||
else {"config_data": env_config_data(env.env), "max_concurrent": env.serve.max_concurrent}
|
||||
)
|
||||
serve_env(
|
||||
**pool_serve_kwargs(env.pool),
|
||||
**pool_serve_kwargs(env.serve.pool),
|
||||
legacy=env.is_legacy,
|
||||
address=address,
|
||||
log_setup=partial(setup_env_server_logging, config.log.level, config.log.json_logging),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
"""Env wrappers over a v1 env server.
|
||||
|
||||
Each ``Env`` owns a v1 ``EnvServer`` (spawned as a child process, or an
|
||||
external one given by ``config.address``) and an ``EnvClient`` to drive it. The
|
||||
external one pinned by ``config.serve.address``) and an ``EnvClient`` to drive it. The
|
||||
orchestrator never *runs* an environment — the agents and their runtimes live only
|
||||
in the server — but it does own the *taskset*: a v1 env's tasks are loaded here,
|
||||
once, and each dispatched env-rollout ships its task's data on the request
|
||||
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
|
||||
@@ -12,7 +12,7 @@ cache — and gives the orchestrator real tasks to cycle, shuffle, and filter. O
|
||||
the legacy (v0) bridge, whose dataset genuinely lives server-side, is still driven
|
||||
by ``task_idx`` (its count comes from ``info``).
|
||||
|
||||
The server answers one ``Episode`` per env-rollout, whose traces we validate into
|
||||
The server answers one ``Episode`` per run request, whose traces we validate into
|
||||
``Trace[WireTaskData]`` — real ``vf.Trace``\\ s (never loose dicts) whose task
|
||||
keeps the env's task-specific fields as extras (``WireTaskData`` allows them).
|
||||
"""
|
||||
@@ -34,7 +34,7 @@ from typing import Generic, TypeVar
|
||||
import verifiers.v1 as vf
|
||||
from verifiers.v1.serve import EnvClient, env_config_data
|
||||
|
||||
from prime_rl.configs.orchestrator import EnvConfig, EvalEnvConfig, TrainEnvConfig
|
||||
from prime_rl.configs.orchestrator import EnvConfig, EvalSourceConfig, TrainSourceConfig
|
||||
from prime_rl.orchestrator.algo import Algorithm, build_algorithm
|
||||
from prime_rl.orchestrator.sampler import Sampler
|
||||
from prime_rl.orchestrator.types import Rollout
|
||||
@@ -112,8 +112,8 @@ class Env:
|
||||
async def start(self, log_dir: Path, log_level: str | None = None, json_logging: bool = False) -> None:
|
||||
"""Spawn the env server (if needed), connect, and load the taskset client-side
|
||||
(legacy instead asks the server for ``info`` — its dataset is server-side)."""
|
||||
external = self.config.address is not None
|
||||
address = self.config.address or await self._spawn(log_dir, log_level or "INFO", json_logging)
|
||||
external = self.config.serve.address is not None
|
||||
address = self.config.serve.address or await self._spawn(log_dir, log_level or "INFO", json_logging)
|
||||
get_logger().debug(f"Connecting {self.name} to env server {address}")
|
||||
self._env_client = EnvClient(address=address)
|
||||
# A spawned server already reported its address *after* binding, so it's up. An
|
||||
@@ -152,12 +152,18 @@ class Env:
|
||||
dict(
|
||||
legacy=True,
|
||||
env_id=self.config.env_id,
|
||||
env_args=self.config.args,
|
||||
extra_env_kwargs=self.config.extra_env_kwargs,
|
||||
env_args=self.config.legacy.args,
|
||||
extra_env_kwargs=self.config.legacy.extra_env_kwargs,
|
||||
)
|
||||
if self.config.is_legacy
|
||||
# Picklable dict — the narrowed config class doesn't survive the spawn.
|
||||
else dict(legacy=False, config_data=env_config_data(self.config.env))
|
||||
# ``max_concurrent`` bounds this worker's episodes in flight — usually unset,
|
||||
# since the dispatcher's ``max_inflight_episodes`` is the run's bound.
|
||||
else dict(
|
||||
legacy=False,
|
||||
config_data=env_config_data(self.config.env),
|
||||
max_concurrent=self.config.serve.max_concurrent,
|
||||
)
|
||||
)
|
||||
process = ctx.Process(
|
||||
target=_run_env_server,
|
||||
@@ -165,7 +171,7 @@ class Env:
|
||||
log_file=str(log_file),
|
||||
log_level=log_level,
|
||||
json_logging=json_logging,
|
||||
**vf.pool_serve_kwargs(self.config.pool),
|
||||
**vf.pool_serve_kwargs(self.config.serve.pool),
|
||||
address="tcp://127.0.0.1:0",
|
||||
address_queue=address_queue,
|
||||
**server_kwargs,
|
||||
@@ -211,14 +217,14 @@ class Env:
|
||||
sampling=self._sampling(cache_salt),
|
||||
)
|
||||
if not episode.traces:
|
||||
error = episode.error
|
||||
error = episode.last_error
|
||||
detail = f"{error.type}: {error.message}" if error is not None else "no traces and no error recorded"
|
||||
raise RuntimeError(f"env-rollout failed before any trace was minted — {detail}")
|
||||
raise RuntimeError(f"episode failed before any trace was produced — {detail}")
|
||||
rollouts = [ROLLOUT_TYPE.model_construct(**dict(wire)) for wire in episode.traces]
|
||||
for rollout in rollouts:
|
||||
rollout.episode_id = episode.id
|
||||
if not episode.ok and rollout.ok:
|
||||
error = episode.error or vf.Error(
|
||||
error = episode.last_error or vf.Error(
|
||||
type="EpisodeFailed", message="A sibling trace in this episode failed"
|
||||
)
|
||||
rollout.errors = [*rollout.errors, error]
|
||||
@@ -246,9 +252,9 @@ class Env:
|
||||
|
||||
|
||||
class TrainEnv(Env):
|
||||
config: TrainEnvConfig
|
||||
config: TrainSourceConfig
|
||||
|
||||
def __init__(self, config: TrainEnvConfig, sampler: Sampler, algorithm: Algorithm):
|
||||
def __init__(self, config: TrainSourceConfig, sampler: Sampler, algorithm: Algorithm):
|
||||
super().__init__(config)
|
||||
self.sampler = sampler
|
||||
self.algorithm = algorithm
|
||||
@@ -256,9 +262,9 @@ class TrainEnv(Env):
|
||||
|
||||
|
||||
class EvalEnv(Env):
|
||||
config: EvalEnvConfig
|
||||
config: EvalSourceConfig
|
||||
|
||||
def __init__(self, config: EvalEnvConfig):
|
||||
def __init__(self, config: EvalSourceConfig):
|
||||
super().__init__(config)
|
||||
self.sampling_args = config.sampling.to_sampling_args()
|
||||
self.examples: list[dict] = []
|
||||
@@ -333,10 +339,10 @@ class TrainEnvs(Envs[TrainEnv]):
|
||||
:class:`Sampler` and runtime :class:`Algorithm`, built from the env's
|
||||
resolved algorithm config."""
|
||||
|
||||
def __init__(self, configs: Sequence[TrainEnvConfig], *, policy_pool, renderer_config=None):
|
||||
def __init__(self, configs: Sequence[TrainSourceConfig], *, policy_pool, renderer_config=None):
|
||||
self._envs: dict[str, TrainEnv] = {}
|
||||
for config in configs:
|
||||
assert config.algo is not None, "TrainEnvConfig.algo must be resolved before env construction"
|
||||
assert config.algo is not None, "TrainSourceConfig.algo must be resolved before env construction"
|
||||
env = TrainEnv(
|
||||
config,
|
||||
Sampler(config.algo.sampling, policy_pool, renderer_config),
|
||||
@@ -348,7 +354,7 @@ class TrainEnvs(Envs[TrainEnv]):
|
||||
class EvalEnvs(Envs[EvalEnv]):
|
||||
"""Collection of evaluation environments."""
|
||||
|
||||
def __init__(self, configs: Sequence[EvalEnvConfig]):
|
||||
def __init__(self, configs: Sequence[EvalSourceConfig]):
|
||||
self._envs: dict[str, EvalEnv] = {}
|
||||
for config in configs:
|
||||
env = EvalEnv(config)
|
||||
|
||||
@@ -6,8 +6,17 @@ A rollout container (``TrainRollouts`` / ``EvalRollouts``) owns the rollout list
|
||||
``rollouts.metrics.num_input_tokens.mean()`` works — and assembles the full
|
||||
``{prefix}/{subset}/<metric>/<stat>`` wandb dict via ``.to_wandb(...)``.
|
||||
|
||||
No I/O, no pandas — plain Python over the ``vf.Trace`` properties each rollout exposes. Aggregation
|
||||
is flat over the rollout list except the solve rates, which group by ``group_id``.
|
||||
The wandb layout mirrors the episode/trace hierarchy, one aggregation per level:
|
||||
|
||||
- ``{prefix}/{subset}/<metric>/<stat>`` — episode level, one value per episode summing its traces
|
||||
(matching ``vf.Episode``'s aggregates). Only the count metrics live here.
|
||||
- ``{prefix}/{subset}/<agent>/<metric>/<stat>`` — agent level, one value per trace, grouped by agent
|
||||
name (``vf.Episode.by_agent``) so agents never mix into one distribution. Everything trace-scoped
|
||||
lives here: reward, rates, timing, custom metrics, the pipeline verdicts, the eval scores.
|
||||
|
||||
A single-agent env has one trace per episode, so the count metrics coincide across levels.
|
||||
|
||||
No I/O, no pandas — plain Python over the ``vf.Trace`` properties each rollout exposes.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -90,26 +99,26 @@ class TimingMetrics(StatGroup):
|
||||
"""Per-phase rollout durations, nested so ``metrics.timing.setup.mean()`` reads naturally.
|
||||
``total`` is the per-rollout sum across all phases."""
|
||||
|
||||
PHASES = ("setup", "generation", "finalize", "scoring")
|
||||
PHASES = ("setup", "agent", "finalize", "scoring")
|
||||
|
||||
@property
|
||||
def setup(self) -> Stat:
|
||||
return Stat([r.timing.setup.duration for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def generation(self) -> Stat:
|
||||
return Stat([r.timing.generation.duration for r in self.rollouts])
|
||||
def agent(self) -> Stat:
|
||||
return Stat([r.timing.agent.duration for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def generation_model(self) -> Stat:
|
||||
"""The share of the generation phase spent inside model calls (inference)."""
|
||||
return Stat([r.timing.generation.model.duration for r in self.rollouts])
|
||||
def agent_model(self) -> Stat:
|
||||
"""The share of the agent phase spent inside model calls (inference)."""
|
||||
return Stat([r.timing.agent.model.duration for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def generation_harness(self) -> Stat:
|
||||
"""The share of the generation phase spent outside model calls (harness, tools,
|
||||
def agent_harness(self) -> Stat:
|
||||
"""The share of the agent phase spent outside model calls (harness, tools,
|
||||
user simulation)."""
|
||||
return Stat([r.timing.generation.harness.duration for r in self.rollouts])
|
||||
return Stat([r.timing.agent.harness.duration for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def finalize(self) -> Stat:
|
||||
@@ -126,16 +135,19 @@ class TimingMetrics(StatGroup):
|
||||
def stats(self) -> dict[str, Stat]:
|
||||
return {
|
||||
**{phase: getattr(self, phase) for phase in self.PHASES},
|
||||
"generation/model": self.generation_model,
|
||||
"generation/harness": self.generation_harness,
|
||||
"agent/model": self.agent_model,
|
||||
"agent/harness": self.agent_harness,
|
||||
"total": self.total,
|
||||
}
|
||||
|
||||
|
||||
class CustomMetrics(StatGroup):
|
||||
"""Per-key ``Stat``s over a dynamic per-rollout dict attribute (env ``@metric``s or reward
|
||||
components), each averaged over the rollouts that report the key. ``value`` extracts the
|
||||
float from each entry (rewards are ``vf.Reward`` records; metrics are plain floats)."""
|
||||
components), each over the rollouts that carry the key. Scoring seeds every expected key
|
||||
with ``None`` before invoking it, so a ``None`` value means the signal never produced a
|
||||
score and counts as 0.0 — the ``effective`` subset excludes errored rollouts and gives the
|
||||
clean means. ``value`` extracts the float from each scored entry (rewards are ``vf.Reward``
|
||||
records; metrics are plain floats)."""
|
||||
|
||||
def __init__(self, rollouts: list[Rollout], attr: str, value: Callable[[Any], float] = float) -> None:
|
||||
super().__init__(rollouts)
|
||||
@@ -146,40 +158,29 @@ class CustomMetrics(StatGroup):
|
||||
names = sorted({name for r in self.rollouts for name in getattr(r, self.attr)})
|
||||
return {
|
||||
name: Stat(
|
||||
[self.value(getattr(r, self.attr)[name]) for r in self.rollouts if name in getattr(r, self.attr)]
|
||||
[
|
||||
self.value(scores[name]) if scores[name] is not None else 0.0
|
||||
for r in self.rollouts
|
||||
if name in (scores := getattr(r, self.attr))
|
||||
]
|
||||
)
|
||||
for name in names
|
||||
}
|
||||
|
||||
|
||||
class RolloutMetrics:
|
||||
"""Metrics shared by train and eval over a rollout list. Distributional metrics are ``Stat``s
|
||||
(mean/max/min); boolean metrics are ``Stat``s of 0/1 (use ``.mean()`` for the rate). ``to_wandb``
|
||||
assembles the full ``{prefix}/{subset}/...`` dict; ``TrainMetrics`` / ``EvalMetrics`` extend it."""
|
||||
class TraceMetrics(StatGroup):
|
||||
"""Trace-level metrics for one agent, every one of them flat over that agent's traces: one
|
||||
sample is one trace, so a fan-out (n same-agent traces in one episode, e.g. n solvers) simply
|
||||
contributes n samples. Weighing whole episodes against each other is the episode level's job;
|
||||
inside a seat the trace is the unit, which is also what the advantage computation samples."""
|
||||
|
||||
def __init__(self, rollouts: list[Rollout]) -> None:
|
||||
self.rollouts = rollouts
|
||||
DISTRIBUTIONS = ("reward", "num_total_tokens", "num_input_tokens", "num_output_tokens", "num_turns", "num_branches")
|
||||
RATES = ("is_truncated", "is_completed")
|
||||
|
||||
# Distributional metrics
|
||||
@property
|
||||
def num_total_tokens(self) -> Stat:
|
||||
return Stat([float(r.num_total_tokens) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def num_input_tokens(self) -> Stat:
|
||||
return Stat([float(r.num_input_tokens) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def num_output_tokens(self) -> Stat:
|
||||
return Stat([float(r.num_output_tokens) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def num_turns(self) -> Stat:
|
||||
return Stat([float(r.num_turns) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def num_branches(self) -> Stat:
|
||||
return Stat([float(r.num_branches) for r in self.rollouts])
|
||||
def stats(self) -> dict[str, Stat]:
|
||||
return {
|
||||
name: Stat([float(getattr(r, name)) for r in self.rollouts]) for name in (*self.DISTRIBUTIONS, *self.RATES)
|
||||
}
|
||||
|
||||
@property
|
||||
def timing(self) -> TimingMetrics:
|
||||
@@ -187,7 +188,7 @@ class RolloutMetrics:
|
||||
|
||||
@property
|
||||
def metrics(self) -> CustomMetrics:
|
||||
"""Env custom ``@metric`` outputs, keyed by name (``metrics.metrics["acc"].mean()``)."""
|
||||
"""Env custom ``@metric`` outputs, keyed by name."""
|
||||
return CustomMetrics(self.rollouts, "metrics")
|
||||
|
||||
@property
|
||||
@@ -196,22 +197,13 @@ class RolloutMetrics:
|
||||
summed into the scalar ``reward``)."""
|
||||
return CustomMetrics(self.rollouts, "rewards", value=lambda reward: reward.value)
|
||||
|
||||
# Boolean rate metrics (0/1 distributions — ``.mean()`` is the rate)
|
||||
@property
|
||||
def is_truncated(self) -> Stat:
|
||||
return Stat([float(r.is_truncated) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def is_completed(self) -> Stat:
|
||||
return Stat([float(r.is_completed) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def has_error(self) -> Stat:
|
||||
return Stat([float(r.has_error) for r in self.rollouts])
|
||||
|
||||
def stop_conditions(self) -> dict[str, float]:
|
||||
"""``generation_truncated`` over all rollouts, then each recorded ``stop_condition``'s rate
|
||||
over the rollouts that recorded one."""
|
||||
"""``generation_truncated`` over the agent's traces, then each recorded
|
||||
``stop_condition``'s rate over the traces that recorded one."""
|
||||
out = {
|
||||
"generation_truncated": sum(
|
||||
1 for r in self.rollouts if r.is_truncated and r.stop_condition != "prompt_too_long"
|
||||
@@ -224,15 +216,16 @@ class RolloutMetrics:
|
||||
return out
|
||||
|
||||
def error_types(self) -> dict[str, int]:
|
||||
"""Count of errored rollouts by error type (the rollout's last error — e.g. ``Cancelled``,
|
||||
"""Count of errored traces by error type (the trace's last error — e.g. ``Cancelled``,
|
||||
``ProviderError``)."""
|
||||
types = [r.error.type for r in self.rollouts if r.has_error]
|
||||
types = [r.last_error.type for r in self.rollouts if r.has_error and r.last_error is not None]
|
||||
return {t: types.count(t) for t in sorted(set(types))}
|
||||
|
||||
def solve_rates(self) -> dict[str, float]:
|
||||
"""Per-group solve rates, assuming binary 0/1 rewards (unspecified for other reward ranges):
|
||||
``solved_none`` (the group earned no reward), ``solved_all`` (every rollout scored 1.0), and
|
||||
``solved_some`` (the mixed remainder — the GRPO-signal groups)."""
|
||||
"""Per-group solve rates over the agent's traces, assuming binary 0/1 rewards (unspecified
|
||||
for other reward ranges): ``solved_none`` (the group earned no reward), ``solved_all``
|
||||
(every trace scored 1.0), and ``solved_some`` (the mixed remainder — the GRPO-signal
|
||||
groups)."""
|
||||
groups: dict = {}
|
||||
for r in self.rollouts:
|
||||
groups.setdefault(r.group_id, []).append(r)
|
||||
@@ -245,6 +238,84 @@ class RolloutMetrics:
|
||||
"solved_some": 1 - (solved_none + solved_all) / n_groups,
|
||||
}
|
||||
|
||||
def to_dict(self, prefix: str, *, subset: Subset) -> dict[str, float]:
|
||||
"""Full ``<stat>`` fan-out for the distributions; ``/mean`` only for the 0/1 rates.
|
||||
Errors live only on the ``all`` subset (``effective`` drops them by construction)."""
|
||||
stats = self.stats()
|
||||
out: dict[str, float] = {}
|
||||
for name in self.DISTRIBUTIONS:
|
||||
out |= stats[name].to_dict(f"{prefix}/{name}")
|
||||
for name in self.RATES:
|
||||
out[f"{prefix}/{name}/mean"] = stats[name].mean()
|
||||
out |= self.timing.to_dict(f"{prefix}/timing")
|
||||
out |= self.metrics.to_dict(f"{prefix}/metrics")
|
||||
out |= self.rewards.to_dict(f"{prefix}/rewards")
|
||||
if subset == "all":
|
||||
out[f"{prefix}/has_error/mean"] = self.has_error.mean()
|
||||
out |= {f"{prefix}/error/{t}": float(count) for t, count in self.error_types().items()}
|
||||
out |= {f"{prefix}/stop_condition/{k}": v for k, v in self.stop_conditions().items()}
|
||||
out |= {f"{prefix}/{k}": v for k, v in self.solve_rates().items()}
|
||||
return out
|
||||
|
||||
|
||||
class EpisodeMetrics:
|
||||
"""Metrics shared by train and eval over a rollout list. The count metrics (tokens/turns/
|
||||
branches) are episode-level — one value per episode, summing its traces — and are the only
|
||||
per-metric keys ``to_wandb`` emits at the env level; every trace-level metric is emitted per
|
||||
agent via ``by_agent()``. The boolean ``Stat`` properties (0/1 distributions, ``.mean()`` is
|
||||
the rate) serve the console log lines. ``TrainMetrics`` / ``EvalMetrics`` extend ``to_wandb``
|
||||
with the train pipeline rates and the eval scores."""
|
||||
|
||||
def __init__(self, rollouts: list[Rollout]) -> None:
|
||||
self.rollouts = rollouts
|
||||
|
||||
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."""
|
||||
grouped: dict[str, list[Rollout]] = {}
|
||||
for r in self.rollouts:
|
||||
grouped.setdefault(r.episode_id or r.id, []).append(r)
|
||||
return list(grouped.values())
|
||||
|
||||
def by_agent(self) -> dict[str, TraceMetrics]:
|
||||
"""Per-agent metric views (``vf.Episode.by_agent`` over the subset's rollouts)."""
|
||||
per_agent: dict[str, list[Rollout]] = {}
|
||||
for r in self.rollouts:
|
||||
per_agent.setdefault(r.agent.name, []).append(r)
|
||||
return {name: TraceMetrics(rollouts) for name, rollouts in sorted(per_agent.items())}
|
||||
|
||||
# Episode-level count metrics: one value per episode, summing its traces — the same
|
||||
# aggregation as ``vf.Episode.num_turns`` / ``num_*_tokens``.
|
||||
@property
|
||||
def num_total_tokens(self) -> Stat:
|
||||
return Stat([float(sum(r.num_total_tokens for r in episode)) for episode in self.episodes()])
|
||||
|
||||
@property
|
||||
def num_input_tokens(self) -> Stat:
|
||||
return Stat([float(sum(r.num_input_tokens for r in episode)) for episode in self.episodes()])
|
||||
|
||||
@property
|
||||
def num_output_tokens(self) -> Stat:
|
||||
return Stat([float(sum(r.num_output_tokens for r in episode)) for episode in self.episodes()])
|
||||
|
||||
@property
|
||||
def num_turns(self) -> Stat:
|
||||
return Stat([float(sum(r.num_turns for r in episode)) for episode in self.episodes()])
|
||||
|
||||
@property
|
||||
def num_branches(self) -> Stat:
|
||||
return Stat([float(sum(r.num_branches for r in episode)) for episode in self.episodes()])
|
||||
|
||||
# Boolean rate metrics for the console log lines (0/1 distributions — ``.mean()`` is the
|
||||
# rate); to_wandb emits their per-agent counterparts instead.
|
||||
@property
|
||||
def is_truncated(self) -> Stat:
|
||||
return Stat([float(r.is_truncated) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def has_error(self) -> Stat:
|
||||
return Stat([float(r.has_error) for r in self.rollouts])
|
||||
|
||||
def to_wandb(self, *, prefix: str, subset: Subset) -> dict[str, float]:
|
||||
"""The common metric dict for one ``{prefix}/{subset}`` slice. Empty input → ``{}``."""
|
||||
if not self.rollouts:
|
||||
@@ -256,59 +327,55 @@ class RolloutMetrics:
|
||||
out |= self.num_output_tokens.to_dict(f"{p}/num_output_tokens")
|
||||
out |= self.num_turns.to_dict(f"{p}/num_turns")
|
||||
out |= self.num_branches.to_dict(f"{p}/num_branches")
|
||||
out |= self.timing.to_dict(f"{p}/timing")
|
||||
out |= self.metrics.to_dict(f"{p}/metrics")
|
||||
out |= self.rewards.to_dict(f"{p}/rewards")
|
||||
out[f"{p}/is_truncated/mean"] = self.is_truncated.mean()
|
||||
out[f"{p}/is_completed/mean"] = self.is_completed.mean()
|
||||
# errors live only on the `all` subset (effective drops them), so emit the rate + the
|
||||
# per-type counts there only
|
||||
if subset == "all":
|
||||
out[f"{p}/has_error/mean"] = self.has_error.mean()
|
||||
out |= {f"{p}/error/{t}": float(count) for t, count in self.error_types().items()}
|
||||
out |= {f"{p}/stop_condition/{k}": v for k, v in self.stop_conditions().items()}
|
||||
out |= {f"{p}/{k}": v for k, v in self.solve_rates().items()}
|
||||
for agent, agent_metrics in self.by_agent().items():
|
||||
out |= agent_metrics.to_dict(f"{p}/{agent}", subset=subset)
|
||||
return out
|
||||
|
||||
|
||||
class TrainMetrics(RolloutMetrics):
|
||||
"""Common metrics plus the reward distribution and filter-pipeline rates."""
|
||||
class TrainMetrics(EpisodeMetrics):
|
||||
"""Common metrics plus the per-agent filter-pipeline rates. ``reward`` (flat over all traces)
|
||||
serves the console log lines; the wandb reward stats are per-agent."""
|
||||
|
||||
@property
|
||||
def reward(self) -> Stat:
|
||||
return Stat([float(r.reward) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def is_trainable(self) -> Stat:
|
||||
return Stat([float(r.is_trainable) for r in self.rollouts])
|
||||
|
||||
@property
|
||||
def is_filtered(self) -> Stat:
|
||||
return Stat([float(r.is_filtered) for r in self.rollouts])
|
||||
|
||||
def filter_rates(self) -> dict[str, float]:
|
||||
"""Per-filter detection rate over all rollouts."""
|
||||
names = sorted({name for r in self.rollouts for name in r.filter_results})
|
||||
return {
|
||||
name: sum(1 for r in self.rollouts if r.filter_results.get(name)) / len(self.rollouts) for name in names
|
||||
}
|
||||
|
||||
def to_wandb(self, *, prefix: str, subset: Subset) -> dict[str, float]:
|
||||
out = super().to_wandb(prefix=prefix, subset=subset)
|
||||
if not self.rollouts:
|
||||
return out
|
||||
p = f"{prefix}/{subset}"
|
||||
out |= self.reward.to_dict(f"{p}/reward")
|
||||
out[f"{p}/is_trainable/mean"] = self.is_trainable.mean()
|
||||
out[f"{p}/is_filtered/mean"] = self.is_filtered.mean()
|
||||
out |= {f"{p}/filters/{k}/mean": v for k, v in self.filter_rates().items()}
|
||||
# The pipeline verdicts are per-trace (an untrainable seat is 0.0 throughout, and filters
|
||||
# only ever run on trainable survivors), so they read per agent like the rest.
|
||||
for agent, traces in self.by_agent().items():
|
||||
p = f"{prefix}/{subset}/{agent}"
|
||||
rollouts = traces.rollouts
|
||||
out[f"{p}/is_trainable/mean"] = sum(float(r.is_trainable) for r in rollouts) / len(rollouts)
|
||||
out[f"{p}/is_filtered/mean"] = sum(float(r.is_filtered) for r in rollouts) / len(rollouts)
|
||||
names = sorted({name for r in rollouts for name in r.filter_results})
|
||||
out |= {
|
||||
f"{p}/filters/{name}/mean": sum(1 for r in rollouts if r.filter_results.get(name)) / len(rollouts)
|
||||
for name in names
|
||||
}
|
||||
return out
|
||||
|
||||
|
||||
class EvalMetrics(RolloutMetrics):
|
||||
"""Common metrics plus the ``avg@<group_size>`` score and (on the effective subset, for
|
||||
binary-reward tasks) pass@k / pass^k. ``group_size`` (the ``avg@k`` k) is supplied by the
|
||||
container so the ``all`` and ``effective`` subsets share one stable key."""
|
||||
def pass_at_k(rollouts: list[Rollout]) -> dict[str, float]:
|
||||
"""pass@k / pass^k averaged over examples; ``{}`` for non-binary rewards."""
|
||||
rewards = [r.reward for r in rollouts]
|
||||
if not set(rewards).issubset({0.0, 1.0}):
|
||||
return {}
|
||||
by_example: dict = {}
|
||||
for r in rollouts:
|
||||
by_example.setdefault(r.group_id, []).append(r.reward)
|
||||
per_example = [compute_pass_metrics(rs) for rs in by_example.values()]
|
||||
keys = sorted({k for d in per_example for k in d})
|
||||
return {k: sum(d[k] for d in per_example if k in d) / sum(1 for d in per_example if k in d) for k in keys}
|
||||
|
||||
|
||||
class EvalMetrics(EpisodeMetrics):
|
||||
"""Common metrics plus the per-agent ``avg@<group_size>`` score and (on the effective subset,
|
||||
for binary-reward tasks) pass@k / pass^k. Both score an agent's own traces, so they live in its
|
||||
subtree like every other trace-level metric. ``group_size`` (the ``avg@k`` k, the run's rollouts
|
||||
per example) is supplied by the container so the ``all`` and ``effective`` subsets — and every
|
||||
agent — share one stable key."""
|
||||
|
||||
def __init__(self, rollouts: list[Rollout], group_size: int) -> None:
|
||||
super().__init__(rollouts)
|
||||
@@ -318,26 +385,13 @@ class EvalMetrics(RolloutMetrics):
|
||||
def reward(self) -> Stat:
|
||||
return Stat([float(r.reward) for r in self.rollouts])
|
||||
|
||||
def pass_at_k(self) -> dict[str, float]:
|
||||
"""pass@k / pass^k averaged over examples; ``{}`` for non-binary rewards."""
|
||||
rewards = [r.reward for r in self.rollouts]
|
||||
if not set(rewards).issubset({0.0, 1.0}):
|
||||
return {}
|
||||
by_example: dict = {}
|
||||
for r in self.rollouts:
|
||||
by_example.setdefault(r.group_id, []).append(r.reward)
|
||||
per_example = [compute_pass_metrics(rs) for rs in by_example.values()]
|
||||
keys = sorted({k for d in per_example for k in d})
|
||||
return {k: sum(d[k] for d in per_example if k in d) / sum(1 for d in per_example if k in d) for k in keys}
|
||||
|
||||
def to_wandb(self, *, prefix: str, subset: Subset) -> dict[str, float]:
|
||||
out = super().to_wandb(prefix=prefix, subset=subset)
|
||||
if not self.rollouts:
|
||||
return out
|
||||
p = f"{prefix}/{subset}"
|
||||
out[f"{p}/avg@{self.group_size}"] = self.reward.mean()
|
||||
if subset == "effective":
|
||||
out |= {f"{p}/{k}": v for k, v in self.pass_at_k().items()}
|
||||
for agent, traces in self.by_agent().items():
|
||||
p = f"{prefix}/{subset}/{agent}"
|
||||
out[f"{p}/avg@{self.group_size}"] = traces.stats()["reward"].mean()
|
||||
if subset == "effective":
|
||||
out |= {f"{p}/{k}": v for k, v in pass_at_k(traces.rollouts).items()}
|
||||
return out
|
||||
|
||||
|
||||
@@ -360,7 +414,7 @@ class TrainRollouts:
|
||||
|
||||
@property
|
||||
def effective(self) -> TrainRollouts:
|
||||
return TrainRollouts([r for r in self.rollouts if not r.has_error and not r.is_filtered and r.trainable])
|
||||
return TrainRollouts([r for r in self.rollouts if not r.has_error and not r.is_filtered and r.agent.trainable])
|
||||
|
||||
def by_env(self) -> dict[str, TrainRollouts]:
|
||||
grouped: dict[str, list[Rollout]] = {}
|
||||
@@ -399,13 +453,15 @@ class EvalRollouts:
|
||||
return self._group_size
|
||||
counts: dict = {}
|
||||
for r in self.rollouts:
|
||||
if r.trainable:
|
||||
if r.agent.trainable:
|
||||
counts[r.group_id] = counts.get(r.group_id, 0) + 1
|
||||
return max(counts.values(), default=0)
|
||||
|
||||
@property
|
||||
def effective(self) -> EvalRollouts:
|
||||
return EvalRollouts([r for r in self.rollouts if not r.has_error and r.trainable], group_size=self.group_size)
|
||||
return EvalRollouts(
|
||||
[r for r in self.rollouts if not r.has_error and r.agent.trainable], group_size=self.group_size
|
||||
)
|
||||
|
||||
@property
|
||||
def metrics(self) -> EvalMetrics:
|
||||
|
||||
@@ -24,6 +24,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
import os
|
||||
import time
|
||||
import uuid
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import tomli_w
|
||||
@@ -156,7 +157,7 @@ class Orchestrator:
|
||||
# Route the in-process v1 library logging through our handler. The
|
||||
# env server runs in a child process, so its logging is separate.
|
||||
intercept_vf_logging(logger="verifiers.v1", level="WARN")
|
||||
algorithms = sorted({env.algo.type for env in config.train.env if env.algo is not None})
|
||||
algorithms = sorted({env.algo.type for env in config.train.source if env.algo is not None})
|
||||
get_logger().info(f"Starting orchestrator (algorithm: {', '.join(algorithms)})")
|
||||
|
||||
if config.bench:
|
||||
@@ -238,9 +239,12 @@ class Orchestrator:
|
||||
tokenizer=self.tokenizer,
|
||||
run_config=config,
|
||||
keep_full_history=config.bench,
|
||||
train_env_names=[env.resolved_name for env in config.train.env],
|
||||
eval_env_names=[env.resolved_name for env in config.eval.env] if config.eval is not None else [],
|
||||
train_env_names=[env.resolved_name for env in config.train.source],
|
||||
eval_env_names=[source.resolved_name for source in config.eval.source] if config.eval is not None else [],
|
||||
)
|
||||
# ``RunInfo.id`` is required on the trace: fall back to a run-local uuid
|
||||
# when no external monitor identity (W&B) exists.
|
||||
self.run_id = self.monitor.run_id or uuid.uuid4().hex
|
||||
|
||||
if config.heartbeat is not None:
|
||||
self.heart = Heartbeat(config.heartbeat.url)
|
||||
@@ -256,7 +260,7 @@ class Orchestrator:
|
||||
|
||||
get_logger().info("Loading training environments")
|
||||
self.train_envs = TrainEnvs(
|
||||
config.train.env, policy_pool=self.policy_inference, renderer_config=config.renderer
|
||||
config.train.source, policy_pool=self.policy_inference, renderer_config=config.renderer
|
||||
)
|
||||
get_logger().debug(
|
||||
f"Loaded {len(self.train_envs)} training environment(s) ({', '.join(self.train_envs.names)})"
|
||||
@@ -270,7 +274,7 @@ class Orchestrator:
|
||||
|
||||
if config.eval is not None:
|
||||
get_logger().info("Loading eval environment(s)")
|
||||
self.eval_envs = EvalEnvs(config.eval.env)
|
||||
self.eval_envs = EvalEnvs(config.eval.source)
|
||||
get_logger().debug(f"Loaded {len(self.eval_envs)} eval environment(s) ({', '.join(self.eval_envs.names)})")
|
||||
await self.eval_envs.start(
|
||||
log_dir=get_log_dir(config.output_dir.parent) / "envs" / "eval",
|
||||
@@ -339,8 +343,10 @@ class Orchestrator:
|
||||
|
||||
self.lora_name = config.model.lora.name if config.model.lora else None
|
||||
|
||||
self.train_source = TrainSource(self.train_envs)
|
||||
|
||||
if self.resume_step is not None and self.ckpt_manager is not None:
|
||||
self.ckpt_manager.load(self.progress, step=self.resume_step)
|
||||
self.ckpt_manager.load(self.progress, self.train_source, step=self.resume_step)
|
||||
# The checkpoint finished step ``resume_step``; resume at the next step. Derive the step
|
||||
# from ``resume_step`` (not the loaded progress.step) so it stays coordinated with the
|
||||
# trainer even when ``ckpt.skip_progress`` left the counter unrestored.
|
||||
@@ -380,7 +386,6 @@ class Orchestrator:
|
||||
self.policy.model_name = self.lora_name
|
||||
self.policy.version = sync_version
|
||||
|
||||
self.train_source = TrainSource(self.train_envs, seed=42)
|
||||
self.eval_source: EvalSource | None = (
|
||||
EvalSource(
|
||||
self.eval_envs,
|
||||
@@ -391,7 +396,7 @@ class Orchestrator:
|
||||
else None
|
||||
)
|
||||
|
||||
assert config.max_inflight_rollouts is not None, "max_inflight_rollouts must be resolved before dispatcher init"
|
||||
assert config.max_inflight_episodes is not None, "max_inflight_episodes must be resolved before dispatcher init"
|
||||
log_interval = config.log.interval
|
||||
wandb_enabled = config.wandb is not None
|
||||
self.dispatcher = RolloutDispatcher(
|
||||
@@ -401,7 +406,7 @@ class Orchestrator:
|
||||
eval_source=self.eval_source,
|
||||
policy_pool=self.policy_inference,
|
||||
policy=self.policy,
|
||||
max_inflight_rollouts=config.max_inflight_rollouts,
|
||||
max_inflight_episodes=config.max_inflight_episodes,
|
||||
tasks_per_minute=config.tasks_per_minute,
|
||||
max_off_policy_steps=config.max_off_policy_steps,
|
||||
)
|
||||
@@ -496,7 +501,7 @@ class Orchestrator:
|
||||
if self.ckpt_manager is not None and self.progress.step > 1:
|
||||
self.progress.step -= 1
|
||||
get_logger().info("Writing final checkpoint")
|
||||
self.ckpt_manager.save(self.progress, step=self.progress.step)
|
||||
self.ckpt_manager.save(self.progress, self.train_source, step=self.progress.step)
|
||||
await self.stop()
|
||||
if clean_exit:
|
||||
get_logger().success("Orchestrator finished.")
|
||||
@@ -527,12 +532,12 @@ class Orchestrator:
|
||||
step = episode[0].eval_step if kind == "eval" else self.progress.step
|
||||
assert step is not None
|
||||
run: vf.RunInfo = (
|
||||
vf.EvalRunInfo(id=self.monitor.run_id, step=step)
|
||||
vf.EvalRunInfo(id=self.run_id, step=step)
|
||||
if kind == "eval"
|
||||
else vf.TrainRunInfo(id=self.monitor.run_id, step=step)
|
||||
else vf.TrainRunInfo(id=self.run_id, step=step)
|
||||
)
|
||||
for rollout in episode:
|
||||
rollout.stamp(
|
||||
rollout.record_run(
|
||||
run,
|
||||
env_name=rollout.env_name,
|
||||
group_id=str(rollout.group_id),
|
||||
@@ -875,15 +880,15 @@ class Orchestrator:
|
||||
metrics["step"] = float(batch.step)
|
||||
self.monitor.log(metrics, step=batch.step)
|
||||
|
||||
# Success line — reward / turns / truncation over the effective set, error rate + branches
|
||||
# over the full returned cohort. ``Stat.mean()`` is 0.0 for an empty set.
|
||||
# Success line — quality metrics over the effective set, error rate over the full returned
|
||||
# cohort. ``Stat.mean()`` is 0.0 for an empty set.
|
||||
eff, full = effective.metrics, rollouts.metrics
|
||||
triggered_at = self.eval_triggered_at.pop((batch.env_name, batch.step), None)
|
||||
elapsed = (time.perf_counter() - triggered_at) if triggered_at is not None else 0.0
|
||||
get_logger().success(
|
||||
f"Evaluated {batch.env_name} (Step {batch.step}) | "
|
||||
f"Policy v{policy_version} | {format_time(elapsed):>7} | Reward {eff.reward.mean():.4f} | "
|
||||
f"Turns {eff.num_turns.mean():.1f} | Branches {full.num_branches.mean():.1f} | "
|
||||
f"Turns {eff.num_turns.mean():.1f} | Branches {eff.num_branches.mean():.1f} | "
|
||||
f"Error {full.has_error.mean():.1%} | Truncation {eff.is_truncated.mean():.1%}"
|
||||
)
|
||||
|
||||
@@ -900,7 +905,9 @@ class Orchestrator:
|
||||
return 0.0
|
||||
get_logger().info(f"Saving checkpoint at step {step}")
|
||||
t = time.perf_counter()
|
||||
await asyncio.to_thread(self.ckpt_manager.save, self.progress, step)
|
||||
# Synchronous on purpose: the payload is tiny, and snapshotting on the
|
||||
# event loop keeps the dispatcher from mutating TrainSource mid-save
|
||||
self.ckpt_manager.save(self.progress, self.train_source, step)
|
||||
return time.perf_counter() - t
|
||||
|
||||
def update_dispatch_gate(self) -> None:
|
||||
|
||||
@@ -155,7 +155,7 @@ class TrainSink:
|
||||
message graph. Training is renderer-only across all modes (RL/OPD student, SFT teacher),
|
||||
so every node already carries its tokens. Errored rollouts are dropped at the group
|
||||
level, so skip them here; untrainable traces never become training data."""
|
||||
if rollout.has_error or not rollout.trainable:
|
||||
if rollout.has_error or not rollout.agent.trainable:
|
||||
return
|
||||
samples = await asyncio.to_thread(
|
||||
trace_to_samples,
|
||||
@@ -198,7 +198,7 @@ class TrainSink:
|
||||
)
|
||||
return
|
||||
# Untrainable traces carry no samples and must not skew the group baseline.
|
||||
survivors = [r for r in survivors if r.trainable]
|
||||
survivors = [r for r in survivors if r.agent.trainable]
|
||||
if not survivors:
|
||||
get_logger().debug(
|
||||
f"Finished group | env={env_name} task_idx={task_idx} | "
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
Weights are each env's configured ``ratio`` (default 1, i.e. equal weight
|
||||
per env). A v1 env serves the tasks the orchestrator loaded client-side: a
|
||||
finite one as a shuffled table (reshuffled on cursor exhaustion), an
|
||||
infinite one (``num_tasks is None``) straight off its generator — every
|
||||
pull is a fresh task and there are no epochs to shuffle. A legacy env's
|
||||
dataset lives on its server, so it serves shuffled task *indices*."""
|
||||
finite one as a shuffled table (reshuffled with ``seed=epoch`` on cursor
|
||||
exhaustion), an infinite one (``num_tasks is None``) straight off its
|
||||
generator — every pull is a fresh task and there are no epochs to shuffle.
|
||||
A legacy env's dataset lives on its server, so it serves shuffled task
|
||||
*indices*."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -22,51 +23,107 @@ class TrainSource:
|
||||
returns its next example (or ``None`` when the env's per-call permit
|
||||
cost doesn't fit — the dispatch loop retries when permits free up).
|
||||
Returned dicts carry ``env_name`` + ``task_idx`` (+ ``task`` for v1 envs,
|
||||
whose data is shipped to the env server at dispatch)."""
|
||||
whose data is shipped to the env server at dispatch).
|
||||
|
||||
def __init__(self, train_envs: TrainEnvs, *, seed: int | None) -> None:
|
||||
self.rng = random.Random(seed)
|
||||
The data position round-trips through a checkpoint via ``state_dict()``
|
||||
/ ``load_state_dict()``: per-env ``{epoch, cursor}`` plus the env-choice
|
||||
RNG state, making the dispatch sequence reproducible across resumes. For
|
||||
a finite env, epochs are 1-indexed and seed that epoch's shuffle; for an
|
||||
infinite env the epoch stays 1 and the cursor counts generator pulls,
|
||||
replayed on restore by fast-forwarding the generator (exact iff it's
|
||||
deterministic). Cursors advance at dispatch time (ahead of shipped
|
||||
batches), so a resume skips the tasks that were in flight at checkpoint
|
||||
time."""
|
||||
|
||||
def __init__(self, train_envs: TrainEnvs) -> None:
|
||||
self.rng = random.Random(42)
|
||||
# The drawn-but-undispatched env. A draw whose permit cost doesn't fit
|
||||
# is held here (head-of-line) rather than redrawn, so the choice stream
|
||||
# advances exactly once per dispatched example and stays reproducible.
|
||||
self.pending_env: str | None = None
|
||||
self.envs = list(train_envs)
|
||||
if not self.envs:
|
||||
raise ValueError("TrainSource needs at least one train env")
|
||||
|
||||
# A finite env's shuffled example table; ``None`` for an infinite env,
|
||||
# whose generator (``self.iters``) is pulled per example.
|
||||
# A finite env's example table in canonical order (each epoch's shuffle
|
||||
# starts from this); ``None`` for an infinite env, whose generator
|
||||
# (``self.iters``) is pulled per example.
|
||||
self.base_rows: dict[str, list[dict] | None] = {}
|
||||
self.examples: dict[str, list[dict] | None] = {}
|
||||
self.iters: dict[str, Iterator[vf.Task]] = {}
|
||||
self.epochs: dict[str, int] = {}
|
||||
self.cursors: dict[str, int] = {}
|
||||
# Group-scoring envs reserve ``group_size`` permits up front;
|
||||
# per-rollout envs need 1
|
||||
self.env_costs: dict[str, int] = {}
|
||||
for env in self.envs:
|
||||
if env.tasks is None: # legacy: sample over the index range from info()
|
||||
rows: list[dict] = [{"task_idx": i, "env_name": env.name} for i in range(env.num_tasks)]
|
||||
self.rng.shuffle(rows)
|
||||
self.examples[env.name] = rows
|
||||
rows: list[dict] | None = [{"task_idx": i, "env_name": env.name} for i in range(env.num_tasks)]
|
||||
elif env.num_tasks is None: # infinite: pull the generator per example
|
||||
self.examples[env.name] = None
|
||||
rows = None
|
||||
self.iters[env.name] = env.tasks
|
||||
else:
|
||||
rows = [{"task_idx": task.data.idx, "task": task, "env_name": env.name} for task in env.tasks]
|
||||
self.rng.shuffle(rows)
|
||||
self.examples[env.name] = rows
|
||||
self.base_rows[env.name] = rows
|
||||
self.epochs[env.name] = 1
|
||||
self.cursors[env.name] = 0
|
||||
self.examples[env.name] = self._shuffle(env.name)
|
||||
self.env_costs[env.name] = env.config.group_size if env.requires_group_scoring else 1
|
||||
|
||||
self.env_names = [e.name for e in self.envs]
|
||||
self.weights: list[float] = [float(e.config.ratio) for e in self.envs]
|
||||
|
||||
def _shuffle(self, env_name: str) -> list[dict] | None:
|
||||
"""The env's example table shuffled for its current epoch — a pure
|
||||
function of (canonical order, epoch), so a restored position replays
|
||||
the exact epoch permutation."""
|
||||
rows = self.base_rows[env_name]
|
||||
if rows is None:
|
||||
return None
|
||||
rows = rows.copy()
|
||||
random.Random(self.epochs[env_name]).shuffle(rows)
|
||||
return rows
|
||||
|
||||
def state_dict(self) -> dict:
|
||||
"""Env-choice RNG state + pending draw + per-env ``{epoch, cursor}``."""
|
||||
return {
|
||||
"rng": self.rng.getstate(),
|
||||
"pending_env": self.pending_env,
|
||||
"envs": {name: {"epoch": self.epochs[name], "cursor": self.cursors[name]} for name in self.epochs},
|
||||
}
|
||||
|
||||
def load_state_dict(self, state_dict: dict) -> None:
|
||||
self.rng.setstate(state_dict["rng"])
|
||||
pending = state_dict["pending_env"]
|
||||
self.pending_env = pending if pending in self.env_costs else None
|
||||
for name, position in state_dict["envs"].items():
|
||||
if name not in self.base_rows:
|
||||
continue
|
||||
self.epochs[name] = position["epoch"]
|
||||
self.cursors[name] = position["cursor"]
|
||||
if self.base_rows[name] is None:
|
||||
for _ in range(position["cursor"]):
|
||||
next(self.iters[name])
|
||||
else:
|
||||
self.examples[name] = self._shuffle(name)
|
||||
|
||||
def next_example(self, available_permits: int) -> dict | None:
|
||||
env_name = self.rng.choices(self.env_names, weights=self.weights, k=1)[0]
|
||||
if self.pending_env is None:
|
||||
self.pending_env = self.rng.choices(self.env_names, weights=self.weights, k=1)[0]
|
||||
env_name = self.pending_env
|
||||
if self.env_costs[env_name] > available_permits:
|
||||
return None
|
||||
self.pending_env = None
|
||||
rows = self.examples[env_name]
|
||||
cursor = self.cursors[env_name]
|
||||
if rows is None: # infinite env: pull the next generated task
|
||||
task = next(self.iters[env_name])
|
||||
self.cursors[env_name] = cursor + 1
|
||||
return {"task_idx": task.data.idx, "task": task, "env_name": env_name}
|
||||
if cursor >= len(rows):
|
||||
self.rng.shuffle(rows)
|
||||
self.epochs[env_name] += 1
|
||||
rows = self._shuffle(env_name)
|
||||
self.examples[env_name] = rows
|
||||
cursor = 0
|
||||
example = rows[cursor]
|
||||
self.cursors[env_name] = cursor + 1
|
||||
|
||||
@@ -77,7 +77,7 @@ class Rollout(vf.Trace[DataT], Generic[DataT]):
|
||||
orchestration metadata lives on it directly (set by the dispatcher once the rollout
|
||||
returns), so there's no wrapper. Train vs eval is the ``kind`` discriminator. All metadata
|
||||
fields are ``exclude=True``, so dumping a Rollout yields a plain trace on the wire; the
|
||||
orchestrator mirrors them onto the trace's own fields via ``vf.Trace.stamp`` (``kind`` as
|
||||
orchestrator mirrors them onto the trace's own fields via ``vf.Trace.record_run`` (``kind`` as
|
||||
``run.type``, the run id, the step, and ``env_name``/``group_id``/``policy_version`` into
|
||||
``info``) when a rollout arrives, so the on-disk records stay fully placeable.
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ async def setup_policy_inference_pool(*, config: OrchestratorConfig, tokenizer):
|
||||
train_client_type="renderer",
|
||||
eval_client_type="openai_chat_completions",
|
||||
renderer_config=config.renderer,
|
||||
pool_size=config.pool_size,
|
||||
)
|
||||
return renderer, inference_pool
|
||||
|
||||
|
||||
@@ -86,8 +86,14 @@ class PerfCounter:
|
||||
return 756e12
|
||||
else: # For H100 SXM and other variants
|
||||
return 989e12
|
||||
if "B200" in device_name:
|
||||
if "GB200" in device_name or "GB300" in device_name:
|
||||
# Grace Blackwell Superchips, dense BF16 per GPU: 2,500 TFLOPS
|
||||
# https://www.nvidia.com/en-us/data-center/dgx-gb200/
|
||||
# https://www.nvidia.com/en-us/data-center/dgx-gb300/
|
||||
return 2.5e15
|
||||
if "B200" in device_name or "B300" in device_name:
|
||||
# https://nvdam.widen.net/s/wwnsxrhm2w/blackwell-datasheet-3384703
|
||||
# Checked after GB200/GB300 to avoid false match on "GB300"
|
||||
return 2.25e15 # This is half of the FLOPS reported in torchtitan
|
||||
# AMD Instinct GPUs
|
||||
if "MI300X" in device_name:
|
||||
|
||||
@@ -236,7 +236,7 @@ class MultiRunManager:
|
||||
with open(config_path, "rb") as f:
|
||||
config_dict = tomli.load(f)
|
||||
|
||||
from verifiers.v1.loaders import skip_plugin_install
|
||||
from verifiers.v1.utils.loaders import skip_plugin_install
|
||||
|
||||
from prime_rl.configs.orchestrator import OrchestratorConfig
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from httpx import AsyncClient
|
||||
from openai import AsyncOpenAI
|
||||
from renderers import RendererConfig
|
||||
from tenacity import AsyncRetrying, retry, retry_if_exception, stop_after_attempt, stop_after_delay, wait_exponential
|
||||
from verifiers.v1.clients.config import EvalClientConfig, TrainClientConfig
|
||||
from verifiers.v1.configs.client import EvalClientConfig, TrainClientConfig
|
||||
|
||||
from prime_rl.configs.shared import ClientConfig
|
||||
from prime_rl.utils.logger import get_logger
|
||||
@@ -122,7 +122,6 @@ class StaticInferencePool:
|
||||
train_client_type: str = "openai_chat_completions",
|
||||
eval_client_type: str = "openai_chat_completions",
|
||||
renderer_config: RendererConfig | None = None,
|
||||
pool_size: int | None = None,
|
||||
):
|
||||
renderer_model_name = model_name if train_client_type == "renderer" else None
|
||||
self._train_clients = setup_clients(
|
||||
@@ -130,7 +129,6 @@ class StaticInferencePool:
|
||||
client_type=train_client_type,
|
||||
renderer_config=renderer_config,
|
||||
renderer_model_name=renderer_model_name,
|
||||
pool_size=pool_size,
|
||||
)
|
||||
self._eval_clients = setup_clients(client_config, client_type=eval_client_type)
|
||||
self._admin_clients = setup_admin_clients(client_config)
|
||||
@@ -195,7 +193,6 @@ async def setup_inference_pool(
|
||||
train_client_type: str = "openai_chat_completions",
|
||||
eval_client_type: str = "openai_chat_completions",
|
||||
renderer_config: RendererConfig | None = None,
|
||||
pool_size: int | None = None,
|
||||
) -> InferencePool:
|
||||
"""Create an inference pool from config (static or elastic)."""
|
||||
if client_config.is_elastic:
|
||||
@@ -207,7 +204,6 @@ async def setup_inference_pool(
|
||||
train_client_type=train_client_type,
|
||||
eval_client_type=eval_client_type,
|
||||
renderer_config=renderer_config,
|
||||
pool_size=pool_size,
|
||||
)
|
||||
|
||||
return StaticInferencePool(
|
||||
@@ -216,7 +212,6 @@ async def setup_inference_pool(
|
||||
train_client_type=train_client_type,
|
||||
eval_client_type=eval_client_type,
|
||||
renderer_config=renderer_config,
|
||||
pool_size=pool_size,
|
||||
)
|
||||
|
||||
|
||||
@@ -225,7 +220,6 @@ def setup_clients(
|
||||
client_type: str = "openai_chat_completions",
|
||||
renderer_config: RendererConfig | None = None,
|
||||
renderer_model_name: str | None = None,
|
||||
pool_size: int | None = None,
|
||||
) -> list[vf.ClientConfig]:
|
||||
"""Build one v1 client config per base URL. ``client_type``
|
||||
``renderer`` → token-in/out (``TrainClientConfig``, with the renderer the env
|
||||
@@ -237,7 +231,6 @@ def setup_clients(
|
||||
if is_renderer:
|
||||
renderer_extra = {
|
||||
"renderer": renderer_config,
|
||||
"pool_size": pool_size or 1,
|
||||
"renderer_model_name": renderer_model_name,
|
||||
}
|
||||
env_headers = {
|
||||
@@ -608,7 +601,7 @@ async def prefill_logprobs(openai: AsyncOpenAI, model: str, token_ids: list[int]
|
||||
+ ``prompt_logprobs`` (the prime-rl server-side extension in
|
||||
``inference/vllm/serving_tokens.py``). Returns one logprob per token (0.0 for
|
||||
the leading token, which has no preceding context)."""
|
||||
from vllm.entrypoints.serve.disagg.protocol import GenerateResponse
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.protocol import GenerateResponse
|
||||
|
||||
# `/inference/v1/generate` is mounted at server root, not under `/v1`: pass an
|
||||
# absolute URL so the SDK skips the base-url merge. vLLM's `GenerateResponse`
|
||||
|
||||
@@ -116,7 +116,6 @@ class ElasticInferencePool:
|
||||
train_client_type: str = "openai_chat_completions",
|
||||
eval_client_type: str = "openai_chat_completions",
|
||||
renderer_config: RendererConfig | None = None,
|
||||
pool_size: int | None = None,
|
||||
):
|
||||
self.logger = get_logger()
|
||||
self.client_config = client_config
|
||||
@@ -129,7 +128,6 @@ class ElasticInferencePool:
|
||||
self.train_client_type = train_client_type
|
||||
self.eval_client_type = eval_client_type
|
||||
self.renderer_config = renderer_config
|
||||
self.pool_size = pool_size
|
||||
self.router_url = client_config.router_url
|
||||
|
||||
self._servers: dict[str, ServerState] = {}
|
||||
@@ -155,7 +153,6 @@ class ElasticInferencePool:
|
||||
train_client_type: str = "openai_chat_completions",
|
||||
eval_client_type: str = "openai_chat_completions",
|
||||
renderer_config: RendererConfig | None = None,
|
||||
pool_size: int | None = None,
|
||||
) -> ElasticInferencePool:
|
||||
if client_config.elastic is None:
|
||||
raise ValueError("Elastic inference pool requires elastic config")
|
||||
@@ -165,7 +162,6 @@ class ElasticInferencePool:
|
||||
train_client_type=train_client_type,
|
||||
eval_client_type=eval_client_type,
|
||||
renderer_config=renderer_config,
|
||||
pool_size=pool_size,
|
||||
)
|
||||
await pool.start()
|
||||
return pool
|
||||
@@ -211,7 +207,6 @@ class ElasticInferencePool:
|
||||
client_type=self.train_client_type,
|
||||
renderer_config=self.renderer_config,
|
||||
renderer_model_name=self.renderer_model_name,
|
||||
pool_size=self.pool_size,
|
||||
)
|
||||
if urls
|
||||
else []
|
||||
|
||||
@@ -15,7 +15,7 @@ import pyarrow as pa
|
||||
import pyarrow.parquet as pq
|
||||
from prime_cli.core.config import Config as PrimeConfig
|
||||
from transformers.tokenization_utils import PreTrainedTokenizer
|
||||
from verifiers.v1.push import trace_to_sample
|
||||
from verifiers.v1.utils.platform import trace_to_sample
|
||||
|
||||
from prime_rl.configs.orchestrator import OrchestratorConfig
|
||||
from prime_rl.configs.shared import PrimeMonitorConfig
|
||||
@@ -168,7 +168,7 @@ class PrimeMonitor(Monitor):
|
||||
payload["batch_size"] = run_config.batch_size
|
||||
payload["rollouts_per_example"] = run_config.group_size
|
||||
payload["seq_len"] = run_config.seq_len
|
||||
payload["environments"] = [{"id": env.id} for env in run_config.train.env]
|
||||
payload["environments"] = [{"id": env.env_id} for env in run_config.train.source]
|
||||
payload["run_config"] = run_config.model_dump(exclude_none=True, mode="json")
|
||||
if run_config.wandb:
|
||||
payload["wandb_project"] = run_config.wandb.project
|
||||
@@ -295,7 +295,7 @@ class PrimeMonitor(Monitor):
|
||||
"""Convert rollouts to Parquet bytes for upload. One row per rollout. The conversation
|
||||
is the unit (no prompt/completion split — meaningless mid-branch): `completion` is the
|
||||
last branch's messages and `trajectory` is one message list per branch. Shares
|
||||
`verifiers.v1.push.trace_to_sample` with verifiers' eval `--push`, so a training-run
|
||||
`verifiers.v1.utils.platform.trace_to_sample` with verifiers' eval `--push`, so a training-run
|
||||
sample and an eval sample land on the platform identically; the RFT-only columns
|
||||
(run/step/advantage/problem_id/env_name) are layered on here."""
|
||||
now = datetime.now(timezone.utc)
|
||||
|
||||
@@ -298,15 +298,21 @@ class WandbMonitor(Monitor):
|
||||
|
||||
OVERVIEW_NAME = "overview"
|
||||
|
||||
# Per-rollout metrics (under "<scope>/all/") shown for BOTH train and eval. Only the reward metrics
|
||||
# differ — train uses "reward/mean", eval uses "avg@k", each shown for the all and effective
|
||||
# subsets — and each section builder prepends its own.
|
||||
# Rollout metrics (under "<scope>/") shown for BOTH train and eval. Quality metrics read the
|
||||
# effective subset — the all subset includes errored rollouts, whose zero values skew the
|
||||
# distributions. has_error only exists on all (effective drops errors by construction). The count
|
||||
# metrics are episode-level exact keys; the trace-level metrics (reward, truncation, errors) live
|
||||
# under the per-agent subtree, whose names are data-dependent — matched by regex, one panel per
|
||||
# agent. Only the score metric differs — train scores with "reward/mean", eval with "avg@k" (its k
|
||||
# dynamic, so also a regex) — and each section builder prepends its own.
|
||||
COMMON_METRICS = [
|
||||
"has_error/mean",
|
||||
"is_truncated/mean",
|
||||
"num_total_tokens/mean",
|
||||
"num_turns/mean",
|
||||
"num_branches/mean",
|
||||
"effective/num_total_tokens/mean",
|
||||
"effective/num_turns/mean",
|
||||
"effective/num_branches/mean",
|
||||
]
|
||||
COMMON_REGEXES = [
|
||||
"all/[^/]+/has_error/mean",
|
||||
"effective/[^/]+/is_truncated/mean",
|
||||
]
|
||||
|
||||
STABILITY_METRICS = ["optim/grad_norm", "entropy/all/mean", "mismatch_kl/all/mean", "kl_ent_ratio/mean"]
|
||||
@@ -348,20 +354,25 @@ def section(name: str, metrics: Sequence[str] = (), regexes: Sequence[str] = ())
|
||||
|
||||
|
||||
def train_section(name: str, scope: str) -> ws.Section:
|
||||
# Env names may carry regex metacharacters (e.g. "+"), so the scope is escaped in the
|
||||
# regex-matched per-agent panels.
|
||||
pattern = re.escape(scope)
|
||||
return section(
|
||||
name,
|
||||
metrics=[f"{scope}/all/reward/mean", f"{scope}/effective/reward/mean"]
|
||||
+ [f"{scope}/all/{m}" for m in COMMON_METRICS],
|
||||
metrics=[f"{scope}/{m}" for m in COMMON_METRICS],
|
||||
regexes=[f"{pattern}/all/[^/]+/reward/mean", f"{pattern}/effective/[^/]+/reward/mean"]
|
||||
+ [f"{pattern}/{r}" for r in COMMON_REGEXES],
|
||||
)
|
||||
|
||||
|
||||
def eval_section(name: str, env_pattern: str) -> ws.Section:
|
||||
# Same metrics as train, but eval's reward is "avg@k" (dynamic k → regex). Everything is a regex so
|
||||
# one section can also serve any env (env_pattern=".*").
|
||||
# Same metrics as train, but eval's reward is the per-agent "avg@k" (dynamic k → regex).
|
||||
# Everything is a regex so one section can also serve any env (env_pattern=".*").
|
||||
return section(
|
||||
name,
|
||||
regexes=[f"eval/{env_pattern}/all/avg@.*", f"eval/{env_pattern}/effective/avg@.*"]
|
||||
+ [f"eval/{env_pattern}/all/{m}" for m in COMMON_METRICS],
|
||||
regexes=[f"eval/{env_pattern}/all/[^/]+/avg@.*", f"eval/{env_pattern}/effective/[^/]+/avg@.*"]
|
||||
+ [f"eval/{env_pattern}/{m}" for m in COMMON_METRICS]
|
||||
+ [f"eval/{env_pattern}/{r}" for r in COMMON_REGEXES],
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Sanity tests for the prime-RL ``ServingTokens`` subclass.
|
||||
|
||||
The full happy-path is owned upstream by vLLM 0.20's
|
||||
The full happy-path is owned upstream by vLLM's
|
||||
``vllm/entrypoints/serve/disagg`` test suite. We only cover the prime-RL
|
||||
deltas here:
|
||||
* ``serialize_routed_experts`` round-trips a compact raw-byte payload.
|
||||
@@ -15,7 +15,7 @@ import asyncio
|
||||
import numpy as np
|
||||
import pybase64
|
||||
from vllm.entrypoints.openai.engine.protocol import UsageInfo
|
||||
from vllm.entrypoints.serve.disagg.protocol import GenerateResponse, GenerateResponseChoice
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.protocol import GenerateResponse, GenerateResponseChoice
|
||||
|
||||
from prime_rl.inference.vllm.routed_experts import serialize_routed_experts
|
||||
from prime_rl.inference.vllm.serving_tokens import (
|
||||
|
||||
@@ -99,6 +99,7 @@ def _build_rollout(
|
||||
|
||||
rollout = Rollout[vf.TaskData](
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
nodes=nodes,
|
||||
calls=calls,
|
||||
rewards={"reward": vf.Reward(score=reward)},
|
||||
|
||||
@@ -162,7 +162,11 @@ def _make_rollout(
|
||||
advantages: list[float] | None = None,
|
||||
) -> Rollout:
|
||||
rollout = Rollout(
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)), nodes=[], rewards={}, env_name="test-env"
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
nodes=[],
|
||||
rewards={},
|
||||
env_name="test-env",
|
||||
)
|
||||
rollout.samples = samples
|
||||
rollout.advantages = advantages
|
||||
@@ -257,6 +261,7 @@ def _two_turn_rollout(observation_role: str = "tool") -> Rollout:
|
||||
]
|
||||
rollout = Rollout(
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
nodes=nodes,
|
||||
rewards={"r": vf.Reward(score=1.0)},
|
||||
env_name="test-env",
|
||||
@@ -308,6 +313,7 @@ def test_echo_weights_only_content_tokens_when_is_content_present():
|
||||
]
|
||||
rollout = Rollout(
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
nodes=nodes,
|
||||
rewards={"r": vf.Reward(score=1.0)},
|
||||
env_name="test-env",
|
||||
|
||||
@@ -59,6 +59,7 @@ def _make_rollout(
|
||||
nodes = [_assistant_node(completion_ids, completion_logprobs)]
|
||||
rollout = Rollout[vf.TaskData](
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt="")),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
nodes=nodes,
|
||||
rewards={"reward": vf.Reward(score=reward)},
|
||||
)
|
||||
@@ -141,6 +142,7 @@ def test_gibberish_aligns_logprobs_under_generation_prompt_scaffold():
|
||||
|
||||
rollout = Rollout[vf.TaskData](
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt="")),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
nodes=[_scaffold_assistant_node([50, 80, 120_000], [-1.0, -0.5, gibberish_filter.logprob_threshold - 1.0])],
|
||||
rewards={"reward": vf.Reward(score=1.0)},
|
||||
)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import math
|
||||
from itertools import count
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
@@ -7,10 +8,14 @@ import verifiers.v1 as vf
|
||||
from prime_rl.orchestrator.metrics import EvalRollouts, Stat, TrainRollouts
|
||||
from prime_rl.orchestrator.utils import compute_pass_metrics
|
||||
|
||||
_ids = count()
|
||||
|
||||
|
||||
def mk(
|
||||
reward: float = 0.0,
|
||||
*,
|
||||
episode_id: str = "",
|
||||
agent_name: str = "agent",
|
||||
num_total_tokens: int = 10,
|
||||
num_input_tokens: int = 4,
|
||||
num_output_tokens: int = 6,
|
||||
@@ -30,14 +35,18 @@ def mk(
|
||||
is_filtered: bool = False,
|
||||
filter_results: dict | None = None,
|
||||
setup: float = 0.0,
|
||||
generation: float = 0.0,
|
||||
generation_model: float = 0.0,
|
||||
generation_harness: float = 0.0,
|
||||
agent: float = 0.0,
|
||||
agent_model: float = 0.0,
|
||||
agent_harness: float = 0.0,
|
||||
finalize: float = 0.0,
|
||||
scoring: float = 0.0,
|
||||
):
|
||||
"""Duck-typed stand-in for ``Rollout``, exposing only the Trace properties the metrics read."""
|
||||
"""Duck-typed stand-in for ``Rollout``, exposing only the Trace properties the metrics read.
|
||||
Without an ``episode_id`` each rollout is its own single-trace episode (the unique ``id``
|
||||
is the grouping fallback)."""
|
||||
return SimpleNamespace(
|
||||
id=f"t{next(_ids)}",
|
||||
episode_id=episode_id,
|
||||
reward=reward,
|
||||
rewards=rewards or {},
|
||||
num_total_tokens=num_total_tokens,
|
||||
@@ -48,21 +57,21 @@ def mk(
|
||||
is_truncated=is_truncated,
|
||||
is_completed=is_completed,
|
||||
has_error=has_error,
|
||||
error=SimpleNamespace(type=error_type) if has_error else None,
|
||||
last_error=SimpleNamespace(type=error_type) if has_error else None,
|
||||
stop_condition=stop_condition,
|
||||
metrics=metrics or {},
|
||||
env_name=env_name,
|
||||
group_id=group_id,
|
||||
trainable=trainable,
|
||||
agent=SimpleNamespace(trainable=trainable, name=agent_name),
|
||||
is_trainable=is_trainable,
|
||||
is_filtered=is_filtered,
|
||||
filter_results=filter_results or {},
|
||||
timing=SimpleNamespace(
|
||||
setup=SimpleNamespace(duration=setup),
|
||||
generation=SimpleNamespace(
|
||||
duration=generation,
|
||||
model=SimpleNamespace(duration=generation_model),
|
||||
harness=SimpleNamespace(duration=generation_harness),
|
||||
agent=SimpleNamespace(
|
||||
duration=agent,
|
||||
model=SimpleNamespace(duration=agent_model),
|
||||
harness=SimpleNamespace(duration=agent_harness),
|
||||
),
|
||||
finalize=SimpleNamespace(duration=finalize),
|
||||
scoring=SimpleNamespace(duration=scoring),
|
||||
@@ -105,20 +114,60 @@ def test_to_wandb_distributions():
|
||||
).metrics
|
||||
assert m.num_input_tokens.mean() == 5.0 # fluent Stat access
|
||||
out = m.to_wandb(prefix="train/agg", subset="all")
|
||||
assert out["train/agg/all/reward/mean"] == 0.5
|
||||
assert out["train/agg/all/agent/reward/mean"] == 0.5
|
||||
assert "train/agg/all/reward/mean" not in out # trace-level metrics are agent-only
|
||||
assert out["train/agg/all/num_total_tokens/mean"] == 15.0
|
||||
assert out["train/agg/all/num_total_tokens/max"] == 20.0 # flat over rollouts, not per-group
|
||||
assert out["train/agg/all/num_total_tokens/max"] == 20.0 # single-trace episodes: one value per rollout
|
||||
assert out["train/agg/all/num_input_tokens/mean"] == 5.0
|
||||
assert out["train/agg/all/num_output_tokens/mean"] == 6.0
|
||||
|
||||
|
||||
def test_episode_and_agent_levels():
|
||||
# Two proposer-solver episodes: one proposer + two solvers each (the solver fan-out).
|
||||
rollouts = [
|
||||
mk(reward=1.0, num_turns=1, agent_name="proposer", episode_id="e1"),
|
||||
mk(reward=0.0, num_turns=2, agent_name="solver", episode_id="e1"),
|
||||
mk(reward=1.0, num_turns=4, agent_name="solver", episode_id="e1"),
|
||||
mk(reward=0.0, num_turns=3, agent_name="proposer", episode_id="e2"),
|
||||
mk(reward=1.0, num_turns=6, agent_name="solver", episode_id="e2"),
|
||||
mk(reward=0.0, num_turns=8, agent_name="solver", episode_id="e2"),
|
||||
]
|
||||
m = TrainRollouts(rollouts).metrics
|
||||
assert m.num_turns.mean() == 12.0 # episode-level sums: 1+2+4 and 3+6+8
|
||||
assert m.num_total_tokens.values == [30.0, 30.0] # summed across the episode's traces
|
||||
out = m.to_wandb(prefix="train/agg", subset="all")
|
||||
assert out["train/agg/all/num_turns/mean"] == 12.0
|
||||
assert out["train/agg/all/proposer/num_turns/mean"] == 2.0 # (1 + 3) / 2
|
||||
assert out["train/agg/all/solver/num_turns/mean"] == 5.0 # flat over the 4 solver traces
|
||||
assert out["train/agg/all/solver/num_turns/max"] == 8.0 # a real trace, not an episode mean
|
||||
assert out["train/agg/all/solver/reward/mean"] == 0.5
|
||||
assert out["train/agg/all/proposer/is_truncated/mean"] == 0.0
|
||||
assert "train/agg/all/proposer/is_truncated/p90" not in out # rates emit /mean only
|
||||
assert "train/agg/all/reward/mean" not in out # reward never pools across agents
|
||||
|
||||
|
||||
def test_agent_metrics_are_flat_over_traces():
|
||||
"""Inside a seat the trace is the unit of aggregation, so an uneven fan-out (one solver trace
|
||||
from this episode, three from that) never reweights anything: every agent-level metric is the
|
||||
plain figure over that agent's rollouts."""
|
||||
rollouts = [
|
||||
mk(agent_name="solver", episode_id="e1", is_truncated=True, reward=1.0),
|
||||
*[mk(agent_name="solver", episode_id="e2", is_truncated=False, reward=0.0) for _ in range(3)],
|
||||
]
|
||||
out = TrainRollouts(rollouts).metrics.to_wandb(prefix="train/agg", subset="all")
|
||||
assert out["train/agg/all/solver/is_truncated/mean"] == 0.25 # 1 of 4 traces, not (1.0 + 0.0) / 2
|
||||
assert out["train/agg/all/solver/is_completed/mean"] == 1.0
|
||||
assert out["train/agg/all/solver/is_trainable/mean"] == 1.0 # sibling rates agree
|
||||
assert out["train/agg/all/solver/reward/mean"] == 0.25 # 1 of 4 traces scored, not (1.0 + 0.0) / 2
|
||||
|
||||
|
||||
def test_boolean_rates_and_error_breakdown_all_only():
|
||||
rc = TrainRollouts([mk(is_truncated=True), mk(has_error=True, error_type="ProviderError"), mk(is_filtered=True)])
|
||||
out = rc.metrics.to_wandb(prefix="train/agg", subset="all")
|
||||
assert out["train/agg/all/is_truncated/mean"] == 1 / 3
|
||||
assert out["train/agg/all/is_completed/mean"] == 1.0
|
||||
assert out["train/agg/all/has_error/mean"] == 1 / 3
|
||||
assert out["train/agg/all/error/ProviderError"] == 1 # error-type breakdown by count
|
||||
assert out["train/agg/all/agent/is_truncated/mean"] == 1 / 3
|
||||
assert out["train/agg/all/agent/is_completed/mean"] == 1.0
|
||||
assert out["train/agg/all/agent/has_error/mean"] == 1 / 3
|
||||
assert out["train/agg/all/agent/error/ProviderError"] == 1 # error-type breakdown by count
|
||||
assert not any("no_response" in k for k in out) # removed metric
|
||||
# has_error + the error-type counts are structurally empty on effective, so emitted on `all` only
|
||||
eff = rc.effective.metrics.to_wandb(prefix="train/agg", subset="effective")
|
||||
@@ -128,42 +177,59 @@ def test_boolean_rates_and_error_breakdown_all_only():
|
||||
def test_solve_rates():
|
||||
groups = {"A": [1.0, 1.0], "B": [0.0, 0.0], "C": [1.0, 0.0], "D": [1.0, 0.0]} # all / none / some / some
|
||||
out = train_wandb([mk(reward=r, group_id=g) for g, rs in groups.items() for r in rs])
|
||||
rates = (out["train/agg/all/solved_all"], out["train/agg/all/solved_none"], out["train/agg/all/solved_some"])
|
||||
rates = (
|
||||
out["train/agg/all/agent/solved_all"],
|
||||
out["train/agg/all/agent/solved_none"],
|
||||
out["train/agg/all/agent/solved_some"],
|
||||
)
|
||||
assert rates == (0.25, 0.25, 0.5)
|
||||
|
||||
|
||||
def test_stop_condition_breakdown():
|
||||
truncated = [mk(is_truncated=True, stop_condition=c) for c in ("length", "max_turns", "prompt_too_long")]
|
||||
out = train_wandb(truncated + [mk(stop_condition=None)])
|
||||
assert out["train/agg/all/stop_condition/generation_truncated"] == 0.5 # truncated & not prompt_too_long, over all
|
||||
assert out["train/agg/all/stop_condition/length"] == 1 / 3 # over the 3 recorded conditions
|
||||
assert out["train/agg/all/stop_condition/prompt_too_long"] == 1 / 3
|
||||
assert out["train/agg/all/agent/stop_condition/generation_truncated"] == 0.5 # truncated & not prompt_too_long
|
||||
assert out["train/agg/all/agent/stop_condition/length"] == 1 / 3 # over the 3 recorded conditions
|
||||
assert out["train/agg/all/agent/stop_condition/prompt_too_long"] == 1 / 3
|
||||
|
||||
|
||||
def test_nested_metrics_and_rewards():
|
||||
rollouts = [
|
||||
mk(metrics={"acc": 1.0}, rewards={"correct": vf.Reward(score=1.0), "format": vf.Reward(score=0.0)}),
|
||||
mk(metrics={"acc": 3.0, "fmt": 5.0}, rewards={"correct": vf.Reward(score=0.0), "format": vf.Reward(score=1.0)}),
|
||||
# scoring failed after seeding: unscored (None) entries count as 0.0 on `all`
|
||||
mk(has_error=True, metrics={"acc": None}, rewards={"correct": None, "format": None}),
|
||||
]
|
||||
m = TrainRollouts(rollouts).metrics
|
||||
assert m.metrics["acc"].mean() == 2.0 and m.rewards["correct"].mean() == 0.5 # nested group access
|
||||
rc = TrainRollouts(rollouts)
|
||||
m = rc.metrics
|
||||
agent = m.by_agent()["agent"]
|
||||
assert agent.metrics["acc"].mean() == pytest.approx(4 / 3) # nested group access
|
||||
assert agent.rewards["correct"].mean() == pytest.approx(1 / 3)
|
||||
out = m.to_wandb(prefix="train/agg", subset="all")
|
||||
assert out["train/agg/all/metrics/acc/mean"] == 2.0 # averaged over reporters
|
||||
assert out["train/agg/all/metrics/fmt/mean"] == 5.0 # single reporter
|
||||
assert out["train/agg/all/rewards/format/mean"] == 0.5
|
||||
assert out["train/agg/all/agent/metrics/acc/mean"] == pytest.approx(4 / 3)
|
||||
assert out["train/agg/all/agent/metrics/fmt/mean"] == 5.0 # single reporter
|
||||
assert out["train/agg/all/agent/rewards/format/mean"] == pytest.approx(1 / 3)
|
||||
# effective drops the errored rollout, so its seeds don't dilute the effective means
|
||||
eff = rc.effective.metrics.to_wandb(prefix="train/agg", subset="effective")
|
||||
assert eff["train/agg/effective/agent/metrics/acc/mean"] == 2.0
|
||||
assert eff["train/agg/effective/agent/rewards/format/mean"] == 0.5
|
||||
# cross-env agg: another env's unscored trace carries different keys, so it can't dilute these
|
||||
other = mk(env_name="other", has_error=True, rewards={"solved": None})
|
||||
agg = TrainRollouts(rollouts + [other]).metrics.to_wandb(prefix="train/agg", subset="all")
|
||||
assert agg["train/agg/all/agent/rewards/format/mean"] == pytest.approx(1 / 3)
|
||||
assert agg["train/agg/all/agent/rewards/solved/mean"] == 0.0
|
||||
|
||||
|
||||
def test_nested_timing():
|
||||
m = TrainRollouts(
|
||||
[mk(setup=1.0, generation=2.0, generation_model=1.5, generation_harness=0.5, finalize=0.5, scoring=0.5)]
|
||||
).metrics
|
||||
assert m.timing.setup.mean() == 1.0 and m.timing.total.mean() == 4.0 # total sums all four phases
|
||||
assert m.timing.generation_model.mean() == 1.5 and m.timing.generation_harness.mean() == 0.5
|
||||
m = TrainRollouts([mk(setup=1.0, agent=2.0, agent_model=1.5, agent_harness=0.5, finalize=0.5, scoring=0.5)]).metrics
|
||||
timing = m.by_agent()["agent"].timing
|
||||
assert timing.setup.mean() == 1.0 and timing.total.mean() == 4.0 # total sums all four phases
|
||||
assert timing.agent_model.mean() == 1.5 and timing.agent_harness.mean() == 0.5
|
||||
out = m.to_wandb(prefix="train/agg", subset="all")
|
||||
assert out["train/agg/all/timing/setup/mean"] == 1.0
|
||||
assert out["train/agg/all/timing/total/mean"] == 4.0
|
||||
assert out["train/agg/all/timing/generation/model/mean"] == 1.5
|
||||
assert out["train/agg/all/timing/generation/harness/mean"] == 0.5
|
||||
assert out["train/agg/all/agent/timing/setup/mean"] == 1.0
|
||||
assert out["train/agg/all/agent/timing/total/mean"] == 4.0
|
||||
assert out["train/agg/all/agent/timing/agent/model/mean"] == 1.5
|
||||
assert out["train/agg/all/agent/timing/agent/harness/mean"] == 0.5
|
||||
|
||||
|
||||
def test_train_only_metrics_absent_from_eval():
|
||||
@@ -172,9 +238,10 @@ def test_train_only_metrics_absent_from_eval():
|
||||
mk(is_trainable=False, filter_results={"gibberish": False}),
|
||||
]
|
||||
out = train_wandb(rollouts)
|
||||
assert out["train/agg/all/is_trainable/mean"] == 0.5
|
||||
assert out["train/agg/all/is_filtered/mean"] == 0.5
|
||||
assert out["train/agg/all/filters/gibberish/mean"] == 0.5
|
||||
assert out["train/agg/all/agent/is_trainable/mean"] == 0.5
|
||||
assert out["train/agg/all/agent/is_filtered/mean"] == 0.5
|
||||
assert out["train/agg/all/agent/filters/gibberish/mean"] == 0.5
|
||||
assert "train/agg/all/is_trainable/mean" not in out # pipeline verdicts are per-trace
|
||||
eval_out = EvalRollouts(rollouts).metrics.to_wandb(prefix="eval/x", subset="all")
|
||||
assert not any("is_trainable" in k or "is_filtered" in k or "/filters/" in k for k in eval_out)
|
||||
|
||||
@@ -182,11 +249,11 @@ def test_train_only_metrics_absent_from_eval():
|
||||
def test_eval_avg_at_k_and_pass_k():
|
||||
binary = EvalRollouts([mk(reward=1.0, group_id="g0"), mk(reward=0.0, group_id="g0")])
|
||||
eff = binary.effective.metrics.to_wandb(prefix="eval/x", subset="effective")
|
||||
assert eff["eval/x/effective/avg@2"] == 0.5 # mean reward under avg@<k> (k derived from the groups)
|
||||
assert not any(k.startswith("eval/x/effective/reward") for k in eff)
|
||||
assert eff["eval/x/effective/pass@1"] == 0.5 and eff["eval/x/effective/pass^2"] == 0.0
|
||||
assert eff["eval/x/effective/agent/avg@2"] == 0.5 # mean reward under avg@<k> (k from the groups)
|
||||
assert "eval/x/effective/avg@2" not in eff # scores are per-agent, never pooled
|
||||
assert eff["eval/x/effective/agent/pass@1"] == 0.5 and eff["eval/x/effective/agent/pass^2"] == 0.0
|
||||
all_out = binary.metrics.to_wandb(prefix="eval/x", subset="all")
|
||||
assert all_out["eval/x/all/avg@2"] == 0.5
|
||||
assert all_out["eval/x/all/agent/avg@2"] == 0.5
|
||||
assert not any("pass@" in k or "pass^" in k for k in all_out) # pass@k effective-only
|
||||
non_binary = EvalRollouts([mk(reward=0.5, group_id="g0"), mk(reward=1.0, group_id="g0")])
|
||||
assert not any("pass@" in k for k in non_binary.effective.metrics.to_wandb(prefix="eval/x", subset="effective"))
|
||||
|
||||
@@ -17,7 +17,6 @@ def test_setup_policy_inference_pool_uses_renderer_when_enabled():
|
||||
name="policy-model",
|
||||
),
|
||||
renderer=renderer_settings,
|
||||
pool_size=None,
|
||||
any_policy_sourced=True,
|
||||
)
|
||||
renderer = object()
|
||||
@@ -44,7 +43,6 @@ def test_setup_policy_inference_pool_uses_renderer_when_enabled():
|
||||
train_client_type="renderer",
|
||||
eval_client_type="openai_chat_completions",
|
||||
renderer_config=renderer_settings,
|
||||
pool_size=None,
|
||||
)
|
||||
|
||||
asyncio.run(run())
|
||||
@@ -65,7 +63,6 @@ def test_setup_policy_inference_pool_keeps_renderer_without_policy_sampling():
|
||||
name="policy-model",
|
||||
),
|
||||
renderer=renderer_settings,
|
||||
pool_size=None,
|
||||
any_policy_sourced=False,
|
||||
)
|
||||
renderer = object()
|
||||
@@ -92,7 +89,6 @@ def test_setup_policy_inference_pool_keeps_renderer_without_policy_sampling():
|
||||
train_client_type="renderer",
|
||||
eval_client_type="openai_chat_completions",
|
||||
renderer_config=renderer_settings,
|
||||
pool_size=None,
|
||||
)
|
||||
|
||||
asyncio.run(run())
|
||||
|
||||
@@ -96,8 +96,8 @@ def test_renderer_client_qwen3_vl_e2e_features_payload_roundtrips_through_vllm()
|
||||
ClientConfig,
|
||||
UserMessage,
|
||||
)
|
||||
from vllm.entrypoints.serve.disagg.mm_serde import decode_mm_kwargs_item
|
||||
from vllm.entrypoints.serve.disagg.protocol import GenerateRequest
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.mm_serde import decode_mm_kwargs_item
|
||||
from vllm.entrypoints.scale_out.token_in_token_out.protocol import GenerateRequest
|
||||
|
||||
# ── Build a real Qwen3VLRenderer with a real processor. ─────────────
|
||||
tokenizer = load_tokenizer(_MODEL)
|
||||
|
||||
@@ -25,11 +25,14 @@ CONFIG_CLASSES = [
|
||||
|
||||
|
||||
def get_config_files() -> list[Path]:
|
||||
"""Any TOML file inside `configs/` or `examples/`."""
|
||||
"""Any TOML file inside `configs/`, `examples/` or `k8s/`."""
|
||||
config_files = list(Path("configs").rglob("*.toml"))
|
||||
example_files = list(Path("examples").rglob("*.toml"))
|
||||
# The k8s example configs are mounted into the chart's containers verbatim, so a
|
||||
# stale key there breaks a deploy with nothing else to catch it.
|
||||
k8s_files = list(Path("k8s").rglob("*.toml"))
|
||||
|
||||
return config_files + example_files
|
||||
return config_files + example_files + k8s_files
|
||||
|
||||
|
||||
@pytest.mark.parametrize("config_file", get_config_files(), ids=lambda x: x.as_posix())
|
||||
@@ -177,10 +180,10 @@ def test_env_algo_overrides_top_level():
|
||||
{
|
||||
"renderer": {"name": "qwen3"}, # echo needs the renderer's role attribution
|
||||
"algo": {"type": "echo"},
|
||||
"train": {"env": [{"id": "a", "algo": {"type": "grpo"}}, {"id": "b"}]},
|
||||
"train": {"source": [{"legacy": {"id": "a"}, "algo": {"type": "grpo"}}, {"legacy": {"id": "b"}}]},
|
||||
}
|
||||
)
|
||||
env_a, env_b = config.train.env
|
||||
env_a, env_b = config.train.source
|
||||
# Env a sets its own algorithm; only env b inherits the top-level echo algorithm.
|
||||
assert env_a.algo is not None and env_a.algo.type == "grpo"
|
||||
assert env_b.algo is not None and env_b.algo.type == "echo"
|
||||
@@ -188,7 +191,23 @@ def test_env_algo_overrides_top_level():
|
||||
# Resolved configs round-trip.
|
||||
dumped = config.model_dump(exclude_none=True)
|
||||
reloaded = OrchestratorConfig.model_validate(dumped)
|
||||
assert reloaded.train.env[0].algo is not None and reloaded.train.env[0].algo.type == "grpo"
|
||||
assert reloaded.train.source[0].algo is not None and reloaded.train.source[0].algo.type == "grpo"
|
||||
|
||||
with pytest.raises(ValidationError, match="env"):
|
||||
OrchestratorConfig.model_validate(
|
||||
{
|
||||
"renderer": {"name": "qwen3"},
|
||||
"train": {"env": [{"legacy": {"id": "removed"}}]},
|
||||
}
|
||||
)
|
||||
|
||||
with pytest.raises(ValidationError, match="env"):
|
||||
OrchestratorConfig.model_validate(
|
||||
{
|
||||
"renderer": {"name": "qwen3"},
|
||||
"eval": {"env": [{"legacy": {"id": "removed"}}]},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_trainer_enable_token_export_cli_flag():
|
||||
|
||||
@@ -32,8 +32,7 @@ def create_run_with_config(output_dir: Path, run_name: str) -> Path:
|
||||
"model": {"name": "test-model"},
|
||||
"batch_size": 2,
|
||||
"group_size": 1,
|
||||
"env": [{"id": "test-env"}],
|
||||
"sampling": {"temperature": 1.0},
|
||||
"train": {"source": [{"legacy": {"id": "test-env"}}], "sampling": {"temperature": 1.0}},
|
||||
# test-model isn't in MODEL_RENDERER_MAP; use the explicit default renderer.
|
||||
"renderer": {"name": "default"},
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ def create_run_with_config(
|
||||
"model": {"name": "test-model"},
|
||||
"batch_size": 32,
|
||||
"group_size": 4,
|
||||
"env": [{"id": "test-env"}],
|
||||
"train": {"source": [{"legacy": {"id": "test-env"}}]},
|
||||
# test-model isn't in MODEL_RENDERER_MAP; use the explicit default renderer.
|
||||
"renderer": {"name": "default"},
|
||||
}
|
||||
@@ -202,7 +202,7 @@ def test_config_loading(tmp_path: Path) -> None:
|
||||
"batch_size": 32,
|
||||
"max_steps": 1000,
|
||||
"group_size": 4,
|
||||
"env": [{"id": "test-env"}],
|
||||
"train": {"source": [{"legacy": {"id": "test-env"}}]},
|
||||
"renderer": {"name": "default"},
|
||||
}
|
||||
create_run_with_config(tmp_path, "run_test123", config=test_config)
|
||||
@@ -247,7 +247,7 @@ def test_config_cleanup_on_deletion(tmp_path: Path) -> None:
|
||||
"model": {"name": "test-model"},
|
||||
"batch_size": 16,
|
||||
"group_size": 4,
|
||||
"env": [{"id": "test-env"}],
|
||||
"train": {"source": [{"legacy": {"id": "test-env"}}]},
|
||||
"renderer": {"name": "default"},
|
||||
}
|
||||
run_dir = create_run_with_config(tmp_path, "run_delete_me", config=test_config)
|
||||
@@ -278,7 +278,7 @@ def test_config_invalid(tmp_path: Path) -> None:
|
||||
"model": {"name": "test-model"},
|
||||
"batch_size": "not-a-number", # Invalid type
|
||||
"group_size": 4,
|
||||
"env": [{"id": "test-env"}],
|
||||
"train": {"source": [{"legacy": {"id": "test-env"}}]},
|
||||
}
|
||||
run_dir = create_run_with_config(tmp_path, "run_invalid", config=invalid_config)
|
||||
config_dir = run_dir / "control"
|
||||
|
||||
@@ -3,7 +3,7 @@ from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import httpx
|
||||
from verifiers.v1.clients.config import EvalClientConfig
|
||||
from verifiers.v1.configs.client import EvalClientConfig
|
||||
|
||||
from prime_rl.configs.shared import ClientConfig
|
||||
from prime_rl.utils.client import _is_retryable_lora_error, check_health, load_lora_adapter, setup_clients
|
||||
|
||||
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
import httpx
|
||||
from verifiers.v1.clients.config import TrainClientConfig
|
||||
from verifiers.v1.configs.client import TrainClientConfig
|
||||
|
||||
from prime_rl.utils.elastic import (
|
||||
AdapterState,
|
||||
|
||||
@@ -37,6 +37,7 @@ def _build_rollout(*, example_id: int, reward: float, task: str) -> Rollout:
|
||||
]
|
||||
rollout = Rollout[vf.TaskData](
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=example_id, prompt=f"prompt-{example_id}")),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
nodes=nodes,
|
||||
rewards={"reward": vf.Reward(score=reward)},
|
||||
)
|
||||
@@ -81,7 +82,8 @@ def test_rollouts_to_parquet_bytes_skips_rollouts_without_trajectory():
|
||||
|
||||
rollout_with_branches = _build_rollout(example_id=1, reward=1.0, task="task-a")
|
||||
rollout_without_branches = Rollout[vf.TaskData](
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=2, prompt="missing-trajectory"))
|
||||
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=2, prompt="missing-trajectory")),
|
||||
agent=vf.AgentInfo(config=vf.AgentConfig()),
|
||||
)
|
||||
assert rollout_without_branches.branches == []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user