Scaling Test-Time Compute with Sampling, Verification, and Selection
A language model asked to write a program or proof can always be run one more time. Whenever the task comes with executable examples, unit tests, or a proof checker, those checks act as a cheap filter: run every candidate against the visible tests, discard failures, and pick a final answer from what survives. Generate-and-filter pipelines carried neural code generation to median human contest rank,1 and repeated-sampling studies such as Large Language Monkeys showed candidate coverage climbing across orders of magnitude in sample count on math, code, and formal proofs. Inference compute is a budget to allocate across parallel attempts (breadth), longer trajectories (depth), and candidate ranking (selection).
Spending that budget well starts with counting which failure mode actually loses points. Two datasets anchor the measurements below. The first is a set of 1,080 multi-turn Python synthesis runs across the 120 public ARC-AGI-2 tasks (nine independent runs per task, averaging ~54,000 generated tokens per run). Each task supplies roughly three small input/output example grids and one or two hidden test inputs, scoring up to two candidate output submissions per test input. Inside an episode, the agent writes Python transforms and tests them against the visible examples; if a run hits its token cap before matching every example, the harness still harvests its highest-scoring partial-fit program or a direct fallback prediction. The second dataset spans 57 public repeated-sampling evaluations from Large Language Monkeys and LiveCodeBench, where candidate programs are filtered against public example tests before grading on hidden test suites.
Across both settings, neither candidate breadth nor voting rules was the primary bottleneck at practical budgets. Nearly three quarters of all lost synthesis score came from programs that passed every supplied example and still produced the wrong output on hidden test inputs.
Counting where test-time compute loses points
Before tuning retry counts or consensus rules, partition missed test inputs into mutually exclusive failure buckets. Replaying the 1,080 synthesis episodes at an average budget of 80,000 generated tokens per task (~1.5 episodes) produced at least one example-passing program on 93.2% of test outputs, leaving 6.8% to rely on partial-fit code or fallback predictions. Overall test accuracy reached 79.3%: 77.5% of test outputs had the true answer inside the verified pool (minus 0.6 percentage points lost when voting selected a competing verified output, netting 76.9%), plus 2.4% recovered by fallbacks on tasks with no full example fit.
Splitting the remaining 20.7 lost percentage points across the three ways a candidate pool can fail shows immediately which stage binds:
| Failure stage at 80,000 tokens per task | Points lost | Share of loss |
|---|---|---|
| Example-passing program found, yet test output wrong (fit-but-wrong) | 15.1 | 73% |
| No program passes all supplied examples (and fallback misses) | 5.0 | 24% |
| Right answer generated in pool, dropped by selector | 0.6 | 3% |
Two conclusions follow directly from that breakdown. First, an oracle selector that picked the right answer every time it appeared in the pool would recover only 0.6 points at this budget; tuning voting weights cannot fix a candidate pool that lacks the right program. Second, 73% of lost score is fit-but-wrong: the model wrote working Python that satisfied every visible example, stopped searching, and missed the true rule. Even under simulated GPU memory pressure that cut off late context extensions, verifier blind spots remained the largest source of error.
Allocating test-time compute therefore splits into two distinct problems: spending tokens efficiently to shrink the 24% unverified gap through breadth and depth, and preventing the 73% fit-but-wrong gap from wasting retries and corrupting consensus votes.
Breadth: why naive retry math overpredicts pass@k
Parallel retries are tracked with pass@k (the probability that at least one of k independent attempts succeeds), estimated without bias from n samples via the Codex combinatoric estimator. Teams often forecast retry gains by plugging a benchmark’s average single-run accuracy into . That formula treats every task as an identical coin, whereas real benchmarks are sharply polarized between routine tasks and near-impossible ones.
In the synthesis runs, a single attempt solved 75.3% of test outputs. Under the identical-coin formula, two independent attempts would solve . Measured pass@2 was 83.0%: a second attempt rescued only of first-try misses. Across all nine runs, 60 of the 120 tasks passed every single time and 11 never passed once, confining all retry gains to the 49 tasks in the middle.
Forecasting that curve does not require a ten-run sweep. Modeling per-task miss rates across a benchmark as a Beta(alpha, beta) distribution2 yields a closed-form product for the k-attempt miss rate:
Measured pass@1 and pass@2 pin down the mean miss rate and the two-miss rate , fixing alpha and beta in a few lines of Python:
from math import prod
def fit_beta(p1, p2):
"""Fit Beta(alpha, beta) to per-task miss rates from pass@1 and pass@2."""
m1, m2 = 1 - p1, 1 - p2
s = (m1 - m2) / (m2 - m1 ** 2) # alpha + beta; requires m2 > m1^2
return m1 * s, (1 - m1) * s
def pass_at_k(a, b, k):
"""Predicted pass@k under Beta(a, b) task difficulty."""
return 1 - prod((a + j) / (a + b + j) for j in range(k))
a, b = fit_beta(0.753, 0.830)
for k in (3, 5, 9):
print(f"k={k}: beta={pass_at_k(a, b, k):.1%} uniform_coin={1 - (1 - 0.753) ** k:.1%}")
Running the snippet tracks the nine-run empirical curve closely while the uniform-coin estimate saturates at 100%:
k=3: beta=86.3% uniform_coin=98.5%
k=5: beta=89.6% uniform_coin=99.9%
k=9: beta=92.4% uniform_coin=100.0%
Measured pass@k at k = 3, 5, 9 landed at 86.6%, 90.7%, and 94.2%; halving the remaining misses required roughly four times as many attempts. Across all 57 public evaluations from Large Language Monkeys and LiveCodeBench, fitting on two samples predicted pass@10 within 0.6 to 3.0 percentage points on average (versus 32 points of error for a uniform coin), before drifting past k = 100 where two early samples carry little signal about near-impossible tasks in the tail.
Depth, restarts, and the single-attempt budget knee
When an active episode reaches 64,000 tokens with helper functions built and two of three examples passing, the scheduler faces a live allocation choice: grant extra tokens to continue the current trajectory, start a fresh attempt from the original prompt, or stop and spend the tokens elsewhere.3 Estimating that trade-off from raw logs goes wrong in two common ways. The first is survivorship bias: easy tasks finish early, so only hard tasks reach 64,000 tokens. The second is ignoring stop-time harvests: halting an episode at 64,000 tokens still banks whatever partial-fit code or fallback prediction the trajectory has already produced.
Comparing continuation against restart also requires separating rescues (tasks wrong at cutoff that turn right afterward) from displacement (tasks already right at cutoff whose answer is overwritten or outvoted afterward). A simplified example over 100 mid-run checkpoints that already yield 40 right answers if stopped immediately, each given 8,000 extra tokens (0.8M tokens total) under majority voting, illustrates why rescues alone mislead:
| Action from checkpoint | Rescued (wrong on stop, right after) | Displaced (right on stop, wrong after) | Total right | Net gain per 1M extra tokens |
|---|---|---|---|---|
| Stop immediately | 0 | 0 | 40 | 0.00 |
| Continue from checkpoint | 12 | 4 | 48 | 10.00 |
| Restart from original prompt | 10 | 1 | 49 | 11.25 |
Continuing rescues more failures than restarting (12 versus 10), yet restarting finishes ahead (49 versus 48) because correlated edits inside one long run outvote a good stop-time candidate four times as often. That displacement column doubles as an invariant check on your selector: whenever an exact verifier certifies correctness and verified candidates strictly outrank unverified ones, displacement must be zero. And if an untouched task waiting in the queue earns 12.5 points per million tokens, both continuation (10.00) and restart (11.25) lose to stopping and serving the fresh task first.
Pairing mid-run synthesis checkpoints against fresh runs of the same task at matched extra tokens measured those terms directly on the ARC-AGI-2 logs. Crediting stopped runs with harvested partial-fit code cut the apparent gain of continuing roughly in half (omitting stop-time harvests had made late extensions look twice as productive as they were). Once harvest credit was counted, continuing beat stopping outright and tied token-matched fresh restarts within task variance. Inside a single turn, lifting a tight per-turn thinking cap from 12,000 tokens (which truncated half of all opening turns mid-thought) to 20,000 solved ~4.6 more tasks per 120 on slightly fewer total tokens, then flattened above 20,000.
Across the full task queue, total score plotted against per-task token budget bends sharply at one mean episode length (~54,000 tokens). Below ~54,000 tokens per task, episodes starve before finishing a first pass, costing ~1.3 percentage points per 1,000 tokens cut. Above ~54,000, extra tokens go into retries on the 49 middle tasks and flatten quickly (79.3% at 80K, 84.2% at 160K, 85.2% at 215K). Every task in a queue should finish one full attempt before any task receives a second.
Why passing the examples fails to certify correctness
Finishing a pass and satisfying every visible example still leaves the 73% fit-but-wrong loss untouched. An executable test harness has zero false negatives on supplied examples and zero visibility outside them, the same specification gap studied in formal program synthesis,4 automated program repair,5 and expanded code benchmarks like EvalPlus.6 Tiny toy domains rarely admit spurious example-passing programs,7 whereas non-trivial tasks routinely admit clean shortcut rules that agree on every small input:
def chain_by_endpoints(pieces):
"""Intended rule: order tuples so each piece[-1] matches next_piece[0]."""
starts = {p[0]: p for p in pieces}
tails = {p[-1] for p in pieces}
head = next(p for p in pieces if p[0] not in tails)
out = [head]
while len(out) < len(pieces):
out.append(starts[out[-1][-1]])
return out
def sort_by_length(pieces):
"""Shortcut rule: sort tuples by length."""
return sorted(pieces, key=len)
examples = [
([(2, 9, 9, 3), (1, 2)], [(1, 2), (2, 9, 9, 3)]),
([(5, 8, 8, 6), (4, 8, 5), (3, 4)], [(3, 4), (4, 8, 5), (5, 8, 8, 6)]),
([(7, 0, 0, 0, 8), (6, 0, 7)], [(6, 0, 7), (7, 0, 0, 0, 8)]),
]
test_input = [(2, 3), (1, 9, 9, 2), (3, 9, 4)]
print("both pass examples:",
all(chain_by_endpoints(x) == y and sort_by_length(x) == y for x, y in examples))
print("intended on test: ", chain_by_endpoints(test_input))
print("shortcut on test: ", sort_by_length(test_input))
Both functions pass all three examples without dead branches or hardcoded lookup tables, then diverge as soon as a shorter tuple sits in the middle of the chain:
both pass examples: True
intended on test: [(1, 9, 9, 2), (2, 3), (3, 9, 4)]
shortcut on test: [(2, 3), (3, 9, 4), (1, 9, 9, 2)]
That exact collision between endpoint chaining and length sorting led five of nine independent synthesis runs on a segment-chaining puzzle to export the same wrong verified output. Auditing wrong example-passing programs across the suite showed why simple static filters miss them: roughly 70% implemented a coherent alternative rule that genuinely satisfied every visible example, ~15% tripped on an unseen boundary shape in the test input, and only ~5% memorized example tables. Label-free heuristics (output invariants, differential line coverage on the test input, penalizing longer abstract syntax trees) failed to separate shortcuts from intended rules because shortcuts like sort_by_length are shorter and cleaner than relational logic.
Public coding benchmarks hit the same ceiling. Across 34 models on LiveCodeBench, 24% of programs passing public examples failed hidden tests (two thirds via timeouts on large inputs), accounting for roughly half of all lost score among the strongest models. As base models get better at satisfying visible checks, remaining errors concentrate in specification gaps.
Lineage-aware voting and settle-then-retry queues
Standard self-consistency voting8 and generated-test ranking9 assume wrong answers scatter while right answers agree. Shared specification shortcuts break that assumption: two wrong example-passing runs from the same model produced the identical wrong output 50% of the time on ARC synthesis and 65% of the time on LiveCodeBench, dropping to 33% when the two runs came from different model families.
As candidate pools grow across multiple retries (where selection loss rises from 0.6 points at 80,000 tokens to 4.6 points across nine runs), three lineage rules keep correlated edits from swamping consensus votes:
- Cap each independent episode at one vote per distinct output so a single trajectory that tweaks and re-submits one shortcut ten times cannot outvote peer runs, breaking ties by how many independent episodes verified an output first.
- Rank partial-fit programs strictly behind full-example passes (admitting unverified outputs only when no full-fit program exists and more than half of visible examples pass), and when a benchmark evaluates top-2 submissions per input, assign the second slot to an independent episode whenever one run produced both top candidates.
- Let forced timeout code harvests and last-resort no-reasoning fallback guesses fill empty submission slots without casting consensus votes against cleanly completed runs.
Combining the single-attempt budget knee with those verification limits yields a simple settle-then-retry queue policy under a fixed total token budget:
- Run one initial pass per task, ordered shortest prompt first so fast tasks finish and bank early.
- Mark a task settled once an episode completes naturally within budget with an example-passing program (natural completions solved ~78% of hidden test inputs versus ~52% for runs cut off at the token cap).
- Spend remaining budget retrying unsettled tasks with the lowest example pass rates first. Across all 34 LiveCodeBench models, settle-then-retry beat uniform two-sample allocation on every single model at equal total sample count.
Spending extra attempts on settled tasks whose verified runs disagreed with each other looked tempting in exploratory logs (disagreed pools had four times the error rate of agreed ones), yet gained 0.0 points across 12 pre-registered confirmation runs. Disagreement flags an ambiguous specification, and drawing one more sample from the identical prompt pulls from the same shortcut distribution. Once every task has finished one full attempt and unsettled misses have been retried, extra test-time compute pays off highest when spent synthesizing discriminating test inputs, tightening specifications, or ensembling across distinct model families rather than repeating identical draws.
References
Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, Thomas Hubert, Peter Choy, Cyprien de Masson d’Autume, Igor Babuschkin, Xinyun Chen, Po-Sen Huang, Johannes Welbl, Sven Gowal, Alexey Cherepanov, James Molloy, Daniel J. Mankowitz, Esme Sutherland Robson, Pushmeet Kohli, Nando de Freitas, Koray Kavukcuoglu, and Oriol Vinyals. 2022. Competition-level code generation with AlphaCode. Science 378, 6624 (2022), 1092–1097. ↩︎
Rylan Schaeffer, Joshua Kazdan, John Hughes, Jordan Juravsky, Sara Price, Aengus Lynch, Erik Jones, Robert Kirk, Azalia Mirhoseini, and Sanmi Koyejo. 2025. How do large language monkeys get their power (laws)? In Proceedings of the 42nd International Conference on Machine Learning (ICML 2025), 2025. 53132–53176. ↩︎
Charlie Snell, Jaehoon Lee, Kelvin Xu, and Aviral Kumar. 2025. Scaling LLM test-time compute optimally can be more effective than scaling parameters for reasoning. In The Thirteenth International Conference on Learning Representations (ICLR 2025), 2025. ↩︎
Saswat Padhi, Todd Millstein, Aditya Nori, and Rahul Sharma. 2019. Overfitting in synthesis: Theory and practice. In Computer Aided Verification (CAV 2019), 2019. 315–334. ↩︎
Edward K. Smith, Earl T. Barr, Claire Le Goues, and Yuriy Brun. 2015. Is the cure worse than the disease? Overfitting in automated program repair. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (ESEC/FSE 2015), 2015. 532–543. ↩︎
Jiawei Liu, Chunqiu Steven Xia, Yuyao Wang, and Lingming Zhang. 2023. Is your code generated by ChatGPT really correct? Rigorous evaluation of large language models for code generation. In Advances in Neural Information Processing Systems 36 (NeurIPS 2023), 2023. 21558–21572. ↩︎
Ruocheng Wang, Eric Zelikman, Gabriel Poesia, Yewen Pu, Nick Haber, and Noah D. Goodman. 2024. Hypothesis search: Inductive reasoning with language models. In The Twelfth International Conference on Learning Representations (ICLR 2024), 2024. ↩︎
Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc Le, Ed Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. 2023. Self-consistency improves chain of thought reasoning in language models. In The Eleventh International Conference on Learning Representations (ICLR 2023), 2023. ↩︎
Bei Chen, Fengji Zhang, Anh Nguyen, Daoguang Zan, Zeqi Lin, Jian-Guang Lou, and Weizhu Chen. 2023. CodeT: Code generation with generated tests. In The Eleventh International Conference on Learning Representations (ICLR 2023), 2023. ↩︎