Sequence Accumulation and Beyond: Infinite Context Length on Single GPU and Large Clusters

Authors

  • Weigao Sun Shanghai AI Laboratory
  • Yongtuo Liu University of Amsterdam
  • Xiaqiang Tang The Hong Kong University of Science and Technology (Guangzhou)
  • Xiaoyu Mo Nanyang Technological University

DOI:

https://doi.org/10.1609/aaai.v39i19.34284

Abstract

Linear sequence modeling methods, such as linear attention, state space modeling, and linear RNNs, have recently been recognized as potential alternatives to softmax attention thanks to their linear complexity and competitive performance. However, although their linear-memory advantage during training enables dealing with long sequences, it is still hard to handle extremely long sequences with very limited computational resources. In this paper, we propose Sequence Accumulation (SA) which leverages the common recurrence feature of linear sequence modeling methods to manage infinite context length even on a single GPU. Specifically, SA divides long input sequences into fixed-length sub-sequences and accumulates intermediate states sequentially, which reaches only constant-memory consumption. Additionally, we further propose Sequence Accumulation with Pipeline Parallelism (SAPP), to train large models with infinite context length, without incurring any additional synchronization costs in the sequence dimension. Extensive experiments with a wide range of context lengths are conducted to validate the effectiveness of SA and SAPP on both single and multiple GPUs. Results show that SA and SAPP enable the training of infinite context length on even very limited resources, and are well compatible with the out-of-the-box distributed training techniques.

Downloads

Published

2025-04-11

How to Cite

Sun, W., Liu, Y., Tang, X., & Mo, X. (2025). Sequence Accumulation and Beyond: Infinite Context Length on Single GPU and Large Clusters. Proceedings of the AAAI Conference on Artificial Intelligence, 39(19), 20725–20733. https://doi.org/10.1609/aaai.v39i19.34284

Issue

Section

AAAI Technical Track on Machine Learning V