Prince Osei Aboagye
← All posts
Mini DeepSeek V4 / Part 08·Dec 2026

Rewards and graderschecking the checker

Spoiler: My numeric checker passed every gold answer and rejected all 222,146 wrong ones; the trouble came from a length penalty that inflated the reward and a grader that hung training.

TL;DR

In RL with verifiable rewards, a program decides whether an answer is right, and the model learns whatever that program pays for. I audited my numeric checker with 644,366 constructed answers on 23,226 problems: every gold answer passed, and none of 222,146 wrong numeric answers did. On 2,698 LaTeX problems, 6 had real holes, so I kept all 28 flagged problems out of training and scoring. On the laptop, the reward’s rise was mostly a length penalty: +0.085 of a +0.112 gain at the highest learning rate. In the control run, a third-party grader hung training at update 16; not grading cut-off answers, plus a 10 s CPU-time limit, fixed it, with 0 timeouts afterwards.

// § 01

What you’ll learn

  • What a verifiable reward is, and the three steps every grader takes: extract, canonicalize, compare.
  • How a format bonus and a length penalty enter the reward, and how each one shows up in the mean reward.
  • How to audit a grader without a model, by feeding it deliberately broken answers.
  • Why false accepts matter most when the model rarely succeeds, by Bayes’ rule.
  • Three ways RL went wrong around a correct grader: an inflated mean reward, a framework’s idea of a pass, and a hang.
// § 02

What a verifiable reward is

In reinforcement learning (RL) for language models, the model writes an answer and receives a number, its reward. With verifiable rewards (RLVR), a program computes that number by checking the answer against a known solution. No learned judge is involved. For math the check is simple in principle: does the final answer equal the gold answer?

\[r(x, y) = \mathbb{1}\!\left[\,\mathrm{canon}\big(\mathrm{extract}(y)\big) = \mathrm{canon}\big(a^\star(x)\big)\,\right] \in \{0, 1\} \tag{1}\]

Here \(x\) is the problem and \(y\) the model’s full response text. \(a^\star(x)\) is the gold answer. \(\mathrm{extract}\) pulls the final answer out of the text, and \(\mathrm{canon}\) maps an answer to a standard form. \(\mathbb{1}[\cdot]\) is 1 when its condition holds and 0 otherwise. If extraction fails, \(r = 0\).

In words: the reward is 1 when the answer the program reads out of the response equals the gold answer, and 0 otherwise.

Kian Kyars’s book on RLVR splits every outcome grader into these steps: extract, canonicalize, reward. Canonicalizing should “Map the extracted artifact to a representation that is stable under harmless surface variation” (Ch. 2). So “$52”, “52.0” and “52 units” should all count as 52, while “52 or 53” should not.

Every grader extracts, canonicalizes and comparesThe three graders of this post, step by step (code/rl/rewards.py, code/rl/boxed_grader.py)responsemodel outputextractfind the final answer1canonicalizea standard form2compareequal to gold?3rewardr ∈ {0, 1}, plus shapinglaptopMiniMind 64Mlast number after thefinal </think>, or elsethe last numberexact fraction(Python Fraction)equal togoldr + length penaltyL 256, C 64no format bonusmain runmy MoE, 8×H100text of the single<answer> block; noneif 0 or 2+ blocksexact fraction;LaTeX: math-verifyequal togoldr + 0.1 format bonus+ length penaltyL 1,024, C 256control runQwen2.5-Math-1.5Bthe last \boxed{…};no box: r = 0mathd normalization,then sympy, thenmath-verify (1 s alarms)any oneequal; strictfor integersr only: no bonus,no penalty; cut offat 3,000 tokens: 0,not graded10 s CPU-time guard (ITIMER_PROF): a grading that hits it scores 0
Figure 1. every grader extracts, canonicalizes and compares; mine differ in each step. Source: code/rl/rewards.py, code/rl/boxed_grader.py.

