LinearARD: Linear-Memory Attention Distillation for RoPE Restoration
Ning Yang, Hengyu Zhong, Wentao Wang, Baoliang Tian, Yuan Zhou, Haijun Zhang, Jun Wang
NeurIPS page · OpenReview · alphaXiv · Open on the map
Category: Efficient LLM Inference & Training › Attention Optimization and Retrieval · Type: new method · Keywords: attention distillation, linear memory, RoPE restoration, large language models, context window extension
Areas: Long Context › Long-context mechanisms › Efficient attention
Summary
LinearARD is a linear-memory attention distillation method that restores RoPE-scaled language models by aligning attention dynamics with a frozen native-RoPE teacher, achieving near-native performance using only 4.25M tokens.
Explained to a 5-year-old
Big computer programs called language models can read and write text. When we want them to remember many words at once, we usually give them a lot of practice with long texts. This practice needs a huge amount of data and a lot of computer time. The researchers found a smarter way to help the models remember long sentences without needing as much practice. They created a special teacher model that already knows how to pay attention, and they used it to guide the student model so it pays attention the same way.
Explained to a 5-year-old, longer
Big computer programs called language models can read and write text. When we want them to remember many words at once, we usually give them a lot of practice with long texts. This practice needs a huge amount of data and a lot of computer time. The researchers found a smarter way to help the models remember long sentences without needing as much practice. They created a special teacher model that already knows how to pay attention, and they used it to guide the student model so it pays attention the same way. The student model learns by matching how its attention is organized, focusing on the patterns of its own questions, keys, and values. To keep the memory usage low, they store only a small amount of information for each word instead of a huge table. This small storage lets the model still compute exact differences between the teacher and student using a clever math trick. The new method works on several popular language models and lets them understand long texts almost as well as before, but it uses far fewer training examples. This makes it possible to run powerful language models on less powerful computers and with less data.
For a technical reader
The method distills a frozen native-RoPE teacher to restore RoPE-scaled students by aligning row-wise distributions of Q, K, V self-relation matrices from the final attention layer. A linear-memory kernel stores per-token log-sum-exp statistics, recomputing logits in the backward pass to obtain exact KL gradients, eliminating the quadratic memory bottleneck. Experiments on LLaMA2-7B, LLaMA3-8B, and Mistral-7B-v0.1 show near-native performance recovery with only 4.25M tokens, a ~60× reduction versus baseline continued pre-training, and strong RULER scores while baselines fail under the same budget.
Problem
Extending context windows in large language models by scaling positional encodings requires massive long-text corpora for continued pre-training, which is data-hungry and computationally expensive.
Method
The approach uses self-distillation with a frozen native-RoPE teacher to align row-wise distributions of Q, K, V self-relation matrices from the final attention layer, employing a linear-memory kernel that stores per-token log-sum-exp statistics and recomputes logits during back-propagation to obtain exact KL gradients.
Results
The approach recovers 93.1%/94.2%/94.3% of native short-context performance on LLaMA2-7B, LLaMA3-8B, and Mistral-7B-v0.1 extended to 32K context and achieves strong long-context robustness on RULER using only 4.25M tokens, which is about 1.6% of the 256M-token budget required by baselines. Under this budget, CPT and LongReD remain near zero on RULER.
Contributions
The paper introduces a linear-memory attention distillation technique that aligns attention dynamics via row-wise distribution matching, enabling efficient restoration of RoPE-scaled models with drastically reduced data requirements. It also demonstrates that relation-level restoration yields a far better efficiency-quality trade-off compared to continued pre-training and prior distillation methods.
Practical relevance
It offers a much more efficient way to extend model context, reducing data and compute requirements while preserving performance.
Research questions this paper is counted under
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction