# Scaling Laws: How to Split Compute Between Parameters and Data

> From Kaplan to Chinchilla: why loss falls as a power law in parameters, data and compute, how to split a compute budget between parameters and tokens, and why today's models are trained on far more data than the compute-optimal amount.

- URL: https://dmxsf.com/en/wiki/pretraining/scaling-laws/
- [DMXSF](https://dmxsf.com/en/about/)
- Intermediate
- Updated: 2026-11-16
- Tags: Scaling laws, Pretraining

## After this page you will be able to

- Say why loss falls as a power law in parameters, data and compute.
- Estimate training compute with C ≈ 6ND, and compare what Kaplan and Chinchilla conclude about splitting parameters and data.
- Given a compute budget, work out the optimal parameter count and number of tokens, and play with the interactive calculator.
- Explain why today's models are trained on far more data than the Chinchilla optimum, and know where scaling laws stop applying.

## The problem: with limited compute, how big a model should you train?

Training a large model easily consumes hundreds of thousands to millions of GPU hours, and there is almost no chance for a redo. Before you start you need to answer a few questions:

- With a fixed compute budget, how large should the model be and how many tokens should it see?
- Before a training run finishes, can its final loss be predicted?
- To lower the loss a little more, should you grow the model, add data, or add compute?

**Scaling laws** are the method of using regularities from small-scale experiments to predict the results of large-scale training. They are not strict theorems but empirical regularities confirmed again and again across many experiments.

## The empirical fact: loss falls as a power law with scale

OpenAI's 2020 study (Kaplan et al.; see the [paper breakdown](https://dmxsf.com/en/blog/scaling-laws-for-neural-language-models/)) found that, as long as nothing else is the bottleneck, the test cross-entropy loss $L$ follows an approximate power law in the **number of parameters $N$**, the **amount of data $D$** and the **training compute $C$**:

$$
L(N) = \left(\frac{N_c}{N}\right)^{\alpha_N},\qquad
L(D) = \left(\frac{D_c}{D}\right)^{\alpha_D},\qquad
L(C) = \left(\frac{C_c}{C}\right)^{\alpha_C}
$$

Here $N_c, D_c, C_c$ are fitted constants, and the exponents are about $\alpha_N \approx 0.076$, $\alpha_D \approx 0.095$ and $\alpha_C \approx 0.050$. These trends held across more than seven orders of magnitude of compute in their experiments.

A power law is a straight line on a log-log plot: every time the scale grows by a fixed factor, the loss is multiplied by a fixed factor. If the parameter count grows 10×, for example, the loss becomes about $10^{-0.076} \approx 0.84$ of what it was. This means two things: returns are **diminishing** (cutting the loss by the same fraction costs more and more resources), but they are also **stable and predictable**.

### Estimating training compute: C ≈ 6ND

For a dense Transformer, every parameter takes part in one multiply-add per token in the forward pass (about $2N$ FLOPs), and the backward pass costs about twice the forward pass (about $4N$), for a total of about $6N$ FLOPs per token. The total compute for training on $D$ tokens is

$$
C \approx 6\,N\,D
$$

This ignores the attention overhead that depends on sequence length, which matters little unless the sequences are very long. Let's check the estimate against Llama 2 7B:

```python
N, D = 6.74e9, 2.0e12     # Llama 2 7B: parameters and training tokens
C = 6 * N * D             # training compute ≈ 8.1e22 FLOPs
gpu_hours = 184_320       # A100-80GB GPU hours reported in the Llama 2 paper
peak = 312e12             # A100 BF16 dense peak (FLOPs/s)
mfu = C / (gpu_hours * 3600 * peak)
print(f"C = {C:.2e} FLOPs, MFU ≈ {mfu:.0%}")
# C = 8.09e+22 FLOPs, MFU ≈ 39%
```

The implied **MFU** (Model FLOPs Utilization, the fraction of hardware peak that goes into useful work) is about 39%, inside the 30%–50% range typical of large-scale training, which shows that $6ND$ is a quite reliable estimate. Which parameters count toward $N$, the attention term, how recomputation changes the FLOPs and the exact definition of MFU are covered in [The Compute and Memory Ledger of Training](https://dmxsf.com/en/wiki/pretraining/compute-and-memory/).

## From Kaplan to Chinchilla: how to split parameters and data

Given that loss falls with $N$ and $D$, the next question is: **at a fixed compute $C$, should the budget go more to parameters or to data?** The early conclusion and the later correction did not agree:

| | Kaplan et al. (2020) | Hoffmann et al. (2022, Chinchilla) |
| --- | --- | --- |
| Core conclusion | As compute grows, make the model bigger first | Parameters and data should grow in equal proportion |
| Optimal parameters | $N \propto C^{0.73}$ | $N \propto C^{0.5}$ |
| Optimal data | $D \propto C^{0.27}$ | $D \propto C^{0.5}$ |
| Representative model | GPT-3: 175B parameters, 300B tokens (about 1.7 tokens/parameter) | Chinchilla: 70B parameters, 1.4T tokens (20 tokens/parameter) |

DeepMind's Chinchilla study trained more than 400 models (from 70 million to over 16 billion parameters, on 5 billion to 500 billion tokens) to refit this law, and verified it experimentally: **Chinchilla, with 70B parameters and 1.4T tokens, used about the same compute as Gopher (280B parameters, 300B tokens) yet was clearly stronger on most evaluations.** The conclusion was that earlier large models were generally "undertrained": many parameters, but not enough data. Later analysis (Porian et al., 2024) attributes the disagreement between the two studies mainly to how parameters and compute were counted (whether the embedding and last-layer costs are included), the length of the learning-rate warmup, and whether the optimizer hyperparameters were tuned separately for each scale.

### A parametric loss formula

Chinchilla writes the loss as a function of parameters and data:

$$
L(N, D) = E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}}
$$

Each of the three terms has an intuitive meaning: $E$ is the **irreducible loss** (the randomness of natural language itself, which no model size or amount of data can remove); $A/N^{\alpha}$ is the loss caused by limited model capacity; $B/D^{\beta}$ is the loss caused by limited data. The larger the model, the smaller the second term; the more data, the smaller the third.

> [!NOTE] About the fitted coefficients
> The Chinchilla paper estimates the optimal ratio with three methods, and all conclude that "parameters and data should grow in roughly equal proportion". The coefficients that the paper gave for the third method (the parametric formula above) were later found by a replication study (Besiroglu et al., 2024) to be inconsistent with the first two. This page uses the coefficients corrected by the replication study, $E=1.8172$, $A=482.01$, $B=2085.43$, $\alpha=0.3478$, $\beta=0.3658$, which agree with the "about 20 tokens per parameter" conclusion. These coefficients only illustrate the trend; do not treat them as an exact prediction for your own data and architecture.

### Given a compute budget, what is the optimal split?

Minimize $L(N, D)$ under the constraint $6ND = C$. Substituting $D = C/(6N)$, differentiating with respect to $N$ and setting the derivative to zero gives a closed-form solution:

$$
N_{\text{opt}} = \left(\frac{\alpha A}{\beta B}\right)^{\frac{1}{\alpha+\beta}} \left(\frac{C}{6}\right)^{\frac{\beta}{\alpha+\beta}},
\qquad
D_{\text{opt}} = \frac{C}{6\,N_{\text{opt}}}
$$

$N_{\text{opt}}$ and $D_{\text{opt}}$ are proportional to $C^{\beta/(\alpha+\beta)}$ and $C^{\alpha/(\alpha+\beta)}$ respectively. When $\alpha \approx \beta$ both exponents are close to 0.5, which is where "parameters and data grow in equal proportion" comes from. Let's just compute it:

