Efficient Sequence Packing without Cross-contamination: Accelerating Large Language Models without Impacting Performance
Not on the map. Why?
Abstract (arXiv)
Effective training of today's large language models (LLMs) depends on large batches and long sequences for throughput and accuracy. To handle variable-length sequences on hardware accelerators, it is common practice to introduce padding tokens, so that all sequences in a batch have the same length. We show in this paper that the variation in sequence lengths in common NLP datasets is such that up to 50% of all tokens can be padding. In less common, but not extreme, cases (e.g. GLUE-cola with sequence length 128), the ratio is up to 89%. Existing methods to address the resulting inefficiency are complicated by the need to avoid cross-contamination in self-attention, by a reduction in accuracy when sequence ordering information is lost, or by customized kernel implementations only valid for specific accelerators. This paper introduces a new formalization of sequence packing in the context of the well-studied bin packing problem, and presents new algorithms based on this formulation which, for example, confer a 2x speedup for phase 2 pre-training in BERT. We show how existing models can be adapted to ensure mathematical equivalence between the original and packed models, meaning that packed models can be trained with existing pre-training and fine-tuning practices.
Key facts. Cited by 8 papers in the map (data through 7 Oct 2026). Builds on 4 of its 26 references that are in the map. First posted on arXiv 29 Jun 2021.
Builds on
4 of 26 references.
References · 4
- 2019ALBERT: A Lite BERT for Self-supervised Learning of Language Representationscited by 2,772
- 2018Neural Network Acceptability Judgmentscited by 952
- 2019Well-Read Students Learn Better: On the Importance of Pre-training Compact Modelscited by 118
- 2019Dissecting the Graphcore IPU Architecture via Microbenchmarkingcited by 47
Built on by
Citing papers per year: 2023: 1; 2024: 2; 2025: 3; 2026: 2.
8 papers.
- 2023Orca 2: Teaching Small Language Models How to Reasoncited by 157
- 2025Eagle 2: Building Post-Training Data Strategies from Scratch for Frontier Vision-Language Modelscited by 69
- 2024Unleashing LLM Reasoning Capability via Scalable Question Synthesis from Scratchcited by 24
- 2026Scalable Training of Mixture-of-Experts Models with Megatron Corecited by 16
- 2026Scaling Mixture-of-Experts Video Pretraining for Embodied Intelligencecited by 13
- 2025Taming the Long-Tail: Efficient Reasoning RL Training with Adaptive Draftercited by 12
- 2024Mixture-of-Instructions: Aligning Large Language Models via Mixture Promptingcited by 4
- 2025A Survey of LLM × DATAcited by 4
- 2026Scaling Mixture-of-Experts Video Pretraining for Embodied Intelligence8 Jul 2026
- 2026Scalable Training of Mixture-of-Experts Models with Megatron Core8 Mar 2026
- 2025Taming the Long-Tail: Efficient Reasoning RL Training with Adaptive Drafter20 Nov 2025
- 2025A Survey of LLM × DATA24 May 2025
- 2025Eagle 2: Building Post-Training Data Strategies from Scratch for Frontier Vision-Language Models20 Jan 2025
- 2024Unleashing LLM Reasoning Capability via Scalable Question Synthesis from Scratch24 Oct 2024
- 2024Mixture-of-Instructions: Aligning Large Language Models via Mixture Prompting29 Apr 2024
- 2023Orca 2: Teaching Small Language Models How to Reason18 Nov 2023