Skip to content

[WIP][RL] Add Terminal-Bench 2.1 experiment via Verifiers - #4888

Closed
wwwjn wants to merge 1 commit into
pytorch:mainfrom
wwwjn:new-task
Closed

wwwjn wants to merge 1 commit into
pytorch:mainfrom
wwwjn:new-task

Conversation

@wwwjn

@wwwjn wwwjn commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add an optional Qwen3.5-9B Terminal-Bench 2.1 experiment under torchtitan/rl/experiments/verifiers/terminal_bench, using the existing TitanRL/Verifiers bridge. Verifiers runs a Docker-isolated Terminus-2 agent and Harbor verifier; TitanRL handles rollout grouping, generation, and training.
  • Load separate, frozen Harbor task trees for training and the 89-task benchmark. Keep the task-specific XML harness, image overrides, and single-pass eval-only behavior inside this experiment; do not change TitanRL core or import task-evolution code and training data from the research branch.
  • Document setup and fidelity limits, and add CPU, Docker grading, and optional published-task-tree tests.

Why

This makes the colleague branch's Terminal-Bench workflow available as a scoped TorchTitan experiment using the Verifiers integration already on main, while preserving the mainline RL interfaces and keeping experimental data generation out of the upstream codebase.

Validation

  • 24 passed across the new tests and existing Verifiers tests, including a Docker Harbor grading smoke test and parsing all 89 published Terminal-Bench 2.1 tasks.
  • pre-commit run --all-files passed with pyrefly-check,lychee-link-checker skipped. Pyrefly cannot complete in this environment because of pre-existing missing dependencies and its configured unused-ignore rewrite; external link checking was not run.
  • No GPU training or matched-checkpoint benchmark comparison was run. This PR does not claim numerical loss/reward parity with the research branch.

Known gaps / follow-ups

  • Daytona is not supported by Verifiers 0.3.1. Add that backend in the Verifiers repository separately; this experiment currently uses Docker and requires prebuilt task images with tmux.
  • Mainline TitanRL uses GRPO rather than the colleague run's DPPO trust-region loss. It also uses eight independent generator replicas rather than one eight-way DP generator, and does not offer the same per-group KV-cache salting or dedicated asynchronous periodic validation.
  • Evaluation is greedy pass@1, not the colleague's pass@5. Comparable results need pinned task/image revisions and a live GPU run against the same checkpoint.

Add a frozen Harbor task adapter, Docker-isolated Terminus-2 harness, Qwen3.5-9B training and evaluation recipes, and CPU/Docker coverage. Reuse the existing Verifiers bridge without changing TitanRL core or importing training-data evolution artifacts.

Co-authored-by: Yichuan Wang <[email protected]>
Co-authored-by: Shuhua Yu <[email protected]>
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 25, 2026
@wwwjn wwwjn changed the title [TitanRL] Add Terminal-Bench 2.1 experiment via Verifiers [WIP][TitanRL] Add Terminal-Bench 2.1 experiment via Verifiers Sep 25, 2026
@wwwjn wwwjn changed the title [WIP][TitanRL] Add Terminal-Bench 2.1 experiment via Verifiers [WIP][RL] Add Terminal-Bench 2.1 experiment via Verifiers Sep 26, 2026
@wwwjn wwwjn closed this Oct 2, 2026
wwwjn added a commit that referenced this pull request Oct 9, 2026
…-A3B) (#4942)

Human Note:
- This PR is using Agent-in-sandbox pattern.
- End to end run verified using coreweave cluster.

## Summary

Adds a Terminal-Bench 2.1 example: the task adapter under
`torchtitan/rl/examples/verifiers/terminal_bench`, the recipes in
`torchtitan_recipes/rl/verifiers_terminal_bench.py`, using the existing
TitanRL/Verifiers bridge. Verifiers runs a Docker-isolated Terminus-2
agent and the Harbor verifier; TitanRL handles rollout grouping,
generation, and training. TitanRL's core is unchanged.

This PR contains the whole experiment: the implementation from #4888
(commit `b758984eb`, unchanged), four fixes for rollouts that report
`reward=0.000` without the model having failed, and training recipes for
Qwen3.5-9B and Qwen3.5-35B-A3B.

- Training and validation tasks are Harbor datasets selected by id
(`org/name@ref`), fetched and cached by the `harbor` CLI the way
Verifiers does it; the recipe refuses to run if the two are the same
dataset. The task-specific XML harness stays inside this experiment.
- Two model sizes share the datasets, sampling, loop and optimizer
settings. Each recipe is one self-contained config in
`torchtitan_recipes/rl/verifiers_terminal_bench.py`. Both train on
`local/tmax@v1` (AI2 TMax, converted by `prepare_tmax.py` into
`~/.cache/harbor/local_tmax_v1`) and validate on
`terminal-bench/terminal-bench-2-1`.
- Validation over the 89 Terminal-Bench 2.1 tasks runs at the start and
end of training, so there is no separate eval-only config.
- Setup, fidelity limits and open dependencies are documented in the
experiment README.


## **100-step run (Qwen3.5-9B-Base, TMax-15K, stock Verifiers
Terminus-2, lr 1e-6)**

| | step 0 (base) | step 100 |
|---|---|---|
| held-out reward (507 unseen tasks x 8 rollouts) | 0.334 | **0.417** |
| held-out pass@8 | 0.586 | 0.655 |
| training reward (mean over steps 1-50 → 51-100) | 0.344 | 0.393 |

- On held-out tasks, reward goes up by +0.083 +- 0.008 (11 SE) after 100
steps. The step-100 policy is better on 217 tasks and worse on 46.
- Most of the gain is the policy finishing tasks within the 30-turn cap
more often, with the same accuracy when it finishes.

The held-out reward is the clearest evidence that training works: the
per-step training curve is noisy because each step trains on 16 new
tasks.

Here are the internal wandb links in case the summary stays internal; I
left them out above in case it's the public PR:
- 100-step training run:
https://meta.wandb.io/jianiw/titanrl_tb35b_sweep/runs/t2f08wy3
- Held-out reward vs training step:
https://meta.wandb.io/jianiw/titanrl_tb35b_sweep/runs/04kwm6md

Note the above run is slightly different some verifiers stock verison.
The above run used agent-outside-sandbox due to network fireware
restriction. We also verified the code runs for agent-in-sandbox (the PR
version as-is):
https://meta-fair.wandb.io/jianiw/sandoq-terminal-bench-agent-in-sandbox/workspace?nw=nwuserjianiw

## Known gaps / follow-ups

- Daytona is not supported by Verifiers 0.3.1. This experiment uses
Docker.
- Datasets are fetched by Harbor id into `~/.cache/harbor`. A cluster
without access to the Harbor Hub can pre-populate that cache; loading
from an arbitrary local path is not supported here.
- The published TB2.1 images do not all ship `tmux`; Harbor's Terminus-2
session installs it at run time, so the task container needs network
then, as scoring already does.
- Mainline TitanRL uses GRPO rather than the colleague run's DPPO
trust-region loss, uses independent generator replicas rather than one
eight-way DP generator, and does not offer the same per-group KV-cache
salting or dedicated asynchronous periodic validation.
- Evaluation is greedy pass@1, not the colleague's pass@5. Comparable
results need pinned task/image revisions and a live GPU run against the
same checkpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant