async streaming grpo w prefetch#5250
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
|
||
| # ---- Shuffle (deferred from produce()) ---- | ||
| shuffled = shuffle_sequence_dict(data) | ||
| dataset._data = shuffled |
There was a problem hiding this comment.
Deferred scoring path missing generation and completion metrics
Medium Severity
_compute_deferred_scores logs reward metrics but omits all generation metrics: num_input_tokens_seen, completions/mean_length, completions/clipped_ratio, completions/mean_terminated_length, IS sampling stats, and self._logs for completion logging. The _generate method skips these on background threads, and the streaming path _compute_streaming_group_scores logs them in its is_last_chunk block — but the non-streaming deferred path never recovers them.


What does this PR do?
companion PR to huggingface/transformers#44259
we may have to require transformers>v5.3.0, depending on when the companion transformers PR is merged.
alongside #5249, there are significant speedups from this.
Fixes # (issue)
Before submitting
Pull Request section?
to it if that's the case.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
Note
High Risk
Refactors GRPO’s core online rollout/training flow to use transformers
DataProducerwith background-thread prefetch and optional streaming scoring, which is concurrency- and training-correctness sensitive (staleness, synchronization, metrics/state updates). Changes also affect vLLM weight syncing and importance-sampling application paths.Overview
Adds an optional transformers
DataProducer-based rollout pipeline forGRPOTrainer, enabling async rollout prefetching and an optional streaming partial-batch mode that incrementally scores prompt groups and yields micro-batches to overlap reward computation with policy logprob scoring.Introduces
GRPODataProducer/RolloutDatasetand updatesGRPOTrainerto create/wire the producer, handle deferred scoring when rollouts are produced on a background thread (including vLLM sync scheduling viavllm_sync_interval), and bypass the legacy_prepare_inputsbuffering path when the producer is enabled. Adds new config flags (use_data_producer,async_prefetch,prefetch_depth,streaming_partial_batch,streaming_min_groups,vllm_sync_interval) and tightens loss application to only useimportance_sampling_ratiowhen present.Written by Cursor Bugbot for commit 91388df. This will update automatically on new commits. Configure here.