Why spend a whole post on this? RL pushes the model toward whatever the grader pays for. The grader is the definition of “right” for training, so a bug in it is a bug in the objective.

Shaping: a format bonus and a length penalty

My main run’s reward added two terms to Eq. (1):

\[R(x, y) = r(x, y) + \beta\, f(y) + \ell\big(n(y)\big) \tag{2}\]

Here \(f(y)\) is 1 when the response is exactly <think>…</think> followed by one <answer>…</answer>, and 0 otherwise. \(\beta = 0.1\) is the format bonus, \(n(y)\) is the response length in tokens, and \(\ell\) is the length penalty below.

In words: a right answer earns 1, a clean layout earns a tenth more, and an overlong answer loses up to 1.

The length penalty is DAPO’s soft overlong punishment:

\[\ell(n) = \begin{cases} 0 & n \le L - C \\[2pt] \dfrac{(L - C) - n}{C} & L - C < n \le L \\[6pt] -1 & n > L \end{cases} \tag{3}\]

Here \(L\) is the length limit and \(C\) the width of the soft band. The main run used \(L = 1{,}024\) and \(C = 256\), so the penalty starts at 768 tokens. The laptop runs used \(L = 256\) and \(C = 64\).

In words: normal lengths get no penalty, the penalty ramps linearly to −1 over the last \(C\) tokens, and it stays at −1 beyond the limit.

The real function gives these rewards:

Answer Reward
right, full format, 20 tokens 1.100
wrong, full format 0.100
right, but no <think> block 1.000
right, full format, 900 tokens 0.584
right, full format, 1,100 tokens 0.100

The 900-token row is \(1 + 0.1 + (768 - 900)/256 = 1.1 - 0.516 = 0.584\).

Why cap the length at all? Generation waits for the longest answer in a batch, and the memory that stores past tokens grows with length. Megatron pads every RL training sequence to the full length. And RL can drift into ever-longer answers. The soft band avoids a cliff for an answer that is almost finished.

The length penalty ramps over the last 256 tokensReward of a well-formed answer vs its length, main run (L = 1,024, C = 256), from code/rl/rewards.pyright answer, full formatwrong answer, full formatreward, Eq. (2)-1.0-0.50.00.51.002565127681,0241,2801,536answer length (tokens)soft band1 + 0.1 format bonus = 1.10 + 0.1 = 0.11.1 − 1 = 0.10.1 − 1 = −0.9900 tokens: 0.584
Figure 2. the length penalty ramps down over the last 256 tokens. Reward from Eq. (2) and Eq. (3) as computed by code/rl/rewards.py. Source: code/rl/rewards.py.

What the mean reward hides

Take the expectation of Eq. (2) over the model’s answers:

\[\mathbb{E}[R] = P(\text{correct}) + \beta\, P(\text{format}) + \mathbb{E}\big[\ell(n)\big] \tag{4}\]

Here \(P(\text{correct})\) is the solve rate, \(P(\text{format})\) the share of well-formed answers, and \(\mathbb{E}[\ell(n)]\) the average length penalty.

In words: the mean reward adds three separate things, so it can rise when only the length term moves.

That is why I log the solve rate on its own, beside the reward. The laptop example below shows what happens otherwise.

How the reward becomes a learning signal

GSPO, my RL method, samples \(G\) answers to each problem and compares them (Part 9 covers the algorithm). Each answer’s advantage is its reward relative to its group:

\[A_i = \begin{cases} \dfrac{R_i - \bar R}{\epsilon + \sigma_R} & \text{if the group is mixed} \\[6pt] 0 & \text{otherwise} \end{cases} \tag{5}\]

Here \(R_i\) is the reward of answer \(i\), \(\bar R\) and \(\sigma_R\) are the mean and standard deviation of rewards in its group, and \(\epsilon = 10^{-4}\). A group is mixed when it holds at least one correct and one wrong answer by \(r\), not by \(R\).

