On-Policy Morphing into Hybrid Attention Models

Disen Lan, Xuanda Wang, Jianbin Zheng, Huafeng Kuang, Wei Tang, Yu ChengarXiv 2026

TL;DR

FlashMorph2 is a new "on-policy" method for converting pretrained Transformers into efficient hybrid attention models (combining full and linear attention). By sampling discrete architectures and jointly optimizing layer selection with weight adaptation, it bridges the gap between selection-time evaluation and post-recovery performance, outperforming previous methods on long-context benchmarks while remaining highly efficient.

What Problem Does This Paper Address?

Standard Transformers suffer from $O(T^2)$ computational and memory complexity due to their self-attention mechanism, making them slow and expensive for long sequences. Hybrid attention models offer a solution by keeping full attention in only a few critical layers and using efficient linear attention elsewhere.

The challenge lies in layer selection: which layers should stay "full" and which should be "linearized"? Previous state-of-the-art methods like FlashMorph used "off-policy" selection. This means they evaluated layer importance using continuous interpolation (mixing both branches) and teacher-forced hidden states with frozen weights. This creates a mismatch: the model used to select layers doesn't behave like the final deployed model, which uses discrete branches, generates its own hidden states, and has adapted weights.

Figure 1. Comparison between FlashMorph and FlashMorph2. FlashMorph uses off-policy teacher-forced continuous gates with frozen model weights, whereas FlashMorph2 samples on-policy discrete hybrid architectures and jointly optimizes layer-selection scores and model weights.

Methods

FlashMorph2 introduces an on-policy layer-selection principle to resolve these mismatches. The core components are:

  1. On-Policy Hybrid Computation: Instead of continuous mixing, the method uses Gumbel-Top-K sampling to pick a discrete set of full-attention layers in every training step. The model then performs an end-to-end forward pass through this sampled architecture. This allows the model to operate on its own self-generated hidden states, capturing how errors from linearized layers might accumulate or be compensated for by later layers.
  2. On-Policy Weight Adaptation: Unlike previous methods that keep weights frozen during selection, FlashMorph2 jointly optimizes layer-selection scores and model weights. This ensures the selection process accounts for how weights will co-adapt to the new hybrid structure during the final recovery phase.
  3. Budget-Constrained Straight-Through Estimator (STE): Since discrete selection is non-differentiable, the authors use a continuous relaxation and a specialized STE to backpropagate gradients to the selection scores while strictly adhering to the prescribed "full-attention budget."

The overall pipeline follows four stages: (1) Layerwise alignment to initialize linear branches, (2) the novel On-Policy Layer Selection, (3) Logits distillation to recover quality, and (4) Long-context finetuning.

Figure 2. Overview of FlashMorph2. Following layerwise alignment, FlashMorph2 constructs a hybrid attention model through on-policy layer selection, jointly optimizing layer scores and model weights over sampled discrete hybrid architectures. The resulting hybrid attention model is further trained using logits distillation and long-context finetuning to recover model quality.

Datasets

  • Training: The models were trained on randomly sampled subsets of the DCLM dataset.
  • Evaluation:
  • RULER: A benchmark for long-context retrieval and understanding.
  • LongBench: A comprehensive suite of 14 long-context tasks (QA, summarization, etc.).
  • Recall-intensive tasks: Evaluated using the prefix-linear-attention suite (e.g., SQuAD, Natural Questions).
  • General Capabilities: Standard benchmarks like WikiText, LAMBADA, ARC, PIQA, and HellaSwag were used to ensure language modeling and reasoning were preserved.

Key Insights and Ideas

  • The "Aha" Moment on Mismatch: The authors realized that layer importance is not an intrinsic, static property. It depends heavily on the surrounding architecture and how the weights are tuned. Evaluating a layer in isolation or with frozen weights leads to suboptimal "off-policy" choices.
  • Error Accumulation Matters: By using self-propagated hidden states during selection, FlashMorph2 can "see" that linearizing an early layer might be more damaging than linearizing a later one because the error propagates through the whole stack.
  • Efficiency vs. Accuracy: While more complex than simple ranking, FlashMorph2 is designed to be "one-time" and extremely fast. It completes selection in a few GPU hours, which is a tiny fraction (<1%) of the total conversion budget.

Key Results

FlashMorph2 consistently outperformed all baselines across different model scales (0.6B to 8B) and linear attention variants (Lightning, GLA, GDN).

  • Performance Gains: It improved average scores over the original FlashMorph by +2.42 points on RULER and +1.08 points on LongBench.
  • Robustness: As shown in Figure 4, FlashMorph2 maintains a significant lead even under tight budgets (e.g., a 6:1 ratio of linear to full attention).
  • Efficiency: It is orders of magnitude faster than search-based methods like PostNAS or ranking methods like KL-LS. For an 8B model, selection takes only ~3.5 GPU hours.

RULER Performance across Hybrid Ratios Layer-selection Efficiency across Model Scales

Limitations and Future Work

  • Computational Overhead: While efficient, FlashMorph2 requires roughly 2x the FLOPs of FlashMorph during the selection stage because it performs end-to-end forward/backward passes rather than local layer-wise updates.
  • Weight Re-initialization: Currently, the weights adapted during the selection stage are discarded, and the model is re-initialized for the final recovery stage to isolate the effect of selection. Future work could explore using these "warm" weights to further speed up the recovery process.
  • Fixed Budgets: The current method assumes a fixed, pre-defined budget of full-attention layers. Exploring dynamic budgets or non-uniform layer configurations (e.g., different head counts) remains an open area.

Summary updated

Abstract

Hybrid attention models combine full and linear attention to achieve a better quality--efficiency trade-off. Converting pretrained Transformers into such models requires identifying which layers should retain full attention under a prescribed budget. We identify two off-policy mismatches in FlashMorph's layer selection: (i) continuous branch interpolation and teacher-forced hidden states differ from discrete hybrid computation; and (ii) frozen model weights fail to account for parameter adaptation during subsequent recovery. We introduce FlashMorph2, an on-policy layer-selection method that (I) evaluates sampled discrete hybrid architectures end to end using their own hidden states, and (II) jointly optimizes layer-selection scores and model weights under the recovery objective to reflect post-adaptation performance. Experiments across Qwen3 model scales and linear-attention variants show that FlashMorph2 consistently outperforms existing layer-selection methods, improving average scores over FlashMorph by $+2.42$ points on RULER, $+1.08$ on LongBench, and $+0.76$ on recall-intensive tasks, while completing layer selection in only $0.72$--$3.57$ GPU hours across 0.6B--8B models, demonstrating high efficiency and scalability.
BibTeX
@misc{lan2026policy,
  author = {Disen Lan and Xuanda Wang and Jianbin Zheng and Huafeng Kuang and Wei Tang and Yu Cheng},
  title = {{On-Policy Morphing into Hybrid Attention Models}},
  year = {2026},
  eprint = {2611.24809},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.24809},
}
Figure