(2/5) Refactor RolloutCompletion in Async Rollout Worker #5318
Open
(2/5) Refactor RolloutCompletion in Async Rollout Worker #5318
Conversation
|
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. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
This was referenced Mar 20, 2026
Tests cover RolloutCompletion message/ID handling, multi-turn trajectory consistency, group scoring, and end-to-end generation flows with tool calling and truncation scenarios. Add comprehensive tests for AsyncRolloutWorker Tests cover RolloutCompletion message/ID handling, multi-turn trajectory construction, score group validation, and end-to-end generation flows with tool calling. Also remove unused variable in _generate_one.
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?
RolloutCompletion,TurnRecord,ToolCallRecord, andTaggedMessage.RolloutGroupto store a unified list ofRolloutCompletionobjects instead of maintaining five separate parallel arrays (completions, completions_ids, tool_mask, etc.)._generate_oneand_score_groupto construct and interact with these new objects natively, drastically improving code readability and making it easier to track multi-turn properties (like execution time and tool arguments) in future PRs.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
Medium Risk
Moderate refactor of async rollout generation/scoring data flow (including tool-call accounting), which could affect token/logprob masks and metrics if any edge cases are missed; coverage is improved with new unit tests.
Overview
Refactors the async GRPO rollout pipeline to use structured dataclasses (
RolloutCompletion,TurnRecord,ToolCallRecord,TaggedMessage) instead of parallel arrays for completion text/ids/logprobs/tool masks and tool-call counts._generate_onenow returns aRolloutCompletionwith per-turn timing, tool-call records (including args, failures, and durations), and a trajectory that avoids duplicating prompt/context messages across turns;_score_groupis updated to consume these helpers forcompletion_ids, logprobs/masks, and tool metrics.Adds a comprehensive
test_async_rollout_worker.pysuite covering completion flattening/masks, multi-turn trajectory uniqueness, truncation at max tool-calling turns, and tool metric computation.Written by Cursor Bugbot for commit 21360b6. This will update automatically on new commits. Configure here.