In words: answers are compared only with their siblings, and only in groups where correctness differs.

So the format bonus and the length penalty cannot create a signal on their own. They only reorder answers inside groups that already mix right and wrong.

// § 03

My three graders

The last-number grader (laptop)

On the laptop I trained MiniMind, a 64M-parameter model that had never seen my answer tags. So its grader read the last number after the final </think>, or else the last number in the response. The reward was \(r + \ell\), with no format term.

A last-number grader has two blind spots:

  • It ignores the working. In one laptop run, 47 of the 81 correct answers to one-operation problems at step 300 also stated a wrong result along the way. “Correct” meant the final number, not the arithmetic.
  • It reads the wrong number when another follows. The answer is 67. Check: 67 - 10 = 57 is read as 57, and So 42 apples (2 boxes). as 2. At step 300 of one run, 3.8% of the wrong answers held the gold answer, just not last.

The tag grader (main run)

For my own model, SFT taught a fixed format (Part 7), so the grader could be strict:

  • Extract: the text inside exactly one <answer>…</answer> block. Zero blocks or two give no answer.
  • Canonicalize: strip $, thousands separators and a trailing period, then parse an exact fraction with Python’s Fraction. “52.0”, “$52” and “52 units” all become 52. Text holding two numbers, like “52 or 53”, parses to nothing.
  • Compare: exact equality of fractions. For LaTeX answers, such as many MATH problems, math-verify decides whether two expressions are equal.

The heart of it, abridged from code/rl/rewards.py:

answer = extract_answer(response)                 # the single <answer> block, or None
if isinstance(gold, Fraction):
    predicted = parse_number(answer)              # exact Fraction, or None
    correct = predicted is not None and predicted == gold
else:
    correct = latex_answers_match(answer, gold)   # math-verify for LaTeX golds
well_formed = format_ok(response)
penalty = overlong_penalty(num_tokens, config.max_tokens, config.cache_tokens)
reward = float(correct) + (config.format_bonus if well_formed else 0.0) + penalty

Evaluation uses the same function, so training and testing agree on what “correct” means.

The \boxed{} grader (control run)

In the control run of Part 14, I ran my RL pipeline on Qwen2.5-Math-1.5B with PocketRL’s data, prompt and grader. The grader is Dr. GRPO’s boxed-answer grader as PocketRL adapted it, copied byte for byte; a test checks the copy. It works like this:

  • it takes the last \boxed{…} only, so an answer with no box scores 0;
  • it tries a normalized string match, then equality under sympy, then math-verify with 1-second alarms;
  • it demands a strict match when the gold is an integer, and refuses unreduced fractions;
  • it pays 1 or 0, with no format reward (“no format reward to avoid hacking”, says its comment) and no length penalty;
  • in training, an answer cut off at 3,000 tokens scores 0, as in PocketRL.

Did the copy behave like the original? On the base model, MATH-500 accuracy averaged over 8 samples read 21.8%, against PocketRL’s published 21.9%. A mistake anywhere in the chain, the grader included, would have shown there. Spot checks agreed too: x = -1 against −1, 18\% against 18, and 2/15 against \frac{2}{15} were all judged right.

// § 04

Auditing the checker with broken answers

The method

You do not need a model to test a grader. Construct answers whose verdict you already know, score them with the real checker exactly as the trainer calls it, and count the mistakes. This follows Envaudit (Shreshth Rajan, arXiv:2606.16062): mutate a known-correct answer, and any mutant that passes exposes a hole.

For each problem, the audit built these cases (shown for a gold of 52):

