SWAN-GPT: An Efficient and Scalable Approach for Long-Context Language Modeling
Krishna C. Puvvada, Faisal Ladhak, Santiago Akle Serrano, Cheng-Ping Hsieh, Shantanu Acharya, Somshubra Majumdar, Fei Jia, Samuel Kriman, Simeng Sun, Dima Rekesh, Boris Ginsburg
TL;DR
SWAN-GPT tackles the long-context problem by showing that a decoder-only Transformer can robustly extrapolate to sequences far longer than its training length. It achieves this with a hybrid architecture that interleaves NoPE global attention and SWA-RoPE local attention, plus a dynamic, logarithmic scaling of attention logits to sustain performance at extreme lengths. The authors provide mechanistic evidence via position-probing and attention-pattern analyses, and demonstrate practical value by converting pre-trained RoPE models to SWAN with only continued pre-training. The results indicate strong long-context performance with competitive short-context benchmarks and a cost-efficient upgrade path for existing models.
Abstract
We present a decoder-only Transformer architecture that robustly generalizes to sequence lengths substantially longer than those seen during training. Our model, SWAN-GPT, interleaves layers without positional encodings (NoPE) and sliding-window attention layers equipped with rotary positional encodings (SWA-RoPE). Experiments demonstrate strong performance on sequence lengths significantly longer than the training length without the need for additional long-context training. This robust length extrapolation is achieved through our novel architecture, enhanced by a straightforward dynamic scaling of attention scores during inference. In addition, SWAN-GPT is more computationally efficient than standard GPT architectures, resulting in cheaper training and higher throughput. Further, we demonstrate that existing pre-trained decoder-only models can be efficiently converted to the SWAN architecture with minimal continued training, enabling longer contexts. Overall, our work presents an effective approach for scaling language models to longer contexts in a robust and efficient manner.
