-
Notifications
You must be signed in to change notification settings - Fork 3k
AsyncGRPO: train loop-owning agents on the engine's own token ids, with a Harbor/OpenEnv example #6947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adithya-s-k
wants to merge
40
commits into
huggingface:main
Choose a base branch
from
adithya-s-k:async-grpo-harbor-example
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
AsyncGRPO: train loop-owning agents on the engine's own token ids, with a Harbor/OpenEnv example #6947
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
c859ad7
Add AsyncGRPO Harbor example: an off-the-shelf coding agent, served t…
adithya-s-k 025f330
async_grpo_harbor: drop the grpo_harbor comparison and trim the rewar…
adithya-s-k 49d8170
async_grpo_harbor: add a single-job Hugging Face Jobs variant
adithya-s-k ffce7cb
async_grpo_harbor_hf_jobs: make the documented command runnable as wr…
adithya-s-k b948986
async_grpo_harbor_hf_jobs: fix four things a first run would have hit
adithya-s-k 437e7be
Merge branch 'main' into async-grpo-harbor-example
sergiopaniego 9376e91
async_grpo_harbor: replace the merged Jobs variant with a launcher
adithya-s-k 9b3c524
launcher: supervise the tunnel for the whole run, not just at startup
adithya-s-k e0e264a
Merge upstream/main (brings VLM support for AsyncGRPOTrainer, #6839)
adithya-s-k 9fd0c78
async_grpo_harbor: add the example to the docs index
adithya-s-k cf4e342
Merge upstream/main into async-grpo-harbor-example
adithya-s-k 3ca92ca
Merge the PR branch's own main-merge (437e7be2) back in
adithya-s-k b00a59c
Merge upstream/main into async-grpo-harbor-example
adithya-s-k 8775780
async_grpo: train on the engine's own token ids, never a re-rendered …
adithya-s-k 78bb609
Merge remote-tracking branch 'upstream/main' into pr6947-work
adithya-s-k 9c4c8fa
async_grpo_harbor: address review — shrink the CLI, one channel for t…
adithya-s-k ca5ceb3
async_grpo: run doc-builder style on the token-ids docstring
adithya-s-k 3cb8efd
async_grpo: keep the verifier's own score visible when rollout_reward…
adithya-s-k 5a0cbe6
Merge remote-tracking branch 'upstream/main' into codex/pr6947-merge-…
adithya-s-k 8e87edb
Preserve captured training tokens and enforce the sampling contract
adithya-s-k a28a3d1
Merge remote-tracking branch 'upstream/main' into codex/pr6947-merge-…
adithya-s-k 68b4db2
Merge remote-tracking branch 'upstream/main' into codex/pr6947-review…
adithya-s-k ef674cc
Fix OpenEnv capture validation and Harbor example lifecycle
adithya-s-k 877928f
Merge remote-tracking branch 'upstream/main' into codex/pr6947-review…
adithya-s-k 7071049
Keep async weight-update pause behavior consistent
adithya-s-k ffc771d
Match Harbor trainer model dtype to the BF16 inference engine
adithya-s-k 88c819a
Size Harbor server sessions for the requested rollout concurrency
adithya-s-k 5150144
Document cold E2B template preparation
adithya-s-k 2579d64
Trim Harbor example documentation and redundant comments
adithya-s-k 5367603
Fix Harbor launcher cancellation and capture error propagation
adithya-s-k ca88b38
Arm signal test cleanup before announcing readiness
adithya-s-k c7e78bc
Mark OpenEnv selection hooks as temporary contract adapters
adithya-s-k 64804b7
Simplify harness validation and sampling setup
adithya-s-k a02f812
Merge remote-tracking branch 'upstream/main' into codex/pr6947-review…
adithya-s-k 1109d4f
Save Harbor example checkpoints and final model
adithya-s-k 350b76c
Merge remote-tracking branch 'upstream/main' into codex/pr6947-review…
adithya-s-k d60b407
Limit Llava mask xfails to affected Transformers versions
adithya-s-k 64cb31d
Pass rollout sampling into harness factory construction and restore k…
adithya-s-k f0f96b9
Close Harbor dataset metadata client before starting rollouts
adithya-s-k 9672567
Merge remote-tracking branch 'upstream/main' into codex/pr6947-review…
adithya-s-k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # AsyncGRPO with Harbor | ||
|
|
||
| An installed agent runs each task through OpenEnv. TRL trains on the engine's captured token IDs, | ||
| logprobs, and loss masks, then updates the same vLLM instance. | ||
|
|
||
| ## Local setup | ||
|
|
||
| Use Python 3.12 and this TRL checkout. Pin OpenEnv to the merge of | ||
| [OpenEnv #1036](https://github.com/huggingface/OpenEnv/pull/1036): | ||
|
|
||
| ```sh | ||
| git clone https://github.com/huggingface/OpenEnv.git OpenEnv | ||
| git -C OpenEnv checkout --detach 34825a772ae54760fb6bf7a8b2073a4a85714004 | ||
| pip install -e . trackio datasets ./OpenEnv | ||
| export PYTHONPATH="$PWD/OpenEnv/envs${PYTHONPATH:+:$PYTHONPATH}" | ||
| ``` | ||
|
|
||
| The source path is required because this revision's environment wheel does not package | ||
| `harbor_env.harness`. Both the core package and the harness above use the same revision. | ||
|
|
||
| Run the OpenEnv server with its sandbox credentials, then start vLLM and the trainer using the commands | ||
| in [async_grpo_harbor.py](async_grpo_harbor.py). The server additionally needs `pip install './OpenEnv[harbor]'`; | ||
| the trainer can use an existing server. Use the same model and vLLM endpoint for rollouts and weight updates. | ||
| Set the server's `MAX_CONCURRENT_ENVS` to at least `--max-inflight + 1` (9 for the defaults); the factory | ||
| keeps one connection for task metadata. The Jobs launcher sets this capacity automatically. | ||
|
|
||
| Training saves a checkpoint every 50 steps, keeps the latest three, and saves the final model and | ||
| tokenizer in the output directory on successful completion, including runs shorter than 50 steps. | ||
|
|
||
| ## Hugging Face Jobs | ||
|
|
||
| [launcher.py](launcher.py) starts the server, vLLM, and trainer on one two-GPU job. It installs the pinned | ||
| OpenEnv runtime and checks out the matching harness source. Pass `HF_TOKEN` and the sandbox credential | ||
| as job secrets. A bucket mounted at `/data` preserves checkpoints and logs. | ||
|
|
||
| Use `--train-script-url` with the raw URL of the TRL revision being tested before the example is merged. | ||
| Use `--tunnel-check-s 0` to disable tunnel supervision. A server restart interrupts existing sessions; | ||
| subsequent sessions receive the new proxy URL. | ||
|
|
||
| ## Capture contract | ||
|
|
||
| - Prompt and completion IDs come from the inference engine; TRL does not re-tokenize captured prompts. | ||
| - `loss_mask` covers prompt plus completion. Prompt positions are zero; completion positions may mix | ||
| zeros and ones. TRL maps the completion span to its generic `TurnRecord.output_mask`. | ||
| - For example, prompt `[10, 11]`, completion `[12, 13, 14]`, and mask `[0, 0, 1, 0, 1]` train on tokens | ||
| `12` and `14`, while retaining `13` as context. A whole-turn filter cannot express this selection. | ||
| - The worker constructs the session factory with its sampling policy. Pass a callable such as | ||
| `partial(HarborSessionFactory, server_url, ...)`; do not configure sampling separately on the factory. | ||
| OpenEnv applies the policy to captured requests. | ||
| - Invalid captures stop the worker. Transport failures remain unscorable; an agent timeout retains | ||
| valid captured turns and the verifier's score. | ||
|
|
||
| Rewritten histories can produce multiple training rows. Token retention does not guarantee equal | ||
| rollout weighting or a suitable memory budget for every harness. | ||
|
|
||
| Run the CPU contract and launcher checks with the pinned checkout on `PYTHONPATH`: | ||
|
|
||
| ```sh | ||
| python -m pytest tests/experimental/test_openenv_tito.py tests/experimental/test_harbor_example.py \ | ||
| tests/experimental/test_async_grpo_trainer.py::TestReconciler tests/test_vllm_control_requests.py -q | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update the
Ready-to-use OpenEnv examplesnote and include more details the harbor integration, no? since the other integration will be removed in #6948