Skip to content

Add a LoRA notebook to the async GRPO math example - #8686

Closed
behroozazarkhalili wants to merge 1 commit into
huggingface:mainfrom
behroozazarkhalili:add-async-grpo-math-notebook
Closed

behroozazarkhalili wants to merge 1 commit into
huggingface:mainfrom
behroozazarkhalili:add-async-grpo-math-notebook

Conversation

@behroozazarkhalili

@behroozazarkhalili behroozazarkhalili commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

This adds examples/async_grpo_math/async_grpo_math.ipynb next to the two scripts, and updates the example's row in the overview.

The notebook starts a vLLM server, trains a LoRA adapter on GSM8K with AsyncGRPOTrainer, and reads the trainer's metrics. The server and the trainer share one GPU. In the committed run, 200 steps take 43 minutes on a 10 GB slice of an H100; correct answers on the GSM8K test set go from 39.9% to 50.2%, and answers in the requested format from 3.5% to 97.0%. It needs a vLLM server, so it does not run on free Colab.

The outputs come from one end-to-end run.


Note

Low Risk
Documentation and example-only changes; no TRL trainer or library code is modified.

Overview
Adds examples/async_grpo_math/async_grpo_math.ipynb, a tutorial that walks through LoRA AsyncGRPOTrainer on GSM8K with Qwen2.5-0.5B-Instruct: vLLM server setup, importable GSM8K reward module, training, trainer metrics, and greedy test-set evaluation against the base model. The committed run shows ~200 steps on a shared 10 GB H100 slice (39.9% → 50.2% correct, 3.5% → 97.0% format).

Updates the async_grpo_math row in docs/source/example_overview.md to mention the notebook, single-GPU co-location, and that it requires a vLLM server (not free Colab).

Reviewed by Cursor Bugbot for commit 72880a2. Bugbot is set up for automated code reviews on this repo. Configure here.

@bot-ci-comment

bot-ci-comment Bot commented Dec 1, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Pages changed in this PR:

@qgallouedec qgallouedec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'm not sure a notebook adds much here: async_grpo_lora_math.py in the same folder already runs LoRA AsyncGRPO on GSM8K, and since AsyncGRPO needs a separate vLLM server, the notebook can't be the Colab-ready version either. I feel like someone landing in this folder wouldn't understand why we have both. @sergiopaniego wdyt?

If we keep it, a few things to bring it closer to the other notebooks:

  • Pass the arguments to AsyncGRPOConfig directly, like grpo_qlora.ipynb, instead of the config dataclasses and the smoke-test mode.
  • Section 7 retells the trainer's source and the defaults cell will drift; a link to the AsyncGRPO docs is enough.
  • hub_model_id points to your account.
  • The notebook says it needs two GPUs, but the committed run shared one 10 GB slice, so the outputs don't come from the setup it describes.

@behroozazarkhalili

Copy link
Copy Markdown
Collaborator Author

Thanks for the review! I'm happy to change whatever you want here.

If you and Sergio decide to keep it, I'll make all four changes:

  • pass the arguments to AsyncGRPOConfig directly, like grpo_qlora.ipynb, and drop the config dataclasses and the smoke-test mode
  • replace section 7 with a link to the AsyncGRPO docs
  • take my account out of hub_model_id
  • make the hardware text match the committed run: one GPU shared by the vLLM server and the trainer

If you'd rather not have a notebook next to async_grpo_lora_math.py, I'm fine with closing this one.

@behroozazarkhalili

Copy link
Copy Markdown
Collaborator Author

One more option, in case it is more useful than a second GSM8K example: I can move the notebook off GSM8K and into its own folder, so it no longer sits next to async_grpo_lora_math.py.

For example, the BioGRID task from grpo_sql_agent, trained with AsyncGRPOTrainer and tools=[query_biogrid]. None of the current AsyncGRPO examples passes Python tools to the trainer, and it would put GRPO and AsyncGRPO side by side on the same task. I'm also fine with another model or dataset if you have one in mind.

@sergiopaniego

Copy link
Copy Markdown
Member

Thanks for putting these notebooks together! After going through all five, I'll close them, with the reason for each in its PR. Mostly they overlap with existing examples or docs, or show a single feature in isolation. The direction we're taking with examples is a task told end to end, with a measured before and after, like the chess example in #8085.

For this one: I agree with Quentin, async_grpo_lora_math.py already covers it, and AsyncGRPO can't run on free Colab.

As Quentin mentioned, updating the existing notebooks would be very welcome: one PR per example, run end to end. Maybe start with one, so we can align on the format before the rest. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants