12 Frontier 1 / 3
  1. In this chapter
  2. Test-Time Compute
  3. Synthetic Data and Self-Improvement
  4. Mechanistic Interpretability
All chapters →

Chapter 12 · Frontier 12.1

Test-Time Compute: Spending Compute on Inference

Test-time compute is extra computation spent while answering each question: voting over samples, verifier selection, revision, search and RL-trained long chains of thought. A reproducible simulation shows what caps the gain, what a fooled verifier does and why wall-clock time differs.

Advanced 28 min read Updated Companion code ↓

After this page you will be able to

  • Tell the four ways of spending test-time compute apart (parallel sampling, sequential revision, search, internalized long chains of thought) and say whether each needs a verifier, outside feedback or special training.
  • Write the closed form of pass@N when problem difficulty follows a Beta distribution, and explain why coverage grows only slowly with N when problems are a mix of easy and hard.
  • Compute the limit of majority voting (the correct answer must be more common than the commonest wrong one), explain how verifier quality sets the gain of best-of-N, and recognize a verifier being gamed.
  • Estimate with the roofline model the wall-clock time of parallel samples versus one long chain, and explain why the same number of tokens can take dozens of times longer.
On this page
  1. Three Routes and One Internalized Route
  2. Why More Inference Compute Helps, and Why It Has a Ceiling
  3. A Simulation You Can Change
  4. The Pool, the Answers and the Verifier
  5. Five Curves
  6. Checking the Simulation
  7. By Difficulty
  8. Allocating Compute by Difficulty: Adaptive Stopping
  9. The Cost: Tokens, FLOPs and Wall-Clock Time
  10. In Practice: When and How
  11. Account separately for generation and verification
  12. Common Mistakes
  13. Summary and Exercises
  14. Quick Self-Test
  15. Further Reading
  16. FAQ

Test-time compute (also called inference-time scaling) is the extra computation spent while answering each question, after training is over: sample several times and vote, let a verifier pick the best candidate, let the model write an answer and then check and revise it, search among several lines of thought, or, as OpenAI o1 and DeepSeek-R1 do, write a long chain of thought before answering. Training compute is paid once and shared by every request; test-time compute is paid again on every request. So it is both another scaling axis, next to parameters, data and training compute, and a new cost center.

This page answers three design questions: where to spend the compute (in parallel, in sequence, or in search); what limits the gain (the difficulty distribution of the problems and how good the answer selection is); and how to count the cost (tokens, FLOPs and wall-clock time are three different things). The answers come from a reproducible simulation of 20,000 problems and a roofline estimate from H100 specifications. They are not evaluations of real models; the conclusions about real models come from the papers of Snell et al. and Brown et al., cited where they are used.

Three Routes and One Internalized Route

MethodWho writes the answersWho picks the answerWhat it needs besidesRepresentative work
Parallel sampling with majority votingN independent responsesThe most frequent final answerFinal answers that can be compared (math, multiple choice)Self-consistency, Wang et al. (2022)
Parallel sampling with best-of-NN independent responsesA verifier (ORM scoring the whole response, PRM scoring each step), unit tests or a proverA reliable verifierCobbe et al. (2021), Lightman et al. (2023), Brown et al. (2024)
Sequential revisionThe model rewrites its previous answerSame, or simply the last versionOutside feedback, or a specially trained revision modelMadaan et al. (2023), Snell et al. (2024)
SearchSeveral candidate lines of thought are expanded step by stepA PRM or self-evaluation prunes step by stepStep-level value estimatesYao et al. (2023), Snell et al. (2024), Wu et al. (2024)
Internalized long chain of thoughtThe model writes on, checks back and switches approach by itselfThe model itselfLarge-scale reinforcement learning with verifiable rewardsOpenAI o1 (2024), DeepSeek-R1 (2025), s1 (2025)

The first three wrap around any existing model and belong to inference-system design. The last one writes “think a bit longer” into the weights and belongs to reasoning reinforcement learning: trained with verifiable rewards, the model tries, checks and backtracks inside its chain of thought. The budget forcing of s1 (Muennighoff et al., 2025) is a minimal method in between: when the model tries to stop thinking, append “Wait” so that it continues, or cut it off by force; the paper reports that s1-32B goes from 50% to 57% on AIME24 this way.

The two kinds of method do not exclude each other. In the o1 announcement OpenAI describes a system, initialized from o1 and trained further, that took part in IOI 2024: for each problem it sampled many candidate submissions and picked 50 using the public test cases, model-generated test cases and a learned scoring function. The same article says o1 improves with more reinforcement learning (train-time compute) and with more time spent thinking (test-time compute).

Why More Inference Compute Helps, and Why It Has a Ceiling

Three facts decide what test-time compute can buy.

  1. A single answer is unstable, but among many attempts one is often right. The fraction of problems where at least one of N attempts is right is called coverage, which is pass@N. Brown et al. (2024, “Large Language Monkeys”) found across tasks and models that coverage grows with the number of samples over four orders of magnitude, often roughly log-linearly. On SWE-bench Lite, the share of issues solved by DeepSeek-Coder-V2-Instruct rises from 15.9% with one sample to 56% with 250 samples, beating the single-sample state of the art of 43% at the time.
  2. Checking an answer is often easier than producing one. Unit tests, compilers, theorem provers, and “does the final answer equal the reference” can all be judged automatically. With such a verifier, coverage turns directly into accuracy. This is also what lets self-improvement bootstrap; see Synthetic data and self-improvement.
  3. Without a reliable selector, coverage is not accuracy. The same paper found that in domains without automatic verifiers, majority voting and reward models plateau after a few hundred samples and do not keep up with the sample count. The IOI example says the same thing: 50 submissions picked at random would have scored 156 points on average, picked by test cases and a scoring function they scored 213, and with 10,000 submissions per problem, with no selection strategy at all, the score was 362.14, above the gold medal threshold.

So the gain of test-time compute splits into two factors: the growth of coverage (sampling makes “one of them is right” more common) and the quality of the selector (whether the right one can be picked out). The simulation below separates them.

A Simulation You Can Change

Experiments on real models are expensive and noisy, and it is hard to separate “the difficulty distribution of the problems” from “how good the selector is”. Here a minimal pool of problems lays them out. Snell et al. (2024) did the real-model version on MATH; this simulation does not replace it, it only answers “which curves appear under these assumptions”. Every curve is computed from the same samples and has a closed form to check against.

The Pool, the Answers and the Verifier

  • Problems are easy or hard. Each problem has a per-sample pass rate pp, drawn as p∼Beta(0.8, 1.2)p\sim\mathrm{Beta}(0.8,\,1.2) with mean 0.4; every sample of a problem is right independently with probability pp.
  • Wrong answers are not uniform. Each problem has 20 distinct wrong answers whose relative probabilities are proportional to 1/k1/k: the 1st is the commonest (0.278 of the wrong samples) and the 20th the rarest (0.014). So “the model keeps making the same mistake” exists, and it sets the limit of majority voting.
  • The verifier gives every sample a score. Correct samples score N(d, 1)\mathcal{N}(d,\,1) and wrong ones N(0, 1)\mathcal{N}(0,\,1). For d=1d=1 and d=2d=2 the AUC (the probability that a random correct sample outscores a random wrong one) is 0.760 and 0.921. The third verifier can be fooled: 5% of the wrong samples get 3 added to their score, so they “look more correct than the correct ones”.
  • Two selection methods. Majority voting takes the most frequent answer (ties broken at random); best-of-N takes the sample with the highest verifier score.
import math

import numpy as np

A, B = 0.8, 1.2        # pass rate p ~ Beta(A, B), mean 0.4
M, K, NMAX = 20000, 20, 256   # problems, wrong answers per problem, samples
D = 2.0                # verifier: correct samples score D std devs higher
Q, SHIFT = 0.05, 3.0   # fooled verifier: 5% of wrong samples get +3
NS = [1, 2, 4, 8, 16, 32, 64, 128, 256]

w = 1.0 / np.arange(1, K + 1)
w /= w.sum()           # wrong-answer weights proportional to 1/k
print(f"Per-problem pass rate p ~ Beta({A}, {B}), mean {A / (A + B):.2f}")
print(f"Wrong-answer weights: 1st {w[0]:.3f}, 20th {w[-1]:.3f}")
auc = {d: 0.5 * (1 + math.erf(d / 2)) for d in (1.0, D)}
print(f"Verifier AUC: {auc[1.0]:.3f} for d=1, {auc[D]:.3f} for d={D:g}")
Per-problem pass rate p ~ Beta(0.8, 1.2), mean 0.40
Wrong-answer weights: 1st 0.278, 20th 0.014
Verifier AUC: 0.760 for d=1, 0.921 for d=2

draw generates all samples at once (256 per problem) and run adds samples one at a time from 1, recording the accuracy of every method at each nn. All methods see the same samples, so differences between curves come from how the answer is picked, not from luck in sampling. run also records a rule for adaptive stopping, used later.

def draw(seed):
    rng = np.random.default_rng(seed)
    p = rng.beta(A, B, size=M)
    ok = rng.random((M, NMAX)) < p[:, None]
    wrong = rng.choice(K, size=(M, NMAX), p=w) + 1
    ans = np.where(ok, 0, wrong)          # 0 is correct, 1..K are wrong
    z = rng.standard_normal((M, NMAX))    # verifier noise
    fool = rng.random((M, NMAX)) < Q
    score = {
        "d1": z + np.where(ok, 1.0, 0.0),
        "d2": z + np.where(ok, D, 0.0),
        "fool": z + np.where(ok, D, np.where(fool, SHIFT, 0.0)),
    }
    tie = rng.random((M, K + 1))          # random priority to break ties
    return p, ans, score, tie


def run(p, ans, score, tie, margins=(2, 3, 4, 5, 6), cap=64):
    rows = np.arange(M)
    counts = np.zeros((M, K + 1), dtype=np.int32)
    cover = np.zeros(M, dtype=bool)
    best = {k: np.full(M, -np.inf) for k in score}
    pick = {k: np.zeros(M, dtype=bool) for k in score}
    curve = {k: [] for k in ["cover", "vote", *score]}
    stop_n = {m: np.full(M, cap) for m in margins}
    stop_ok = {m: np.zeros(M, dtype=bool) for m in margins}
    done = {m: np.zeros(M, dtype=bool) for m in margins}
    snap = {}
    for n in range(NMAX):
        a = ans[:, n]
        counts[rows, a] += 1
        cover |= a == 0
        for k, sc in score.items():
            up = sc[:, n] > best[k]
            best[k] = np.where(up, sc[:, n], best[k])
            pick[k] = np.where(up, a == 0, pick[k])
            curve[k].append(pick[k].mean())
        vote = (counts + tie).argmax(axis=1) == 0
        curve["cover"].append(cover.mean())
        curve["vote"].append(vote.mean())
        if n < cap:
            top2 = np.partition(counts, -2, axis=1)[:, -2:]
            gap = top2[:, 1] - top2[:, 0]
            for m in margins:
                new = ~done[m] & (gap >= m)
                stop_n[m][new] = n + 1
                stop_ok[m][new] = vote[new]
                done[m] |= new
        if n == cap - 1:
            for m in margins:
                stop_ok[m][~done[m]] = vote[~done[m]]
            snap = {"cover": cover.copy(), "vote": vote.copy()}
            snap.update({k: pick[k].copy() for k in score})
    adapt = {m: (stop_n[m].mean(), stop_ok[m].mean()) for m in margins}
    return {"p": p, "curve": curve, "snap": snap, "adapt": adapt}

Five Curves

curves draws the pool with 5 random seeds and averages them. In the column names, BoN-d1 and BoN-d2 are best-of-N with verifier d=1d=1 and d=2d=2, and the last column is the fooled verifier.

runs = [run(*draw(seed)) for seed in range(5)]
names = ["cover", "vote", "d1", "d2", "fool"]
acc = {k: np.array([r["curve"][k] for r in runs]) for k in names}
mean = {k: v.mean(axis=0) for k, v in acc.items()}
sd = {k: v.std(axis=0) for k, v in acc.items()}
print("N     pass@N   vote   BoN-d1  BoN-d2  BoN-d2+fool")
for n in NS:
    row = "  ".join(f"{mean[k][n - 1]:6.3f}" for k in names)
    print(f"{n:<4}  {row}")
worst = max(sd[k][n - 1] for k in names for n in NS)
print(f"Std dev across the 5 seeds: at most {worst:.4f}")
print(f"At N=1 all five columns agree: mean pass rate {mean['cover'][0]:.3f}"
      f" (theory {A / (A + B):.3f})")
N     pass@N   vote   BoN-d1  BoN-d2  BoN-d2+fool
1      0.403   0.403   0.403   0.403   0.403
2      0.563   0.402   0.485   0.538   0.526
4      0.707   0.508   0.556   0.657   0.621
8      0.815   0.585   0.616   0.751   0.675
16     0.888   0.629   0.666   0.819   0.684
32     0.934   0.651   0.709   0.868   0.660
64     0.962   0.658   0.743   0.903   0.618
128    0.978   0.660   0.773   0.928   0.569
256    0.988   0.661   0.799   0.947   0.523
Std dev across the 5 seeds: at most 0.0037
At N=1 all five columns agree: mean pass rate 0.403 (theory 0.400)
Accuracy of five selection methods versus samples per problem N Line chart: the horizontal axis is the number of samples per problem N (1 to 256, log scale), the vertical axis is accuracy (starting at 0.3). pass@N rises from 0.403 to 0.988 and bounds every selection method; best-of-N with verifier d=2 reaches 0.947 and with d=1 reaches 0.799; majority vote levels off near 0.66 after N=64; the fooled verifier peaks at 0.684 at N=16 and then falls to 0.523. 1 2 4 8 16 32 64 128 256 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 accuracy (axis starts at 0.3) samples per problem N (log scale) pass@N (coverage, upper bound) best-of-N, verifier d=2 best-of-N, verifier d=1 majority vote best-of-N, fooled verifier
Simulated 20,000 problems, mean of 5 random seeds (data from the curves output above). pass@N bounds every selection method; majority vote levels off near 0.66; the better the verifier, the closer best-of-N gets to the bound; the circle marks the peak of the fooled verifier (N=16, 0.684), after which more samples make it worse.

The standard deviation across the 5 seeds is at most 0.0037, far below the differences discussed here. Four things to read off the chart:

  1. Coverage grows slowly, and the hard problems hold it back. pass@N goes from 0.403 at N=1 to 0.888 at N=16 and reaches 0.988 only at N=256. It bounds every selection method.
  2. Majority voting saturates quickly. It barely improves after N=16 and levels off at 0.661 at N=256. The next subsection computes why: voting can only rescue problems where the correct answer is more common than the commonest wrong one.
  3. Best-of-N turns sampling into accuracy, and its ceiling is the verifier. With verifier d=2d=2 (AUC 0.921) accuracy at N=256 is 0.947, close to the coverage of 0.988; with d=1d=1 (AUC 0.760) it is only 0.799. The worse the verifier, the less the same compute buys.
  4. A verifier can be gamed, and the larger N is, the more dangerous it gets. The fooled verifier peaks at 0.684 at N=16 and then falls all the way to 0.523 at N=256; by N=64 it is already below majority voting with no verifier (0.618 versus 0.658). The reason is that best-of-N takes a maximum: the larger N is, the more likely the maximum comes from the 5% the verifier misjudges. This is the smallest version of what Gao et al. (2022) studied as reward model overoptimization (the harder you optimize a proxy, the worse the true objective gets); the Reward Models page reproduces the same curve on the reward-model side.

The widget below is the interactive version of these five curves: the same construction rerun in your browser (4,000 questions, 3 seeds); drag N to read each method’s accuracy and switch the difficulty distribution — switch to “p = 0.4 everywhere” and coverage instantly shows how much the hard questions were holding it back; the exact anchors (the pass@N closed form and the majority-vote limit) are given alongside.

Checking the Simulation

A simulation is only trustworthy if something else computes the same quantity. pass@N has a closed form:

E[1−(1−p)N]=1−B(a, b+N)B(a, b),p∼Beta(a, b)\mathbb{E}\big[1-(1-p)^{N}\big]=1-\frac{B(a,\,b+N)}{B(a,\,b)},\qquad p\sim\mathrm{Beta}(a,\,b)

where BB is the Beta function, here with a=0.8a=0.8 and b=1.2b=1.2. The limit of majority voting has a closed form too: as N→∞N\to\infty the correct answer becomes the most frequent answer on a problem if and only if p>(1−p) w1p>(1-p)\,w_1, where w1w_1 is the weight of the commonest wrong answer. That is p>p∗=w11+w1p>p^{*}=\frac{w_1}{1+w_1}, so the limit accuracy is P(p>p∗)P(p>p^{*}).

def beta_fn(x, y):
    return math.exp(math.lgamma(x) + math.lgamma(y) - math.lgamma(x + y))


print("N     pass@N exact  sim     diff")
for n in NS:
    exact = 1 - beta_fn(A, B + n) / beta_fn(A, B)
    sim = mean["cover"][n - 1]
    print(f"{n:<4}  {exact:12.3f}  {sim:6.3f}  {sim - exact:+.3f}")
homo = 1 - (1 - A / (A + B)) ** 16
print(f"With p = 0.4 on every problem, pass@16 would be {homo:.4f};")
print(f"with easy and hard problems it is {mean['cover'][15]:.3f}")
# Majority vote limit: p must beat the commonest wrong answer, (1-p) * w[0]
p_star = w[0] / (1 + w[0])
x = np.linspace(p_star, 1, 400001)
f = x ** (A - 1) * (1 - x) ** (B - 1) / beta_fn(A, B)
limit = float(((f[1:] + f[:-1]) * np.diff(x)).sum() / 2)
print(f"Majority-vote limit: P(p > {p_star:.4f}) = {limit:.3f}; "
      f"simulation at N=256 gives {mean['vote'][255]:.3f}")
N     pass@N exact  sim     diff
1            0.400   0.403  +0.003
2            0.560   0.563  +0.003
4            0.704   0.707  +0.002
8            0.814   0.815  +0.001
16           0.888   0.888  +0.001
32           0.934   0.934  +0.001
64           0.961   0.962  +0.001
128          0.978   0.978  +0.000
256          0.987   0.988  +0.000
With p = 0.4 on every problem, pass@16 would be 0.9997;
with easy and hard problems it is 0.888
Majority-vote limit: P(p > 0.2175) = 0.662; simulation at N=256 gives 0.661

The simulation differs from the exact value by at most 0.003 (at N=1N=1 and N=2N=2; this is sampling error from 20,000 problems and is of the same order as the standard deviation across seeds above). Two conclusions can be read off directly:

  • Coverage grows slowly because problems are a mix of easy and hard. If every problem had p=0.4p=0.4, pass@16 would already be 0.9997; with a batch of very hard problems in the pool it is only 0.888. The “coverage grows log-linearly with samples” that Brown et al. observed is a phenomenon of the same kind; this is the same kind, not a reproduction of that paper.
  • The limit of majority voting is set by the model’s systematic errors, not by N. With w1=0.278w_1=0.278, p∗=0.2175p^{*}=0.2175 and the limit is 0.662, and the simulation at N=256 is already 0.661. When the model keeps making the same mistake, more samples only vote that mistake in more firmly.

By Difficulty

Split the problems into five bins by their pass rate pp and look at each method’s accuracy in each bin at N=64 (data of the first seed):

p0, snap = runs[0]["p"], runs[0]["snap"]
edges = [0.0, 0.05, 0.2, 0.5, 0.8, 1.0001]
print("p range       share   pass@1  pass@64  vote@64  BoN-d2@64  BoN-fool@64")
for lo, hi in zip(edges[:-1], edges[1:]):
    sel = (p0 >= lo) & (p0 < hi)
    cells = [snap[k][sel].mean() for k in ("cover", "vote", "d2", "fool")]
    label = f"[{lo:.2f}, {min(hi, 1):.2f}{']' if hi > 1 else ')'}"
    print(f"{label:<12}  {sel.mean():5.3f}   {p0[sel].mean():6.3f}  "
          f"{cells[0]:7.3f}  {cells[1]:7.3f}  "
          f"{cells[2]:9.3f}  {cells[3]:11.3f}")
p range       share   pass@1  pass@64  vote@64  BoN-d2@64  BoN-fool@64
[0.00, 0.05)  0.102    0.022    0.639    0.000      0.353        0.111
[0.05, 0.20)  0.215    0.122    0.996    0.095      0.885        0.377
[0.20, 0.50)  0.325    0.343    1.000    0.860      0.988        0.651
[0.50, 0.80)  0.248    0.643    1.000    1.000      0.999        0.855
[0.80, 1.00]  0.110    0.893    1.000    1.000      1.000        0.958

In the hardest bin (p<0.05p<0.05, a share of 0.102) coverage is 0.639, majority voting is 0.000, best-of-N with verifier d=2d=2 recovers 0.353, and the fooled verifier only 0.111. In the bin with pp between 0.05 and 0.2 (share 0.215) voting gets only 0.095 while the d=2d=2 verifier gets 0.885. By pp between 0.2 and 0.5 voting already gets 0.860, and on easier problems every method is close to 1.

The conclusion: on easy problems cheap voting is enough, hard problems need a verifier; but on medium-difficulty problems the fooled verifier (0.651) is far worse than voting with no verifier (0.860). Hard problems are exactly where a verifier errs most easily, which is one reason Snell et al. found that the strategy should depend on difficulty.

Allocating Compute by Difficulty: Adaptive Stopping

A fixed N is wasteful on easy problems: the first two or three samples already agree and there is no need to fill up to N. Adaptive stopping (the idea of Adaptive-Consistency, Aggarwal et al., 2023) decides from the samples drawn so far whether to continue. Here is the simplest rule: stop when the leading answer is mm votes ahead of the runner-up, with at most 64 samples. The paper uses a stopping criterion based on a Beta distribution; this page uses the vote margin instead.

