Critical Sequence Length: A Note on How Document Structure Bounds Gradient-Noise Reduction
Abstract
Gradient noise in large language model pretraining decreases with sequence length only up to a data-dependent critical length, beyond which longer sequences add context without reducing noise, shaping batch-size and sequence-length trade-offs.
LLM pre-training commonly treats every token in a training sequence as an independent sample of the gradient. Under this assumption, gradient noise scales as 1/(BS) for batch size B and sequence length S, so B is halved whenever S is doubled. We show that this rule breaks down beyond a certain length, and that the point where it breaks down can be measured. Guided by a simple model of how gradient noise arises in next-token training, we split the noise into two parts: a per-token term that averages away as 1/S, and a floor, caused by correlations between tokens of the same document, that does not. The two meet at a critical sequence length S*. Below it, longer sequences reduce gradient noise; above it, they add context but barely reduce the noise. We test this picture on GPT models from 125M to 1B parameters, trained on short web documents (FineWeb-Edu) and on whole books (Project Gutenberg), and find that it fits well, with informative exceptions on books and on artificially chopped data. Three findings stand out. First, S* is set by the data: it depends on the documents and on how they are packed into sequences, and chopping documents into short pieces halves the floor. Second, the critical length measured on the updates that AdamW actually applies is largely stable across model sizes and training time (and, at 1B, across corpora) and grows only with the training length, whereas the raw-gradient version varies widely. Third, validation loss is lowest when training near this length and changes little beyond it, but downstream performance is more fragile: it drops modestly as more documents are packed into each sequence and collapses when documents are chopped into short pieces. Intra-document attention masking keeps the critical length stable under heavy packing and lowers the loss. These results lead to a simple, regime-aware rule for trading batch size against sequence length.
Community
An empirical note on how gradient noise in LLM pre-training depends on batch size versus sequence length.
The usual rule treats every token as an independent gradient sample: double the sequence length, halve the batch, and the noise per step stays the same. We find this holds only up to a critical sequence length S*. Tokens from the same document have correlated gradients, so beyond S* a longer sequence adds context but barely reduces the noise.
Main findings (GPT models from 125M to 1B, trained on FineWeb-Edu and Project Gutenberg):
- Gradient noise splits into a per-token term that falls as 1/S and a within-document floor that doesn't. The two meet at S*.
- S* is set by the data: how long the documents are and how they're packed into sequences.
- Measured on the updates AdamW actually applies, S*_adam is stable across model size and training time, at roughly 800–3,000 tokens.
- Validation loss is lowest near S*_adam. Downstream scores are more fragile than the loss when many short documents are packed into each sequence.
- Practical rule: halve the batch when you double S only up to S*_adam, then hold it fixed.
Blog post with the main figures: https://www.sunnyguha.com/blog/critical-sequence-length/
This is an automated message from the Librarian Bot. I found the following papers similar to this paper.
The following papers were recommended by the Semantic Scholar API
- What Is a Repeated Token Worth? The Scaling Geometry of Multi-Epoch Pretraining (2026)
- What a Weight Update Buys: Leverage Across Training Stages (2026)
- Benefit and Cost of Random-Token Replacement under Repeated Data: A Known-Entropy Decomposition and Evidence from Ten Real Corpora (2026)
- How Far Does Lossless Re-tokenization Move an RLVR Update? (2026)
- What the Loss Curve Misses: FP4 Pretraining Slows the Acquisition of Rare Facts (2026)
- Attention Temperature Confounds Zero-Shot Context Extension (2026)
- Selective Weight Decay Opens Two Mismatches Between a Language Model and Its Embedding Table (2026)
Please give a thumbs up to this comment if you found it helpful!
If you want recommendations for any Paper on Hugging Face checkout this Space
You can directly ask Librarian Bot for paper recommendations by tagging it in a comment: @librarian-bot recommend
Models citing this paper 0
No model linking this paper
Datasets citing this paper 0
No dataset linking this paper
Spaces citing this paper 0
No Space linking this paper