Module contents
Stage 6 of 8Research 110 min

Third approach: parametric fit with uncertainty

Fit a parametric scaling surface and diagnose numerical and statistical uncertainty.

After this lesson you can

  • Implement log-scale Huber fitting with an initialization grid and L-BFGS.
  • Calculate bootstrap intervals for all parameters and implied optimal allocation.
  • Study sensitivity to excluded points and the Huber delta choice.
  • Compare implied allocation with approaches 1 and 2.

Before you start

One surface, not a collection of curves

The envelope method asks which run wins at each budget. isoFLOP profiles fit a parabola to each slice and read its vertex. Hoffmann and colleagues’ third approach changes the question: is there one function L(N,D)L(N,D) explaining all runs’ final losses at once, whatever their budgets? If so, the optimum at any budget can be obtained with pencil and paper, even for budgets nobody has trained. That is its power and danger: the surface shares information across slices, but also imposes its shape on all of them.

In the Chinchilla paper this approach differed most from the other two (a=0.46a=0.46 versus 0.500.50 and 0.490.49) and published the narrowest interval, (0.454, 0.455)(0.454,\,0.455). Two years later a reanalysis showed that the optimizer had stopped before convergence. This lesson reproduces the full fit using p14-l05’s 105 actual runs, teaches how to trigger and detect that failure, and ends with a table comparing the three approaches on the same data.

InteractiveThe surface and its isoFLOP slice

Height and color show predicted loss. Blue points are the means of the 35 configurations, and gray lines show the five measured budgets.

  • isoFLOP slice of the surface
  • runs (seed mean and range)
  • fitted minimum
  • Approach 2 vertex
4.00
C (FLOPs)8.00·10¹¹
N∗N^\ast from the fit27 924
Approach 2 vertex28 278
D∗/N∗D^\ast/N^\ast171.0
Loss at N∗N^\ast2.3850
Exponent a=β/(α+β)a=\beta/(\alpha+\beta)0.397
Budgetmeasured
In 3D, the surface fitted to p14-l05's 105 runs (points: means of each configuration). In the plane, the surface slice along C = 6ND, with budget runs when measured (k = 0, 1, 2, 3, 4), the fit minimum (orange) and approach 2's parabola vertex (aqua). The switch refits without the largest budget and shows how it predicts those runs.

Start at k=4k=4, the largest budget, 8⋅10118\cdot10^{11} FLOPs. The surface minimum falls at 27 924 parameters and approach 2’s parabola vertex at 28 278: two methods on the same runs agree within 1.3 %. Explore the other measured budgets: at k=2k=2 the difference reaches 7 % (16 100 versus 17 317), outside the vertex bootstrap interval. The surface forces all five optima onto an exact power law; each parabola follows its own profile, with its noise and deviations. Then move kk to 6 and −2-2: the surface still gives a minimum, but no runs support it. Finally activate the switch: the fit without the largest budget predicts losses higher than observed for six of its seven configurations, by up to 0.004 nats, and its N∗N^\ast at that budget rises 5 %. That is the difference between fitting and predicting.

What the parametric form claims

Hoffmann motivates the form with a classic risk decomposition: EE would be loss of the ideal generating process, “the entropy of natural text”; A/NαA/N^\alpha, what a perfectly trained finite-size model loses; B/DβB/D^\beta, what is lost through finitely many steps on a sample. This is motivation, not a theorem. Separability excludes interactions between size and data, and nothing guarantees each term is an exact power over the measured range. In our lab the artificial source has known entropy, 2.2497 nats, and we can check whether EE recovers it. It does not.

Coefficients depend on units and exponents do not. If n=N/103n=N/10^3, the parameter term is AN−α=(A 10−3α) n−αA N^{-\alpha}=(A\,10^{-3\alpha})\,n^{-\alpha}: α\alpha remains intact and AA changes value. The lab measures NN in thousands and DD in millions so log⁡A\log A and log⁡B\log B are order one. What does change exponents is counting NN differently: adding embedding parameters adds a constant to NN, not a factor, and distorts the curve particularly for small models. Before comparing exponents across studies, check that they count parameters and tokens the same way.

Identifiability depends on design, not the optimizer. If all runs had the same NN, the term E+A/NαE+A/N^\alpha would be a single constant and no method could separate EE, AA and α\alpha. The p14-l05 isoFLOP profiles are better than that but not ideal: the 35 points occupy five diagonals in the (log⁡N,log⁡D)(\log N,\log D) plane, because within each budget log⁡N+log⁡D\log N+\log D is constant. Within each diagonal NN and DD vary in opposite directions; between diagonals both grow. This geometry allows separation of the two terms, and limits how much we can trust the surface far from the diagonals.

The fit: Huber on logarithms, log-sum-exp and L-BFGS

Hoffmann minimizes the Huber loss of the difference between log predicted and log observed loss:

min⁡θ ∑iρδ(log⁡Lθ(Ni,Di)−log⁡Li),ρδ(r)={12r2,∣r∣≤δ,δ(∣r∣−12δ),∣r∣>δ,\min_{\theta}\ \sum_{i}\rho_\delta\big(\log L_\theta(N_i,D_i)-\log L_i\big),\qquad \rho_\delta(r)= \begin{cases} \tfrac12r^2,& |r|\leq\delta,\\[2pt] \delta\big(|r|-\tfrac12\delta\big),& |r|>\delta, \end{cases}

with δ=10−3\delta=10^{-3}. The logarithm turns residuals into relative errors: predicting 2.02 when observing 2 and predicting 4.04 when observing 4 give the same residual, log⁡1.01\log 1.01. With δ=10−3\delta=10^{-3}, residuals above 0.1 % enter the linear branch and their influence on gradient is bounded by δ\delta. Hoffmann reports that larger δ\delta made the fit adapt to small budgets and predict held-out large ones worse, while smaller values did not change predictions. Understand what δ\delta does on each dataset: here the largest residual is 0.0018, so with δ≥0.002\delta\geq0.002 Huber is exactly least squares.

To evaluate log⁡Lθ\log L_\theta without overflow, parameterize e=log⁡Ee=\log E, a0=log⁡Aa_0=\log A, b0=log⁡Bb_0=\log B (also guaranteeing E,A,B>0E,A,B>0) and use the log-sum-exp identity:

u1=e,u2=a0−αlog⁡N,u3=b0−βlog⁡D,log⁡Lθ=m+log⁡∑j=13euj−m,m=max⁡juj.u_1=e,\quad u_2=a_0-\alpha\log N,\quad u_3=b_0-\beta\log D, \qquad \log L_\theta=m+\log\sum_{j=1}^3 e^{u_j-m},\quad m=\max_j u_j.

The evaluated exponents are nonpositive and the sum lies between 1 and 3, so there is no overflow or cancellation loss. The gradient follows cleanly. With wj=euj/∑keukw_j=e^{u_j}/\sum_k e^{u_k}, the fraction of predicted loss contributed by each term, derivatives of log⁡Lθ\log L_\theta with respect to (e,a0,b0,α,β)(e,a_0,b_0,\alpha,\beta) are

(w1, w2, w3, −w2log⁡N, −w3log⁡D),\big(w_1,\ w_2,\ w_3,\ -w_2\log N,\ -w_3\log D\big),

and the objective gradient is the sum over observations of ρδ′(ri)=clip⁡(ri,−δ,δ)\rho_\delta'(r_i)=\operatorname{clip}(r_i,-\delta,\delta) times that vector. Note what it says: if the data term contributes 1 % of loss in a region (w3=0.01w_3=0.01), information about β\beta from those points is multiplied by 0.01. With our lab losses from 2.38 to 2.49 nats and a reducible component, L−EL-E, between 0.08 and 0.19 nats, derivatives are small and the objective almost flat in some directions.

The problem is not convex in all five parameters, so Hoffmann starts L-BFGS from a grid of starts, α,β∈{0,0.5,…,2}\alpha,\beta\in\{0,0.5,\dots,2\}, e∈{−1,−0.5,…,1}e\in\{-1,-0.5,\dots,1\} and a0,b0∈{0,5,…,25}a_0,b_0\in\{0,5,\dots,25\}: 5⋅5⋅5⋅6⋅6=45005\cdot5\cdot5\cdot6\cdot6=4500 starts, retaining the lowest objective. But a trap subtler than local minima exists. SciPy’s L-BFGS-B stopping criterion is

fk−fk+1max⁡{∣fk∣,∣fk+1∣,1}≤ftol=2.2⋅10−9omax⁡i∣(proj⁡∇f)i∣≤gtol=10−5.\frac{f_k-f_{k+1}}{\max\{|f_k|,|f_{k+1}|,1\}}\leq \texttt{ftol}=2.2\cdot10^{-9}\quad\text{o}\quad \max_i|(\operatorname{proj}\nabla f)_i|\leq\texttt{gtol}=10^{-5}.

The 1 in the denominator makes the criterion absolute when the objective is below 1. A sum of 105 Huber residuals of order 10−310^{-3} is about 3⋅10−53\cdot10^{-5}, and its gradient is smaller still: with default tolerances, an iteration reducing the objective by 0.007 % already counts as convergence, and a gradient of 10−510^{-5} is the same order as the objective itself. The optimizer stops far from the minimum and reports success. If the objective is averaged rather than summed, the problem is multiplied by the number of observations.

What Besiroglu and colleagues’ replication found

Hoffmann and colleagues, section 3.3 and appendix D.2, fit the form to “all final losses of experiments from approaches 1 and 2,” using the procedure above, and publish E=1.69E=1.69, A=406.4A=406.4, B=410.7B=410.7, α=0.34\alpha=0.34 and β=0.28\beta=0.28, in unscaled parameters and tokens. Their table 2 gives a=0.46a=0.46 with 10th and 90th percentiles (0.454, 0.455)(0.454,\,0.455) and b=0.54b=0.54 with (0.542, 0.543)(0.542,\,0.543), estimated using 100 resamples of 80 % of data. Approach 2 has interval (0.462, 0.534)(0.462,\,0.534), seventy times wider.

Besiroglu, Erdil, Barnett and You did not have the losses, so reconstructed 245 points from figure 4 and refitted the same form using the same procedure, excluding five outliers from their main analysis. They did not retrain models. They draw four conclusions:

  1. The published fit fits the data poorly. Residuals of Hoffmann’s parameters on reconstructed points are not centered on zero, and the best fit of the same form is clearly different: E=1.8172E=1.8172, A=482.01A=482.01, B=2085.43B=2085.43, α=0.3478\alpha=0.3478, β=0.3658\beta=0.3658, with a=0.5126a=0.5126 and standard error 0.02 (their table 1).
  2. Premature stopping is the likely cause. According to confirmation from an author, Hoffmann averaged Huber values rather than summing them. With an objective hundreds of times smaller, the L-BFGS-B stopping criterion fired too early, both in the fit and every resample.
  3. The interval is impossible. Such a narrow interval would require over 600 000 experiments, when probably fewer than 500 were done. The natural explanation is the same: if each replicate starts near the central fit and the optimizer stops almost immediately, replicates barely move and the interval measures the optimizer, not the data.
  4. Corrected, approach 3 agrees with the other two. Published parameters imply about 70 tokens per parameter, versus 20 in approaches 1 and 2; the refit gives about 20 and a=0.51a=0.51.

They also point out rounding. The paper’s source code gives β≈0.2849\beta\approx0.2849, not 0.28. With D=1011D=10^{11} tokens, substituting one for the other multiplies the data term by D0.0049=1.13D^{0.0049}=1.13, 13 % more in that summand. With unrounded values, a=0.2849/(0.3392+0.2849)=0.456a=0.2849/(0.3392+0.2849)=0.456, rounded to the published 0.46; rounded values give 0.28/0.62=0.4520.28/0.62=0.452. Always save parameters with all digits: predictions are regenerated from them, not the paper’s table.

For the bootstrap, Besiroglu used 4000 resamples of 240 points with BFGS and without the start grid. Their intervals and Hoffmann’s measure different things: one covers variation of 240 digitized points, the other 80 % subsamples of original data. Neither covers functional-form error.

From fit to optimal allocation

To compare with other approaches use the same FLOP accounting. With C=6NDC=6ND and K=C/6K=C/6, substituting D=K/ND=K/N reduces the problem to one variable. This is the surface’s implied allocation law.

Proof

Write s=log⁡Ns=\log N. The loss component depending on NN is h(s)=Ae−αs+BK−βeβsh(s)=A e^{-\alpha s}+B K^{-\beta}e^{\beta s}, because EE is constant. Its derivatives are

h′(s)=−αAe−αs+βBK−βeβs,h′′(s)=α2Ae−αs+β2BK−βeβs>0.h'(s)=-\alpha A e^{-\alpha s}+\beta B K^{-\beta}e^{\beta s},\qquad h''(s)=\alpha^2 A e^{-\alpha s}+\beta^2 B K^{-\beta}e^{\beta s}>0.

Thus hh is strictly convex in ss, and h(s)→∞h(s)\to\infty as s→±∞s\to\pm\infty (the first term dominates on the left and the second on the right). A strictly convex coercive function on R\mathbb{R} has a unique minimum, the unique zero of h′h': e(α+β)s=αAKβ/(βB)e^{(\alpha+\beta)s}=\alpha A K^{\beta}/(\beta B), that is, N∗α+β=(αA/βB) KβN_\ast^{\alpha+\beta}=(\alpha A/\beta B)\,K^\beta, which is the formula. Since N↦log⁡NN\mapsto\log N is an increasing bijection from (0,∞)(0,\infty) to R\mathbb{R}, this is the unique minimum in NN. The rest is arithmetic: D∗=K/N∗D_\ast=K/N_\ast has exponent 1−a=b1-a=b, and D∗/N∗=K/N∗2∝K1−2a=K(α−β)/(α+β)D_\ast/N_\ast=K/N_\ast^2\propto K^{1-2a}=K^{(\alpha-\beta)/(\alpha+\beta)}.

∎

Condition h′=0h'=0 reads αA/N∗α=βB/D∗β\alpha A/N_\ast^\alpha=\beta B/D_\ast^\beta: at the optimum the two error terms are not equal, but the terms multiplied by their exponents are. This is equal marginal benefit: shifting a small fraction of compute from parameters to data does not change loss to first order. EE does not appear in allocation, but does in joint estimation of the other parameters: misestimated EE shifts α\alpha and β\beta, and with them aa.

The rule shows why uncertainty must be propagated jointly. If α\alpha and β\beta rise and fall together their ratio barely changes; if they move oppositely it changes much more. Two marginal intervals do not suffice to infer one for aa. The exponent is not the whole law: constant GG determines frontier position, and two studies with similar exponents can recommend different sizes at a particular budget. The lesson’s final table therefore also compares N∗N_\ast at a common budget.

The theorem optimizes the model continuously under an exact constraint. If 6ND6ND ceases to describe cost, for example because attention matters at long contexts, the constraint is no longer ND=KND=K and the minimum must be found numerically on the surface under the correct constraint. If N∗N_\ast falls outside the training range, the formula gives a number, but it is an extrapolation.

Lab 1: check the procedure against known truth

Before fitting real data, check that code recovers known parameters. Generate exact separable-form losses with (E,A,B,α,β)=(1.8, 1.2, 1.1, 0.34, 0.28)(E,A,B,\alpha,\beta)=(1.8,\,1.2,\,1.1,\,0.34,\,0.28) over a 6×66\times6 grid of n=N/106n=N/10^6 and d=D/106d=D/10^6, adding Gaussian noise of standard deviation 10−310^{-3} to their logarithms in three replicates. The objective and analytical gradient are written once and checked against finite differences.

[ ]Objective, gradient and multistart fit on synthetic dataBrowser
import numpy as np
from scipy.optimize import minimize, check_grad

def objective(theta, x, y, logL, delta):
    """Suma de Huber de log L_theta - log L y su gradiente; logL tiene forma (réplicas, puntos)."""
    e, a, b, alpha, beta = theta
    u = np.stack([np.full_like(x, e), a - alpha*x, b - beta*y])   # (3, puntos)
    m = u.max(axis=0)
    w = np.exp(u - m)
    s = w.sum(axis=0)
    w /= s                                    # pesos w_j de cada término
    r = (m + np.log(s)) - logL                # log-sum-exp estable menos el dato
    v = np.abs(r)
    f = np.where(v <= delta, .5*r*r, delta*(v - .5*delta)).sum()
    g = np.clip(r, -delta, delta).sum(axis=0) * w
    return float(f), np.array([g[0].sum(), g[1].sum(), g[2].sum(),
                               -(x*g[1]).sum(), -(y*g[2]).sum()])

TIGHT = {"maxiter": 10000, "ftol": 1e-15, "gtol": 1e-10}
BOUNDS = [(-3, 3), (-10, 10), (-10, 10), (.01, 3), (.01, 3)]

def fit(x, y, logL, delta, starts, options=TIGHT):
    runs = [minimize(objective, s, args=(x, y, logL, delta), jac=True,
                     method="L-BFGS-B", bounds=BOUNDS, options=options) for s in starts]
    ok = [r for r in runs if r.success and np.isfinite(r.fun)]
    return (min(ok, key=lambda r: r.fun) if ok else None), runs

def natural(theta):
    """(log E, log A, log B, alfa, beta) -> (E, A, B, alfa, beta)."""
    return np.r_[np.exp(theta[:3]), theta[3:]]

def at_bound(theta, tol=1e-6):
    return [i for i, (v, (lo, hi)) in enumerate(zip(theta, BOUNDS)) if min(v - lo, hi - v) < tol]

# Datos sintéticos con verdad conocida: n y d en millones, rejilla 6 x 6, 3 réplicas
grid = np.array([1., 3., 10., 30., 100., 300.])
nn, dd = np.meshgrid(grid, grid, indexing="ij")
xs, ys = np.log(nn.ravel()), np.log(dd.ravel())
true = np.array([1.8, 1.2, 1.1, .34, .28])
clean = np.log(true[0] + true[1]*np.exp(-true[3]*xs) + true[2]*np.exp(-true[4]*ys))
logLs = clean + np.random.default_rng(41).normal(0, .001, size=(3, len(xs)))

theta0 = np.array([.4, .1, .1, .3, .3])
print("gradiente analítico frente a diferencias finitas:",
      f"{check_grad(lambda t: objective(t, xs, ys, logLs, .001)[0], lambda t: objective(t, xs, ys, logLs, .001)[1], theta0):.1e}")
starts = [np.array([np.log(e), np.log(a), np.log(b), al, be])
          for e, a, b, al, be in [(1.5, 1, 1, .3, .3), (2, 1.5, .8, .5, .2),
                                  (1, .8, 1.5, .2, .5), (2.2, 2, 2, .7, .7)]]
best_s, runs_s = fit(xs, ys, logLs, .001, starts)
for i, r in enumerate(runs_s):
    print(i, "éxito", r.success, "objetivo", f"{r.fun:.8g}", "iteraciones", r.nit,
          "|grad| máx", f"{np.abs(r.jac).max():.1e}")
est = natural(best_s.x)
print("verdad     :", true)
print("estimación :", np.round(est, 4), "límites activos:", at_bound(best_s.x))
print("a = beta/(alfa+beta):", round(est[4]/(est[3]+est[4]), 4), " verdad:", round(.28/.62, 4))

All four starts reach the same objective, 3.9530127⋅10−53.9530127\cdot10^{-5}, with gradients between 10−910^{-9} and 2⋅10−82\cdot10^{-8}, and estimate (1.8048, 1.1976, 1.0978, 0.3417, 0.2812)(1.8048,\,1.1976,\,1.0978,\,0.3417,\,0.2812): a=0.4514a=0.4514 versus true 0.4516. Analytical gradient matches finite differences to 10−910^{-9}. This tests code, not science: here the form is correct by construction and the grid wide (six orders of magnitude between smallest and largest term). Neither will hold for real data.

Lab 2: the 105 runs of p14-l05

The p14-l05 lab trained a perceptron on a GPU over an artificial Zipf source with entropy 2.2497 nats: five budgets between 5⋅10105\cdot10^{10} and 8⋅10118\cdot10^{11} FLOPs, seven sizes per budget and three seeds per configuration, with the registered learning-rate rule. The next cell contains their final evaluation losses (rounded to five decimals, well below seed noise) and fits the surface to all 105, one per run, as Hoffmann does. It fits twice from the same eight starts: with strict tolerances and SciPy defaults.

[ ]Fit the 105 runs and the tolerance trapBrowser
# 35 configuraciones de p14-l05 (5 presupuestos x 7 tamaños): N, D y pérdida de las semillas 11, 22, 33
runs = np.array([
    [2705, 3080192, 2.48461, 2.48272, 2.48767],
    [4080, 2041856, 2.46882, 2.46924, 2.46797],
    [6180, 1347584, 2.45880, 2.46023, 2.45975],
    [9060, 919552, 2.45426, 2.45971, 2.45708],
    [13617, 610304, 2.46141, 2.46065, 2.46011],
    [20192, 411648, 2.46465, 2.46661, 2.46929],
    [30432, 272384, 2.48127, 2.47803, 2.48300],
    [3945, 4222976, 2.45666, 2.45846, 2.45389],
    [5856, 2844672, 2.44681, 2.44713, 2.44630],
    [8672, 1921024, 2.43713, 2.43701, 2.44033],
    [12912, 1290240, 2.43736, 2.43751, 2.43432],
    [19337, 860160, 2.43736, 2.43892, 2.43917],
    [28697, 579584, 2.44672, 2.44741, 2.44755],
    [42720, 389120, 2.45564, 2.46085, 2.45327],
    [5540, 6014976, 2.43320, 2.43439, 2.43570],
    [8292, 4018176, 2.42337, 2.42355, 2.42516],
    [12225, 2725888, 2.41632, 2.41779, 2.41788],
    [18225, 1828864, 2.41817, 2.41341, 2.41942],
    [27345, 1218560, 2.42012, 2.41873, 2.41855],
    [40665, 819200, 2.42861, 2.42459, 2.42611],
    [60465, 550912, 2.43923, 2.43798, 2.43687],
    [7737, 8615936, 2.41228, 2.41202, 2.41432],
    [11556, 5767168, 2.40357, 2.40477, 2.40385],
    [17412, 3827712, 2.39853, 2.39803, 2.39973],
    [25700, 2592768, 2.39851, 2.40063, 2.39715],
    [38660, 1724416, 2.40218, 2.40378, 2.40183],
    [57537, 1157120, 2.41062, 2.40985, 2.41073],
    [85892, 774144, 2.41900, 2.42076, 2.41891],
    [10905, 12226560, 2.39348, 2.39326, 2.39224],
    [16356, 8151040, 2.38698, 2.38612, 2.38573],
    [24420, 5459968, 2.38396, 2.38227, 2.38282],
    [36705, 3631104, 2.38625, 2.38337, 2.38486],
    [54681, 2437120, 2.38809, 2.38639, 2.38822],
    [81252, 1640448, 2.39400, 2.39610, 2.39755],
    [121257, 1097728, 2.40343, 2.40457, 2.40258],
])
budgets = np.repeat([5e10, 1e11, 2e11, 4e11, 8e11], 7)
x, y = np.log(runs[:, 0] / 1e3), np.log(runs[:, 1] / 1e6)   # N en miles, D en millones
logL = np.log(runs[:, 2:]).T                                # (3 semillas, 35 configuraciones)
inits = [np.array([e, 0., 0., al, be]) for e in (0., 1.) for al in (.3, 1.) for be in (.3, 1.)]
best, tight = fit(x, y, logL, 1e-3, inits)
_, loose = fit(x, y, logL, 1e-3, inits, options={})        # tolerancias por defecto de SciPy
print("inicio  objetivo ajustado   objetivo por defecto  (E, alfa, beta) por defecto")
for i, (r, q) in enumerate(zip(tight, loose)):
    E_, _, _, al_, be_ = natural(q.x)
    print(f"{i:5d}  {r.fun:.10f}  {q.fun:.10f}   ({E_:.3f}, {al_:.3f}, {be_:.3f})  éxito={q.success}")
theta = best.x
E, A, B, alpha, beta = natural(theta)
print("E, A, B, alfa, beta:", np.round([E, A, B, alpha, beta], 4), " límites activos:", at_bound(theta))
print("entropía de la fuente 2.2497; E - entropía =", round(E - 2.2497, 4))

def allocation(theta, C):
    """N* y D* bajo C = 6ND para el ajuste en miles de parámetros y millones de tokens."""
    E, A, B, alpha, beta = natural(theta)
    G = (alpha*A / (beta*B)) ** (1/(alpha + beta))
    n = G * (np.asarray(C) / 6e9) ** (beta/(alpha + beta))  # en miles
    return 1e3*n, np.asarray(C) / (6e3*n)

C5 = np.array([5e10, 1e11, 2e11, 4e11, 8e11])
n_star, d_star = allocation(theta, C5)
print("a =", round(beta/(alpha + beta), 4), "| N*:", np.round(n_star).astype(int),
      "| D*/N*:", np.round(d_star/n_star, 1))
u = np.stack([np.full_like(x, theta[0]), theta[1] - alpha*x, theta[2] - beta*y])
pred = np.log(np.exp(u).sum(axis=0))
print("residuo medio por presupuesto (1e-4):", np.round((pred - logL.mean(0)).reshape(5, 7).mean(1)*1e4, 1),
      "| error típico de esa media (1e-4):", round(float(np.sqrt(logL.var(0, ddof=1).mean()/21))*1e4, 1))

Read the table by columns. With strict tolerances all eight starts reach the same objective, 2.99054⋅10−52.99054\cdot10^{-5}, and parameters. With defaults the first three stop at objectives 4 to 7.4 times greater and absurd parameters such as α=0.041\alpha=0.041 and β=0.035\beta=0.035, and all eight say éxito=True. The other five finish near but not at the optimum: their objectives differ from the best from the sixth significant digit, and the exact stopping point even varies across platforms (this cell in the browser and native CPython does not give the same figures in those rows, while strict-fit rows do). A prematurely stopped result is not even reproducible. A start grid does not protect against this failure; it only hides it better, because the best of eight premature results may appear reasonable. This is exactly the mechanism Besiroglu identified in Chinchilla, reproduced on a CPU with five parameters.

The correct fit is E=2.2984E=2.2984, A=0.2210A=0.2210, B=0.0928B=0.0928, α=0.5586\alpha=0.5586 and β=0.3681\beta=0.3681 (NN in thousands, DD in millions), with no active bound. It implies a=0.3972a=0.3972 and optima from 9282 to 27 924 parameters between smallest and largest budget, with D∗/N∗D_\ast/N_\ast growing from 96.7 to 171.0, as C0.206C^{0.206}. Compare p14-l05: approach 2 gave a=0.397a=0.397 and vertices from 9439 to 28 278.

Two details show that the form, though useful, is not exact for this source:

  • EE is not entropy. E=2.2984E=2.2984 exceeds minimum achievable loss, 2.2497, by 0.049 nats, and the next section’s bootstrap places it between 2.293 and 2.303. With infinite models and data the surface predicts a plateau the source does not have. Over the measured range, EE absorbs curvature not captured by two powers; it should not be read as a physical bound. For the same reason Hoffmann’s E=1.69E=1.69 is not a measurement of text entropy.
  • Residuals have structure. Averaged by budget they are (5.4, −3.1, −4.4, −1.0, 3.0)⋅10−4(5.4,\,-3.1,\,-4.4,\,-1.0,\,3.0)\cdot10^{-4} in log loss, with standard error 1.4⋅10−41.4\cdot10^{-4} per mean: up to four standard errors, U-shaped over CC. A separable form cannot represent a budget-specific shift. An untested candidate cause is the learning-rate rule, which changes with CC and thus with the slice.

Uncertainty: what is resampled and what is not

Bootstrapping a scaling law repeats the full estimator on resampled data: the nonconvex fit with its convergence criterion, the transformation a=β/(α+β)a=\beta/(\alpha+\beta) and allocation N∗(C)N_\ast(C) in each replicate, taking percentiles only at the end. Calculating α\alpha and β\beta percentiles separately and combining them destroys their correlation.

The resampling unit must reflect how data were generated. Here each configuration has three independent seeds, so we resample seeds with replacement within each configuration, the same scheme by which p14-l05 applied the nonparametric bootstrap to profiles, making approach intervals comparable. If seeds were paired between configurations (the same data seed for every size), whole seeds would need resampling. Each replicate starts at the full-sample fit, as Besiroglu did, with strict tolerances. If line search ends abnormally, the replicate is retried with the start grid rather than discarded, because discarding difficult replicates biases the distribution.

[ ]Seed bootstrap: parameters, exponent and allocationBrowser
REPS = 120                                   # con 1000 tarda unos 15 s; véase el texto
boot_rng = np.random.default_rng(2026)
cols = np.arange(logL.shape[1])
samples, retried, failed = [], 0, 0
for _ in range(REPS):
    draw = boot_rng.integers(0, 3, size=logL.shape)     # semillas con reposición dentro de cada configuración
    sample = logL[draw, cols]
    r, _ = fit(x, y, sample, 1e-3, [theta])             # arranca en el ajuste completo
    if r is None:                                        # parada anómala: se repite con la rejilla entera
        retried += 1
        r, _ = fit(x, y, sample, 1e-3, inits)
    if r is None or at_bound(r.x):
        failed += 1
        continue
    n8, d8 = allocation(r.x, 8e11)
    z = natural(r.x)
    samples.append([*z, z[4]/(z[3] + z[4]), n8, d8/n8])
samples = np.array(samples)
print("réplicas", REPS, "| repetidas con la rejilla", retried, "| descartadas", failed)
names = ["E", "A", "B", "alfa", "beta", "a", "N*(8e11)", "D*/N*(8e11)"]
q = np.percentile(samples, [5, 10, 90, 95], axis=0)
for k, name in enumerate(names):
    print(f"{name:12s} p5-p95 [{q[0, k]:.4g}, {q[3, k]:.4g}]   p10-p90 [{q[1, k]:.4g}, {q[2, k]:.4g}]")
print("correlación entre alfa y beta en las réplicas:", round(np.corrcoef(samples[:, 3], samples[:, 4])[0, 1], 2))

One hundred twenty replicates take a couple of seconds and show the order of magnitude, although their 5th and 95th percentiles still have appreciable Monte Carlo error. With REPS = 1000 the result is: aa between 0.383 and 0.410 (5th and 95th percentiles) or between 0.386 and 0.408 (10th and 90th); EE between 2.293 and 2.303; N∗(8⋅1011)N_\ast(8\cdot10^{11}) between 27 290 and 28 490; D∗/N∗D_\ast/N_\ast between 164 and 179. Six of the thousand replicates ended with abnormal line-search stopping from the full fit; retried with the grid, they reached the same objective to twelve significant figures, so none was discarded. The standard deviation of aa across replicates is 0.008, and correlation between α\alpha and β\beta is 0.46.

That positive correlation narrows the interval for aa. By the delta method, Var⁡(a)≈g⊤Σg\operatorname{Var}(a)\approx g^\top\Sigma g with g=(−β, α)/(α+β)2g=\big(-\beta,\ \alpha\big)/(\alpha+\beta)^2 the gradient of aa with respect to (α,β)(\alpha,\beta): the cross term 2gαgβρ σασβ2g_\alpha g_\beta\rho\,\sigma_\alpha\sigma_\beta is negative when ρ>0\rho>0. With ρ=0\rho=0 the standard deviation of aa would be 0.0105 instead of 0.008. This is the third numeric exercise.

The interval is conditional on three things: functional form, design (these 35 points) and training rule. It covers only seed variation. It excludes observed residual structure, rate-rule effects and what happens outside the range. More replicates reduce percentile Monte Carlo error, not scarcity of units: three seeds per configuration remain three. The remaining question is how much the result changes with reasonable choices the bootstrap does not explore.

Sensitivity: delta, included points and a held-out prediction

[ ]Sensitivity to delta and included points, and largest-budget predictionBrowser
def refit(mask=slice(None), delta=1e-3):
    r, _ = fit(x[mask], y[mask], logL[:, mask], delta, [theta, inits[3]])
    return r

print("variante                        a       N*(8e11)   E")
for label, mask, delta in [("base", slice(None), 1e-3), ("delta = 1e-4", slice(None), 1e-4),
                           ("delta = 1e-2", slice(None), 1e-2),
                           ("sin el presupuesto 5e10", budgets > 5e10, 1e-3),
                           ("sin el presupuesto 8e11", budgets < 8e11, 1e-3),
                           ("sin los extremos de cada perfil", np.tile([0, 1, 1, 1, 1, 1, 0], 5) == 1, 1e-3)]:
    r = refit(mask, delta)
    z = natural(r.x)
    print(f"{label:32s} {z[4]/(z[3]+z[4]):.4f}  {allocation(r.x, 8e11)[0]:8.0f}  {z[0]:.4f}  límites {at_bound(r.x)}")

held = budgets == 8e11
r = refit(~held)
u = np.stack([np.full_like(x, r.x[0]), r.x[1] - r.x[3]*x, r.x[2] - r.x[4]*y])
pred = np.exp(np.log(np.exp(u).sum(axis=0)))[held]
obs = runs[held, 2:].mean(axis=1)
print("\npredicción a 8e11 sin verla:", np.round(pred, 4))
print("media observada            :", np.round(obs, 4))
print("error (nats)               :", np.round(pred - obs, 4),
      "| desviación típica entre semillas:", round(float(runs[held, 2:].std(axis=1, ddof=1).mean()), 4))
print("parámetros del ajuste sin 8e11:", np.round(natural(r.x), 4))

δ\delta barely matters here: aa goes from 0.3944 with δ=10−4\delta=10^{-4} to 0.3985 with δ=10−2\delta=10^{-2}, already least squares. There are no outliers to guard against. Included points matter much more. Removing the smallest budget gives a=0.382a=0.382; removing profile endpoints, 0.3830.383; removing the largest, 0.4180.418. The variant range, 0.382 to 0.418, is wider than the 90 % bootstrap interval, 0.383 to 0.410, and is not centered on it. Removing the largest budget shifts aa by 0.021, 2.6 times the full-fit bootstrap standard deviation. This alone does not prove misspecification, because a fit with fewer points is noisier, but together with U-shaped residuals it points in that direction: the separable form describes budgets unequally well, and inclusion changes the exponent.

The held-out prediction confirms it. Fitting the four smaller budgets predicts the seven 8⋅10118\cdot10^{11} configurations with errors from −0.0004-0.0004 to +0.0040+0.0040 nats, six above observed and the three largest at small sizes, while seed standard deviation is 0.0011. The surface extrapolated by only factor 2 in compute is too pessimistic, and its allocation shifts: N∗(8⋅1011)N_\ast(8\cdot10^{11}) moves from 27 924 to 29 432. The next lesson turns this check into a protocol: register prediction before training and evaluate without retuning.

Comparison among the three approaches

All three estimates come from the same 105 runs. Approaches 1 and 2 are in p14-l05; 3 is in this lesson.

Approachaa [p5, p95]N∗(8⋅1011)N_\ast(8\cdot10^{11}) [p5, p95]D∗/N∗D_\ast/N_\ast [p5, p95]
1. Envelope0.385 (no interval)24 420 (winner)223.6
2. Profiles0.397 [0.387, 0.408]28 278 [27 679, 28 882]166.7 [159.8, 174.0]
3. Surface0.397 [0.383, 0.410]27 924 [27 290, 28 490]171.0 [164.2, 179.0]
3. Variants0.382 to 0.41826 961 to 29 432

The envelope has no interval because it chooses among seven discrete sizes per profile. The final row is the range of five sensitivity variants, not a statistical interval.

Approaches 2 and 3 agree in aa to the third digit and in N∗(8⋅1011)N_\ast(8\cdot10^{11}) within 1.3 %, although at intermediate budgets their optima differ by up to 7 %; 1 lies slightly below due to discretization, as seen in p14-l05. This is what Besiroglu found in Chinchilla once the optimizer was corrected. But agreement is not three independent confirmations: all use the same runs, intervals 2 and 3 resample the same seeds, and any common bias, such as the rate rule, affects them equally. Nor does it make the number transferable: a=0.397a=0.397 from a Zipf source with a perceptron says nothing about 0.5 for a text transformer.

For the project’s verifiable result, the table must be accompanied by all five parameters with full digits, final objective and stop message for each start, number of repeated or discarded replicates, resampling scheme, sensitivity variants and criteria, and held-out prediction with error. If a reasonable variant changes the decision, publish both.

Exercises

NumericFrom Chinchilla's fit to exponent
With Hoffmann's published approach 3 exponents, α=0.34\alpha=0.34 and β=0.28\beta=0.28, calculate exponent aa of N∗∝CaN_\ast\propto C^a under C=6NDC=6ND.
NumericWhen L-BFGS-B stops
In the lab, the Huber sum at optimum is 2.99054⋅10−52.99054\cdot10^{-5} over 105 observations. Suppose that, like Hoffmann, you average rather than sum the objective, and use SciPy's default tolerance ftol=2.220446⋅10−9\texttt{ftol}=2.220446\cdot10^{-9}, with criterion (fk−fk+1)/max⁡{∣fk∣,∣fk+1∣,1}≤ftol(f_k-f_{k+1})/\max\{|f_k|,|f_{k+1}|,1\}\leq\texttt{ftol}. Near the optimum, what relative per-iteration objective reduction, (fk−fk+1)/fk(f_k-f_{k+1})/f_k, suffices for the optimizer to declare convergence?
NumericCorrelation narrows the interval
In the bootstrap, α\alpha and β\beta have standard deviations σα=σβ=0.0135\sigma_\alpha=\sigma_\beta=0.0135 and correlation ρ=0.46\rho=0.46, around α=0.559\alpha=0.559 and β=0.368\beta=0.368. Using the delta method, what is the approximate standard deviation of a=β/(α+β)a=\beta/(\alpha+\beta)?
QuizAn interval seventy times narrower
With the same experiments, Chinchilla approach 2 gives aa 10th and 90th percentiles (0.462, 0.534)(0.462,\,0.534) and approach 3 (0.454, 0.455)(0.454,\,0.455). What is most reasonable?
QuizWhich interval to publish
Your seed bootstrap gives a∈[0.383, 0.410]a\in[0.383,\,0.410] (5th and 95th percentiles). Removing the largest budget gives a=0.418a=0.418; removing the smallest gives 0.3820.382; and the fit without the largest predicts its losses with bias about +0.002 nats. What do you report?
QuizWhich convention change leaves the exponent intact?
You will compare your α\alpha with another study. Which convention change does not alter fitted α\alpha (with noiseless data of the exact form)?
ProofDerive allocation
Prove: Let A,B,α,β,K>0A,B,\alpha,\beta,K>0, L=E+AN−α+BD−βL=E+AN^{-\alpha}+BD^{-\beta} and constraint ND=KND=K. Prove there is a unique optimal N∗N_\ast and calculate the exponents of N∗N_\ast and D∗/N∗D_\ast/N_\ast against KK.
0
Substitute D = K/N and work with s = log N.

Step 1 of 4. What condition characterizes the stationary point in s = log N?

CodeA multistart fit that does not stop prematurely
Implement fit_parametric_loss(N, D, L, delta, init_grid). Each start is (log E, log A, log B, α, β). Minimize with L-BFGS-B the Huber sum of predicted log L minus observed log L, evaluating predicted log L with log-sum-exp, with positive bounds for exponents and tolerances appropriate to an objective of order 1e-5 (the last test uses data where defaults stop far from the optimum). Call the optimizer as scipy.optimize.minimize, since tests replace it to inspect your objective, which must return the value (or value and gradient pair). Return the successful finite result with lowest objective; if none exists, raise RuntimeError. For any nonpositive input or nonpositive delta, raise ValueError.
import numpy as np
import scipy.optimize
from scipy.special import logsumexp

def fit_parametric_loss(N, D, L, delta, init_grid):
  """Devuelve el mejor OptimizeResult entre los inicios de init_grid."""
  pass
Shift+Enter to run
Key idea

The surface E+A/Nα+B/DβE+A/N^\alpha+B/D^\beta summarizes all runs in five parameters and gives allocation in closed form, N∗∝Cβ/(α+β)N_\ast\propto C^{\beta/(\alpha+\beta)}. Its weakness is numerical before statistical: with an objective of order 10−510^{-5}, L-BFGS-B stops far from the optimum, declares success and produces impossible intervals, as happened to Chinchilla. With appropriate tolerances, multiple starts and a bootstrap refitting each replicate, the 105 p14-l05 runs give a=0.397a=0.397 [0.383, 0.410], like isoFLOP profiles. But EE is not entropy, residuals have structure, and removing a budget moves aa more than the whole interval. Publish both uncertainties and test the surface with a held-out prediction.