print("Rule: stop when the leading answer is m votes ahead; at most 64 samples")
print("m   mean samples  accuracy  fixed N to match  times saved")
vote = mean["vote"]
for m in (2, 3, 4, 5, 6):
    n_avg = np.mean([r["adapt"][m][0] for r in runs])
    a_acc = np.mean([r["adapt"][m][1] for r in runs])
    hit = vote >= a_acc
    need = int(hit.argmax()) + 1 if hit.any() else None
    saved = f"{need / n_avg:.2f}" if need else "-"
    print(f"{m}   {n_avg:12.1f}  {a_acc:8.3f}  {need or '-':>16}  {saved:>11}")
print(f"Fixed-N majority vote: N=16 gives {vote[15]:.3f}, "
      f"N=64 gives {vote[63]:.3f}")
Rule: stop when the leading answer is m votes ahead; at most 64 samples
m   mean samples  accuracy  fixed N to match  times saved
2            8.5     0.618                13         1.53
3           15.3     0.645                24         1.57
4           21.2     0.653                35         1.65
5           26.0     0.656                50         1.92
6           30.1     0.657                55         1.83
Fixed-N majority vote: N=16 gives 0.629, N=64 gives 0.658

With m=2m=2 the mean is only 8.5 samples for 0.618, where fixed-N majority voting needs 13 to match it, a saving of 1.53 times; with m=5m=5 the mean is 26.0 samples for 0.656, where fixed N needs 50, a saving of 1.92 times. The saving ranges from 1.53 to 1.92 times. Aggarwal et al. report on 17 reasoning and code datasets with 3 models a sample budget reduced by up to 7.9 times with an average accuracy drop below 0.1%; Snell et al. save up to about 4 times by allocating compute by difficulty. The saving here is smaller because this pool does not have that many easy problems, and the saving comes only from the easy ones: on hard problems voting itself picks wrong (0.000 and 0.095 in the previous subsection), and stopping early does not help.

Two cautions. First, adaptive stopping uses the agreement among the samples drawn so far as its estimate of difficulty and costs no extra compute; Snell et al. estimated difficulty with 2048 samples, a cost their comparison does not count. Second, the more aggressive the rule (the smaller mm), the more it saves, but accuracy falls back toward the N=1 level: the 0.618 of m=2m=2 is still below the 0.658 of fixed N=64.

The Cost: Tokens, FLOPs and Wall-Clock Time

Coverage and selection are only half of the bill; the other half is cost, and the number of tokens, FLOPs and wall-clock time are three different things. The roofline page showed that small-batch decoding is stuck on the bandwidth for reading weights. Every decoding step reads all the weights once, whether the batch holds 1 sequence or 64, so 64 parallel samples nearly ride for free, while one long chain can only be written one step at a time. The lower bound of the time per step is the larger of the time to read memory and the time to compute:

tstep=max⁡ ⁣(W+c Lˉ κBW, 2 P cF)t_{\text{step}}=\max\!\Big(\frac{W+c\,\bar{L}\,\kappa}{\mathrm{BW}},\ \frac{2\,P\,c}{F}\Big)

WW is the size of the weights in bytes (W=2PW=2P in BF16), cc is the number of concurrent sequences, Lˉ\bar{L} is the mean context length, κ\kappa is the KV cache in bytes per token, PP is the number of parameters, and BW\mathrm{BW} and FF are the memory bandwidth and peak compute. The estimate below uses the Llama 3 8B configuration and the H100 SXM specification (bandwidth 3.35 TB/s, dense BF16 compute 989 TFLOPS, sources in GPU and Roofline). It is a lower bound computed from specifications, not a measurement; it ignores prefill, prefix sharing, speculative decoding and scheduling overhead.

LAYERS, HID, HEADS, KVH, FFN, VOCAB = 32, 4096, 32, 8, 14336, 128256
hd = HID // HEADS
attn = 2 * HID * HID + 2 * HID * KVH * hd
params = 2 * VOCAB * HID + LAYERS * (attn + 3 * HID * FFN + 2 * HID) + HID
kv_tok = 2 * LAYERS * KVH * hd * 2          # K and V per token, BF16
BW, PEAK = 3.35e12, 989e12                  # H100 SXM: bandwidth, dense BF16


def wall(batch, length, prompt=500):
    ctx = prompt + length / 2               # mean context while decoding
    mem = (2 * params + batch * ctx * kv_tok) / BW
    cmp_ = 2 * params * batch / PEAK
    return length * max(mem, cmp_), mem > cmp_


print(f"Llama 3 8B: {params / 1e9:.2f}B parameters, KV {kv_tok // 1024} "
      f"KiB/token")
print("chains x length   tokens   est. time   bound by")
for batch, length in [(64, 1000), (16, 4000), (4, 16000), (1, 64000)]:
    t, mem_bound = wall(batch, length)
    print(f"{batch:>3} x {length:<6}      {batch * length:>7,}  {t:7.1f} s"
          f"    {'memory bandwidth' if mem_bound else 'compute'}")
ratio = wall(1, 64000)[0] / wall(64, 1000)[0]
print(f"Same 64,000 tokens: one long chain is {ratio:.0f} times slower "
      f"than 64 in parallel")
