Repository navigation
fix(reward): follow the GRPO reward contract in MathORM - #10266
Open
Lesereingrape wants to merge 1 commit into
Open
Lesereingrape wants to merge 1 commit into
Lesereingrape wants to merge 1 commit into
Conversation
This was referenced Nov 3, 2026
This branch has not been deployed
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 is changed / 改动内容
MathORM.__call__now follows the reward-function contract that the GRPO dispatch uses, like every otherbuilt-in ORM: it receives the completion texts and the dataset
solutioncolumn, and still unwrapsInferRequestobjects for programmatic callers (the sameisinstance(..., str)branchReactORMuses).Why / 原因
--reward_funcs mathcrashed as soon as rewards were computed, becauseMathORMwas the only registered ORMleft assuming
List[InferRequest]whileswift/rl_core/grpo_algorithm.py::compute_rewards_per_funcpassescompletions: List[str]positionally plus the dataset columns as kwargs:solutioncolumn (what the math datasets and the reward function guide document) →TypeError: MathORM.__call__() missing 1 required positional argument: 'ground_truths'ground_truthscolumn →AttributeError: 'str' object has no attribute 'messages'atswift/rewards/orm.py:444Closes #10265
Test / 测试
TestMathORMCompletionscases intests/utils/test_rewards.py(completion strings,solutionkwarg,InferRequest): the module runsFAILED (errors=2)ondbc395ffwithout the fix andOKwith it.compute_rewards_per_func) with asolutioncolumn: crash before thechange,
[[1.0], [0.0]]after it for\boxed{3}vs4against\boxed{3}.tests/utils/test_math_orm_expressions.py, which callsMathORMwithInferRequestobjects, keeps passing.flake8,yapfandisortclean on both files.