TL;DR
This paper introduces HyLo (HYbrid LOng-context), a novel upcycling recipe that transforms pretrained Transformer large language models (LLMs) into highly efficient hybrid architectures combining attention with linear sequence models (Mamba2 or Gated DeltaNet). By utilizing a memory-efficient, teacher-guided distillation process, HyLo extends the usable context length of models by up to 32× and slashes KV-cache memory consumption by over 90%. This allows for efficient serving of up to 2-million-token contexts on standard hardware without the prohibitive cost of training a hybrid model from scratch.
What Problem Does This Paper Address?
While standard Transformer-based LLMs excel at many tasks, their self-attention mechanism suffers from quadratic computational and memory complexity relative to sequence length. This creates a massive bottleneck for long-context applications like document analysis or code generation, primarily due to the exploding size of the Key-Value (KV) cache.
Hybrid architectures—which interleave standard attention with linear sequence models like State Space Models (SSMs)—offer a sub-quadratic alternative. However, training these hybrid models from scratch is immensely expensive. "Model upcycling" aims to solve this by converting existing pretrained Transformers into hybrid models. Unfortunately, prior upcycling methods focused almost exclusively on maintaining short-context performance, completely ignoring long-context capabilities or running into severe out-of-memory (OOM) errors during extended context training.
The authors address this gap by creating an upcycling framework explicitly designed to preserve short-context quality while unlocking massive long-context scaling.
Methods
The authors propose HyLo, an end-to-end recipe consisting of architectural adaptation, a novel initialization scheme, and a memory-optimized two-stage training pipeline:
- Architecture Design: HyLo replaces a subset of standard attention layers with a combination of Multi-Head Latent Attention (MLA) (to compress the KV cache) and linear recurrent blocks, specifically Mamba-2 or Gated DeltaNet (GDN).
- GDN Initialization: The paper introduces a method to initialize GDN blocks directly from pretrained Transformer weights by expanding Grouped-Query Attention (GQA) heads and performing dimension truncation to match submatrices.
- Two-Stage Fine-Tuning:
- Stage I (Enhanced-ILD): Pure MLA and linear models undergo Enhanced Intermediate Layer Distillation. Unlike previous methods that only align hidden states, HyLo also minimizes the $L_2$ distance between the token-mixer (attention) outputs of the teacher and student.
- Stage II (Long-Context SFT): The blocks are assembled into a hybrid model and fine-tuned end-to-end. Context windows are progressively scaled from 2K up to 64K tokens using output-level Knowledge Distillation (KD).
- Memory-Efficient Distillation: To prevent OOM errors when computing KL divergence at 64K context lengths, the authors implement Fused Hidden-State KL (Logit-Free Distillation). This technique bypasses materializing massive logit tensors by computing the loss directly from the hidden states and the LM head weights inside a tiled Triton kernel.
Finally, the authors integrate HyLo into the vLLM runtime, adapting the engine to handle heterogeneous layer types and custom cache allocation logic.
Datasets
- Training: The models are fine-tuned using a standard Supervised Fine-Tuning (SFT) dataset (Stage I uses 20% of the data; Stage II uses the full dataset).
- Short-Context Evaluation: Evaluated via
lm-eval-harnessacross common sense reasoning benchmarks: ARC-Challenge, ARC-Easy, HellaSwag, OpenBookQA, PIQA, RACE, and WinoGrande. Math reasoning is evaluated on GSM8K. - Long-Context Evaluation: Evaluated using the RULER benchmark (comprising 13 distinct long-context tasks) across 8K, 16K, 32K, and 64K context lengths, alongside synthetic Needle in a Haystack tests.
Key Insights and Ideas
- Long-Context is Not Inherited: Upcycled hybrid models do not automatically inherit the long-context capabilities of their source Transformers. Explicit long-context training is mandatory.
- The Power of the Teacher: Knowledge distillation from a larger teacher model (e.g., an 8B teacher for a 1B student) yields massive performance boosts specifically on long-context tasks, far outweighing its impact on short-context tasks.
- Bypassing the Logit Bottleneck: Standard KL distillation at 64K context requires gigabytes of memory just to hold the logit tensors. Fusing the hidden states directly with the LM head weights inside custom kernels is what makes long-context distillation practically viable on standard hardware.
- Explicit Training Beats Interpolation: While zero-shot position interpolation methods like YaRN help extend context, training directly on longer sequences yields vastly superior long-context reasoning performance.
Key Results
- KV-Cache Reduction: HyLo reduces the KV-cache memory footprint by more than 90%.
- Context Extension: HyLo successfully processes up to 2M-token contexts (prefill and decoding) within vLLM on 8× AMD MI300X GPUs, whereas standard Llama baselines crash due to OOM errors beyond 64K.
- Benchmark Superiority: HyLo models consistently outperform state-of-the-art upcycled hybrid baselines on the RULER benchmark.
- Data Efficiency: At a similar scale, HyLo-Qwen-1.7B (trained on only 10B tokens) significantly outperformed JetNemotron-2B (trained on 400B tokens from scratch) on GSM8K, common sense reasoning, and RULER-64K.
Limitations and Future Work
- Short-Context Trade-off: The authors noted a slight degradation in short-context common sense reasoning performance after executing long-context fine-tuning, a common side-effect when adapting models to massive context windows.
- Future Directions: The authors plan to focus on closing the remaining performance gap at extreme context lengths, further optimizing distillation efficiency, and testing the framework on broader downstream applications requiring robust long-context reasoning.
Summary updated