Kind Examples Must
gold 52 pass
valid other forms $52, 52 units, 52., +52, 52.0; 1,234 for 1234; 1/4 for 0.25; a \boxed{} gold pass
junk empty, a space, NaN, nan, inf, -inf, Infinity, None, ? fail
wrong, numeric ×1.34 (69.68), ×10 (520), ÷10 (5.2), +1 (53), −1 (51), negated (−52), 0, the hedge “52 or 53”, every other number in the question fail
wrong, LaTeX first digit bumped, negated, “+1” appended, 0, 1, a swapped fraction fail
structure tricks two answer blocks; no tags; the gold only inside <think>, a wrong number in the answer fail

Each file gets a class, in Envaudit’s terms: DEGENERATE-ACCEPT if any junk answer passes, else SLACK if any wrong answer or trick passes, else TIGHT. The audit also reports a free score: the share of a file’s problems that its most common gold answer would pass.

One worked example from the tests: “Ann has 12 apples at $3 each and 8 oranges at $2 each. What does she spend?” The gold is 52, the audit builds 30 answers (the gold, 5 valid forms, 9 junk answers, 8 wrong values, the question’s 4 other numbers and 3 structure tricks), and the checker judged every one correctly. The audit is itself tested: its test plants a checker that accepts anything containing “52”, and the audit must call it SLACK, which it does.

Kian Kyars shows the opposite failure in a GRPO training script he walks through: “$42, 42.0, and 1,000 all score 0.0” (Ch. 5). The audit’s “valid other forms” row tests exactly that kind of false reject.

Predictions, written before the run

I committed seven predictions with the code, before the full run:

  • every numeric gold passes (about 95% confident);
  • no wrong numeric answer passes (about 90%);
  • no junk answer passes, on any path (about 95%);
  • at least 99% of valid numeric forms pass (about 80%);
  • at least 99% of LaTeX golds pass (about 70%);
  • the LaTeX path is SLACK on at least one problem (about 50%);
  • the free score is at most 5% in every file (about 70%).

Six held. The last failed on two small sets, as its stated reason had warned: a constant answer scores 8.33% on SVAMP and 7.78% on MultiArith.

Results

The audit ran in 128 s on a laptop CPU, over 23,226 problems: 20,528 numeric and 2,698 LaTeX.

Case Answers tried Wrong verdicts
gold answers 23,226 0 rejected
valid other forms 106,045 0 rejected
junk answers 209,034 0 accepted
wrong answers, numeric problems 222,146 0 accepted
wrong answers, LaTeX problems 14,237 35 accepted
structure tricks 69,678 1 accepted

Per file, every set without LaTeX came out TIGHT. The two files with LaTeX problems were SLACK.

File Problems (numeric / LaTeX) Class Wrong accepted Free score
GSM8K test 1,319 / 0 TIGHT 0 3.03% (“5”)
SVAMP test 300 / 0 TIGHT 0 8.33% (“1”)
MultiArith test 180 / 0 TIGHT 0 7.78% (“9”)
ASDiv test 407 / 0 TIGHT 0 4.91% (“7”)
MAWPS test 520 / 0 TIGHT 0 0.96% (“30”)
MATH test 3,176 / 1,824 SLACK 23 (+1 trick) 2.96% (“2”)
RL hard tier 9,526 / 874 SLACK 12 2.77% (“6”)
RL medium tier 1,905 / 0 TIGHT 0 4.04% (“2”)
RL easy tier 1,195 / 0 TIGHT 0 1.67% (“37”)
RL warm-up tier 2,000 / 0 TIGHT 0 1.25% (“38”)

Reading the LaTeX holes by hand

All 35 accepted wrong answers and the 1 accepted trick sat on 28 LaTeX problems: 9 in RL training, 19 in the MATH test. I read every one.

  • Equal by accident (7 problems). A negated zero vector is still zero, and “1” equals 100\%.
  • Odd notation tolerated (15). -(x = c) passes for golds written as equations, such as x = 2. Realistic wrong answers, x = −c and −c, were rejected.
  • Real holes (6). A plausible wrong answer passes. 2007 + \frac\pi 2 accepts 3007 + \frac\pi 2, because the fraction lacks braces. \frac{1}{2004!} accepts \frac{2}{2004!}: both are tiny, inside the checker’s tolerance.

