Commit 1023b42
sophistry_bench_sprint_env: add training example and results (#853)
* docs+examples(sophistry_bench_sprint_env): add training example and results
Adds the prime-rl GRPO config and per-step metrics from a 100-step run
against the deployed env, plus a README section showing the reward-hacking
signature (aggregate_reward up, correctness_reward flat). Also adds a
from-scratch TRL GRPOTrainer example for training against the Space
directly, for anyone without Prime Intellect access.
* examples(sophistry_bench_sprint_grpo): add --push-to-hub to publish checkpoint
Closes the gap between local training output and an actual Hub artifact,
matching the maintainer's "deployed to Hugging Face" ask for the training
side, not just the Space.
* fix(sophistry_bench_sprint_env): correct deployed Space repo id
The env is actually hosted at openenv-community/sophistry_bench_sprint_env,
not anushaacharya/sophistry_bench_sprint_env as originally documented in #787 --
verified via `hf spaces info`.
* docs(sophistry_bench_sprint_env): lead with TRL example, demote Prime Intellect to a note
Reframes the Training section so the TRL GRPOTrainer script (verified
end-to-end against the deployed Space) is the primary documented path,
matching this repo's own guidance that TRL is the recommended framework.
The Prime Intellect run becomes supplementary evidence, not the headline.
Also switches the script to GenericEnvClient + a directly-constructed
UVProvider (avoiding a sync/async event-loop mismatch from mixing
asyncio.run(from_env(...)) with .sync()), and bumps the default model to
Qwen2.5-0.5B-Instruct for a cheaper, faster default run.
* docs+examples(sophistry_bench_sprint_grpo): add real HF Jobs run results
Runs the TRL GRPO example for real on Hugging Face Jobs (a10g-small, 100
steps, Qwen2.5-0.5B-Instruct) and documents the results honestly: the proxy
reward (aggregate_reward) climbs and plateaus, confirming the example trains
correctly end-to-end on HF infrastructure, but at this much smaller scale
(~800 total rollouts vs. the Prime Intellect run's ~12,800) the policy
collapses to near-empty completions rather than converging on the
claim_count_cliff target -- a different reward-hacking shortcut, not a
replication of the Prime Intellect run's specific curve. correctness_reward
stays noisy/decoupled either way, which is the core finding both runs share.
Also extends the reward_func to log per-step reward components (not just the
scalar reward), since correctness_reward/n_claims live in
observation["components"], which the trainer never needed but the README
table does. Opts into SPRINT_EXPOSE_CORRECTNESS=1 for the locally-run clone
(not the shared Space) since this is exactly the "trusted measurement code"
use case the env's own README carves out -- never fed back into the prompt.
Tuning notes from getting this to actually run without OOM on a10g-small:
- per_device_train_batch_size is the *total* rollout count per step (must be
divisible by num_generations), not unique-prompts * num_generations.
- bf16 matters more than usual here: entropy/logprob computation materializes
a [batch, completion_len, vocab_size] logits tensor, and a ~150K-token
vocab (Qwen2.5) dominates memory at fp32.
- gradient_checkpointing=True had no measurable effect in this setup (same
OOM numbers with and without); reducing batch size was what actually fixed
it. Left in since it's harmless, but don't rely on it alone.
* fix(sophistry_bench_sprint_grpo): harden against review findings
From a self-review pass before requesting maintainer review on #853:
- Validate --per-device-batch-size % --num-generations == 0 up front, before
the ~180s env clone/start and dataset build -- previously this only
surfaced as an opaque ValueError deep inside GRPOTrainer construction.
- Extract completion-text parsing into _completion_text(), which now raises
a clear error on an empty/malformed completion list instead of a bare
IndexError/TypeError.
- Assert completions and seed are the same length in the reward function,
instead of letting zip() silently truncate and misalign reward<->task.
- Write the components CSV under output_dir (which save_model() already
guarantees exists) instead of a sibling path derived from --out's
basename, which could fail if --out's parent directory doesn't exist.
- Extract the CSV-writing block into write_metrics_csv().
Also tried switching make_sync_client() to the simpler from_env() + .sync()
pattern, now that #854 fixes the event-loop mismatch that motivated building
it manually in the first place -- and reverted. The fixed connect() does
correctly reconnect on the new loop instead of hanging, but it can't cleanly
close the *old* connection first (its event loop is already gone), so the
old one is simply abandoned. That's harmless for envs that allow concurrent
sessions, but this one doesn't (SUPPORTS_CONCURRENT_SESSIONS = False): the
abandoned connection occupies the only session slot, and the real one fails
with CAPACITY_REACHED. Confirmed by reproducing it locally. make_sync_client()
avoids the problem by never creating that doomed first connection at all.
Updated its docstring to explain both reasons.
* simplify(sophistry_bench_sprint): cut footprint per review
Addressing @burtenshaw's review on #853:
- Drop training/hf_jobs_metrics.csv, training/metrics.csv,
training/sophistry_bench_sprint.toml -- envs and examples should be
decoupled; these were training artifacts, not env source.
- Drop the custom metrics_log/components-CSV tracking in the example script
entirely (reward_func just returns rewards now, like every other
reward_funcs example in this repo) rather than wiring up trackio for a
one-off script.
- Inline make_sync_client() into main() -- it was only used once.
- Cut the module docstring and inline comments down to the essentials;
the full event-loop/single-session explanation lives in #854 and the
CAPACITY_REACHED finding, not duplicated here in prose.
- Condense the env README's "Training" section from two tables + ~40 lines
of analysis to one paragraph; the full numbers are in the PR description.
Re-verified end-to-end after the rewrite (4 episodes, 1 step): trains,
saves a real checkpoint, no regressions.
---------
Co-authored-by: burtenshaw <ben.burtenshaw@gmail.com>1 parent fa94751 commit 1023b42
3 files changed
Lines changed: 190 additions & 2 deletions
File tree
- docs/source/environments
- envs/sophistry_bench_sprint_env
- examples
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
70 | 86 | | |
71 | 87 | | |
72 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
0 commit comments