Command Palette
Search for a command to run...
HydraHead: 헤드 수준의 기능적 이질성에서 전문화된 어텐션 혼합으로
HydraHead: 헤드 수준의 기능적 이질성에서 전문화된 어텐션 혼합으로
Zhentao Tan Wei Chen Jingyi Shen Yao Liu Xu Shen Yue Wu Jieping Ye
초록
어텐션의 이차적 복잡성(Quadratic Complexity)은 긴 컨텍스트 처리에 있어 치명적인 병목 현상으로 작용하며, 이는 하이브리드 어텐션 설계에 대한 관심을 고조시켰다. 대부분의 오픈소스 하이브리드 모델은 레이어 차원(Layer-wise) 전략을 채택한다. 그러나 기존 연구들은 선형 어텐션(Linear Attention, LA)과 풀 어텐션(Full Attention, FA)을 통합하는 데 내재된 어려움을 지적해 왔으며, 이는 여전히 어텐션 하이브리드화 설계 공간이 충분히 탐구되지 않았음을 시사한다. 이 설계 공간을 탐색하기 위해, 우리는 해석 가능성 분석을 수행하였으며 그 결과, 레이어들은 블록 단위(Block-wise)로 기능적 유사성을 나타내는 반면, 동일한 레이어 내 개별 헤드(Head)들은 동일한 입력 특징을 공유함에도 불구하고 뚜렷한 기능적 전문화(Functional Specialization)를 보여준다는 사실을 관찰했다. 이러한 헤드 차원의 이질성(Head-level Heterogeneity)은 이질적인 어텐션 신호를 융합하기 위해 자연스럽고 원칙적인粒度(Granularity)를 제공한다는 점을 시사한다. 이러한 통찰을 바탕으로, 우리는 FA와 LA를 헤드 축(Axis)을 따라 하이브리드화하는 새로운 아키텍처인 'HydraHead'를 제안한다. HydraHead는 두 가지 주요 혁신을 특징으로 한다. 첫째, 해석 가능성 기반의 선택 전략으로 정보 검색에 중요한 헤드들을 식별하여 해당 헤드들에 대해 FA만 유지한다는 점이다. 둘째, FA와 LA의 출력 분포 간 격차를 조정하는 스케일 정규화 융합 모듈(Scale-normalized Fusion Module)을 적용한다는 점이다. 파라미터 재사용(Parameter Reuse)과 지능형 전달(Distillation)을 포함한 3단계 전달 파이프라인(Pipeline)을 활용하여, 우리는 최소한의 훈련 오버헤드로 고성능 하이브리드 모델을 달성했다. 통합된 훈련 설정 하에서, HydraHead는 긴 컨텍스트 작업에서 다른 하이브리드 설계들보다 우수한 성능을 보이며 강력한 일반 추론(General Reasoning) 능력도 유지한다. 해석 가능성 기반의 헤드 선택 덕분에, HydraHead는 7:1의 LA:FA 비율에서 3:1의 레이어 차원 하이브리드 모델과 동등한 긴 컨텍스트 성능을 달성한다. 더욱 중요한 것은, 단지 15B 토큰으로만 훈련된 HydraHead가 512K 컨텍스트 길이에서 기존 기반 모델(Baseline) 대비 69% 이상 개선된 성능을 보여, 네이티브 컨텍스트 길이가 256K인 동급 최상위 모델인 Qwen3.5에 근접한다는 점이다. 이는 헤드 레벨(HLevel) 하이브리드화가 가지는 상당한 스케일링 잠재력(Scaling Potential)을 부각시킨다.
One-sentence Summary
HydraHead, a head-level attention hybridization architecture, employs interpretability-driven selection to preserve full attention only for retrieval-critical heads and a scale-normalized fusion module to reconcile output distributions, achieving over 69% improvement over the baseline at 512K context length and matching a 3:1 layer-wise hybrid's long-context performance at a 7:1 linear-to-full attention ratio after training on only 15B tokens.
Key Contributions
- Interpretability analysis reveals that transformer layers exhibit block-wise functional similarity while attention heads within a layer specialize in distinct functions, establishing the head dimension as a principled granularity for fusing heterogeneous attention mechanisms.
- HydraHead hybridizes full and linear attention along the head axis, using an interpretability-driven selection strategy to retain full attention only on retrieval-critical heads and a scale-normalized fusion module to reconcile the distributional mismatch between the two attention types.
- A three-stage transfer pipeline with parameter reuse and distillation trains HydraHead, achieving over 69% improvement on NIAH benchmarks at 512K context with 15B training tokens, matching a 3:1 layer-wise hybrid’s long-context performance at a 7:1 LA-to-FA ratio, and approaching Qwen3.5 without degrading general reasoning.
Introduction
The shift from static LLMs to autonomous agents that plan and reason over long horizons has made extending context windows essential, but standard full attention scales quadratically with sequence length. Linear attention mechanisms offer linear complexity yet often suffer from expressivity collapse, struggling with precise retrieval. Hybrid architectures that interleave different attention types across layers have emerged as a compromise, but layer-wise designs face a challenge: layer outputs vary smoothly, making it hard to decide where to place each mechanism, and training such hybrids remains difficult, leaving the design space underexplored. The authors leverage mechanistic interpretability to show that individual attention heads within a layer exhibit sharp functional heterogeneity, with only a sparse subset critical for retrieval, while layers lack clear boundaries. They propose HydraHead, a fine-grained head-level hybridization architecture that uses a lightweight, one-shot interpretability-based selection to assign full attention only to retrieval-critical heads and linear attention to the rest, combined with a head-wise scale-normalized fusion and a three-stage transfer pipeline to effectively train the hybrid model.
Method
The authors introduce HydraHead, a novel architecture that hybridizes Full Attention (FA) and Linear Attention (LA) along the head axis to balance computational efficiency and representational expressivity. The method comprises three key components: an interpretability-driven head selection strategy, the head-wise hybrid attention module, and a three-stage transfer learning pipeline.
Head Importance Estimation via Causal Intervention
To determine which heads require the precision of FA and which can utilize the efficiency of LA, the authors employ causal intervention techniques to estimate head necessity. They use activation patching to measure the direct causal effect of each head on target behaviors (receivers) and path patching to trace upstream contributions (senders). By fusing these scores across multiple target capabilities, they compute a unified importance score Sh for each head. Heads are then ranked, and FA is retained only for the top-K causally indispensable heads, while the remainder are assigned to LA.
Head-wise Hybridization
The authors explore various hybridization granularities to identify the optimal design space. As illustrated in the figure below, they compare layer-wise, token-wise, and head-wise paradigms, ultimately adopting a head-wise selection strategy where specific heads are exclusively assigned to either the FA or LA branch based on functional importance.
The core architecture partitions the set of query heads H into two disjoint subsets: HF for FA and HL for the LA branch (specifically Gated DeltaNet, GDN). The framework diagram below details this process. Input projections are routed to their respective branches in parallel.
A fundamental challenge in hybridizing FA and LA is the distributional gap between their outputs. FA produces sharp, low-entropy distributions modulated by query norm, while LA yields smoother, higher-entropy representations. To reconcile this, the authors propose a Head-wise Scale-normalized Fusion module. They apply RMSNorm independently to each head's output Oh to unify feature scales:
O^h=Norm(Oh)These normalized outputs are concatenated along the head dimension to preserve functional identity. A learnable head-wise scaling vector γ∈RH is then introduced to adaptively recalibrate the contribution of each head:
O~:,h:=γh⋅O^:,h:,∀h∈[1,H]The modulated tensor is reshaped and projected to produce the final attention output.
Branch-specific Refinements
The internal structural designs of the two attention types are also optimized to enhance performance under head-wise hybridization. The figure below illustrates the specific configurations for the FA and LA branches.
For the FA branch, the authors remove Rotary Position Embedding (RoPE) and instead apply a log-scale coefficient to query features to stabilize attention distributions in long-context scenarios. An auxiliary gate branch is also introduced to boost representational capacity and alleviate the attention sink phenomenon. For the GDN branch, RoPE is explicitly integrated into query and key projections to compensate for the limited positional sensitivity of linear recurrence. Additionally, the number of key-value heads is expanded to match the query heads, transitioning from a Grouped-Query Attention configuration to a Multi-Head Attention-like setup to enhance representational capacity.
Efficient Hybrid Transfer Learning
To convert a pre-trained standard FA model into the hybrid architecture with minimal training overhead, the authors leverage a three-stage transfer pipeline.
Stage 1: Parameter Migration and Layer-wise Output Alignment The FA heads are initialized with pre-trained weights, and a lightweight gate branch is added with near-zero weights to approximate an identity function initially. The LA heads reuse the Q,K,V projection weights from the original FA layers, using channel-wise repetition to handle dimension mismatches. The model is trained to align the hidden states of each hybrid layer HHybrid(l) with the original FA layer HFA(l) using Mean Squared Error loss:
Lalign=l=1∑L∣∣HFA(l)(x)−HHybrid(l)(x)∣∣22Stage 2: Global Logits Distillation The entire model is unfrozen, and global knowledge distillation is performed to align the final output distribution of the student model with the teacher model. This stage combines KL divergence loss with cross-entropy loss to ensure global semantic coherence:
LKD=DKL(Pteacher(⋅∣x)∥Pstudent(⋅∣x))Stage 3: Long-Context Fine-tuning Finally, the model undergoes standard supervised fine-tuning using the Next Token Prediction objective with extended context lengths to consolidate long-context capabilities:
LNTP=−t∑logPstudent(xt+1∣x1:t)Experiment
The experiments evaluate HydraHead, a head-wise hybrid attention architecture that converts a pretrained Transformer by assigning full attention to a small subset of heads selected through causal interpretability and linear attention to the rest, using a three-stage transfer learning pipeline on Qwen3-1.7B. Controlled comparisons show that head-wise hybridization consistently outperforms layer-wise and token-wise alternatives, achieving a superior balance between long-context retrieval and general reasoning, while ablation studies confirm that feature normalization, query decomposition, and head-wise scale modulation are critical for stable fusion of heterogeneous attention features. Interpretability-guided selection proves essential because retrieval-critical heads are sparse, scattered across layers, and causally verified, making per-head allocation far more effective than uniform or random strategies. Scaling to over 15 billion tokens, HydraHead surpasses existing hybrid models and matches standard Transformers in reasoning while maintaining robust extrapolation to 256K context, demonstrating that fine-grained head-wise mixing is a promising design principle for efficient long-context models.
The authors investigate feature fusion strategies for their head-wise hybrid architecture, comparing direct concatenation without normalization, head-wise scale modulation, and head-wise gated competition. Results show that feature normalization is critical, as removing it causes substantial performance drops in long-context retrieval tasks. Head-wise scale modulation emerges as the most effective fusion method, significantly outperforming gated competition in extended context scenarios while maintaining robust general reasoning capabilities. Removing feature normalization leads to significant degradation in single-key retrieval performance across both native and extended context lengths. Head-wise scale modulation provides the most stable representations for long-range dependencies, achieving substantial improvements over gated competition in extended context tasks. The head-wise scale modulation variant consistently outperforms other fusion strategies across nearly all evaluation metrics, establishing it as the optimal default model.
The authors optimize the three-stage training pipeline for their head-wise hybrid architecture by scaling up data volume, increasing batch sizes, and extending context lengths in the final stage. This optimized configuration yields consistent performance improvements across evaluation benchmarks, particularly enhancing long-context multi-key retrieval and complex general reasoning capabilities. In contrast, baseline layer-wise hybrid models show limited or divergent scaling behavior under the same settings, highlighting the proposed architecture's superior capacity to absorb additional training data. The optimized training setup significantly boosts the hybrid model's accuracy on intricate long-context dependencies and challenging reasoning tasks. Increasing the context length and batch size in the later training stages stabilizes optimization dynamics across the heterogeneous attention branches. The head-wise hybrid design demonstrates a higher capacity for leveraging scaled training data compared to layer-wise alternatives, which suffer from performance degradation in certain retrieval tasks.
The authors evaluate their proposed head-wise hybrid architecture against standard full attention models and other hybrid baselines on long-context retrieval benchmarks. Results show that the proposed method maintains high retrieval accuracy across extended context lengths up to 256K tokens, whereas competing hybrid models and standard attention variants suffer severe performance degradation. This demonstrates the model's superior ability to balance efficient long-context extrapolation with robust retrieval capabilities. The proposed head-wise hybrid architecture achieves state-of-the-art performance on long-context retrieval tasks, significantly outperforming other hybrid designs at extended sequence lengths. While standard full attention models fail to retrieve information beyond their native context window, the proposed method sustains high accuracy even at extreme context lengths. The head-wise hybrid design effectively prevents the severe performance collapse observed in competing hybrid models when handling sequences far beyond the training context length.
The authors compare a layer-wise hybrid architecture with a standard ratio against their head-wise Global-Interp-C model using a more aggressive ratio of linear attention. Results indicate that the head-wise approach maintains long-context retrieval performance broadly comparable to the layer-wise baseline. Crucially, the head-wise model demonstrates a substantial advantage in general reasoning capabilities, particularly on challenging benchmarks, despite the higher proportion of linear attention. The head-wise model with a higher linear attention ratio achieves long-context performance comparable to the layer-wise baseline with a lower ratio. The head-wise architecture significantly outperforms the layer-wise hybrid in general reasoning tasks, showing large gains on hard benchmarks. Interpretability-guided head selection enables aggressive compression while preserving strong general-domain capabilities.
The authors optimize a three-stage training pipeline for their head-wise hybrid architecture by progressively increasing the batch size and context length. Scaling up the training data and adjusting hyperparameters across these stages significantly enhances knowledge transfer and stabilizes optimization dynamics for heterogeneous attention branches. This optimized configuration leads to consistent performance improvements across long-context retrieval and complex reasoning benchmarks, demonstrating that head-wise hybridization absorbs additional training data more effectively than layer-wise alternatives. The training configuration progressively increases batch sizes and dramatically extends the context length in the final stage to accommodate long-context dependencies. The learning rate schedule utilizes cosine decay during the initial training phases before switching to a constant rate for the final long-context adaptation. Scaling up the token count and batch size across the three stages enables the head-wise architecture to effectively internalize heterogeneous attention patterns.
The experiments evaluate a head-wise hybrid attention architecture through fusion strategy comparisons, training pipeline optimization, long-context retrieval benchmarks up to 256K tokens, and trade-offs with aggressive linear attention ratios. Feature normalization proves essential, and head-wise scale modulation emerges as the most effective fusion method, yielding stable long-range representations. Scaling data, batch sizes, and context lengths in a three-stage pipeline consistently improves long-context retrieval and complex reasoning, with the head-wise design absorbing additional data far better than layer-wise alternatives. The architecture maintains high retrieval accuracy at extreme lengths where other models collapse, and interpretability-guided head selection allows a higher proportion of linear attention while preserving strong general reasoning, establishing the head-wise hybrid as a robust and scalable approach.