Test-time compute: choose where the next sample is worth spending
推理时计算
Solve a finite allocation problem and charge for difficulty estimates and damaging revisions.
test-time-computeThe hardest question may be a poor place for the next sample
You have twelve sampling units and four questions. One is usually solved on the first attempt; another is almost never solved. Giving every question three attempts is simple. Giving most attempts to the hardest question sounds reasonable. Neither necessarily maximizes the expected number solved.
Test-time compute is computation spent when solving an input, beyond choosing a model’s fixed training budget. For language-model reasoning it can include longer generation, several candidate solutions, verification, revision or search. This article studies fixed-model inference strategies. More computation is a resource, not a guarantee of more correct answers.
Snell and colleagues, sections 3.1–3.2, choose inference strategies according to estimated problem difficulty and compute budget. They distinguish oracle difficulty from model-predicted difficulty and explicitly note that their experiments do not charge the difficulty-estimation overhead. Wang and colleagues, section 2, illustrate a different aggregation choice: sampling paths and voting on final answers. The selector and its cost belong in the comparison.
Write down the cost and the selection assumption
A useful bookkeeping identity separates candidate generation, checking and any preliminary estimation:
Here is a generation count and a verification count. Costs must share a declared unit: tokens, measured latency, FLOPs or another resource. These units are not interchangeable. Parallel samples may reduce latency while leaving total work high.
For a particularly simple model, each independent candidate for question succeeds with probability , and a perfect verifier selects a correct answer whenever one appears. With attempts:
This is an oracle-selection success probability, not the accuracy of majority voting or an imperfect reward model. With a faulty selector, generating a correct candidate is not enough to ensure that it is chosen.
The marginal benefit of one additional attempt is:
Returns decrease as attempts accumulate. A question that is initially easy soon saturates; an almost impossible question can have a small marginal return from the start. A moderately difficult question may deserve the next unit.
Our finite objective allocates an integer budget across equally weighted questions, with at least one attempt each:
It maximizes an expected count of solved questions, not a probability that all questions are solved. Unequal importance, minimum service levels or different per-sample costs would define a different problem. Known values make this an allocation oracle rather than a ready deployment strategy.
Dynamic programming solves the stated problem exactly. Let be the best expected count for the first questions using units:
Other impossible initial states have value . Store the maximizing to reconstruct an allocation. The code uses arithmetic operations and storage. For this special diminishing-return model, greedy allocation by marginal benefit also works; the dynamic program offers a direct check without assuming that property for more general costs.
Serial revision has different behavior. Suppose a wrong answer is repaired with probability per revision and a correct one is damaged with probability . Its correctness evolves as:
For , solving this two-state recurrence gives:
Thus additional revisions can improve or worsen correctness. The model has no learning, and its repair/damage probabilities are constant by construction. Real revision quality can depend on the whole preceding text. It is not equivalent to taking independent samples and selecting the best.
Allocate a budget and charge for the probe
Run the complete Python/NumPy program. The four probabilities are (0.8,0.6,0.2,0.05) and the total budget is 12 equal sampling units. A brute-force enumeration in the tests independently checks the dynamic-programming result.
"""Original finite compute allocation: known probabilities and an oracle verifier, not deployed LLM costs."""
import json
import numpy as np
def success(p,n):
if not np.isfinite(p) or not 0<=p<=1 or type(n) is not int or n<0:raise ValueError("Invalid probability or count")
return 1-(1-p)**n
def allocate(probabilities,budget):
p=np.asarray(probabilities,dtype=float);m=len(p)
if (p.ndim!=1 or m==0 or not np.isfinite(p).all() or np.any((p<0)|(p>1))
or type(budget) is not int or budget<m):raise ValueError("At least one sample per task required")
values=np.full((m+1,budget+1),-np.inf);choices=np.zeros((m+1,budget+1),dtype=int);values[0,0]=0
for k in range(1,m+1):
for b in range(k,budget+1):
for n in range(1,b-k+2):
candidate=values[k-1,b-n]+success(float(p[k-1]),n)
if candidate>values[k,b]:values[k,b]=candidate;choices[k,b]=n
counts=[];b=budget
for k in range(m,0,-1):n=int(choices[k,b]);counts.append(n);b-=n
return counts[::-1],float(values[m,budget])
def evaluate(probabilities,counts):return sum(success(float(p),int(n)) for p,n in zip(probabilities,counts))
def revision_accuracy(initial,repair,damage,steps):
if type(steps) is not int or steps<0 or any(not np.isfinite(p) or not 0<=p<=1 for p in [initial,repair,damage]):raise ValueError("Invalid Markov parameters")
p=initial
for _ in range(steps):p=p*(1-damage)+(1-p)*repair
return p
def demo():
p=[.8,.6,.2,.05];B=12
optimum,value=allocate(p,B);wrong,_=allocate(p[::-1],B);with_probe,_=allocate(p,B-4)
allocations=[dict(name=n,counts=c,expected_correct=evaluate(p,c)) for n,c in [('uniform',[3]*4),('known_probabilities',optimum),('reversed_estimates',wrong),('four_unit_probe',with_probe)]]
serial=[dict(n=n,repairing=revision_accuracy(.3,.4,.05,n-1),damaging=revision_accuracy(.8,.05,.3,n-1),parallel_oracle=success(.3,n)) for n in range(1,9)]
return dict(probabilities=p,budget=B,allocations=allocations,optimal_value=value,serial=serial,
scope='Expected count of solved tasks, equal sample units; probe cost is explicitly deducted.')
if __name__=='__main__':print(json.dumps(demo(),indent=2))
Uniform allocation (3,3,3,3) gives expected solved count 2.558625. The optimum (2,3,6,1) gives 2.683856: the hardest question receives only one attempt, while the moderately difficult third question receives six.
If the allocator mistakenly reverses the difficulty probabilities, it chooses (1,6,3,2) and achieves only 2.381404 under the true probabilities. If obtaining the correct probabilities costs four units, only eight remain: allocation (2,2,3,1) achieves 2.338. The latter is a constructed cost example, not an estimate of any model’s real profiling overhead.
The serial example starts either at correctness 0.3 with repair 0.4 and damage 0.05, or at correctness 0.8 with repair 0.05 and damage 0.3. The first improves toward ; the second degrades toward . More revisions do not have one universal direction of benefit.
The independent-success formula assumes constant known probabilities and perfect candidate checking. The program neither measures a language model nor charges token lengths or GPU time. It makes the resource and oracle assumptions explicit so that the allocation can be audited.
Estimating difficulty is itself a decision
Snell’s section 3.2 forms difficulty bins using 2,048 sampled solutions per problem, contrasting ground-truth checks with verifier scores. Their reported analysis uses two-fold strategy selection within bins and acknowledges excluded estimation cost. A deployment must decide how much to spend on diagnosing a question before spending on solving it.
Verifier reliability and sampling diversity matter alongside budget. An imperfect scorer can prefer a newly generated mistake; correlated samples violate the independent success formula. Voting, best-of-N, weighted answer aggregation and search use different selection rules and should not share an accuracy claim merely because they use the same number of candidates.
Report both total computation and wall-clock conditions. Equal sample counts can hide different sequence lengths, verifier passes and search overhead. Comparing a smaller model with more inference work against a larger one also requires a specified training–inference tradeoff and workload, not just two accuracy numbers.
Spend the next unit deliberately
- For one attempt already used, compare the next-sample benefit for and .
Answer: Both are . Initial pass probability alone does not rank every later allocation decision.
- Why does the optimum assign only one attempt to the question with ?
Answer: After its required first attempt, the next marginal gain is . Other available allocations produce greater marginal gains within this twelve-unit budget. The objective rewards expected solved count, not effort on the hardest task.
- Can the formula be used directly for majority-vote accuracy?
Answer: No. It is the probability of at least one success with independent trials, coupled here to a perfect selector. Voting can reject a correct minority answer; its accuracy requires a different calculation.
- A revision repairs 5% of wrong answers but damages 30% of correct ones. What long-run correctness does the two-state model predict?
Answer: . Starting at 0.8 therefore deteriorates toward about 0.142857 rather than improving indefinitely.
An inference budget needs a complete accounting boundary
Snell’s sections 3–5 connect difficulty, proposal changes, verifier targets and search. Wang’s section 2 provides a distinct sampling-and-voting baseline. Reproduce the selection rule, include the cost of obtaining its signals, and state whether success is measured on actual outputs or calculated with an oracle.
Make a prediction, then check
Should the hardest question always receive the most extra samples?
Learning objectives
- Compare serial revision, parallel sampling and task-level allocation under explicit cost and oracle assumptions.
- Reproduce the finite example and state its experimental limits.
Prerequisites & connections
Explore related knowledge →References
- Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters — v1
Charlie Snell; Jaehoon Lee; Kelvin Xu; Aviral Kumar · 2024 - Self-Consistency Improves Chain of Thought Reasoning in Language Models — v1
Xuezhi Wang; Jason Wei; Dale Schuurmans; Quoc Le; Ed H. Chi; Denny Zhou · 2022
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-20 · Single AI author. Viewed PDF5/6/7, sections3.1/3.2,4,5.1/5.2: budget allocation, oracle/model-predicted difficulty, excluded difficulty-estimation cost, two-fold selection, rollout value targets and aggregation/search. No scaling benchmark replicated. Read section2 and viewed PDF2/3: sampled paths, plurality on parsed answers, first-encountered tie rule and distinction from likelihood-weighted voting. Version1 results are not replaced by later abstracts. Seven paired equations and four explained exercises. Budget dynamic programming verified by exhaustive allocations under known probabilities and a perfect selector. Probing costs, reversed estimates and damaging revisions retained; not a measured LLM scaling law.
- Budget dynamic programming verified by exhaustive allocations under known probabilities and a perfect selector. Probing costs, reversed estimates and damaging revisions retained; not a measured LLM scaling law.
- Four computed SVG variants per topic;11 numeric/geometry tests and36 responsive cases passed. Twelve selected final captures directly viewed. Full article acceptance recorded separately.
Source locations checked:
- Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters — v1 · Viewed PDF5/6/7, sections3.1/3.2,4,5.1/5.2: budget allocation, oracle/model-predicted difficulty, excluded difficulty-estimation cost, two-fold selection, rollout value targets and aggregation/search. No scaling benchmark replicated.
- Self-Consistency Improves Chain of Thought Reasoning in Language Models — v1 · Read section2 and viewed PDF2/3: sampled paths, plurality on parsed answers, first-encountered tie rule and distinction from likelihood-weighted voting. Version1 results are not replaced by later abstracts.
Related topics