LAWCAT: Efficient Distillation from Quadratic to Linear Attention with Convolution across Tokens for Long Context Modeling

Zeyu Liu, Souvik Kundu, Lianghao Jiang, Anni Li, Srikanth Ronanki, Sravan Bodapati, Gourav Datta, Peter A. Beerel · DOI

Introduction

Standard Transformer models rely on softmax self-attention, which scales quadratically ($O(N^2)$) with sequence length. This creates a massive computational and memory bottleneck for latency-sensitive, long-context applications. While modern linear attention architectures (like Mamba or Gated Linear Attention) solve the complexity issue, training them from scratch requires billions of tokens and massive compute resources.

LAWCAT (Linear Attention with Convolution Across Time) addresses this challenge by efficiently distilling existing pre-trained quadratic transformers into linear models. This framework retains strong reasoning and retrieval capabilities across extended context windows while using minimal training data and compute.

Methodology: The LAWCAT Framework

Instead of training from scratch, LAWCAT distills models like Llama 3.2 and Mistral using a two-stage process: layer-wise MSE loss to match linear attention outputs to the teacher's softmax outputs, followed by LoRA fine-tuning. To bridge the architectural gap between softmax and linear attention, LAWCAT introduces two key modifications:

  1. Causal Conv1D Layer: Before queries and keys interact, they pass through a causal depthwise 1D convolution. This bakes in a strong inductive bias for local dependencies, mimicking the way softmax attention naturally groups and amplifies locally coherent patterns.
  2. Normalized Gated Linear Attention (GLA): Unlike some recent linear models that drop the normalization denominator, LAWCAT retains it. This normalization is critical for preventing attention dilution and allows the model to generalize to sequence lengths far beyond its training data.
Architecture of the Gated Linear Attention with Normalization and Causal Conv1D layers used in LAWCAT.

Key Results and Length Generalization

The primary breakthrough of LAWCAT is its ability to generalize to long contexts despite being distilled on very short (1K token) sequences.

Accuracy vs. Context Length for Llama and Mistral models, comparing LAWCAT against baselines and LoLCATs.

As shown in the evaluation, a Mistral-7B model distilled with LAWCAT maintained >90% passkey retrieval accuracy up to 22K tokens, far exceeding the original model's 8K limit. In contrast, prior distillation work (LoLCATs) suffered from a major flaw: failing to generalize to sequence lengths longer than what they saw during the distillation process.

On more complex tasks like BABILong (multi-hop reasoning), LAWCAT consistently doubled the accuracy of the baseline Llama 3.2 1B model across context lengths from 0K to 32K. This performance is achieved with extreme data efficiency, using less than 0.1% of the tokens typically required for pre-training models from scratch.

Efficiency and Latency

Beyond accuracy, LAWCAT provides significant computational benefits. For sequences longer than 8K tokens, LAWCAT exhibits faster prefill latency than highly optimized FlashAttention-2 implementations. By removing Rotary Position Embeddings (RoPE), which the authors found introduced rigid length-based biases, the recurrent formulation of linear attention naturally captures sequence order more effectively for long contexts.

Conclusion

LAWCAT demonstrates that integrating local convolutions and proper normalization into the distillation process allows linear attention models to inherit the power of quadratic teachers while overcoming their scaling limitations. This provides a highly efficient, low-latency solution for deploying long-context LLMs on edge devices without the massive compute costs of traditional training.

Summary updated

BibTeX
@misc{liu2025lawcat,
  author = {Zeyu Liu and Souvik Kundu and Lianghao Jiang and Anni Li and Srikanth Ronanki and Sravan Bodapati and Gourav Datta and Peter A. Beerel},
  title = {{LAWCAT: Efficient Distillation from Quadratic to Linear Attention with Convolution across Tokens for Long Context Modeling}},
  year = {2025},
  eprint = {2509.18467},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.18467},
}
Figure