kv_end = (500 + 64000) * kv_tok / 2**30
print(f"KV cache at the end of one 64,000-token chain: {kv_end:.1f} GiB")
Llama 3 8B: 8.03B parameters, KV 128 KiB/token
chains x length   tokens   est. time   bound by
 64 x 1000         64,000      7.3 s    memory bandwidth
 16 x 4000         64,000     25.4 s    memory bandwidth
  4 x 16000        64,000     98.0 s    memory bandwidth
  1 x 64000        64,000    388.2 s    memory bandwidth
Same 64,000 tokens: one long chain is 53 times slower than 64 in parallel
KV cache at the end of one 64,000-token chain: 7.9 GiB

The four splits generate the same number of tokens, yet take from 7.3 to 388.2 seconds: one chain of 64,000 tokens is 53 times slower than 64 parallel samples of 1,000 tokens each, and all four rows are memory-bandwidth-bound. Three consequences:

  1. For low latency, sample in parallel and add a selector; do not lengthen the chain of thought. The wall-clock time of 64 parallel samples is about that of one; the price is a selector and enough memory for 64 KV caches.
  2. A long chain is both slow and memory-hungry. At the end of one 64,000-token chain the KV cache is 7.9 GiB. This is why models with long chains of thought make KV cache compression and continuous batching indispensable.
  3. The longer the thinking, the higher the bill. OpenAI’s documentation says the reasoning tokens of a reasoning model, though invisible, occupy the context window and are billed as output tokens, anywhere from a few hundred to tens of thousands (consulted in November 2026). Whether it is worth it depends on how hard the task is and how costly a wrong answer is.

In Practice: When and How

SituationSuggestionEvidence
An automatic verifier exists (unit tests, compiler, prover, executable answer)Sample in parallel, then filter with the verifier; coverage turns directly into accuracySWE-bench Lite 15.9% to 56%; IOI with 10,000 submissions
Answers can be compared but there is no verifier (math, multiple choice)Majority voting, with adaptive stopping to save samples; estimate its limit firstThe limit is set by systematic errors (limit 0.662)
Many hard problemsFirst check whether pass@N is clearly above pass@1; if so invest in a verifier, if not more compute is uselessIn the hardest bin pass@64 is 0.639 and voting 0.000
Latency-sensitiveN parallel samples plus a selector rather than a longer chain of thoughtThe 53-fold wall-clock gap
Verifiable hard problems that need backtracking and self-checks, latency relaxedA reasoning model with a long chain of thoughtSelection happens inside the model
Open-ended writing, dialogueLimited gain: no reliable selectorVoting and reward models plateau after a few hundred samples (Brown et al.)

A few rules save detours when evaluating a test-time compute scheme:

  • Report pass@1, pass@N and the accuracy after selection together. The gap between the last two is the selector’s loss; a large gap means the bottleneck is the selector, not the sampling (see pass@k in The Statistics of Evaluation).
  • Compare at a fixed budget: the same number of tokens, FLOPs or dollars, not the same “number of answers”.
  • Scan N and evaluate the verifier on held-out data. The fooled verifier peaks at N=16, which you cannot see without a scan.
  • Choose the strategy and evaluate it on different problems. Snell et al. cross-validate twofold in every difficulty bin so that the strategy is not both chosen and scored on one test set.
  • Prefer executable checks to learned verifiers where you can. A unit test is not fooled by something that merely looks right.

Account separately for generation and verification

The reasoning and formal mathematics lectures in Berkeley Advanced LLM Agents illustrate two kinds of verification. When a model grades natural-language solutions, use human-labeled examples to see which errors it accepts. When using a proof checker such as Lean, first confirm that the formal statement matches the original problem, then check the proof. A passing proof establishes the formal statement supplied to the checker.

Compare single generation and candidate verification on the same problems and under the same generation budget. Record candidate coverage, selected-answer accuracy, verification cost, and timeouts separately. If a correct candidate is often available and the final selection fails, inspect the selector. If correct answers rarely reach the candidate pool, improve generation first.

Common Mistakes

  1. Treating pass@N as the model’s accuracy. pass@N says “one of N is right”; at deployment nobody knows which one.
  2. Believing majority voting keeps improving with N. Its limit is 0.662, held down by systematic errors.
  3. Believing “check it again” always helps. Huang et al. (2023) found that without outside feedback models struggle to correct their own reasoning, and sometimes get worse; effective revision usually relies on an outside signal (unit tests, tools, a specially trained revision model).
  4. Comparing methods by the number of answers when lengths differ. One chain of 10,000 tokens and 10 answers of 1,000 tokens use the same number of tokens but differ a lot in time (see the cost section), and different models answer at different lengths.
  5. Choosing the strategy and evaluating it on the same problems. This overstates the gain; Snell et al. avoid it with cross-validation.

Summary and Exercises

  • The gain of test-time compute = the growth of coverage × the quality of the selector. Coverage (pass@N) is the ceiling, and the selection method decides how much of it you get.
  • When problems are a mix of easy and hard, coverage grows only slowly with N; with p∼Beta(0.8,1.2)p\sim\mathrm{Beta}(0.8,1.2) pass@16 is 0.888, while with every pp equal to 0.4 it would be 0.9997.
  • The limit of majority voting is P(p>p∗)P(p>p^{*}), set by the model’s systematic errors (0.662 here); the gain of best-of-N depends on verifier quality, and a verifier can be gamed, the more dangerously the larger N is.
  • Adaptive stopping allocates compute by the agreement among the samples so far and saves 1.53 to 1.92 times the samples on this pool.
  • Equal FLOPs do not mean equal speed: decoding is limited by memory bandwidth, so parallel samples are nearly free and one long chain is 53 times slower.

Quick Self-Test