I kept all 28 flagged problems out. The 9 training problems were dropped, and the 19 MATH test problems were left out of the MATH score and reported, leaving 4,981 scored. The exclusion removed 9 of 10,400 hard-tier problems and 19 of 5,000 MATH problems. Every remaining problem is one where the checker rejected every wrong answer it was shown. The list is code/rl/latex_flagged.json.

The free score

The free score is the floor any reported accuracy must beat. Always answering “1” scores 8.33% on SVAMP (25 of 300), and always answering “9” scores 7.78% on MultiArith (14 of 180). After SFT, my model’s greedy accuracy was 3.3% on both, below the floor.

The floor matters for training too. On the RL medium tier, always answering “2” passes 4.04% of problems. My model’s solve rate there at the start of RL was 2.73%. A policy that learned one constant could have out-earned honest attempts. Answer diversity shows whether that is happening: at the start there were 25.6 distinct answers per group of 32.

On SVAMP and MultiArith, a constant answer beats the SFT modelFree score (always the set's most common gold answer) and the SFT model's greedy accuracy, %free score: one constant answerSFT model, greedy% of problems0246810SVAMPASDivMultiArithGSM8KMATHMAWPSSFT model: step 175, one greedy evaluation on 8×H1008.334.917.783.032.960.963.35.73.32.00.50.0whole sets: like for likegreedy on 200-problem subsets,free score on whole sets
Figure 3. on SVAMP and MultiArith, a constant answer beats the SFT model. Free score per set and the SFT model’s greedy accuracy; one evaluation, one seed; only the three sets scored whole compare like for like. Source: the checker audit and the after-SFT evaluation (Results).
// § 05

False accepts, false rejects and a low solve rate

A grader makes two kinds of error:

  • a false accept pays 1 for a wrong answer; its rate is \(\mathrm{FPR} = P(\text{accept} \mid \text{wrong})\);
  • a false reject pays 0 for a right answer; the true-accept rate is \(\mathrm{TPR} = P(\text{accept} \mid \text{correct})\).

Suppose the model answers correctly with probability \(p\). Then the share of rewarded answers that are truly right is

\[P(\text{correct} \mid \text{accepted}) = \frac{p\,\mathrm{TPR}}{p\,\mathrm{TPR} + (1 - p)\,\mathrm{FPR}} \tag{6}\]

Here \(p\) is the solve rate, and TPR and FPR are the grader’s two rates. Kian Kyars calls this the precision of the accepted pool (his Eq. 6.3).

In words: when right answers are rare, even a rare false accept makes up a large share of everything the grader pays for.

Derivation

Bayes’ rule gives \(P(C \mid A) = P(A \mid C)\,P(C) / P(A)\), where \(C\) is “correct” and \(A\) is “accepted”. The total probability of acceptance splits over right and wrong answers:

\[P(A) = P(A \mid C)\,P(C) + P(A \mid \neg C)\,P(\neg C) = \mathrm{TPR}\cdot p + \mathrm{FPR}\cdot(1-p) \tag{7}\]

Substituting \(P(A \mid C) = \mathrm{TPR}\) and \(P(C) = p\) into Bayes’ rule gives Eq. (6).

In words: an acceptance comes either from a right answer the grader caught or from a wrong answer it let through.

What the numbers look like

Kian Kyars’s illustrative example: at \(p = 0.05\), \(\mathrm{TPR} = 0.9\) and \(\mathrm{FPR} = 0.01\), Eq. (6) gives \(0.045 / (0.045 + 0.0095) \approx 0.83\). About 17% of rewarded answers are wrong. With \(\mathrm{FPR} = 0.05\), precision falls to about 0.49.

Now my regime, as illustrative arithmetic. At the start of RL my model solved 2.73% of medium-tier answers. With \(\mathrm{TPR} = 1\) and an assumed 1% false-accept rate, Eq. (6) gives \(0.0273 / (0.0273 + 0.9727 \times 0.01) \approx 0.74\): about a quarter of rewards would go to wrong answers. In the control run, the solve rate over updates 1–50 was 29.3%. The same assumed 1% would leave precision at \(0.293 / (0.293 + 0.707 \times 0.01) \approx 0.98\). A weak model needs a stricter grader than a strong one.

At low solve rates, false accepts swamp the rewardP(correct | accepted) from Eq. (6), TPR = 1, for assumed false-accept rates (illustrative)FPR = 0.1%FPR = 1%FPR = 5%share of rewarded answers that are right00.250.50.7510.1%0.3%1%3%10%30%solve rate p (log scale)medium tier, start of RL: p = 2.73%precision 0.74 at FPR 1%control run, updates 1–50: p = 29.3%precision 0.98 at FPR 1%
Figure 4. at low solve rates, false accepts swamp the reward. Curves from Eq. (6), illustrative; the marked solve rates are measured. Source: Eq. (6); the solve rates of the main run’s first GSPO step and the control run’s first 50 updates (Results).

The same split shows up in the reward the policy sees:

\[\mathbb{E}[r] = p\,\mathrm{TPR} + (1 - p)\,\mathrm{FPR} \tag{8}\]

Here the first term is earned by right answers and the second by wrong answers the grader let through.

In words: RL raises the probability of whatever gets accepted. A false-accept pattern that is easy to produce can be learned instead of the math.

False rejects

False rejects mislead less but waste signal. In a group, a rejected right answer gets a negative advantage, and a group with one right answer can turn all-wrong and teach nothing. My graders reject some right answers:

  • by design: right answers in the wrong layout, with no answer tags or two answer blocks. In the control run’s training, answers cut off at 3,000 tokens also score 0, whatever they say;
  • by limitation: number words such as “fifty-two” and mixed numbers such as “1 1/2” do not parse;
  • by bad labels: a rounded gold answer such as 3.67 for 11/3 rejects the exact answer. The SFT data build dropped such questions for this reason (Part 3).

What the audit does not show

The audit used constructed answers. It shows the checker is tight against those mutants; it does not measure the false-accept or false-reject rate on my model’s own answers. That needs a hand-labelled sample of real answers, which I have not made. The audit also checks the marker, not the answer key: it cannot tell whether a gold label is itself right.

// § 06

What went wrong

1. The reward rose; the model barely did

On the laptop, Run 2b trained MiniMind at three learning rates for 60 steps each. I split the change in mean reward, steps 1–20 against 41–60, into its two terms.

Learning rate Mean reward change From solve rate From length penalty Answers cut at 256 tokens
1e-7 +0.042 +0.000 +0.042 14.3% → 10.6%
3e-7 +0.121 +0.004 +0.117 15.5% → 5.9%
1e-6 +0.112 +0.027 +0.085 11.0% → 3.4%

By Eq. (4), with no format term, the reward rises with the solve rate or with a smaller length penalty. At 1e-6 only about a quarter of the gain was correctness; at 1e-7, none was. Of the 0.085 from length, about 0.075 came from fewer answers cut off at the cap, and about 0.010 from the soft band.

Most of the reward gain was the length penaltyChange in mean reward, steps 1–20 → 41–60, by term; MiniMind 64M on a laptop RTX 3060 (6 GB), one run per ratefrom the solve ratefrom the length penaltychange in mean reward0.000.050.100.15learning rate 1e-7learning rate 3e-7learning rate 1e-6 length +0.042solve +0.000total +0.042cut at 256 tokens: 14.3% → 10.6%length +0.117solve +0.004total +0.121cut at 256 tokens: 15.5% → 5.9%length +0.085solve +0.027total +0.112cut at 256 tokens: 11.0% → 3.4%
Figure 5. most of the reward gain was the length penalty. Change in mean reward, steps 1–20 against 41–60, by term; one run per rate, MiniMind 64M on a laptop RTX 3060 (6 GB). Source: the step logs of the laptop’s Run 2b (Results).

The model learned to stop rambling into the 256-token cap; whether it learned that before learning to solve more was not tested. The lesson stuck: report the solve rate and held-out accuracy, never the mean reward alone.

2. Megatron’s evaluation would have counted the wrong answers

Before reusing Megatron-LM’s RL evaluation, I read what it treats as a pass. Its pass@k evaluation counts a pass when the reward equals 1.0 exactly. My reward gives 1.1 to a right, well-formed answer, so no good answer would ever count. The only answers at exactly 1.0 were right answers with a broken format. The numbers would have looked plausible, all near zero, and been wrong.

The fix was my own evaluation, judged by correctness. Each answer is scored with my reward and its token count and marked right or wrong; pass@1 to pass@k come from those marks. Reusing a framework’s evaluation means checking what it treats as a pass.

3. The grader that hung training

The symptom. In the control run, I found the log silent since 04:33, after update 16, mid-generation with 8 answers left. Updates had taken about 68 s each until then. The process was alive, and the GPU sat at 0% while holding 64 GB.

The diagnosis. A debugger could not attach inside the container. The process table showed the main thread running at 99.9% of a core, its CPU time up 507 ticks in 5 s. So it was busy, not waiting: a computation that never returned. Megatron runs the reward code on the thread that also drives generation, and the grader’s sympy path (grade_answer_sympy calls sympy.simplify) has no timeout. Its authors knew the risk. A comment in the grader reads “sympy might hang – we don’t care about trying to be lenient in these cases” (code/rl/boxed_grader.py).

Why the obvious fix fails. The grader already uses 1-second alarms, signal.alarm, around its math-verify calls. A process has one such alarm, and each inner alarm cancels any outer one when it exits. The grader also has bare except: clauses, which swallow a single interrupt.

The fix: two guards.

  1. Unfinished training answers are not graded. With PocketRL’s setting they score 0 whatever they say, and they are the degenerate loops most likely to hold a pathological \boxed{}.
  2. Each grading gets a 10 s CPU-time limit on a different timer, ITIMER_PROF. It fires again every 0.5 s past the limit, so a swallowed interrupt cannot stop it. A grading that hits the limit scores 0 and is counted.
previous = signal.signal(signal.SIGPROF, _on_cpu_limit)  # raises a BaseException, past `except Exception`
signal.setitimer(signal.ITIMER_PROF, cpu_seconds, 0.5)    # 10 s of CPU time, then every 0.5 s
try:
    info, value = grade(response, gold, fast=False)
    return info, value, False
except _GradeCpuLimit:
    return {"formatted": extract_boxed(response) is not None}, 0.0, True
finally:
    signal.setitimer(signal.ITIMER_PROF, 0)           # always disarm and restore
    signal.signal(signal.SIGPROF, previous)

Verified. Four tests cover the guards. Two fake graders, one that spins forever and one that swallows the interrupt and spins again, are both stopped in about 0.2 CPU-seconds. The timer and handler are restored afterwards. GSPO restarted from the beginning, since the hung run had no checkpoint before update 50. No grading reached the limit in the rest of the run: 0 timeouts through update 100.

Limits. Signals reach only Python’s main thread, so the guard works only there; elsewhere the call runs unguarded. Megatron runs the reward code on its main thread, so the guard applies here. The sturdier alternative is to run the grader in a separate process.

Lessons. A watchdog must report silence, not only the lines it expects. Mine matched only some log lines, so I found the hang 14 minutes late. And untimed third-party reward code can hang an RL run that drives generation on the same thread.

// § 07

Run it yourself

Hardware and time. Everything here runs on a laptop CPU: the audit took 128 s, and the tests take seconds.

1. Build the problems and audit the checker (from MyModel/code):

python3 scripts/build_curriculum.py          # writes ../data/curriculum/*.jsonl, at pinned dataset revisions
python3 scripts/audit_checker.py --curriculum ../data/curriculum --out ../logs/checker_audit
python -m unittest tests.test_checker_audit tests.test_rewards_and_curriculum -v

2. Score one answer yourself (Python, from MyModel/code):

from fractions import Fraction
from rl.rewards import score_response

score_response("<think>12*3 + 8*2</think>\n<answer>52</answer>", Fraction(52), num_tokens=20)
# Score(correct=True, format_ok=True, length_penalty=0.0, reward=1.1)
score_response("<think>12*3 + 8*2</think>\n<answer>52 or 53</answer>", Fraction(52), num_tokens=20)
# Score(correct=False, format_ok=True, length_penalty=0.0, reward=0.1)

3. The control run’s grader and its guards need PocketRL’s pinned packages:

python -m pip install "sympy==1.14.0" "pylatexenc==3.0b2" "math-verify[antlr4-13-2]==0.9.0"
python -m unittest tests.test_boxed_grader tests.test_score_boxed_guards -v

Code and outputs:

Results to expect: the same classes and free scores as the table above, TIGHT on every file without LaTeX, and every test passing. The audit’s counts depend only on the data and the checker, so they should match ours exactly with the same dataset revisions and math-verify 0.9.0.

// § 08

What to take away

  • The grader is the objective. RL optimizes what it pays for, bugs included.
  • Audit a grader with answers whose verdicts you know: gold and valid forms must pass; junk, near misses and tricks must fail.
  • Report the free score beside small test sets. On two of mine, a constant answer beat the SFT model.
  • At a low solve rate, false accepts dominate the reward. At 2.73%, an assumed 1% false-accept rate would put about a quarter of rewards on wrong answers.
  • Never read the mean reward as learning; split it into its terms. On the laptop most of the gain was a length penalty.
  • Put a time limit on any third-party grader, and make the watchdog report silence.

References

  1. Kian Kyars, Reinforcement Learning from Verifiable Rewards (v1 of 2026-09-26; accessed 2026-12-03): Ch. 2, “Outcome Rewards”, https://rlvrbook.com/chapters/02-outcome-rewards.html; Ch. 5, “Turning Checks into Training Signal”, https://rlvrbook.com/chapters/05-turning-checks-into-training-signal.html; Ch. 6, “Search and Test Time Verification”, https://rlvrbook.com/chapters/06-search-and-test-time-verification.html
  2. Shreshth Rajan, “Auditing Reward Hackability in Code RL Training Environments”, arXiv:2606.16062. https://arxiv.org/abs/2606.16062
  3. Yu et al., “DAPO: An Open-Source LLM Reinforcement Learning System at Scale”, arXiv:2503.14476. https://arxiv.org/abs/2503.14476
  4. Liu et al., “Understanding R1-Zero-Like Training: A Critical Perspective” (Dr. GRPO), arXiv:2503.20783; grader code at https://github.com/sail-sg/understand-r1-zero
  5. Stephen Chung and Wenyu Du, “PocketRL: Training a 7B Language Model with Reinforcement Learning on One RTX 5090”, arXiv:2611.37942; code at https://github.com/dualverse-ai/pocketrl
  6. Hugging Face, Math-Verify. https://github.com/huggingface/Math-Verify
  7. Zheng et al., “Group Sequence Policy Optimization”, arXiv:2507.18071. https://arxiv.org/abs/2507.18071

Cite this

@misc{aboagye2026minidsv4part08,
  author       = {Aboagye, Prince Osei},
  title        = {Mini DeepSeek V4, Part 8: Rewards and graders: checking the checker},
  year         = {2026},
  howpublished = {\url{https://poaboagye.github.io/blog/08-rewards-and-graders/}}
}