Skip to content

Streaming GRPO: unaligned chunks from the floor, and silent per-chunk advantage normalization for reinforce_plus_plus #5240

Open

Description

@saumishr

Follow-up from the review of #5036, which added async_rl.max_groups_for_streaming_train. Both items are pre-existing on main; neither is introduced by that PR, and both were deliberately left out of it to keep its scope to the knob it adds.

1. GRPO streaming chunks are only aligned when the cap happens to bind

PPO derives a group_multiple at setup (resolve_ppo_chunk_alignment) and hands it to the sampler, so every chunk it selects is a whole number of DP-and-microbatch-aligned groups. GRPO passes no group_multiple at all, so _finalize_selection returns whatever the bounds allow and the chunk size is decided by how many groups happen to be ready.

The training dispatch then shards that chunk without allow_uneven_shards (it is passed only on the generation paths — vllm_generation.py, trtllm_generation.py), so an unaligned chunk reaches the assertion in BatchedDataDict.shard_by_batch_size, and under static batching the second assertion in make_microbatch_iterator. Either one fires mid-step, with the whole allocation already up.

Concretely, with min_groups_for_streaming_train: 2, 2 generations per prompt and a policy DP of 4, a moment where 3 groups are ready produces 6 samples, which 4 ranks cannot split. Nothing validates this today.

#5036 added validate_grpo_chunk_cap_alignment, but by construction it can only check the full-cap chunk — it has no way to constrain a chunk the sampler shortens on its own.

Proposed fix: give GRPO a group_multiple the way PPO has, derived from the policy's sample_multiple (DP size, times the train/logprob microbatch LCM when sequence packing and dynamic batching are both off). Every chunk is then aligned by construction, the floor is covered as well as the cap, and validate_grpo_chunk_cap_alignment can be deleted rather than carried as a partial guard.

2. reinforce_plus_plus silently changes its advantages under streaming

reinforce_plus_plus reduces over the entire batch — it is excluded from SHARD_INVARIANT_ESTIMATORS for exactly that reason, and the comment there names it explicitly. Under streaming the advantage stage runs per chunk, so the normalization statistics are computed over a chunk rather than the step, and the advantages a run trains on become a function of where the chunk boundaries land.

Streaming PPO already warns about the same effect for GAE:

Streaming PPO with ppo.adv_estimator.normalize_advantages=true normalizes GAE advantages per chunk instead of across the full batch. Changing chunk boundaries can change normalized advantages.

There is no equivalent warning for grpo.adv_estimator.name: reinforce_plus_plus, so a user who lowers min_groups_for_streaming_train (or now sets max_groups_for_streaming_train) changes their advantages with no signal at all.

Proposed fix: at minimum, warn at setup when a streaming GRPO run uses a batch-reducing estimator, mirroring the PPO warning. Better would be to make the reduction two-pass across chunks so the statistics stay step-wide, which would remove the caveat rather than document it.

cc @terrykong

Activity

  1. added
    bug
    on Nov 16, 2026
  2. GBX-Max1220 commented on Nov 18, 2026

    @GBX-Max1220

    Hi @saumishr,

    I ran a small CPU-only experiment on the Reinforce++ streaming normalization issue and found one detail that might be useful.

    Even when chunks are perfectly aligned with prompt groups, so the group baselines are unchanged, per-chunk normalization can still change the direction of the aggregate policy gradient.

    The reason is that each chunk gets its own 1/std factor. That changes the relative weighting of chunk contributions, even when the chunk means are zero.

    In one deterministic heterogeneous-reward example, the chunk-normalized gradient had cosine similarity 0.789 with the full-batch gradient, and one coordinate changed sign. A sparse-reward control with equal token lengths showed no difference, so this isn't universal.

    I also saw PR #5216, which already addresses the global-statistics requirement by rejecting incompatible streaming configurations. I'm not proposing a competing fix — just sharing a concrete gradient-level reason why that restriction matters.

    Happy to share the small reproducible CPU script if useful.

    Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions