[RL] Fix shape mismatch on tail batch in GRPO training#4252
Open
susanbao wants to merge 4 commits into
Open
Conversation
…inder=True and doubling test dataset slice
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
SurbhiJainUSC
approved these changes
Jun 25, 2026
Collaborator
|
@susanbao - can you please fix CI tests? |
A9isha
approved these changes
Jun 26, 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.
1. Bug b/527547702: Host CPU OOM (Exit Code 137) during GRPO Training
jax-tpu) crashed due to an Out-Of-Memory (OOM) error (exit code 137).num_procs) in the math grading pool was calculated dynamically based on the verification queue size (len(items)). Because the number of completions requiring symbolic checking fluctuated constantly, the pool was repeatedly destroyed and recreated at almost every training iteration. Terminating and spawning new processes (which eagerly re-import heavy libraries likesympyandmath_verify) caused host memory (RSS) to leak and grow monotonically until hitting the container's 100G limit.num_procsinmath_verify_pool.pyfromlen(items), keeping the pool size stable atmin(_DEFAULT_MAX_PROCS, cpu_count)throughout the training execution.2. Bug b/527296510: Shape mismatch crash in JAX shard_map due to tail batch
ValueErrorshape mismatch occurred in JAXshard_mapbecause the batch dimension was not divisible by the FSDP mesh dimension.train_rl.pydid not specifydrop_remainder=Trueduring batching, JAX attempted to compile and shard these variable-size batches.drop_remainder=Trueto the.batch(...)calls for both thetrain_datasetandtest_datasetin train_rl.py to guarantee only constant-size batches are passed to JAX. The unit test configurations in train_rl_test.py were also updated to fit the test data sizes, preventing the new remainder-dropping logic from causing empty batches and failing the unit tests.BUGs: b/527547702, b/527296510.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.