Repository navigation
fix(tbench2_env): treat a nan or inf reward.txt as no verdict - #1570
Open
zuraiz-anjum wants to merge 1 commit into
Open
zuraiz-anjum wants to merge 1 commit into
zuraiz-anjum wants to merge 1 commit into
Conversation
_parse_canonical_reward returns None for an empty or non-numeric reward.txt, and the callers raise so the episode is reported as a scoring error instead of a reward. float() also accepts "nan", "inf" and "-inf", so those values went through as the reward, and a NaN or infinite reward reached the trainer. Return None for a value that is not finite, the same rule the coding_tools, jupyter and terminus envs already apply to their reward files. Tests cover the local and the Docker evaluate paths.
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.
Summary
_parse_canonical_rewardintbench2_envreturnsNonefor an empty or non-numericreward.txt, and the callers raise so the episode is reported as a scoring error. Butfloat()also acceptsnan,infand-inf, so areward.txtholding one of those went through as the reward. This makes a value that is not finite count as no verdict too.Type of Change
Alignment Checklist
Before submitting, verify:
.claude/docs/PRINCIPLES.mdand this PR aligns with our principles.claude/docs/INVARIANTS.mdand no invariants are violated/pre-submit-pr(orbash .claude/hooks/lint.shand tests) and addressed all issuesRFC Status
Details
Since #1025, a missing verdict raises in
_require_canonical_verdict, so RL consumers can drop the episode instead of training on a false 0.0. On main,__TB2_REWARD__:nanis parsed asfloat("nan"),_evaluate_taskand_evaluate_dockerreturnreward=nanwithtests_passed: False, and the NaN goes to the trainer.infgoes through the same way.The other envs that read a reward file already reject this case:
_parse_reward_overrideincoding_tools_env,jupyter_envandterminus_envreturns no reward whenmath.isfinite(value)is false. This applies the same check in_parse_canonical_reward, so both the local and the Docker path raise "canonical harness produced no verdict", the same as for an emptyreward.txt. I also updated the docstring.Test Plan
Two tests in
tests/envs/test_tbench2_env.py, next to the missing-verdict tests from #1025:test_evaluate_non_finite_verdict_raises, fornan,infand-infon the local path. It also checks that the staged tests and the verifier dir are still wiped.test_evaluate_docker_non_finite_verdict_raisesfornanon the Docker path, with the fake container.Run with
PYTHONPATH=src:envs pytest tests/envs/test_tbench2_env.py:DID NOT RAISE), the existing verdict tests pass.The three checks from
.claude/hooks/lint.sh(usort check,ruff format --check,ruff check) are clean on the files this PR touches; the findings a tree-wide run reports are in other files and are the same on main.Note
Low Risk
Scoring-path guard only; finite rewards unchanged. Low blast radius—errors instead of NaN/inf rewards.
Overview
Canonical TB2 reward parsing now treats
nan,inf, and-infin the verifier marker line as no verdict (None), not a valid score—float()accepts those strings, so they used to propagate to the trainer.The docstring on
_parse_canonical_rewardwas updated to match. Tests cover withheld local evaluate for all three non-finite strings (staging still wiped) and Docker evaluate with ananmarker, both expecting the sameRuntimeErroras an empty or missing verdict.Reviewed by Cursor Bugbot for commit f6c2840. Bugbot is set up for automated code reviews on this repo. Configure here.