Swapping 1% of a Pretraining Batch Can Inflate the Gradient ~300×
bremen79 · x · 2026-12-02
Blogger bremen79 published a new post, "How Much of a Batch Does It Take to Change the Gradient?" (with code), and broke down the experiments in a 9-part thread:
- At update 2507 of an LLM training run, the gradient spiked. Inspecting the batch revealed a long stretch of DNA from a patent application — in a batch of roughly 500K tokens.
- Controlled experiment: running the same update twice from identical model and optimizer state, replacing the 26 windows containing DNA (5% of the batch) with ordinary text from the same batch showed keeping the DNA made the gradient norm 2.8× larger.
Takeaway: replacing just 1% of a pretraining batch can inflate the gradient 300× with almost no change in loss — an empirical, reproducible finding relevant to data mixing and gradient-spike debugging.
Related event: Orabona: Replacing 1% of a Batch Can Amplify Gradients ~300x(3 posts)→
More from Research
- Nature MI paper: closed multi-agent LLM loops narrow ideas instead of exploring — profjamesevans · 2026-12-02
- Training postmortem: even clean data can produce gradient spikes that become loss spikes — bremen79 · 2026-12-02
- Gradient spikes exposed garbled text in the FineWeb dataset — bremen79 · 2026-12-02
- 5% readable-text replacement doubles gradient norm on Pythia 1B, thread finds — bremen79 · 2026-12-02
- A single 'with with with' inflates OLMo 1B gradient norms 330x — bremen79 · 2026-12-02
- Readable Text Works Too: 'With With With' Inflates OLMo Gradients 330× — bremen79 · 2026-12-02