AsyncGRPOTrainer: add ProcessorMixin handling#5895
Open
rycerzes wants to merge 3 commits into
Open
Conversation
Add model_init_kwargs to AsyncGRPOConfig and use create_model_from_path in the trainer, matching GRPOTrainer's model loading behavior. This allows passing custom kwargs (e.g., attn_implementation, dtype) when loading the model from a string. Closes part of huggingface#5831
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 90afff0. Configure here.
Member
|
at this point I don't know if it's very useful to integrate processor, a the asynchronous grpo trainer doesn't support vlm yet. |
qgallouedec
reviewed
Jun 1, 2026
Use AutoProcessor.from_pretrained when no processing_class is provided, and extract the tokenizer from ProcessorMixin instances. This supports VLM-style models (e.g., Qwen3.5) that use a processor without requiring vision inputs, matching the behavior already present in GRPOTrainer. Closes part of huggingface#5831
Align processor handling with GRPOTrainer by preserving the original processing_class on the trainer and storing the extracted tokenizer separately for tokenizer-only AsyncGRPO paths. Replace the shallow processor plumbing checks with a text-only Qwen3.5/VLM regression test that verifies training works and visual parameters remain unchanged
Contributor
Author
Yes I agree, this isn’t for full VLM support. The scope is text-only training for processor-backed models like Qwen3.5 Updated to stack on #5893, tests passing :) |
90afff0 to
af4f768
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

What does this PR do?
Adds
ProcessorMixinsupport toAsyncGRPOTrainer, matching the existing behavior inGRPOTrainer.Currently,
AsyncGRPOTraineronly usesAutoTokenizerwhen noprocessing_classis provided, and only acceptsPreTrainedTokenizerBaseinstances. This fails for models like Qwen3.5 that use a processor (e.g.,Qwen3_5ForConditionalGenerationreturns aProcessorMixinfromAutoProcessor).This PR:
AutoProcessor.from_pretrained()instead ofAutoTokenizer.from_pretrained()when noprocessing_classis providedPreTrainedTokenizerBaseandProcessorMixinasprocessing_classProcessorMixininstances (processing_class.tokenizer)super().__init__()andAsyncRolloutWorkerpad_token ← eos_tokenwhen not set)Changes:
async_grpo_trainer.py: update imports (AutoProcessor,ProcessorMixin), updateprocessing_classtype hint and docstring, add processor/tokenizer extraction logicTests:
test_processor_mixin_handling: passes anAutoProcessorinstance asprocessing_classand verifies the trainer extracts aPreTrainedTokenizerBasetest_auto_processor_when_none: omitsprocessing_classentirely and verifies the trainer auto-loads viaAutoProcessorwith a valid pad tokenCloses part of #5831
Before submitting
AI writing disclosure
Who can review?
@qgallouedec
Note
Medium Risk
Touches core trainer initialization, model loading, and tokenization paths used by async GRPO training; changes are scoped and mirrored from GRPOTrainer with new tests.
Overview
AsyncGRPOTrainernow aligns withGRPOTrainerfor multimodal and model-loading behavior. When noprocessing_classis passed, it loadsAutoProcessor(left truncation/padding) instead ofAutoTokenizer, acceptsProcessorMixinorPreTrainedTokenizerBase, normalizespad_tokenon the inner tokenizer, and passes that tokenizer to the rollout worker and data collator while still handing the full processor to the base trainer.Model weights are loaded via
create_model_from_pathwith optionalAsyncGRPOConfig.model_init_kwargs(e.g. dtype), withdevice_map=Noneforced for FSDP2.Tests add
model_init_kwargscoverage, extend the rollout stub for processor-only prompt data, and add a gated VLM training test that checks non-visual weights update while visual weights stay fixed on text-only data.Reviewed by Cursor Bugbot for commit af4f768. Bugbot is set up for automated code reviews on this repo. Configure here.