NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Distilling to Hybrid Attention Models via KL-Guided Layer Selection

Yanhong Li, Songlin Yang, Shawn Tan, Mayank Mishra, Rameswar Panda, Jiawei Zhou, Yoon Kim · DOI

Abstract

Standard Large Language Models (LLMs) rely on softmax attention, which suffers from quadratic computational complexity relative to sequence length. While linear attention and State Space Models (SSMs) offer constant-memory decoding, they frequently fail at associative recall tasks. This paper presents a novel methodology for constructing hybrid models that strategically interleave a small number of softmax layers within a predominantly linear architecture. By employing a KL-divergence-based importance score, we identify critical layers for retention, achieving state-of-the-art performance on long-context benchmarks while maintaining the efficiency of linear models.

The Problem: The Efficiency-Recall Trade-off

As sequence lengths in modern AI applications grow, the $O(N^2)$ cost of standard Transformers becomes a primary bottleneck. Linear attention mechanisms provide a scalable alternative but struggle with "associative recall"—the ability to retrieve specific information from distant parts of a context. Hybrid architectures, which combine both attention types, offer a promising middle ground. However, identifying which layers should remain as softmax attention has previously relied on sub-optimal heuristics, such as uniform interleaving, or expensive task-specific evaluations.

Methodology: KL-Guided Layer Selection (GA-S2)

We propose KL-Guided Layer Selection (GA-S2), a principled, unsupervised recipe for determining layer importance. The process involves three stages:

  1. Initial Distillation: A pure softmax "teacher" model is distilled into an all-linear "student" using hidden state alignment and distribution matching.
  2. Importance Scoring: We conduct a "one-swap" experiment. For each layer in the all-linear student, we temporarily restore the teacher's original softmax attention and perform brief finetuning on generic text. We then measure the resulting reduction in KL-divergence between the student and teacher outputs.
  3. Greedy Selection: Layers are ranked by their KL-reduction scores, and the top-$K$ layers are selected to remain as softmax in the final hybrid model.

This approach is notably efficient as it utilizes generic text (DCLM mixture) rather than specialized datasets and the importance rankings stabilize early in the training process.

The Recall-Reasoning Dichotomy

A key finding of this work is the distinct behavior of different task types. "Reasoning" tasks (logic, general knowledge) are handled effectively by linear attention; even models with zero softmax layers perform well on standard commonsense benchmarks. Conversely, "recall" tasks are highly sensitive to layer selection.

Performance dichotomy between recall (RULER) and reasoning (Common Sense) as softmax layers are added.

As shown in the figure above, while Common Sense accuracy remains relatively flat regardless of the number of full-attention layers, RULER performance (a proxy for recall) scales sharply as critical layers are restored to softmax attention.

Key Results and Performance

Our GA-S2 method consistently outperforms standard heuristics across multiple model families, including Llama-3.2 and Qwen2.5. On the RULER benchmark, which tests information retrieval up to 32k tokens, the GA-S2 selection strategy significantly exceeds the performance of uniform interleaving.

Comparison of layer selection strategies on the RULER benchmark across different softmax-to-linear ratios.

For a Qwen2.5-3B model with only 12.5% softmax layers, GA-S2 achieved a score of 0.662, compared to 0.441 for the uniform approach. Furthermore, in Needle-in-a-Haystack tests, our distilled hybrid models maintained near-perfect retrieval accuracy up to 65k tokens, closely matching the performance of the original all-softmax teacher models.

Conclusion

By moving beyond simple heuristics to a principled KL-guided selection process, we can create hybrid models that capture the best of both worlds: the reasoning and recall capabilities of Transformers with the inference efficiency of linear models. Future work will explore finer-grained selection at the head level and investigate the impact of specialized training data on layer importance maps.

Summary updated

BibTeX
@inproceedings{li2026distilling,
  author = {Yanhong Li and Songlin Yang and Shawn Tan and Mayank Mishra and Rameswar Panda and Jiawei Zhou and Yoon Kim},
  title = {{Distilling to Hybrid Attention Models via KL-Guided Layer Selection}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=RzbsHcFqIf},
}
Figure