On this page
Ask a language model for all integer solutions to . Under single-pass greedy decoding, the model gets one forward pass per token to jump straight to the answer. Because splits into three regimes (, with even , and with ), a single pass often returns and misses the negative-base roots . Allowing intermediate derivations, parallel rollouts, verification, or tree search turns fixed-depth recall into an explicit search computation.
This is test-time compute scaling: trading inference tokens and verifier calls under frozen weights for higher accuracy. Strategies span single-pass decoding to flat Best-of- (scoring full candidates over a shared prompt prefix) to step-level beam search guided by a process reward model (PRM), while expanding KV caches, delaying visible text behind hidden thought, and multiplying output bills.
Two axes of compute scaling
Pretraining scaling laws [1] tie loss to parameters , tokens , and train compute , yet standard decoding spends constant FLOPs per token regardless of task hardness. Test-time compute adds an orthogonal axis that adapts search effort per prompt:
Snell et al. [2] showed on MATH [3] that a 14x smaller model with adaptive test-time search matches or beats a much larger single-pass model at equal FLOPs. OpenAI o1 [4] confirmed smooth AIME gains from both RL training compute and inference search compute.

Chain-of-thought scaling and hidden reasoning budgets
Chain-of-thought (CoT) [5] converts extra token positions into working memory. RL-trained reasoning models such as o1 [4] and DeepSeek-R1 [6] self-check and backtrack, yet longer traces are not universally better: overthinking [7] [8] and inverse-scaling studies [9] show excess thinking on easy prompts can overturn correct initial answers.
| Technique | Core Mechanism | Best Fit | Principal Failure Mode |
|---|---|---|---|
| Extended CoT | One self-correcting trace | Multi-step synthesis and logic | Overthinking easy tasks; output cutoff |
| Best-of-N | Sample full paths, vote/rerank | Verifiable code and math | Proxy reward hacking; wasted easy-prompt work |
| Sequential Revision | Critique and edit drafts in rounds | Test-guided code repair | Unverified self-edits drifting off truth |
| PRM Tree Search | Score partial prefixes and prune | Deep symbolic proofs | False pruning from noisy step scorers |
Across OpenAI (reasoning.effort + max_output_tokens) [10], Gemini (thinking_budget) [11], and Claude extended thinking (budget_tokens) [12], hidden reasoning tokens bill as output and share max_output_tokens (so a tight 2,000-token cap can finish inside hidden reasoning with zero visible text), yet are dropped from Turn 2 prompt history so multi-turn context grows only with prompts and visible replies.
Best-of-N sampling: coverage vs. selection
Best-of- draws independent trajectories at nonzero temperature and selects one winner. Having a right answer in the pool (coverage) and picking it (selection) are distinct problems. At single-sample success rate , coverage is . From samples with correct solutions, the unbiased pass@k estimator is:
Easy prompts saturate fast ( hits at ), whereas hard prompts () need to reach , showing why uniform wastes compute.

import numpy as np
from scipy.special import comb
n_values = np.array([1, 2, 4, 8, 16, 32, 64])
for p in [0.60, 0.25, 0.05]:
print(f"p={p:.2f} -> coverage@N:", np.round(1.0 - (1.0 - p) ** n_values, 3).tolist())
M, c_counts = 32, np.array([28, 14, 5, 2, 0])
for k in [1, 4, 8]:
print(f"Batch mean unbiased pass@{k}: {(1.0 - comb(M - c_counts, k) / comb(M, k)).mean():.4f}")p=0.60 -> coverage@N: [0.6, 0.84, 0.974, 0.999, 1.0, 1.0, 1.0]
p=0.25 -> coverage@N: [0.25, 0.438, 0.684, 0.9, 0.99, 1.0, 1.0]
p=0.05 -> coverage@N: [0.05, 0.098, 0.185, 0.337, 0.56, 0.806, 0.962]
Batch mean unbiased pass@1: 0.3063
Batch mean unbiased pass@4: 0.5329
Batch mean unbiased pass@8: 0.6457Maj@k, weighted voting, and Goodhart over-optimization
Without an exact unit test or symbolic checker, pipelines pick winners via majority voting (Maj@k), verifier-weighted voting (summing verifier scores per equivalent final answer), or argmax over a reward model:
Maj@k(self-consistency) works only when the right answer is the plurality mode; a systematic misconception occurring >50% of the time drivesMaj@kto 0% as grows.- Weighted voting dampens outlier hallucinations by combining verifier confidence with answer consensus.
- Noisy proxy
argmax(Goodhart decay): under , extreme noise eventually lets confident wrong traces win. Below, oracle coverage reaches1.000and max proxy score climbs to1.090, yet true accuracy peaks atN = 8(0.570) before collapsing to0.335atN = 64.

import numpy as np
rng = np.random.default_rng(7)
n_prompts, max_n = 2000, 64
is_correct = rng.random((n_prompts, max_n)) < 0.35
proxy = np.where(is_correct, rng.normal(0.72, 0.14, (n_prompts, max_n)), rng.normal(0.45, 0.28, (n_prompts, max_n)))
for N in [1, 2, 4, 8, 16, 32, 64]:
sub_corr, sub_score = is_correct[:, :N], proxy[:, :N]
picked = sub_corr[np.arange(n_prompts), np.argmax(sub_score, axis=1)]
print(f"N={N:2d} | oracle_cov={sub_corr.any(axis=1).mean():.3f} | max_proxy={sub_score.max(axis=1).mean():.3f} | true_acc={picked.mean():.3f}")N= 1 | oracle_cov=0.364 | max_proxy=0.556 | true_acc=0.364
N= 2 | oracle_cov=0.591 | max_proxy=0.700 | true_acc=0.495
N= 4 | oracle_cov=0.810 | max_proxy=0.805 | true_acc=0.569
N= 8 | oracle_cov=0.965 | max_proxy=0.892 | true_acc=0.570
N=16 | oracle_cov=0.999 | max_proxy=0.963 | true_acc=0.521
N=32 | oracle_cov=1.000 | max_proxy=1.027 | true_acc=0.429
N=64 | oracle_cov=1.000 | max_proxy=1.090 | true_acc=0.335Do not equate pass@1 gains with pass@k exploration [13]. Because is concave in , sharpening easy prompts () while collapsing hard tails () lifts mean pass@1 (0.450 -> 0.475) while slashing true pass@4 (0.791 -> 0.593). Always compute 1 - (1 - p_i)^k per prompt before averaging.
Sequential revision and tree search
Sequential revision
Sequential revision conditions round on draft plus verifier feedback or compiler tracebacks. With external tests, accuracy jumps across rounds t1 to t3 before plateauing; unverified self-edits drift downward past t2. Stop once marginal gain drops below and retain the highest-verified draft.
Tree search: beam search, MCTS, and lookahead
Step-level tree search branches after intermediate steps () instead of waiting until completion to discard broken traces:
- PRM beam search expands each active prefix into next steps, scores them with a PRM, and retains the top- beams. Solving at keeps both (
0.91) and (0.89) alive to recover all six roots , pruning incomplete paths (0.24) at step 2. - Lookahead search rolls candidate steps steps forward before scoring, reducing greedy myopia at higher compute cost.
- Monte Carlo tree search (MCTS) balances exploration and exploitation via UCB/PUCT selection and value backpropagation, thriving on deep trees with exact terminal checks at the cost of sequential latency.

Aggregating step scores via or creates a monotone upper bound for exact branch-and-bound pruning, but permanently penalizes temporary early uncertainty. Snell et al. [2] showed that last-step PRM scoring ( alone) beats min and prod because summarizes completion probability from the whole prefix . Below, a compact PyTorch PRM preserves a recovered trajectory (last=0.999) that min caps at 0.321:
import torch
import torch.nn as nn
torch.manual_seed(42)
class StepPRM(nn.Module):
def __init__(self) -> None:
super().__init__()
self.net = nn.Sequential(nn.Linear(4, 8), nn.Tanh(), nn.Linear(8, 1), nn.Sigmoid())
with torch.no_grad():
self.net[0].weight.copy_(torch.tensor([
[1.4, 1.2, -1.6, -1.8], [0.9, 1.1, -1.2, -1.4],
[-1.1, -0.9, 1.5, 1.6], [0.8, 0.7, -0.8, -1.0],
[1.0, 0.5, -1.1, -1.2], [0.4, 1.3, -0.9, -1.5],
[-0.6, -0.8, 1.2, 1.1], [0.7, 0.9, -0.7, -0.9],
]))
self.net[0].bias.zero_()
self.net[2].weight.copy_(torch.tensor([[1.1, 0.9, -1.2, 0.7, 0.8, 1.0, -0.9, 0.7]]))
self.net[2].bias.fill_(-0.2)
def forward(self, features: torch.Tensor) -> torch.Tensor:
return self.net(features).squeeze(-1)
prm = StepPRM().eval()
paths = {
"a=1 & a=-1 (even b)": torch.tensor([[0.8, 0.9, 0.1, 0.0], [1.0, 1.0, 0.0, 0.0]]),
"a=1 & b=0 (skip a=-1)": torch.tensor([[0.8, 0.2, 0.1, 0.8], [0.7, 0.1, 0.0, 0.9]]),
"uncertain split -> recovered": torch.tensor([[0.3, 0.4, 0.5, 0.1], [1.0, 1.0, 0.0, 0.0]]),
}
with torch.no_grad():
for label, feats in paths.items():
scores = prm(feats)
print(f"{label:28s} | last={scores[-1]:.3f} | min={scores.min():.3f}")a=1 & a=-1 (even b) | last=0.999 | min=0.998
a=1 & b=0 (skip a=-1) | last=0.029 | min=0.029
uncertain split -> recovered | last=0.999 | min=0.321PRM vs. ORM verification tradeoffs
An Outcome Reward Model (ORM) scores only the finished answer . ORMs are cheap to supervise from final answers or tests, but give sparse terminal credit: a sign error at step 4 of an 8-step proof triggers one low score at step 8 with zero localization.
A Process Reward Model (PRM) scores every prefix . Instead of costly human step annotations like PRM800K [14], automated systems like Math-Shepherd [15] define PRM targets via Monte Carlo rollout recoverability, estimating the fraction of completions from that reach a verified final answer:
Notice that a Monte Carlo PRM measures completion recoverability rather than strictly local step truth: if a generator self-corrects an earlier slip on 2 of 5 continuations, , whereas an unrecoverable error yields .

Early PRM pruning cuts wasted decode work (~30% or more on failed branches), at two costs: generating rollouts per prefix makes training data expensive, and noisy small- labels can falsely prune valid unconventional derivations.
Training models to reason with RLVR
Rather than relying purely on external search, models can internalize reflection, checking, and backtracking directly via Reinforcement Learning with Verifiable Rewards (RLVR), as in DeepSeek-R1-Zero and the four-stage DeepSeek-R1 pipeline (cold-start SFT, verifiable GRPO, rejection-sampled SFT on fresh V3-Base weights, and broad RL).[6] As developed in RLVR & Verifiable Rewards Training, GRPO computes group-relative advantages directly from verifiable outcomes without a separate critic network.
Compute-optimal test-time scaling and routing
Snell et al. [2] frame compute-optimal scaling as allocating both strategy and FLOPs by estimated prompt difficulty , balancing pretraining parameters against inference search:
- Easy prompts: single-pass decoding or light revision; extra search wastes latency and invites overthinking.
- Medium prompts: sequential revision or moderate Best-of- ( to ) yields steep accuracy gains per FLOP.
- Hard prompts (): PRM beam search or deep CoT outperforms flat Best-of- and lets smaller models overtake larger single-pass models; on the hardest prompts where base coverage nears zero, pretraining a stronger base model still wins.
In serving, a difficulty router applies accuracy and p95 latency cutoffs first, then picks the lowest-cost feasible tier on the Pareto frontier (for example, routing easy prompts to single-pass at 0.2 s, medium to revision at 3.8 s, and only hard prompts to deep PRM search at 11.5 s):

Serving geometry: KV sharing, visible TTFT, and distillation
Prefix-shared KV caching and visible TTFT
Each cached token position in a transformer with layers, KV heads, head dimension , and bytes per scalar occupies bytes (128 KiB/token for 32 layers, 8 KV heads, , FP16). Across parallel branches on a -token prompt with -token tails, unshared caches use 5.00 GiB, whereas copy-on-write prefix sharing via PagedAttention [16] or RadixAttention [17] keeps one prompt block plus eight tails (1.50 GiB, saving 70%).

Hidden thinking tokens decode autoregressively before the first visible token arrives:
At 80 tokens/s, hidden tokens delay visible output to 13.0 s (200 ms prefill plus 12.8 s hidden decode), capping hidden thought at 224 tokens under a 3,000 ms TTFT budget. Because hidden tokens bill at output rates, 2,700 hidden plus 300 visible tokens cost 10x a direct answer.
import numpy as np
bytes_per_tok = 2 * 32 * 8 * 128 * 2
prompt_tok, branch_tok, n_branches = 4096, 1024, 8
unshared_gib = n_branches * (prompt_tok + branch_tok) * bytes_per_tok / (1024 ** 3)
shared_gib = (prompt_tok + n_branches * branch_tok) * bytes_per_tok / (1024 ** 3)
max_hidden_tok = int((3000.0 - 200.0) * 80.0 / 1000.0)
print(f"KV footprint: unshared={unshared_gib:.2f} GiB vs shared={shared_gib:.2f} GiB (concurrency={int(24.0 // shared_gib)} in 24 GiB)")
print(f"Max hidden CoT under 3000 ms visible TTFT at 80 tok/s: {max_hidden_tok} tokens")KV footprint: unshared=5.00 GiB vs shared=1.50 GiB (concurrency=16 in 24 GiB)
Max hidden CoT under 3000 ms visible TTFT at 80 tok/s: 224 tokensDistillation into compact models
Supervised distillation on verified traces from a large reasoning teacher transfers structured backtracking into compact dense students without online RL.[6] On AIME 2024, distilled Qwen models reach 28.9% (1.5B), 55.5% (7B), and 72.6% (32B) versus 79.8% for 671B DeepSeek-R1. Because trace-only distillation imitates accepted paths without conferring an external verifier, distilled students still benefit from domain verifiers at runtime.