minerva_math / putnam_axiom: `is_equiv` scores every sympy-equivalent answer as wrong on Windows (`signal.SIGALRM` is missing)
On Windows, minerva_math and putnam_axiom give exact_match = 0 to every answer that only sympy can match to the gold (0.5 vs \frac{1}{2}, 1+x vs x+1, \sqrt{8} vs 2\sqrt{2}). No error is reported. Only answers that equal the gold string after normalization get credit.
Reproduction
from lm_eval.tasks.minerva_math import utils
print(utils.is_equiv(r"\frac{1}{2}", "0.5")) # Windows: False, Linux: True
doc = {"solution": r"... $\boxed{\frac{1}{2}}$.", "answer": r"\frac{1}{2}"}
resp = "Final Answer: The final answer is $0.5$. I hope it is correct."
print(utils.process_results(doc, [resp])) # Windows: {'exact_match': 0, 'math_verify': 0}
utils.timeout(seconds=5).__enter__()
# AttributeError: module 'signal' has no attribute 'SIGALRM'Expected vs actual
Call (Windows, lm_eval[math] installed) |
Expected | Actual |
|---|---|---|
minerva_math.utils.is_equiv(r"\frac{1}{2}", "0.5") |
True |
False |
minerva_math.utils.is_equiv("1+x", "x+1") |
True |
False |
minerva_math.utils.is_equiv(r"\sqrt{8}", r"2\sqrt{2}") |
True |
False |
putnam_axiom.utils.is_equiv("0.5", r"\frac{1}{2}") |
True |
False |
minerva_math.utils.process_results(...)["exact_match"], gold \frac{1}{2}, answer 0.5 |
1 |
0 |
The repo's own tests show it too. On Windows, pytest tests/test_minerva_math.py fails these four tests: test_mathematically_equal_answers_still_compare_equal, both test_is_equiv_indexed_roots_through_pipeline cases, and test_is_equiv_shorthand_still_works. There are three more failures, but those come from the separate NORMS issue that #4073 addresses. CI doesn't catch any of this because the module is skipped when the [math] extra isn't installed.
Cause
timeout.__enter__ calls signal.signal(signal.SIGALRM, ...). Windows has no signal.SIGALRM, so this raises AttributeError. The exception reaches the catch-all except Exception at the end of is_equiv, which logs it at debug level and returns False. Off the main thread on Linux, signal.signal raises ValueError and you get the same silent False.
The same code is in:
lm_eval/tasks/minerva_math/utils.py(timeout,is_equiv)lm_eval/tasks/putnam_axiom/utils.py(same copy)lm_eval/tasks/leaderboard/math/utils.py(same copy;exact_match_originalis also 0 for0.5vs\frac{1}{2}on Windows; I know this file is frozen)lm_eval/tasks/score/math/math_grader.py(time_limitusessignal.setitimer;math_equal("x+1", "1+x")andmath_equal(r"\frac{1}{2}", "0.5")returnFalseon Windows)- The open PR #3655 adds the same
_timeoutclass tohendrycks_math.
On Windows the task's second metric, math_verify, is also 0 for this pair. That comes from Math-Verify's own Windows timeout problem (huggingface/Math-Verify#79, fix proposed in huggingface/Math-Verify#80), not from this repo. So on Windows both minerva_math metrics are currently wrong for these answers.
Suggested fix
Run the block without a time limit when the alarm can't be set. jsonschema_bench/metrics.py::_run_with_timeout (#3923) already does this:
def __init__(self, seconds=1, error_message="Timeout"):
self.seconds = seconds
self.error_message = error_message
self.armed = False
def __enter__(self):
try:
signal.signal(signal.SIGALRM, self.handle_timeout)
except (AttributeError, ValueError): # no SIGALRM (Windows) / not main thread
return
self.armed = True
signal.alarm(self.seconds)
def __exit__(self, exc_type, value, traceback):
if self.armed:
signal.alarm(0)Behaviour on Linux and macOS in the main thread doesn't change. The trade-off: on Windows a pathological sympy.simplify call has no time limit. Right now it gets a wrong score instead. I have a small PR with this change for minerva_math and putnam_axiom, plus regression tests, and can open it if this approach works for you. I left leaderboard/math alone because it is frozen. The change wouldn't move any Linux number, though, so I can add it if you want Windows runs to match the published scores. score/math could get the same treatment in a follow-up.
Environment
- Windows 11 Pro 10.0.26200, x86-64, CPU only
- CPython 3.13.14
- lm-evaluation-harness
main@ d6de8164 (0.4.14.dev0; these task files are unchanged since v0.4.13), installed withpip install -e ".[math,dev]" - sympy 1.14.0, antlr4-python3-runtime 4.11.0, math-verify 0.9.0
Found while systematically testing graders with meaning-preserving rewrites of gold answers and provably wrong answers.
I plan to mention this case, by mechanism only, in a write-up on grader reliability no earlier than 2026-10-31; happy to wait longer if you need.
Source: EleutherAI/lm-evaluation-harness