Skip to content

fix: math_equal rejects leading-zero integers incorrectly equated by sympy (#319)#331

Merged
James-CUDA merged 1 commit into
James-CUDA:mainfrom
fazalpsinfo-cmyk:fix/leading-zero-math-319
Jul 15, 2026
Merged

fix: math_equal rejects leading-zero integers incorrectly equated by sympy (#319)#331
James-CUDA merged 1 commit into
James-CUDA:mainfrom
fazalpsinfo-cmyk:fix/leading-zero-math-319

Conversation

@fazalpsinfo-cmyk

Copy link
Copy Markdown
Contributor

Fix: AIME leading-zero answers corrupted by sympy fallback

AIME answers are zero-padded 3-digit integers (000-999). When a model
answers 5 against reference 005, the numeric comparison bridges them
because _as_number strips leading zeros (both evaluate to 5.0).

Fix

Reject numeric and sympy fallback when either normalized answer is a
zero-padded all-digit string (starts with 0, length > 1, all digits).
This forces AIME-style answers to match only via exact string equality.

The guard is deliberately narrow (.isdigit()) so legitimate comparisons
like 0.5 vs 1/2 and 0.333 vs 1/3 are unaffected.

Fixes #319


Support my work: If this fix helped, consider buying me a coffee at https://buymeacoffee.com/muhamedfazalps

…equates (James-CUDA#319)

AIME answers are zero-padded 3-digit integers (000-999). When a model
answers '005' and the reference is '009', _as_number strips the leading
zeros (5.0 vs 9.0, not close), then the sympy fallback evaluates both
as integers and returns False (5 != 9). However, a model that answers
'5' against reference '005' would hit the numeric path since
_as_number('5') == _as_number('005') == 5.0, grading the wrong answer
as correct.

Fix: reject both numeric and sympy fallback when either normalized
answer is a zero-padded all-digit string (starts with '0', has length
> 1, and consists entirely of digits). This preserves legitimate
comparisons like '0.5' vs '1/2'.

Fixes James-CUDA#319
@James-CUDA
James-CUDA merged commit 0ec56bf into James-CUDA:main Jul 15, 2026
carlh7777 added a commit to carlh7777/Gittensor-TinyRouter that referenced this pull request Jul 15, 2026
…ero-padding checks

Updated the `_is_zero_padded` function to first check the length of the string before accessing its first character, preventing an IndexError when handling empty strings. Added a regression test to ensure that empty strings are correctly handled without raising exceptions. This change addresses issues surfaced during CI tests related to scoring empty probes in the math_equal function.

Fixes James-CUDA#319, James-CUDA#331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] math_equal grades leading-zero numbers as equal (05 == 09) via the sympy fallback; corrupts AIME grading

2 participants