The Critical Sequence Length
· Paper (arXiv) · Code
A short summary of my paper, Critical Sequence Length: A Note on How Document Structure Bounds Gradient-Noise Reduction, on how sequence length, batch size and document structure shape gradient noise in LLM pre-training.
The rule of thumb
When you change the training sequence length of an LLM, there’s a standard way to adjust the batch. A batch of sequences, each tokens long, holds tokens. If every token is an independent sample of the gradient, the noise in each step scales as . So if you double , you halve , and the noise per step stays the same. That’s the rule most people use, and recent convergence analyses assume it too.
But tokens aren’t independent. Tokens in the same document share a topic, a style and a context, so their gradients point in similar directions. Averaging correlated samples helps less than averaging independent ones. Beyond some length, a longer sequence stops reducing the noise, while the rule keeps telling you to shrink the batch. You end up taking more optimizer steps, each one noisier, for the same number of tokens.
I wanted to know where that point is, what sets it, and what it means for training. So I measured it: about 15,000 gradient-covariance measurements on GPT-style models from 125M to 1B parameters, trained on two corpora that sit at opposite extremes. FineWeb-Edu is short web documents, about 1,100 tokens on average. Project Gutenberg is whole books, about 85,000 tokens each.
Two kinds of noise
Start from a simple model of each token’s gradient. Every token has its own noise, and tokens in the same sequence share a correlated part. Under a few mild assumptions, the total gradient noise at batch and sequence length comes out as
The first term is the per-token noise, , which averages away as just as the rule of thumb says. The second is a floor, , that comes from tokens in the same document pushing the gradient the same way. Averaging over more tokens can’t remove it.
The two terms are equal at the critical sequence length
Below , a longer sequence works like a bigger batch: each doubling roughly halves the noise. Above it, a longer sequence adds context but almost no new gradient signal. The per-token noise is roughly a thousand times larger than the floor, so sits at a few thousand tokens, which is right where modern pre-training runs operate.
The equation makes simple predictions you can check. Plotted against , the noise times should fall on a straight line, whose slope is the per-token noise and whose intercept is the floor. It does, in every FineWeb-Edu run, with at every scale. The noise also falls as , to within a few percent, from a single sequence up to .

The data sets the critical length
The two terms come from different places. The per-token noise is a general optimization quantity. The floor is specific to next-token training: it measures how correlated the gradients of tokens in the same document are. So should depend on the documents, and it does.
Books make the point clearly. A book is one long, coherent document, so even distant tokens share content. At 1B and a training length of 1,024 tokens, the floor is 5.3× higher on Gutenberg than on FineWeb-Edu, and the raw-gradient drops from about 2,100 to about 225. Same model, same training recipe; only the documents changed. Going the other way, cutting web documents into short pieces before training roughly halves the floor.
Measure it where AdamW lives
There’s a catch. The raw-gradient is fragile. It drifts through training, moves with the training length, differs by up to 10× between corpora, and its fit gets unreliable at long training lengths.
But AdamW doesn’t step along the raw gradient. It divides each coordinate by a running estimate of its size, . So I repeated the same decomposition on the update AdamW actually applies, reading straight from the saved optimizer state. That gives an AdamW-frame critical length, . It costs one extra weighted sum on the same measurements, and it’s far better behaved:
- It’s stable across model size. At the same budget it’s 833 at 350M and 796 at 1B.
- It settles early. It stays within about a factor of two after the first ~15% of training, so you can measure it once on an early checkpoint.
- It’s mostly stable across corpora. At 1B, the raw-gradient value differs by up to 9.5× between web text and books. The AdamW-frame value puts both in the same band.
- It stays in a narrow range. It falls between about 800 and 3,000 tokens in the well-trained runs, though it does grow with the training length.

In panels (a)–(c), each line is one training length, followed through training. After the first checkpoint or two they stay roughly level, while the raw-gradient value drifts several-fold over the same checkpoints. Panel (d) shows the final value against the training length: it rises with , and 350M and 1B nearly overlap. The 125M model sits higher, but it was trained on a smaller budget (10 tokens per parameter instead of 40), so it isn’t a like-for-like comparison.
The reason is that dividing by removes the overall scale of the gradients and keeps only how the noise is spread across parameters. A bigger model, a different corpus or a later checkpoint mostly rescales the gradients, which moves both raw terms together and drags the raw around. The AdamW frame divides that scale out.
What it means for training
Validation loss is lowest near . In every model-size and budget setting I trained, the best training length was within a factor of about 1.5 of . The minimum is shallow, though. Going past it raised the loss by less than 0.07 nats, and at 1B the loss was almost flat across an 8× range of lengths.
Downstream scores are more fragile than the loss. On a short-document corpus, a long training sequence is a stack of unrelated documents. I count them with , the average number of document boundaries per sequence. On FineWeb-Edu, goes from 0 at 1,024 tokens to about 6 at 8,192 and 14 at 16,384.

Packing more documents into each sequence barely moves the loss (a): even at it’s at most 0.07 nats above the best run, and at 1B it’s under 0.02. The 1B benchmark average, over MMLU, HellaSwag and ARC, drops about 2.6 points from to (b, blue). That’s modest, but bigger than the loss suggests. Chopping documents into short pieces, by inserting an end-of-text token every tokens before training, is far worse: the benchmark average falls to chance (b, red), while the validation loss of those 1B models changes by only a few percent. Chopping also breaks documents into incoherent fragments, so not all of that collapse is due to itself. Still, a packing choice that looks harmless on the loss curve can damage what the model can do.
Intra-document attention masking fixes the packing problem. If tokens can only attend within their own document, stays near 1,000 at every training length instead of growing with the number of packed documents. Masking also lowered the loss at every length, by up to 0.17 nats where packing mixes the most documents.
Stop shrinking the batch once you pass . To keep the update noise fixed when the sequence length changes, follow the usual trade only up to the critical length, then hold the batch:
Take a 1B model tuned at and , with , moved to . The rule of thumb quarters the batch to 128. The regime-aware rule gives , about half as many optimizer steps for the same tokens.

In short
- Measure once, on a checkpoint about 15% of the way into training, at the training length you plan to use.
- Spend most of training near it. Go longer when the model needs a long context window, not to cut gradient noise.
- Fill long sequences with genuinely long documents, or mask attention across documents, and track downstream scores as well as loss.
- Past , keep the batch where it is.
- Measure again whenever the data mix changes, for example at annealing or long-context extension.
These results have limits. The models reach 1B parameters, with one architecture family, AdamW and a cosine schedule. I used two single-source corpora, not a real pre-training mix. Most runs use one seed, and I haven’t yet tested the batch rule end to end in a full training run. The full paper has the derivation, the fit details and the robustness checks. The code is on GitHub.
Citation
@misc{guha2026critical,
title = {Critical Sequence Length: A Note on How Document Structure
Bounds Gradient-Noise Reduction},
author = {Guha, Sunny},
year = {2026},
eprint = {2612.03183},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2612.03183}
}