1. Every problem in the pool has a per-sample pass rate of 0.4. Compared with p∼Beta(0.8,1.2)p\sim\mathrm{Beta}(0.8,1.2) (also mean 0.4), which has the higher pass@N at N=16?

  • They are equal, because the mean pass rate is the same
  • Every pp equal to 0.4 is higher (0.9997 versus 0.888)
  • The mix of easy and hard is higher, because it contains some very easy problems
  • They cannot be compared because the distributions differ

With every p=0.4p=0.4, pass@16 is 1−0.616=0.99971-0.6^{16}=0.9997; with a mix of easy and hard problems, a batch of problems with pp near 0 holds it back to 0.888. The same mean pass rate gives very different coverage, which is why you should first ask “what is the difficulty distribution” when reading a coverage curve.

2. What decides the limit accuracy of majority voting as N→∞N\to\infty?

  • N: the more samples, the closer to 1
  • The verifier’s AUC
  • The share of problems where the correct answer’s probability exceeds the commonest wrong answer’s (0.662 here)
  • The number of parameters of the model

As N→∞N\to\infty the most frequent answer on a problem is the one with the highest probability, so voting is right if and only if p>(1−p) w1p>(1-p)\,w_1. Here p∗=0.2175p^{*}=0.2175 and P(p>p∗)=0.662P(p>p^{*})=0.662, and the simulation at N=256 gives 0.661.

3. The best-of-N curve of the fooled verifier peaks at 0.684 at N=16 and then falls. What is the main reason?

  • The samples stop being independent when N is large
  • Coverage falls as N grows
  • Best-of-N takes a maximum, and the larger N is, the more likely the maximum comes from the 5% of wrong samples the verifier misjudges
  • Simulation noise: the standard deviation across 5 seeds is 0.1

Coverage only rises with N; the samples stay independent in the simulation; the standard deviation across 5 seeds is at most 0.0037, far smaller than the fall from 0.684 to 0.523. The fall comes from selecting a maximum: the 5% of fooled samples score higher than the correct ones, and the more samples there are, the more likely they are to be picked.

4. At N=64, on the hardest bin (p<0.05p<0.05, share 0.102), which method recovers the most correct answers?

  • Majority voting, because it needs no verifier
  • Best-of-N with verifier d=2d=2, which recovers 0.353
  • Best-of-N with the fooled verifier, which recovers 0.111
  • pass@64 with 0.639 is highest, so it is the best method

Majority voting gets 0.000 on this bin: correct answers are so rare that the commonest wrong answer outvotes them. The 0.639 of pass@64 means “one of them is right”; it is not a method you can use at deployment but the ceiling of all selection methods.

5. For the same 64,000 generated tokens, what is the ratio of the estimated wall-clock time of 64 parallel samples of 1,000 tokens to that of one chain of 64,000 tokens?

  • About 1:1, because the FLOPs are the same
  • About 1:64, because the number of tokens differs by a factor of 64
  • About 1:53, because decoding is limited by memory bandwidth, parallel samples share one weight read per step, and a long chain can only be written one step at a time
  • Parallel is slower, because 64 copies of the weights must be read

In the table 64×1000 takes 7.3 seconds and 1×64000 takes 388.2 seconds, a ratio of 53. Every step reads some 16 GB of weights, and a few more sequences in the batch barely add to that; a long chain repeats the step 64,000 times. The ratio is not exactly 64 because the 64 parallel sequences read 64 KV caches per step, more than the single cache the long chain reads.

Exercises:

  1. When every problem has p=0.4p=0.4 and samples are independent, how many samples does pass@N need to reach 0.99? And for the pool with p∼Beta(0.8, 1.2)p\sim\mathrm{Beta}(0.8,\,1.2)?
  2. If the weights of the 20 wrong answers were uniform (0.05 each), what would the limit of majority voting be? What does the comparison with 0.662 say?
  3. Why does the curve of the fooled verifier fall at large N while a normal verifier with d=2d=2 does not? Name one way to mitigate it in a real system.
  4. With a context of about 1,000 tokens and Llama 3 8B (weights in BF16, KV cache of 128 KiB per token), at how many concurrent sequences does the KV cache read per step exceed the weights read? What does this mean for the claim that “parallel sampling is nearly free”?
Reference answers
  1. With every p=0.4p=0.4: 1−0.6N≥0.991-0.6^{N}\ge0.99 needs N≥ln⁡0.01/ln⁡0.6≈9.02N\ge\ln0.01/\ln0.6\approx9.02, so N=10N=10 (0.9899 at N=9 and 0.9940 at N=10). For the pool with p∼Beta(0.8,1.2)p\sim\mathrm{Beta}(0.8,1.2), solving the closed form 1−B(a,b+N)/B(a,b)≥0.991-B(a,b+N)/B(a,b)\ge0.99 gives N=351N=351 (0.98998 at N=350 and 0.99001 at N=351). For the same 0.99 that is 10 samples against about 35 times as many, because the pool holds a batch of very hard problems.
  2. With uniform weights w1=0.05w_1=0.05, so p∗=0.05/1.05=0.0476p^{*}=0.05/1.05=0.0476 and the limit accuracy is P(p>p∗)=0.898P(p>p^{*})=0.898, far above 0.662. When wrong answers are spread out they split the votes among themselves and none outvotes the correct answer, so voting works better; when the errors concentrate on one answer (systematic errors) the ceiling of voting is low. This is why “does the model err randomly or always in the same place” matters so much for test-time compute.
  3. Best-of-N takes a maximum. With a normal verifier correct samples score higher overall, so the more samples there are, the more likely the maximum is a correct one and the curve rises with N; with the fooled verifier, 5% of the wrong samples score higher than the correct ones, and the larger N is, the more likely they appear and rank first. Mitigations: scan N on held-out data and stop near the peak; replace the learned verifier with executable checks (unit tests); ensemble several different verifiers and take a conservative score; add adversarial examples when training the verifier.
  4. Per sequence and step the KV cache read is 1000×128 KiB≈0.1311000\times128\ \mathrm{KiB}\approx0.131 GB against 16.06 GB of weights; they are equal at about 16.06/0.131≈122.516.06/0.131\approx122.5, that is about 123 sequences. Below that, the time per step is mostly the weight read and one more sequence adds little time; above it, reading the KV cache becomes the main part of each step and every extra sequence adds noticeable time. So “parallel sampling is nearly free” holds only when concurrency is moderate and the context is not too long; when a large N meets a long context, the KV cache is the main cost.