```python
E, A, B, alpha, beta = 1.8172, 482.01, 2085.43, 0.3478, 0.3658

def loss(N, D):
    return E + A / N**alpha + B / D**beta

def compute_optimal(C):
    """Given compute C, return the (parameters N, tokens D) that minimize the loss."""
    N = (alpha * A / (beta * B)) ** (1 / (alpha + beta)) * (C / 6) ** (beta / (alpha + beta))
    return N, C / (6 * N)

for C in [1e21, 1e22, 1e23, 5.76e23, 1e25]:
    N, D = compute_optimal(C)
    print(f"C={C:.2e}  N={N/1e9:7.1f}B  D={D/1e12:6.3f}T  D/N={D/N:5.1f}  loss={loss(N, D):.3f}")
```

Output:

| Training compute $C$ (FLOPs) | Optimal parameters $N$ | Optimal tokens $D$ | $D/N$ | Predicted loss |
| --- | --- | --- | --- | --- |
| $10^{21}$ | 2.8B | 0.06T | 21.6 | 2.306 |
| $10^{22}$ | 9.0B | 0.18T | 20.4 | 2.141 |
| $10^{23}$ | 29.4B | 0.57T | 19.2 | 2.032 |
| $5.76\times10^{23}$ (Gopher scale) | 72.2B | 1.33T | 18.4 | 1.974 |
| $10^{25}$ | 312.1B | 5.34T | 17.1 | 1.912 |

At Gopher-scale compute the optimum is about 72B parameters and 1.3T tokens, which is almost Chinchilla itself, and across the whole range $D/N$ stays around 20. This gives an easy rule of thumb: **about 20 training tokens per parameter**. Combined with $C \approx 6ND$, that is $C \approx 120N^2$, so the optimal parameter count is about $\sqrt{C/120}$.

Plotting the loss against the parameter count at fixed compute gives the "IsoFLOP curves" from the Chinchilla paper:

*Figure: IsoFLOP curves: fix the training compute C ≈ 6ND, vary the parameter count N (the number of training tokens D = C / 6N changes with it) and record the final loss. The curves are drawn from the Chinchilla parametric loss formula (with the coefficients from the replication study) and only illustrate the trend.*

Every curve is U-shaped: on the left the model is too small and capacity-limited; on the right the model is too large, and the same compute can feed it only a little data, so it is undertrained. The lowest point is the optimal parameter count for that budget, and the bigger the budget, the further right the optimum lies.

## Beyond the Chinchilla optimum: why today's models are trained so "excessively"

The Chinchilla optimum answers: **what is the least training compute needed to reach a given loss?** But after release a model will be called billions of times, and the inference cost per token is about $2N$ FLOPs, proportional to the parameter count. So the real total cost is

$$
\text{total cost} \approx \underbrace{6\,N\,D}_{\text{training}} + \underbrace{2\,N\,T_{\text{serve}}}_{\text{inference}}
$$

where $T_{\text{serve}}$ is the total number of tokens the model will generate or process during its lifetime. If the final loss is required to hit a fixed target (we take 2.0, purely for demonstration), what does the cheapest model look like for different amounts of traffic?

```python
import numpy as np

def tokens_needed(N, target):
    """Training tokens a model with N parameters needs to reach the target loss."""
    gap = target - E - A / N**alpha
    return (B / gap) ** (1 / beta) if gap > 0 else np.inf

def best_model(target, served_tokens):
    best = None
    for N in np.logspace(9, 12.5, 4000):
        D = tokens_needed(N, target)
        if np.isfinite(D):
            cost = 6 * N * D + 2 * N * served_tokens   # training + inference FLOPs
            if best is None or cost < best[0]:
                best = (cost, N, D)
    return best

for served in [0, 1e12, 1e13, 1e14, 1e15]:
    cost, N, D = best_model(target=2.0, served_tokens=served)
    print(f"served {served:.0e} tokens: N={N/1e9:5.1f}B  D={D/1e12:5.2f}T  D/N={D/N:5.0f}")
```

The output, tidied up:

| Expected total tokens served | Cheapest parameter count | Training tokens | Tokens / parameter |
| --- | --- | --- | --- |
| 0 (train only, no serving) | 46.9B | 0.88T | 19 |
| $10^{12}$ | 34.3B | 1.25T | 36 |
| $10^{13}$ | 20.0B | 3.01T | 150 |
| $10^{14}$ | 12.7B | 11.12T | 876 |
| $10^{15}$ | 9.6B | 50.60T | 5264 |

With zero traffic we recover the Chinchilla optimum (about 19 tokens per parameter); the more traffic, the more the best choice becomes a **smaller model trained on far more data than the "optimum"**. This calculation counts only FLOPs, whereas real inference is also affected by memory bandwidth, the KV cache (see [KV Cache and Inference Performance](https://dmxsf.com/en/wiki/inference/kv-cache/)) and batching efficiency, and the fitted formula is extrapolated at extreme token-to-parameter ratios, so treat it as a trend rather than exact numbers. But the direction matches industry practice exactly:

| Model | Parameters | Training tokens | Tokens / parameter |
| --- | --- | --- | --- |
| GPT-3 (2020) | 175B | 300B | about 1.7 |
| Chinchilla (2022) | 70B | 1.4T | 20 |
| LLaMA 7B (2023) | 7B | 1T | about 143 |
| Llama 2 7B (2023) | 7B | 2T | about 286 |
| Llama 3 8B (2024) | 8B | 15T | about 1,875 |

The LLaMA paper states its goal explicitly as "the best performance at a given **inference** budget", and so deliberately trains smaller models for longer (see the [LLaMA explainer](https://dmxsf.com/en/blog/llama-open-and-efficient-foundation-language-models/)). Later open models pushed the ratio even higher, and observed that the loss keeps falling even at data sizes far beyond the Chinchilla optimum.

## Using scaling laws in practice

A typical workflow is:

1. **Run a set of small experiments.** Pick a few small compute budgets and, for each budget, train models of several sizes (IsoFLOP experiments). Tune the learning rate and batch size separately for every size, or the curve will reflect hyperparameters instead of scale.
2. **Fit the curves.** Find the size with the lowest loss at each budget, or fit $L(N, D)$ directly.
3. **Extrapolate.** Use the fit to predict the optimal scale and final loss at the target compute.
4. **Compare during training.** During the real run, keep comparing the actual loss with the prediction; a deviation often points to a problem with data, learning rate or implementation. The GPT-4 technical report, for example, says the final loss could be predicted from models using no more than 1/1000 of GPT-4's compute.

Be restrained about extrapolation distance: a common rule of thumb is that extrapolating two or three orders of magnitude beyond the fitted range calls for special care.

## The limits of scaling laws

1. **Loss is not capability.** Loss falls smoothly, but downstream accuracy can seem to jump "suddenly" at some scale. Schaeffer et al. (2023) point out that many so-called "emergent" phenomena come from the choice of evaluation metric: with a continuous metric the curve is often smooth.
2. **Data is finite.** The total amount of high-quality text is limited, and the returns from repeating data diminish: Muennighoff et al. (2023) found that repeating data for up to about 4 epochs performs close to fresh data, after which the benefit decays quickly (the effective-data formula and a table computed from it are in [Pretraining Data Engineering](https://dmxsf.com/en/wiki/pretraining/data-engineering/)).
3. **Data quality can shift the whole curve.** With the same number of tokens, better filtering, deduplication and mixing lower the whole loss curve.
4. **MoE uses active parameters for compute.** The training compute of a sparse mixture-of-experts model should be estimated from the active parameters, $C \approx 6\,N_{\text{active}}\,D$; memory and communication are determined by the total parameter count. See [Modern LLM Architecture](https://dmxsf.com/en/wiki/architecture/modern-llm-architecture/).
5. **A new scaling dimension has appeared: inference-time compute.** Models such as o1 and DeepSeek-R1 spend compute on "thinking", and accuracy rises markedly after they generate a long chain of reasoning. Snell et al. (2024) found that on easier problems, spending extra compute at inference time can even beat a model 14 times larger. See [Reinforcement Learning for Reasoning: RLVR and GRPO](https://dmxsf.com/en/wiki/post-training/reasoning-rl/).

## Test extrapolation with a small budget

[CS336 Assignment 3](https://cs336.stanford.edu/#assignments) gives students a limited pilot budget to predict the configuration and validation loss at a larger budget. For self-study, hold out a larger compute tier and inspect it after fitting and selection.

1. **Find the optimum within each tier.** Sweep model size and adjust token count to keep compute comparable. If loss keeps decreasing all the way to a sweep boundary, test farther in that direction before treating the boundary as an optimum.
2. **Fit across tiers.** Use the estimated optima to fit model size and token budget. Record the fit range, model family, data, and learning-rate schedule. Refit on different ranges to see how stable the extrapolated optimum is.
3. **Check the predictions.** Record the predicted configuration, loss, and error tolerance before inspecting the held-out tier. A fixed-FLOP study should also report wall time or GPU-hours because communication and operator efficiency can change the actual cost.

## Summary and exercises

**Key points of this page:**

1. Loss falls as a power law in parameters, data and compute: predictable, but with diminishing returns.
2. Training compute can be estimated as $C \approx 6ND$, and MFU converts it to GPU hours.
3. Chinchilla concluded that parameters and data should grow in equal proportion, about 20 tokens per parameter.
4. Once inference cost is counted, the best choice is a smaller model with far more data than the "optimum", which explains why today's open models are trained on far more tokens than the Chinchilla ratio.
5. Scaling laws are a planning tool; their limits include the ceiling on data, data quality, evaluation metrics and inference-time compute.

### Quick self-check

**1. With the parameter exponent fitted by Kaplan et al. (about 0.076), by roughly what factor does the test loss change when you make the model 10 times larger?**

- [ ] 0.10
- [ ] 0.50
- [x] 0.84
- [ ] 0.92

> In a power law the loss is multiplied by 10 to the power −0.076, about 0.84. That shows the returns are diminishing: each further reduction of the loss by the same ratio costs more and more resources, yet the trend is stable and predictable.

**2. What is the main difference between Kaplan et al. (2020) and Chinchilla (2022) on how to split a fixed compute budget between parameters and data?**

- [ ] None, they reach the same conclusion at different model sizes
- [x] Kaplan says to favor making the model larger as compute grows, while Chinchilla says parameters and data should grow in equal proportion
- [ ] Kaplan says to favor more data, Chinchilla says to favor a larger model
- [ ] Chinchilla finds that neither parameters nor data matter, only compute does

> Kaplan's optimal parameter count is roughly proportional to C to the power 0.73 and the data to only the power 0.27; Chinchilla has about 0.5 for both. Later analysis attributes the difference mainly to how parameters and compute are counted, the length of the learning-rate warmup, and whether the optimizer hyperparameters were tuned separately for each scale.

**3. With the rules of thumb D≈20N and C≈6ND, about what is the optimal parameter count for a training budget of 1.2×10^21 FLOPs?**

- [ ] About 0.3B
- [x] About 3.2B
- [ ] About 10B
- [ ] About 32B

> Combining the two gives C≈120N², so N≈√(1.2×10^21/120)=√(10^19)≈3.2×10^9, with a matching data size of about 20N≈63B tokens.

**4. Llama 3 8B was trained on about 15T tokens, far beyond Chinchilla's 20 tokens per parameter. Why did Meta do it anyway?**

- [ ] Because Chinchilla's conclusion has been refuted
- [ ] Because more data always makes the model larger
- [x] Because the Chinchilla optimum only minimizes training compute; a released model serves a huge number of requests and inference cost is proportional to the parameter count, so training a smaller model for longer lowers the total cost
- [ ] Because 15T tokens is exactly the minimum data needed to train an 8B model

> The total cost is roughly 6ND for training plus 2N times the total number of served tokens for inference. The more is served, the more the best choice is a smaller model with far more than the optimal amount of data. The fitted formula is extrapolated at extreme token-per-parameter ratios, so read it as a trend.

**5. In Chinchilla's parametric loss L(N, D) = E + A/N^α + B/D^β, what does the constant E stand for?**

- [ ] The loss caused by limited model capacity
- [ ] The loss caused by limited data
- [x] The irreducible loss: the randomness of natural language itself, which no model size or amount of data can remove
- [ ] The upper limit of training compute

> The second term A/N^α is the loss caused by limited model capacity and the third term B/D^β the loss caused by limited data. The larger the model and the more the data, the smaller these two terms get, but the loss never goes below E.

**6. What does MFU (Model FLOPs Utilization), used when working back from the training efficiency, mean?**

- [ ] The share of GPU memory taken by the model parameters
- [x] The share of the hardware's peak compute that is actually useful, typically 30% to 50% in large-scale training
- [ ] The share of the dataset that the training tokens cover
- [ ] The utilization of the GPU's memory bandwidth

> The page estimates the training compute of Llama 2 7B as about 8.1×10^22 FLOPs with 6ND and, combined with the reported 184,320 A100 GPU hours, works back to an MFU of about 39%, inside the usual range, which shows that 6ND is a reliable estimate.

**Exercises:**

1. You have a budget of $10^{22}$ FLOPs. Estimate the optimal $N$ and $D$ from $D \approx 20N$ and $C \approx 6ND$.
2. How many FLOPs does it take to train a 7B model on 3T tokens? How many GPU hours does it take on H100s (BF16 dense peak about 989 TFLOPS) at 40% MFU?
3. Llama 3 8B was trained on 15T tokens, whereas 20 tokens per parameter would need only about 160B. Why did Meta still choose to train for so long?

<details>
<summary>Reference answers</summary>

1. From $C = 120N^2$ we get $N = \sqrt{10^{22}/120} \approx 9.1\times10^{9}$, i.e. about 9B parameters; $D = 20N \approx 1.8\times10^{11}$, i.e. about 180B tokens. This agrees with the $10^{22}$ row of the table above.
2. $C = 6 \times 7\times10^{9} \times 3\times10^{12} = 1.26\times10^{23}$ FLOPs. The effective throughput is $989\times10^{12}\times0.4 \approx 3.96\times10^{14}$ FLOPs/s, so the time needed is about $3.2\times10^{8}$ seconds, i.e. about 88,000 GPU hours.
3. Because after release the model serves a large number of requests and inference cost is proportional to the parameter count. Spending more training compute to train the small model for longer buys lower serving cost, and the loss keeps falling at data sizes far beyond the Chinchilla optimum.

</details>

## Further reading

- Kaplan et al., [Scaling Laws for Neural Language Models](https://arxiv.org/abs/2001.08361) (2020), with a [paper breakdown](https://dmxsf.com/en/blog/scaling-laws-for-neural-language-models/) that checks its numbers and what later work corrected
- Hoffmann et al., [Training Compute-Optimal Large Language Models](https://arxiv.org/abs/2203.15556) (2022), with a [paper breakdown](https://dmxsf.com/en/blog/chinchilla-training-compute-optimal-large-language-models/) that recomputes Table 3 and lists the paper's own inconsistencies
- Besiroglu et al., [Chinchilla Scaling: A replication attempt](https://arxiv.org/abs/2404.10102) (2024)
- Porian et al., [Resolving Discrepancies in Compute-Optimal Scaling of Language Models](https://arxiv.org/abs/2406.19146) (2024)
- Touvron et al., [LLaMA: Open and Efficient Foundation Language Models](https://arxiv.org/abs/2302.13971) (2023)
- Muennighoff et al., [Scaling Data-Constrained Language Models](https://arxiv.org/abs/2305.16264) (2023)
- Schaeffer et al., [Are Emergent Abilities of Large Language Models a Mirage?](https://arxiv.org/abs/2304.15004) (2023)
- Snell et al., [Scaling LLM Test-Time Compute Optimally can be More Effective than Scaling Model Parameters](https://arxiv.org/abs/2408.03314) (2024); [paper breakdown](https://dmxsf.com/en/blog/scaling-llm-test-time-compute-optimally-can-be-more-effective-than-scaling-model-parameters/): spending test-time compute by difficulty, and the FLOPs-matched comparison with a 14x larger model.
- How Llama 3 used IsoFLOPs curves to settle on 405B, and how sensitive the extrapolation is to rounding of the coefficients: see the [Llama 3 breakdown](https://dmxsf.com/en/blog/the-llama-3-herd-of-models/).

- Caballero et al., [Broken Neural Scaling Laws](https://arxiv.org/abs/2211.04325) (2023): smooth power laws break under data constraints, a framework for the post-Chinchilla corrections.
- Ruan et al., [Observational Scaling Laws](https://arxiv.org/abs/2405.10938) (2024): fits scaling curves from public benchmark scores alone, reinterpreting "emergence" with smooth power laws.
- Schaeffer et al., [Are Emergent Abilities of Large Language Models a Mirage?](https://arxiv.org/abs/2304.15004) (2023): explains "emergence" through metric choice, a reminder of how sensitive power-law fits are to the metric.

## Companion code

[Scaling laws: the formulas, the serving cost, and a tiny study of our own](https://github.com/dmxsf/dmxsf/tree/main/labs/pretraining/scaling-laws): The page's power laws and compute-optimal split recomputed, what serving cost does to the best model, a real tiny scaling study (tune the learning rate per size, train a grid, fit L(N, D), predict an unseen run), and what a 12-point fit can and cannot identify.

- Run it in the companion repository (add --quick for a fast pass): `uv run dmxsf run pretraining/scaling-laws`
- [View the lab script](https://github.com/dmxsf/dmxsf/blob/main/labs/pretraining/scaling-laws/run.py)
- [Lab write-up](https://github.com/dmxsf/dmxsf/blob/main/labs/pretraining/scaling-laws/README.en.md)
- [`scaling.py`](https://github.com/dmxsf/dmxsf/blob/main/src/dmxsf/pretraining/scaling.py)
- [`accounting.py`](https://github.com/dmxsf/dmxsf/blob/main/src/dmxsf/pretraining/accounting.py)
- [Find this lab in the catalog](https://dmxsf.com/en/code/#scaling-laws)

## FAQ

### What is the Chinchilla-optimal ratio of parameters to data?

Empirically about 20 training tokens per parameter (D ≈ 20N), together with the training-compute approximation C ≈ 6ND. In other words, every time compute grows 4×, parameters and data each grow roughly 2×. This ratio minimizes training compute and ignores inference cost.

### Why are models like Llama 3 trained on far more tokens than the Chinchilla optimum?

Because after release a model serves a huge number of requests, and inference cost is proportional to the parameter count. Training a smaller model for longer costs more compute during training but makes every inference cheaper; with enough traffic the total cost is lower. Llama 3 8B was trained on about 15T tokens, roughly 1,875 tokens per parameter.

### How do I estimate the compute and GPU hours needed to train a model?

The training compute of a dense model is about 6ND FLOPs (N parameters, D training tokens). Divide by the effective throughput of one GPU (peak FLOPs times model FLOPs utilization, MFU, which is typically 30%–50% in large-scale training) to get the GPU seconds required.

### Can scaling laws break down?

Within the range covered by many experiments, the power-law trend of loss versus scale has been confirmed again and again, but extrapolating to larger scales is always uncertain, and data quality, the ceiling on total data, the training recipe and new scaling dimensions (such as inference-time compute) all change the curve. Scaling laws should be treated as a planning tool, not as laws of nature.
