Adjoint sharding for very long context training of state space models
Not on the map. Why?
Abstract (arXiv)
Despite very fast progress, efficiently training large language models (LLMs) in very long contexts remains challenging. Existing methods fall back to training LLMs with short contexts (a maximum of a few thousands tokens in training) and use inference time techniques when evaluating on long contexts (above 1M tokens context window at inference). As opposed to long-context-inference, training on very long context input prompts is quickly limited by GPU memory availability and by the prohibitively long training times it requires on state-of-the-art hardware. Meanwhile, many real-life applications require not only inference but also training/fine-tuning with long context on specific tasks. Such applications include, for example, augmenting the context with various sources of raw reference information for fact extraction, fact summarization, or fact reconciliation tasks. We propose adjoint sharding, a novel technique that comprises sharding gradient calculation during training to reduce memory requirements by orders of magnitude, making training on very long context computationally tractable. Adjoint sharding is based on the adjoint method and computes equivalent gradients to backpropagation. We also propose truncated adjoint sharding to speed up the algorithm while maintaining performance. We provide a distributed version, and a paralleled version of adjoint sharding to further speed up training. Empirical results show the proposed adjoint sharding algorithm reduces memory usage by up to 3X with a 1.27B parameter large language model on 1M context length training. This allows to increase the maximum context length during training or fine-tuning of a 1.27B parameter model from 35K tokens to above 100K tokens on a training infrastructure composed of five AWS P4 instances.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 40 of its 54 references that are in the map. First posted on arXiv 1 Jan 2025.
Builds on
40 of 54 references.
References · 40
- 2015Deep Residual Learning for Image Recognitioncited by 51,809
- 2023Segment Anythingcited by 8,158
- 2022Scalable Diffusion Models with Transformerscited by 5,931
- 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,616
- 2018Neural Ordinary Differential Equationscited by 3,733
- 2022FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awarenesscited by 3,611
- 2020Longformer: The Long-Document Transformercited by 3,362
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,551
- 2023Efficient Streaming Language Models with Attention Sinkscited by 2,115
- 2024Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Dualitycited by 1,283
- 2019ZeRO: Memory Optimizations Toward Training Trillion Parameter Modelscited by 1,278
- 2017Mixed Precision Trainingcited by 1,135
28 more
- 2015Automatic differentiation in machine learning: a surveycited by 846
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 721
- 2021Combining Recurrent, Convolutional, and Continuous-time Models with Linear State-Space Layerscited by 607
- 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 584
- 2024FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precisioncited by 507
- 2022Hungry Hungry Hippos: Towards Language Modeling with State Space Modelscited by 495
- 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 448
- 2023Resurrecting Recurrent Neural Networks for Long Sequencescited by 397
- 2019Augmented Neural ODEscited by 396
- 2021ZeRO-Offload: Democratizing Billion-Scale Model Trainingcited by 339
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 302
- 2021Focal Self-attention for Local-Global Interactions in Vision Transformerscited by 286
- 2021Attention Mechanisms in Computer Vision: A Surveycited by 232
- 2024World Model on Million-Length Video And Language With Blockwise RingAttentioncited by 196
- 2019A Survey on Distributed Machine Learningcited by 187
- 2024An Empirical Study of Mamba-based Language Modelscited by 177
- 2023Focused Transformer: Contrastive Training for Context Scalingcited by 133
- 2022How to Train Your HiPPO: State Space Models with Generalized Orthogonal Basis Projectionscited by 121
- 2022Fast Finite Width Neural Tangent Kernelcited by 62
- 2024MoE-Mamba: Efficient Selective State Space Models with Mixture of Expertscited by 60
- 2017Unbiasing Truncated Backpropagation Through Timecited by 37
- 2024BlackMamba: Mixture of Experts for State-Space Modelscited by 37
- 2024Cut Your Losses in Large-Vocabulary Language Modelscited by 35
- 2022Simplifying and Understanding State Space Models with Diagonal Linear RNNscited by 23
- 2019Optimal checkpointing for heterogeneous chains: how to train deep neural networks with limited memorycited by 22
- 2024Mini-Sequence Transformer: Optimizing Intermediate Memory for Long Sequences Trainingcited by 6
- 2021Fast Jacobian-Vector Product for Deep Networkscited by 4
- 2023The Backpropagation algorithm for a math studentcited by 2
Built on by
Not cited yet.
Similar, not cited
Close in wording, no citation either way
- 2025InfiniteHiP: Extending Language Model Context Up to 3 Million Tokens on a Single GPU
- 2024A Little Goes a Long Way: Efficient Long Context Training and Inference with Partial Contexts
- 2025Generalizing From Short to Long: Effective Data Synthesis for Long-Context Instruction Tuning
- 2024Discovering the Gems in Early Layers: Accelerating Long-Context LLMs with 1000x Input Token Reduction
- 2026DepthKV: Layer-Dependent KV Cache Pruning for Long-Context LLM Inference
- 2025From 128K to 4M: Efficient Training of Ultra-Long Context Large Language Models
- 2025MOM: Memory-Efficient Offloaded Mini-Sequence Inference for Long Context Language Models
- 2025Pruning Laws for Large Language Models