The numbers come from running the page’s own code a little further (answers runs after the scripts above and uses beta_fn, params and kv_tok):

def pass_at(n):
    return 1 - beta_fn(A, B + n) / beta_fn(A, B)


n = 1
while 1 - 0.6 ** n < 0.99:
    n += 1
print(f"Exercise 1: every p=0.4, N={n - 1} gives {1 - 0.6 ** (n - 1):.4f}, "
      f"N={n} gives {1 - 0.6 ** n:.4f}")
n = 1
while pass_at(n) < 0.99:
    n += 1
print(f"            Beta pool, N={n - 1} gives {pass_at(n - 1):.5f}, "
      f"N={n} gives {pass_at(n):.5f}")
w1 = 1 / K                       # weight of each wrong answer if uniform
p_star = w1 / (1 + w1)
x = np.linspace(p_star, 1, 400001)
f = x ** (A - 1) * (1 - x) ** (B - 1) / beta_fn(A, B)
limit_u = float(((f[1:] + f[:-1]) * np.diff(x)).sum() / 2)
print(f"Exercise 2: w1={w1}, p*={p_star:.4f}, limit {limit_u:.3f}")
kv_seq = 1000 * kv_tok / 1e9     # KV of one sequence at 1000 tokens (GB)
print(f"Exercise 4: weights {2 * params / 1e9:.2f} GB, KV of one sequence "
      f"{kv_seq:.3f} GB,")
print(f"            equal at {2 * params / 1e9 / kv_seq:.1f} sequences")
Exercise 1: every p=0.4, N=9 gives 0.9899, N=10 gives 0.9940
            Beta pool, N=350 gives 0.98998, N=351 gives 0.99001
Exercise 2: w1=0.05, p*=0.0476, limit 0.898
Exercise 4: weights 16.06 GB, KV of one sequence 0.131 GB,
            equal at 122.5 sequences

Further Reading

FAQ

What is test-time compute (inference-time scaling), and how does it differ from training compute?
Test-time compute is the extra computation spent while answering each question after training has finished: parallel sampling with voting, picking an answer with a verifier, sequential revision, search, and the long chains of thought that reinforcement learning produces. Training compute is paid once and shared by every request; test-time compute is paid again on every request, so it is both another scaling axis next to parameters, data and training compute and a new cost center. In the o1 announcement OpenAI reported that o1 improves with more reinforcement learning (train-time compute) and with more time spent thinking (test-time compute).
What is the difference between majority voting and best-of-N, and what does each need?
Majority voting takes the most frequent final answer among N samples. It needs no verifier but needs answers that can be compared (math, multiple choice), and its limit is set by the model's systematic errors: in this page's simulation only problems where the correct answer is more common than the commonest wrong answer can be voted right, so the limit is 0.662 however large N gets. Best-of-N scores every sample with a verifier and keeps the highest, so it needs a reliable verifier (unit tests, a prover or a reward model) and its gain depends on the verifier's quality: on the same pool a verifier with AUC 0.921 reaches 0.947 at N=256 and one with AUC 0.760 only 0.799.
What happens when the verifier is inaccurate?
Best-of-N takes a maximum, so the more samples there are, the more likely it is to pick one the verifier misjudges. In this page's simulation, if just 5% of the wrong samples receive high scores, accuracy peaks at 0.684 at N=16 and then falls to 0.523 at N=256, and at N=64 it is already below majority voting without any verifier (0.618 versus 0.658). This is the smallest version of reward model overoptimization (Gao et al., 2022). Mitigations: cap N and scan it on held-out data, replace learned verifiers with executable checks such as unit tests, and ensemble several verifiers.
Is a long-chain reasoning model such as DeepSeek-R1 the same thing as sampling many times and voting?
No, though the two can be stacked. Sampling and voting is done by the inference system outside the model: N independent answers, picked by an external rule or verifier. A long chain of thought is a trained ability: inside one response the model tries, checks and backtracks, so the selection happens within the model. Their latency also differs: for the same 64,000 generated tokens, 64 parallel samples and one long chain differ by a factor of 53 in this page's roofline estimate (7.3 seconds versus 388.2 seconds), because decoding is limited by memory bandwidth and parallel samples share each step's weight reads.
Which tasks suit test-time compute?
Tasks with an automatic verifier where the model is right some of the time: code that unit tests can judge, math whose final answer can be checked, theorem proving. The test is whether pass@N is clearly above pass@1, which means the correct answer is in the model's distribution but unstable. Where there is no automatic verifier (open-ended writing, dialogue) the selector becomes the bottleneck: Brown et al. (2024) saw majority voting and reward models plateau after a few hundred samples. Problems the model essentially cannot solve (the hardest 0.102 of the pool in this page's simulation, with p near 0) are hard to recover by sampling more.