Repository navigation
RFC 013: Task sampling and in-training evaluation - #1256
Matheus-F-Scatolin wants to merge 7 commits into
Conversation
Proposes a TaskSampler protocol (sequential, uniform, cost-aware curriculum), a generic TaskAPIClient, an EnvEvalHarness built on the collect pipeline, EvalSchedule, and an `openenv eval` command. Includes preliminary results from a single-seed pilot (Llama-3.2-1B, GRPO + LoRA, reasoning_gym_env) and lists the index entry in rfcs/README.md. Co-Authored-By: Tiago Perrupato Antunes <tiagoperrupato@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a95de40. Configure here.
|
We pushed a revision of the RFC with results on three more seeds; the list of changes is in the description. The pilot's per-token result did not repeat. Difference to uniform sampling, in points of test success (500 questions), as the mean of the evaluations at 4 to 5 million generated tokens ("per token") and at steps 100 to 700 ("per episode"):
Per episode, seed 2 is read at steps 100 to 700 for each pair of runs that reached step 700. The rule we wrote before the run read every run of a seed only up to the step all of them reached; one run of seed 2 stopped at step 223, and that rule gives +3.9 for the curriculum, with the same conclusion. Three new seeds are a pattern, not a significance test. What changed in the proposal:
Three questions for the maintainers are in #1445. The trial's code and logs are at Matheus-F-Scatolin/OpenEnv@rfc-013-trial. |
There was a problem hiding this comment.
Thanks @Matheus-F-Scatolin @tiagoperrupato for the RFC and the trial data. The TaskSampler protocol, TaskAPIClient, the eval harness and its reproducibility checks look good to me. I'm requesting changes on the cost path only, with details inline:
- Keep cost out of the sampling weights. I found no lab report or paper that divides a task's sampling weight by its cost. Labs that handle cost keep per-source shares and give slow sources more rollout capacity (MiMo-V2.6, LongCat-Flash-Thinking-2601, MiniMax M2), and budget-aware methods move rollouts toward hard tasks (Knapsack RL). With dollar costs from an environment (#1382), dividing would starve the expensive, hard tasks. Costs should be reported, and used for budgets and concurrency.
- State the trainer hooks a sampler needs. It needs to draw prompts from
sample(n)and to callupdateon every scored group before dynamic-sampling filters such as huggingface/trl#7609 drop the all-pass and all-fail groups. Aligning with prime-rl'sTaskSamplerwould help, andCurriculumSamplercan stay an example (open question 9). - Cite the trainer-side pieces rather than define them. Post-generation filtering and per-environment mixture shares are enforced by the trainer's rollout scheduler, and the
groupkey already carries the metadata those shares need.
Dividing a task's sampling weight by its cost starves expensive, hard tasks, and no lab report or paper found does it. service_spend is for accounting and for planning budgets and concurrency; a trainer can still report it to RFC 013's update() as costs. Refs openenv#1382, openenv#1256
|
Thanks @rycerzes for the careful review. 2a5bbf6 revises the RFC:
On the sources: we read the five reports, huggingface/trl#7609 and prime-rl's sampler. For lab practice they support what you describe: none of them divides a task's sampling weight by its cost. Outside lab reports the idea does exist. Graves et al. (2017) divide a task's learning progress by the time a sample of it takes to process (the length of its longest input sequence), and two 2026 preprints that apply the idea to GRPO, DUET and Cost-Aware Learning, divide a usefulness term by the square root of the cost, to allocate rollouts within a batch and to sample update minibatches. Cost-aware Bayesian optimization also documents the failure you expect, in best-point search: a plain value/cost ratio keeps choosing cheap, low-value points (Lee et al., 2020; Astudillo et al., 2021). The RFC cites Graves et al., DUET and Cost-Aware Learning in Alternatives Considered; the last two allocate rollouts or minibatches, not tasks. One nuance on MiniMax-M2: it gives the instability of batches tilted toward short, easy tasks as the reason for its windowed FIFO, without a measurement, and that tilt comes from completion order in an asynchronous pipeline, not from a constant reweighting such as dividing by cost. |
rycerzes
left a comment
There was a problem hiding this comment.
Thanks for addressing the issues @tiagoperrupato @Matheus-F-Scatolin
you can resolve the review conversation since they are outdated now
One suggestion: keep the RFC to OpenEnv's side. The prime-rl wrapper sketch (L155) and the TRL IterableDataset path (L257) describe those trainers' internals and would fit better in their repos or in the examples/ of rollout step 6. The two hooks (L255) and the notes on what stays with the trainer (L259, L261) are enough here.
|
Thanks @rycerzes for the approval and the suggestion. 693135e takes it: the RFC no longer sketches a prime-rl wrapper (in 693135e also states what RFC 014 (#1508) and |

Summary
Adds RFC 013, which proposes trainer-side task sampling and in-training evaluation on top of the existing Task API: a
TaskSamplerprotocol with sequential and uniform samplers in core, a curriculum sampler offered as an example, a genericTaskAPIClient, anEnvEvalHarnessbuilt from theopenenv collectpipeline's pieces, anEvalSchedule, and anopenenv evalcommand. It targets the "simple evals that can be scored by a script" step of RFC 000's phase three. This PR only adds the RFC and its index entry; no code changes.The RFC includes results measured on a laptop (Llama-3.2-1B, GRPO + LoRA in MLX,
reasoning_gym_envchain_sumin five difficulty tiers): a single-seed pilot, then a trial on three more seeds, with predictions and the rules for reading the results written down before it ran. A curriculum that targets GRPO signal learned more than uniform sampling per environment episode on all four seeds, and per generated token on the three new ones (+5.5, +18.3 and +14.4 points); on the pilot's seed, uniform sampling was ahead per token by 7.7 points. Three new seeds are a pattern, not a significance test. Weighting the curriculum by token cost with the formula of the first version did worse than the signal-only curriculum, and a corrected form matched it per generated token without beating it, so theCurriculumSamplerweights by signal only and the samplers proposed here report signal per episode and per unit of the cost the trainer reports.Pilot code and logs: Matheus-F-Scatolin/OpenEnv@rfc-013-pilot. Trial code and logs: Matheus-F-Scatolin/OpenEnv@rfc-013-trial.
Questions for the maintainers are in #1445.
Changes since 2026-09-27
costargument from the curriculum, stated the two hooks a sampler needs in a trainer and their limits in TRL, addedmetrics()to the protocol, left shares across sources to the trainer, reported how far the signal formula over-predicts, cited prior work on rollout allocation and filtering, narrowed the reference experiment to uniform sampling against the curriculum on five new seeds, answered open question 6 and proposed a direction for open question 5.posttrain_envrelies on, so that it counts in groups, episodes and cost but in nothing estimated from rewards, added open question 10, and stated how evaluation counts each case: such a rollout, and one lost to a failure of the infrastructure, leavessuccess_rate,mean_rewardandpass@kand is reported separately, a failure of the policy gets the environment's own score or counts as not solved,mean_rewardis read only together witherror_rate, and checkpoint comparison lists the tasks it leaves out.Type of Change
Alignment Checklist
Before submitting, verify:
PRINCIPLES.md) and this PR aligns with our principlesINVARIANTS.md) and no invariants are violated (one tension is flagged below)lint.shand tests) and addressed all issues. Not run: the PR changes only Markdown inrfcs/, whichlint.shand the tests do not cover, so it adds no new finding.RFC Status
Test Plan
Docs only. To rerun the pilot (Apple Silicon, MLX needs the Metal GPU):
The pilot's script writes today's date into every prompt, through the model's chat template, and stops after 150 minutes of training, so a rerun on another day or another machine gives other numbers than the stored logs. The trial's trainer fixes the date and stops on generated tokens; run again on seed 0, it reproduced the pilot's stored logs step for step for the first 370 steps of uniform sampling and 158 of the curriculum. To regenerate every table and figure of the trial from its stored logs, without a GPU:
The README of that branch gives the commands that ran the trial itself.
Alignment Review
Alignment review done by hand against this diff, following the project's alignment-review checklist.
Automated Checks
rfcs/Open RFCs Context
update.reasoning_gym_envas a partial answer to its open question 2 (cheap, but single-turn with no tool use).openenv evalresults (open question 4).update.posttrain_env(Add experimental posttrain_env prototype (RFC 014) #1500) ends an episode whose score job fails with a reward ofNoneand still reports its spend; the samplers count that episode and its spend inepisodesandcost, and leave its reward out of every estimate made from rewards.Tier 1: Fixes Required
None: the PR changes only Markdown.
Tier 2: Alignment Discussion
Principle Conflicts
ALIGNMENT FLAG: Task metadata over HTTP
/reset,/step,/state#1156)TaskAPIClientconsumes the existing HTTP-only Task API routes, as documented in the Task API guide. The RFC adds no routes, but it adds a core consumer of them. D5 isolates this in one class so a later WebSocket move changes onlyTaskAPIClient.ALIGNMENT FLAG: Evaluation follows the collect pipeline
openenv collectresolves onlyopenspiel:andreasoning_gym:specs,CollectRunnerpasses no seed and records no failed episode (rollout step 5 adds both), and Harbor, which runs a whole agent per call, is not covered by the first version (D3, open question 8).RFC Conflicts
ALIGNMENT FLAG: Task API helpers in core
EnvClient,SyncEnvClient) do not ship Task API methods, because task specs are environment-specific")TaskAPIClienttoopenenv.core. D6 argues it keeps specs untyped and adds nothing toEnvClient, so the guide's reasoning still holds, but this reverses a documented choice and should be agreed explicitly.No conflicts found with the dual API boundary, rewards-in-environment, client-server separation, or "one env = one trajectory": samplers run on the orchestration side and only read rewards the environment computes, and a reward the environment could not give is left out of everything estimated from rewards and of the evaluation's
success_rate,mean_rewardandpass@k, never counted as zero, while its episode and its cost still count; a failure of the policy that reaches the environment gets the environment's own score.Summary
Disclosure
#1250 and #1252, cited in the RFC, are by one of the authors. This PR was prepared with AI assistance.
Note
Low Risk
Only Markdown is added; follow-on PRs would touch eval, collect pipeline, and core APIs, which the RFC flags for maintainer review (HTTP Task API, generic client in core).
Overview
This PR is documentation only: it adds RFC 013 (~540 lines) and a Reward & Evaluation index line in
rfcs/README.md. No runtime or library code changes.The RFC specifies trainer-side task sampling and in-training evaluation on top of the Task API: a
TaskSamplerprotocol (SequentialSampler,UniformSampler, optional exampleCurriculumSampler),TaskAPIClient,EnvEvalHarness/compare_eval_results,openenv eval, andEvalSchedule. It defines howNonerewards (environment unscored rollouts) affect sampler stats and eval metrics (error_rate,unscored_rate,infra_error_rate, checkpointleft_outtasks), drops cost from curriculum weights after multi-seed trials, and lays out a six-step rollout (guide + client, env Task API, samplers, harness/CLI/collect fixes, schedule + reference experiment). Preliminary GRPO/MLX results onreasoning_gym_envare included; implementation is deferred to follow-on PRs.Reviewed by Cursor Bugbot for commit 693135e. Bugbot is set up for automated code reviews on this repo. Configure here.