Lune

NeurIPS2024Top-tier venue

The Mamba in the Llama: Distilling and Accelerating Hybrid Models

Junxiong Wang, Daniele Paliotta, Avner May, Alexander M. Rush, Tri Dao

Abstract

Linear RNN architectures, like Mamba, can be competitive with Transformer models in language modeling while having advantageous deployment characteristics. Given the focus on training large-scale Transformer models, we consider the challenge of converting these pretrained models for deployment. We demonstrate that it is feasible to distill large Transformers into linear RNNs by reusing the linear projection weights from attention layers with academic GPU resources. The resulting hybrid model, which incorporates a quarter of the attention layers, achieves performance comparable to the original Transformer in chat benchmarks and outperforms open-source hybrid Mamba models trained from scratch with trillions of tokens in both chat benchmarks and general benchmarks. Moreover, we introduce a hardware-aware speculative decoding algorithm that accelerates the inference speed of Mamba and hybrid models. Overall we show how, with limited computation resources, we can remove many of the original attention layers and generate from the resulting model more efficiently. Our top-performing model, distilled from Llama3-8B-Instruct, achieves a 29.61 length-controlled win rate on AlpacaEval 2 against GPT-4 and 7.35 on MT-Bench, surpassing the best 8B scale instruction-tuned linear RNN model. We also find that the distilled model has natural length extrapolation, showing almost perfect accuracy in the needle-in-a-haystack test at 20x the distillation length. Code and pre-trained checkpoints are open-sourced at https://github.com/jxiw/MambaInLlama and https://github.com/itsdaniele/speculative_mamba.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

47 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Measuring Massive Multitask Language Understanding cites Language Models are Few-Shot Learners
  • MoBA: Mixture of Block Attention for Long-Context LLMs cites Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
  • Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search cites Measuring Massive Multitask Language Understanding
  • Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search cites Efficiently Modeling Long Sequences with Structured State Spaces
  • Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search cites TruthfulQA: Measuring How Models Mimic Human Falsehoods
  • Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search cites Test-Time Training Done Right
  • Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search cites Language Models are Few-Shot Learners
  • Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search cites Gated Slot Attention for Efficient Linear-Time Sequence Modeling
  • Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search cites Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
  • Direct Preference Optimization: Your Language Model is Secretly a Reward Model cites Language Models are Few-Shot Learners
  • TruthfulQA: Measuring How Models Mimic Human Falsehoods cites Measuring Massive Multitask Language Understanding
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites Measuring Massive Multitask Language Understanding
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites Efficiently Modeling Long Sequences with Structured State Spaces
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites Language Models are Few-Shot Learners
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers47

  1. MoBA: Mixture of Block Attention for Long-Context LLMsEnzhe Lu, Zhejun Jiang, Jingyuan Liu, Yulun Du et al.NeurIPS 2025 · 219 citations
  2. Test-Time Training Done RightTianyuan Zhang, Sai Bi, Yicong Hong, Kai Zhang et al.ICLR 2026 · 127 citations
  3. Gated Slot Attention for Efficient Linear-Time Sequence ModelingYu Zhang, Songlin Yang, Rui-Jie Zhu, Yue Zhang et al.NeurIPS 2024 · 93 citations
  4. Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic ModelsAviv Bick, Kevin Y. Li, Eric P. Xing, J. Zico Kolter et al.NeurIPS 2024 · 78 citations
  5. Jet-Nemotron: Efficient Language Model with Post Neural Architecture SearchYuxian Gu, Qinghao Hu, Haocheng Xi, Junyu Chen et al.NeurIPS 2025 · 39 citations

Builds on35

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Direct Preference Optimization: Your Language Model is Secretly a Reward ModelRafael Rafailov, Archit Sharma, Eric Mitchell, Christopher D. Manning et al.NeurIPS 2023 · 10,924 citations
  3. Measuring Massive Multitask Language UnderstandingDan Hendrycks, Collin Burns, Steven Basart, Andy Zou et al.ICLR 2021 · 7,905 citations
  4. Efficiently Modeling Long Sequences with Structured State SpacesAlbert Gu, Karan Goel, Christopher RéICLR 2022 · 3,482 citations
  5. TruthfulQA: Measuring How Models Mimic Human FalsehoodsStephanie Lin, Jacob Hilton, Owain EvansACL 2022 · 3,228 citations

Related papers

  1. MaTVLM: Hybrid Mamba-Transformer for Efficient Vision-Language ModelingYingyue Li, Bencheng Liao, Wenyu Liu, Xinggang WangICCV 2025 · 1 citation
  2. Joint Fine-tuning and Conversion of Pretrained Speech and Language Models towards Linear ComplexityMutian He, Philip N. GarnerICLR 2025
  3. Gated Linear Attention Transformers with Hardware-Efficient TrainingSonglin Yang, Bailin Wang, Yikang Shen, Rameswar Panda et al.ICML 2024 · 390 citations
  4. Effective Distillation to Hybrid xLSTM ArchitecturesLukas Hauzenberger, Niklas Schmidinger, Thomas Schmied, Anamaria-Roberta Hartl et al.ICML 2026 · 3 citations
  5. Mamba Drafters for Speculative DecodingDaewon Choi, Seunghyuk Oh, Saket Dingliwal, Jihoon Tack et al.EMNLP Findings 2025 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines