fix: re-schedule empty trajectories to guarantee full groups#2014
Merged
Conversation
…completion Empty trajectories were filtered after sampling from the buffer, which could yield incomplete groups and break the advantage computation's assumption that each group has exactly `rollouts_per_example` rollouts. Now empty trajectories are detected per-rollout as they complete. When one is found, `rollouts_to_schedule` is incremented so the group naturally re-fills via `_fill_inflight_requests`, and the group is only yielded once it has the full count of non-empty rollouts. Co-Authored-By: Claude Opus 4.6 <[email protected]>
samsja
approved these changes
Mar 10, 2026
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.
Summary
rollouts_per_examplerollouts.view(-1, rollouts_per_example)— either crashing on misaligned tensors or silently computing wrong per-problem baselinesrollouts_to_scheduleis incremented so the group naturally re-fills, and only complete groups are yielded🤖 Generated with Claude Code
Note
Medium Risk
Touches core rollout scheduling/group completion logic; a bug could cause groups to stall or skew batch composition, but the change is small and localized.
Overview
Prevents incomplete rollout groups by handling empty trajectories before group completion.
In
Scheduler.generate_batch, each finished rollout is now checked for an emptytrajectory; empty results incrementbatch/empty_rollouts, log a warning, and increasegroup.rollouts_to_scheduleso the group naturally re-fills, while the previous post-sampling filtering of empty rollouts is removed.Written by Cursor Bugbot for commit b43629f. This will update automatically on new commits. Configure here.