Reduce GRPO trainer memory - #29
Merged
Merged
Conversation
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 changed
24,576to16,384tokens.PYTORCH_CUDA_ALLOC_CONF=expandable_segments:Trueat CLI startup unless the operator supplied another allocator configuration.Why
The 24,576-token cap prevented the trainer's forward/logprob OOM, but a later variable-length batch still OOMed during backward due to fragmentation: PyTorch had 10.41 GiB reserved but unused and attempted an 11.66 GiB allocation.
A 16,384-token GRPO context reserves 4,096 tokens for generation and bounds the sampled prompt to 12,288 tokens. Expandable segments reduce fragmentation across the highly variable data-agent trajectories. Evaluation behavior remains unchanged.
The failed GRPO stage still had zero reward variance,
loss=0, andgrad_norm=0, so restarting from the saved SFT checkpoint loses no learned policy update.Validation
224package contract tests pass.26focused bridge/CLI tests pass.git diff --checkpass.logprobs=truefitted to exactly12,288prompt tokens and returned a sidecar with the same exact prompt-ID count.