\documentclass[11pt]{article} \usepackage{common} \begin{document} \notehead{0207}{Test-time scaling: a cost model for samples versus self-correction}{Batch M2. Companion notebook: \texttt{notebooks/0207-test-time-scaling-cost-model.ipynb} (exact rationals, quadrature and Monte Carlo; executed).} \begin{problem} \question{With a perfect verifier, how should inference compute be split between fresh samples and revisions, and when should sampling stop?} At inference time a prover with a verifier can spend compute in two ways: more independent samples (pass@$n$), or longer sequential chains in which failed attempts are revised using compiler feedback (note 0204). With a perfect verifier the accounting changes qualitatively compared with chat-style best-of-$n$: nothing is lost to selection, and sampling can stop at the first success. This note builds the cost model: coverage versus $n$ over a population of problems, the expected cost with early stopping, the optimal stopping rule, the break-even between a fresh sample and a revision, and what an imperfect verifier would do instead. \end{problem} \stepcounter{section}% the problem box counts as section 1: keeps every \S and notebook cross-reference stable \section{Notation} \begin{center} \begin{tabular}{@{}p{0.36\linewidth}p{0.60\linewidth}@{}} \toprule Symbol & Meaning \\ \midrule $p$ & solve probability of one sample on a given problem; across problems $p\sim\mathrm{Beta}(a,b)$ \\ $n$ & number of attempts (budget cap); $N\sim\mathrm{Geom}(p)$ the index of the first success \\ $\mathrm{cov}(n)=\E_p[1-(1-p)^n]$ & coverage (best-of-$n$ with a perfect verifier) \\ $c$ & cost of one attempt (generation plus verification); $U$ value of a solved problem \\ $h_j=\Pr[\text{success at attempt }j{+}1\mid j\text{ failures}]$ & posterior hazard \\ $p_1,\ q$ & success of a fresh attempt; success of a revision given earlier failures \\ $\rho$ & cost of a revision relative to a fresh attempt \\ $\phi$ & false-accept rate of an imperfect verifier \\ \bottomrule \end{tabular} \end{center} \section{Derivation} \subsection{Coverage with a perfect verifier} A problem with solve probability $p$ is solved by $n$ attempts with probability $1-(1-p)^n$ and, because the verifier is exact, \emph{the solving attempt can be identified}: the selection loss of note 0201 is zero. Over a population with density $\propto p^{a-1}(1-p)^{b-1}$, \begin{equation}\label{eq:cov} \E_p(1-p)^n=\int_0^1\frac{p^{a-1}(1-p)^{b+n-1}}{B(a,b)}dp=\frac{B(a,b+n)}{B(a,b)},\qquad \mathrm{cov}(n)=1-\frac{B(a,b+n)}{B(a,b)} . \end{equation} Using $B(a,b+n)=\Gamma(a)\Gamma(b+n)/\Gamma(a+b+n)$ and $\Gamma(b+n)/\Gamma(a+b+n)\sim n^{-a}$, \begin{equation}\label{eq:tail} 1-\mathrm{cov}(n)\ \sim\ \frac{\Gamma(a+b)}{\Gamma(b)}\,n^{-a}\qquad(n\to\infty). \end{equation} The uncovered fraction is a power law in $n$ whose exponent $a$ is the order of the density of problems near $p=0$: the heavier the tail of hard problems (small $a$), the slower the gain from more samples. Notebook: (\ref{eq:cov}) matches Monte Carlo ($2\times10^6$ problems) within $1.3$ standard errors for $n\in\{1,\dots,256\}$; the ratio of exact uncovered fraction to (\ref{eq:tail}) is $0.939$ at $n=10$, $0.9933$ at $100$ and $1.0000$ at $10^5$. Large Language Monkeys observes coverage rising log-linearly over four orders of magnitude and models it as $c\approx\exp(ak^b)$ (Fig.~5), and notes some curves do not follow it closely \cite{lm}. Fitting that law to Beta-mixture curves on $k\in[1,10^4]$ gives mean absolute errors $0.006$, $0.001$, $0.006$ (maxima $0.026,0.012,0.053$) for three Beta populations, comparable to the errors in that paper's fits; we do not claim the Beta model is the true generative process, only that a mixture of per-problem geometric laws reproduces the shape. \subsection{Early stopping: the expected cost with a perfect verifier} Sample until the first verified success or $n$ attempts. Then the attempts used are $\min(N,n)$ and \begin{equation}\label{eq:early} \E\min(N,n)=\sum_{j=0}^{n-1}\Pr[N>j]=\sum_{j=0}^{n-1}(1-p)^j=\frac{1-(1-p)^n}{p}, \end{equation} exactly (rational arithmetic; also by direct enumeration of the truncated geometric distribution). Averaging over the population, $\sum_{j