Skip to content

Conversation

@chivatam
Copy link

@chivatam chivatam commented Oct 15, 2025

Context

What is the purpose of this PR? Is it to

  • add a new feature
  • fix a bug
  • update tests and/or documentation
  • other (please add here)

Please link to any issues this PR addresses.

Changelog

What are the changes made in this PR?

  1. Fix trajectory concatenation: Update generate_trajectory_batched to properly handle the 'answers' field which is a list of strings, not a tensor.

  2. Update reward function signature: Modify batched_rewards call to include device parameter and handle multiple reward functions properly.

  3. Add missing fields to GRPOTrajectory: Add rewards and successes fields to the GRPOTrajectory NamedTuple and update docstring.

  4. Fix GRPOStats concatenation: Update the concatenation logic in the training loop to properly handle the metadata field.

  5. Fix reward indexing: Correct the answer indexing in batched_rewards function from answers[b][g] to answers[b].

These changes ensure that distributed GRPO training works correctly with proper trajectory handling and reward computation.

Test plan

Please make sure to do each of the following if applicable to your PR. If you're unsure about any one of these just ask and we will happily help. We also have a contributing page for some guidance on contributing.

  • run pre-commit hooks and linters (make sure you've first installed via pre-commit install)
  • add unit tests for any new functionality
  • update docstrings for any new or updated methods or classes
  • run unit tests via pytest tests
  • run recipe tests via pytest tests -m integration_test
  • manually run any new or modified recipes with sufficient proof of correctness
  • include relevant commands and any other artifacts in this summary (pastes of loss curves, eval results, etc.)

UX

If your function changed a public API, please add a dummy example of what the user experience will look like when calling it.
Here is a docstring example
and a tutorial example

  • I did not change any public API
  • I have added an example to docs or docstrings

This commit addresses several issues in the distributed GRPO implementation:

1. **Fix trajectory concatenation**: Update generate_trajectory_batched to properly
   handle the 'answers' field which is a list of strings, not a tensor.

2. **Update reward function signature**: Modify batched_rewards call to include
   device parameter and handle multiple reward functions properly.

3. **Add missing fields to GRPOTrajectory**: Add rewards and successes fields
   to the GRPOTrajectory NamedTuple and update docstring.

4. **Fix GRPOStats concatenation**: Update the concatenation logic in the training
   loop to properly handle the metadata field.

5. **Fix reward indexing**: Correct the answer indexing in batched_rewards function
   from answers[b][g] to answers[b].

These changes ensure that distributed GRPO training works correctly with proper
trajectory handling and reward computation.
@meta-cla
Copy link

meta-cla bot commented Oct 15, 2025

Hi @chivatam!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla
Copy link

meta-cla bot commented Oct 15, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 15, 2025
@chivatam
Copy link
Author

@joecummings
lmk if there are any additional edits!

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant