fix(math_group): replace raw == with MathRubric for math-aware answer comparison#1315
Open
jfeldstein wants to merge 5 commits intoPrimeIntellect-ai:mainfrom
Open
fix(math_group): replace raw == with MathRubric for math-aware answer comparison#1315jfeldstein wants to merge 5 commits intoPrimeIntellect-ai:mainfrom
jfeldstein wants to merge 5 commits intoPrimeIntellect-ai:mainfrom
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 679975e. Configure here.
e163b12 to
be0f944
Compare
be0f944 to
634dd86
Compare
MathRubric uses math_verify for symbolic comparison; raw string equality
misses cases like \frac{1}{2} vs 0.5 or \frac{3}{4} vs \dfrac{3}{4}.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both sub-env rubrics now use vf.MathRubric, consistent with gsm8k, math_python, and doublecheck environments. Format-reward weights are unchanged (gsm8k: 0.0 metric, math: 0.2 weighted). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
MathRubric spawns a ProcessPoolExecutor; without teardown propagation those workers leak when the EnvGroup is torn down. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
EnvGroupRubric.teardown() now iterates child envs and calls rubric.teardown() on each, which propagates through RubricGroup to MathRubric.teardown() and shuts down the ProcessPoolExecutor. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
634dd86 to
9b12cb0
Compare
CI Style workflow runs ruff format --check.
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.

Currently
Both sub-env rubrics in
math_groupuse raw Python string equality to score answers:Semantically equivalent LaTeX forms receive 0 reward instead of 1 — e.g.
\frac{1}{2}vs0.5,\frac{3}{4}vs\dfrac{3}{4},1 + xvsx + 1.math-verifywas already declared as a dependency inenvironments/math_group/pyproject.tomlbut never used.Change Summary
Two independent TDD cycles, four commits:
Reward function fix (
environments/math_group/math_group.py)vf.Rubric(...)calls withvf.MathRubric(parser=parser), consistent withgsm8k,math_python, anddoublecheckenvironments0.0(metric), math0.2(weighted)Teardown propagation fix (
verifiers/envs/env_group.py)EnvGroupRubric.teardown()override to propagate teardown to child rubricsMathRubricspawns aProcessPoolExecutor; previously those workers leaked when theEnvGroupwas torn down (vf.Rubricheld no resources so this was harmless before this PR)EnvGroupRubric→RubricGroup.teardown()→MathRubric.teardown()→ executor shutdownAcceptance Criteria
pytest tests/test_math_group.py— 13 tests passpytest tests/test_math_rubric.py tests/test_rubric.py tests/test_rubric_group.py tests/test_env_group.py— existing tests still pass\frac{1}{2}vs0.5,\frac{3}{4}vs\dfrac{3}{4},1 + xvsx + 1all score 1.0MathRubricexecutors are shut down whenEnvGroupis torn downNotes
math-verifywas already in the environment'spyproject.tomlmath_answer_reward_func/gsm8k_answer_reward_func→correct_answer, consistent with every other math environment in the repo. Both old names are confirmed unused anywhere else in the codebase (ripgrep: 0 matches).Note
Medium Risk
Changes reward scoring semantics for
math_groupfrom string equality to math-aware equivalence, which can affect training/eval outcomes. Also adds teardown propagation inEnvGroupRubric, touching lifecycle management and async cleanup paths.Overview
math_groupnow usesvf.MathRubricfor bothgsm8kandmathsub-environments, replacing raw string-equality answer checks so symbolically equivalent LaTeX/decimal forms score as correct; themathenv still applies a0.2weighted format bonus whilegsm8ktracks format as a metric.Adds a
EnvGroupRubric.teardown()override to propagate teardown to child environment rubrics (preventingMathRubricexecutor leaks), and introducestests/test_math_group.pycovering equivalence scoring, format bonus contribution, wrong-answer regression, and teardown propagation.Reviewed by Cursor Bugbot for commit d1bef95. Bugbot is set up for automated code reviews on this repo. Configure here.