feat: optionally track other reward components #366
+76
−11
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.
Motivation
For R1 style of RL, there are many components of reward, like format score or reward score. It is currently not trivial to track different components. It is especially inconvenient when reading validation results, when we might want to read the outcome accuracy instead of only reward score.
Design
In this PR I slightly modify
verl/workers/reward_manager/naive.py
to expect thecompute_score
function to either expect a float (final reward) or a dict (new).The dict returned should be in the format
ray_trainer.py
is also modified to handle both dict and float returned from reward_manager. It will then log the extra info from the reward function.Example Usage
We can modify
verl/verl/utils/reward_score/gsm8k.py
to allow separate logging of format rewardsBreaking changes
There are no breaking changes in this PR. It is still possible to use the reward functions under
utils/reward_score
Possible future work
Logging of reward and validation can be enhanced further.