betaFeedback

WorksComputer Science

The Effect of Layer Ordering in Hybrid Architectures

Abstract

Hybrid attention is rapidly becoming the dominant architectural choice for frontier models. Despite their successes, such architectures complicate model design by introducing additional choices, including the types and locations of layers. This combinatorially large design space has been studied empirically, but given the vast expense of training and evaluating models with different configurations, a principled understanding of the effects of layer selection and ordering is needed. We provide the first such analysis, showing that the dominant hybrid architecture is highly task-specific. Concretely, for any layer configuration, we prove that there exists a task where we can construct a model with this configuration that provably outperforms any other model of any different configuration under fixed resource constraints. Empirically, we observe that for standard training, learned hybrid architectures exhibit separations between layer orderings that match our theoretical findings. For instance, under the same memory budget, the optimal architecture predicted by our theory for a segmented retrieval task consistently achieves perfect accuracy, whereas the next strongest plateaus below 0.5. These results extend to deeper models, where ``containing'' the dominant architecture for a task indicates whether the model attains high performance. In addition, we investigate the mechanisms learned by hybrids, observing that Transformer layers contribute the largest share of performance on associative recall across architectures. This work establishes insights into task-dependent hybrid architecture design relevant to the training and scaling of frontier-scale hybrids.

Introduction

Hybrid architectures have become the design of choice for frontier models [20, 25, 12]. This is due to their superior scalability: the quadratic complexity of full self-attention limits the vanilla Transformer architecture on long-context tasks [11, 24]. Hybrid models replace many self-attention layers with efficient subquadratic alternatives that require smaller memory and offer faster inference. Popular choices include state-space layers like linear attention, Mamba, Gated DeltaNet, etc. [8, 32]. The use of these layers produces scalable and highly-performant models.

However, as each layer can be selected from among many variations, layer selection and ordering is a critical design challenge [32, 8, 10]. Indeed, each layer type brings different constraints when processing sequences: full-attention is memory-bound by retrieval distance while recurrent alternatives are bound by their state size. The most popular layer ordering among frontier models uses a block design that involves one softmax-attention layer followed by many subquadratic layers. This is supported empirically [29]. While some work has investigated the selection ratio between softmax-attention and linear attention [30, 7] and others have shown a theoretical separation with hybrids utilizing less memory [6], the benefits and drawbacks of various layer orderings are still unclear. Given the combinatorially large space of different layer orderings, a complete empirical sweep across architectures is intractable.

Structure of tasks that exhibit performance differences among different hybrid architectures

Figure 1. Structure of tasks that exhibit performance differences among different hybrid architectures. Large gaps need SSM layers to communicate each segment’s query, while the dense computation per segment is done by the Transformers.

A theoretical characterization of hybrid architectures would cut down on this combinatorial space. However, identifying differences between hybrid layer orderings is highly challenging. Tasks can be solved by a variety of algorithms, each best suited for a different hybrid architecture. For instance, the greatest difficulty stems from processing order: some architectures focus on reordering the sequence in early layers to allow for a few later layers to solve the task. These shortcuts can reduce model size and depth compared to more direct algorithms with sequential processing.

In this work, we obtain a new theory-driven approach to hybrid architecture design. Inspired by [6], we study the expressivity of different hybrid architectures under computational resource constraints. We identify tasks and associated architecture designs where no other design (i.e., layer ordering) is able to solve the task under identical constraints. We begin by abstracting full-attention (TF) and sub-quadratic attention variants as generalized windowed functions and generalized state-space models (SSMs), respectively. This allows us to focus on the critical elements constraining layer types: the window width, state size, and embedding precision. For a given layer ordering of generalized SSMs and generalized causal windowed models, we show there exists a task and hybrid architecture such that any architecture deviating from the provided one must use more resources at some layer. This indicates that large-scale hybrid architecture design is situation-specific; in other words, structural properties of a desired task determines the optimal hybrid architecture.

In addition, we zoom in on 2- and 3-layer hybrid architectures to characterize and expand the set of such separating tasks. These tasks are natural, mirroring behaviors found in real-world natural language scenarios. Specifically, we establish tasks where the TF →\to SSM (TS) and TF →\to SSM →\to TF (TST) architectures are resource optimal. The task for TST supplies a natural task that requires layer alternation in a hybrid design. For these tasks, we show a separation in learnability between different layer orderings. By modifying the context window for the Transformers and varying the state in Mamba, we constrain the memory of these hybrid under some fixed budget. We empirically show that the learned hybrids exhibit identical separations as predicted theoretically. For segmented retrieval (designed for the TS architectures) and the TST task, we observe a phenomenon crucial for large-scale design: on hybrids of depth 4 and depth 5, containing TS or TST as a sub-architecture determines performance. This suggests that such “containment” is important in deep hybrids.

We empirically study such deeper hybrids as well. We find that a T* S* architecture achieves higher performance than all S* T* architectures for this task. Mechanistically, through linear probing, we observe that the top-performing model, TTSSSSSS, shows a slow increase in decodability in its SSM layers which are not seen in TTTSSSSS. This supports that hybrid design is nuanced, as slightly different architectures fail to use their SSM layers to improve performance.

The paper is structured as follows. In Section 2, we begin with proving that there are tasks and resource constraints for any hybrid architecture that any other architecture must violate. For shallow hybrids, we establish a natural task family capturing important operations in natural language. In Section 3, we experiment on these natural tasks, identifying that these separations appear for learned hybrids. Lastly, in Section 4, we experiment on 8-layer hybrids on associative recall, observing that mildly different architectures have drastically different performances.

Theoretical Foundations for Hybrid Layer Ordering

In this section, we introduce our main theorem on model superiority, where we show that for each architecture, there is a task on which it is dominant. We begin with a summary of notation in Appendix A before discussing the main theorem separating architectures of differing layer orderings.

Preliminaries and Notation. We consider sequence-to-sequence token prediction problems. Let V\mathcal{V} be some vocabulary of tokens, V=∣V∣V = |\mathcal{V}|, and x⃗=(xi)i=1L\vec{x} = (x_i)_{i=1}^{L} be an input sequence. A language model MM is a sequence-to-sequence map M:VL→VmM : \mathcal{V}^{L} \to\mathcal{V}^{m} of the form M(x⃗)=FN∘FN−1∘⋯∘F1(x⃗)M(\vec{x}) = F_N \circ F_{N-1} \circ\cdots\circ F_1(\vec{x}), where ∘\circ is function composition and each FiF_i is a sequence-to-sequence map called a layer. Through the paper, we will consider the input and output of FiF_i at each position to be in {0,1}P\{0,1\}^{P}, for some P∈N+P \in\mathbb{N}_{+}, where we call PP the precision of the model. We will consider two types of layers as abstractions of state space models (SSM) and causal windowed attention (TF). The embedded input sequence x⃗=(x1,…,xL)\vec{x} = (x_1, \ldots, x_L) uses PP precision, i.e x⃗\vec{x} is such that xi∈{0,1}Px_i \in\{0,1\}^{P}.

Transformer Layer. We say a layer F:({0,1}P)L→({0,1}P)LF : (\{0,1\}^{P})^{L} \to(\{0,1\}^{P})^{L} is a T-layer (TF) with window size WW if there exists a map ff such that for i∈[L]i \in[L], F(x⃗)i=f(xi−W+1,…,xi)∈{0,1}PF(\vec{x})_i = f(x_{i-W+1}, \ldots, x_i) \in\{0,1\}^{P}. In other words, a T-layer can be an arbitrary PP-precision causal nonlinear function, whose output depends on the past WW positions of the input. Standard transformer implementations with the windowed attention mechanism falls into this category (See Appendix A for formal definitions).

State-Space Model Layer. We say a layer F:({0,1}P)L→({0,1}P)LF : (\{0,1\}^{P})^{L} \to(\{0,1\}^{P})^{L} is an S-layer (SSM) with bit complexity BB if there exists a finite set S\mathcal{S} of size at most 2B2^{B}, an update rule u:S×{0,1}P→Su : \mathcal{S} \times\{0,1\}^{P} \to\mathcal{S} and an output function r:S→{0,1}Pr : \mathcal{S} \to\{0,1\}^{P} such that St=u(St−1,x⃗t)S_t = u(S_{t-1}, \vec{x}_t) and F(x⃗)t=r(St)F(\vec{x})_t = r(S_t) hold.

These definitions capture the core difference between these layers: Transformers perfectly recall their recent context, while SSMs store a compressed version of the context [18].

We define Σ:={S,T}\Sigma:= \{S, T\}. An architecture profile AA is a finite word A=A1A2⋯AD∈Σ∗A = A_1 A_2 \cdots A_D \in\Sigma^{*}, whose depth is ∣A∣:=D|A| := D. For two architecture profiles A,BA, B, we write A⪯BA \preceq B if AA is a subsequence of BB: there exist indices 1≤i1<⋯<i∣A∣≤∣B∣1 \le i_1 < \cdots< i_{|A|} \le|B| such that ∀j∈[∣A∣],Aj=Bij\forall j \in[|A|], A_j = B_{i_j}. Notice that every nonempty architecture profile AA can be written as A=X1r1X2r2⋯XkrkA = X_1^{r_1} X_2^{r_2} \cdots X_k^{r_k}, with ∑i=1kri=∣A∣\sum_{i=1}^{k} r_i = |A| and ri∈N+r_i \in\mathbb{N}_{+}. Here, Xi∈ΣX_i \in\Sigma and Xi≠Xi+1X_i \ne X_{i+1} for i∈[k−1]i \in[k-1]. The architecture XiriX_i^{r_i} is comprised of rir_i layers of type XiX_i without a gap. We define comp⁡(A):=X1X2⋯Xk\operatorname{comp}(A) := X_1 X_2 \cdots X_k as the compression of AA. Let B,P,W∈N+B, P, W \in\mathbb{N}_{+}, and denote MA(B,P,W)M_A(B, P, W) for the class of hybrid models with profile AA, such that every S-layer has a state space with size at most 2B2^{B}, every T-layer has a window size at most WW, and each intermediate tokens between layers belong to a token space with size at most 2P2^{P}.

The empty architecture represents the identity sequence map. Note that since both an S-layer and a T-layer contain the identity map, when A⪯BA \preceq B, a model M∈MA(B,P,W)M \in\mathcal{M}_{A}(B,P,W) can be simulated by a model M′∈MB(B,P,W)M' \in\mathcal{M}_{B}(B,P,W). In particular, if ∣A∣=∣B∣|A| = |B|, then A⪯BA \preceq B forces A=BA = B.

Expressivity and Efficiency Tradeoff under Budget Constraints

Our method to evaluate the choice of different layer orderings is to understand, under a given budget BB, PP, WW on the state size, precision, and the window length, whether for a given task there exists a hybrid model M∈MA(B,P,W)M \in\mathcal{M}_{A}(B,P,W) that can solve the task with good accuracy. If there exists a model M∈Mτ(B,P,W)M \in\mathcal{M}_{\tau}(B,P,W) that solves some given task perfectly, while a model with the same depth but with a different profile must require some computational budgets far beyond BB, PP, WW, then τ\tau is called the dominant choice of ordering for this task. Our main theoretical result reveals task-dependence in the choice of hybrid layer ordering, formalized in Theorem 1.

References

  1. [1]Simran Arora, Sabri Eyuboglu, Aman Timalsina, Isys Johnson, Michael Poli, James Zou, Atri Rudra, and Christopher Re. Zoology: Measuring and improving recall in efficient language models. In The Twelfth International Conference on Learning Representations, 2024.arxiv.org/abs/2312.04927
  2. [2]Sangmin Bae, Bilge Acun, Chien-Yu Lin, Haroun Habeeb, Seungyeon Kim, Liang Luo, Junjie Wang, and Carole-Jean Wu. Hybrid architectures for language models: Systematic analysis and design insights, 2026.arxiv.org/abs/2510.04800
  3. [3]Satwik Bhattamishra, Michael Hahn, Phil Blunsom, and Varun Kanade. Separations in the representational capabilities of transformers and recurrent architectures. Advances in Neural Information Processing Systems, 37:36002–36045, 2024.arxiv.org/abs/2406.09347
  4. [4]Aviv Bick, Eric P. Xing, and Albert Gu. Retrieval-aware distillation for transformer-SSM hybrids. In Forty-third International Conference on Machine Learning, 2026.arxiv.org/abs/2602.11374
  5. [5]Lijie Chen, Binghui Peng, and Hongyun Wu. Theoretical limitations of multi-layer transformer. In 2025 IEEE 66th Annual Symposium on Foundations of Computer Science (FOCS), pages 2631–2653. IEEE, 2025.arxiv.org/abs/2412.02975
  6. [6]John Cooper, Ilias Diakonikolas, Mingchen Ma, and Frederic Sala. Expressivity-efficiency tradeoffs for hybrid sequence models. In Forty-third International Conference on Machine Learning, 2026.arxiv.org/abs/2603.08859
  7. [7]Yonggan Fu, Xin Dong, Shizhe Diao, Matthijs Van kerbsilck, Hanrong Ye, Wonmin Byeon, Yashaswi Karnati, Lucas Liebenewein, Maksim Khadkevich, Alexander Keller, Jan Kautz, Yingyan Celine Lin, and Pavlo Molchanov. Nemotron-flash: Towards latency-optimal hybrid small language models. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025.arxiv.org/abs/2511.18890
  8. [8]Albert Gu and Tri Dao. Mamba: Linear-time sequence modeling with selective state spaces. In First Conference on Language Modeling, 2024.arxiv.org/abs/2312.00752
  9. [9]Samy Jelassi, David Brandfonbrener, Sham M. Kakade, and Eran Malach. Repeat after me: Transformers are better than state space models at copying. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 21502–21521. PMLR, 21–27 Jul 2024.arxiv.org/abs/2402.01032
  10. [10]Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are RNNs: Fast autoregressive transformers with linear attention. In Proceedings of the 37th International Conference on Machine Learning, volume 119 of Proceedings of Machine Learning Research, pages 5156–5165. PMLR, 13–18 Jul 2020.arxiv.org/abs/2006.16236
  11. [11]Feyza Duman Keles, Pruthuvi Mahesakya Wijewardena, and Chinmay Hegde. On the computational complexity of self-attention. In Proceedings of The 34th International Conference on Algorithmic Learning Theory, volume 201 of Proceedings of Machine Learning Research, pages 597–619. PMLR, 20 Feb–23 Feb 2023.arxiv.org/abs/2209.04881
  12. [12]Kimi Team, Yu Zhang, Zongyu Lin, Xingcheng Yao, Jiaxi Hu, Fanqing Meng, Chengyin Liu, Xin Men, Songlin Yang, Zhiyuan Li, Wentao Li, Enzhe Lu, Weizhou Liu, Yanru Chen, Weixin Xu, Longhui Yu, Yejie Wang, Yu Fan, Longguang Zhong, Enming Yuan, Dehao Zhang, Yizhi Zhang, T. Y. Liu, Haiming Wang, Shengjun Fang, Weiran He, Shaowei Liu, Yiwei Li, Jianlin Su, Jiezhong Qiu, Bo Pang, Junjie Yan, Zhejun Jiang, Weixiao Huang, Bohong Yin, Jiacheng You, Chu Wei, Zhengtao Wang, Chao Hong, Yutian Chen, Guanduo Chen, Yucheng Wang, Huabin Zheng, Feng Wang, Yibo Liu, Mengnan Dong, Zheng Zhang, Siyuan Pan, Wenhao Wu, Yuhao Wu, Longyu Guan, Jiawen Tao, Guohong Fu, Xinran Xu, Yuzhi Wang, Guokun Lai, Yuxin Wu, Xinyu Zhou, Zhilin Yang, and Yulun Du. Kimi linear: An expressive, efficient attention architecture, 2025.
  13. [13]Eyal Kushilevitz. Communication complexity. In Advances in Computers, volume 44, pages 331–360. Elsevier, 1997.
  14. [14]Hyunji Lee, Wenhao Yu, Hongming Zhang, Kaixin Ma, Jiyeon Kim, Dong Yu, and Minjoon Seo. Understanding and enhancing mamba-transformer hybrids for memory recall and language modeling. In Lucas Charpentier, Leshem Choshen, Ryan Coterell, Mustafa Omer Gul, Michael Y. Hu, Jing Liu, Jaap Jumelet, Tal Linzen, Aaron Mueller, Candace Ross, Raj Sanjay Shah, Alex Warstadt, Ethan Gotlieb Wilcox, and Adina Williams, editors, Proceedings of the First BabyLM Workshop, pages 380–398, Suzhou, China, November 2025. Association for Computational Linguistics.arxiv.org/abs/2510.26912
  15. [15]Barak Lenz, Opher Lieber, Alan Arazi, Amir Bergman, Avshalom Manevich, Barak Peleg, Ben Aviram, Chen Almagor, Clara Fridman, Dan Padnos, Daniel Gissin, Daniel Jannai, Dor Muhlgay, Dor Zimberg, Edden M. Gerber, Elad Dolev, Eran Krakowsky, Erez Safahi, Erez Schwartz, Gal Cohen, Gal Shachaf, Haim Rozenblum, Hofit Bata, Ido Blass, Inbal Magar, Itay Dalmedigos, Jhonathan Osin, Julie Fadlon, Maria Rozman, Matan Danos, Michael Gokhman, Mor Zusman, Naama Gidron, Nir Ratner, Noam Gat, Noam Rozen, Oded Fried, Ohad Leshno, Omer Antverg, Omri Abend, Or Dagan, Orit Cohavi, Raz Alon, Ro’i Belson, Roi Cohen, Rom Gilad, Roman Glozman, Shahar Lev, Shai Shalev-Shwartz, Shaked Haim Meirom, Tal Delbari, Tal Ness, Tomer Asida, Tom Ben Gal, Tom Braude, Uriya Pumerantz, Josh Cohen, Yonatan Belinkov, Yuval Globerson, Yuval Peleg Levy, and Yoav Shoham. Jamba: Hybrid transformer-mamba language models. In The Thirteenth International Conference on Learning Representations, 2025.arxiv.org/abs/2403.19887
  16. [16]William Merrill, Yanhong Li, Tyler Romero, Anej Svete, Caia Costello, Pradeep Dasigi, Dirk Groen-eveld, David Heineman, Bailey Kuehl, Nathan Lambert, Chuan Li, Kyle Lo, Saumya Malik, DJ Matusz, Benjamin Minixhofer, Jacob Morrison, Luca Soldaini, Finbarr Timbers, Pete Walsh, Noah A. Smith, Hannaneh Hajishirzi, and Ashish Sabharwal. Olmo hybrid: From theory to practice and back, 2026.arxiv.org/abs/2604.03444
  17. [17]Kurt Felix Michalak and Steven Abreu. Some attention is all you need for retrieval. In Mechanistic Interpretability Workshop at NeurIPS 2025, 2025.arxiv.org/abs/2510.19861
  18. [18]Elvis Nunez, Luca Zancato, Benjamin Bowman, Aditya Golatkar, Wei Xia, and Stefano Soatto. Expansion span: Combining fading memory and retrieval in hybrid state space models. In Proceedings of the International Conference on Neuro-symbolic Systems, volume 288 of Proceedings of Machine Learning Research, pages 570–596. PMLR, 28–30 May 2025.arxiv.org/abs/2412.13328
  19. [19]NVIDIA. Nemotron-h: A family of accurate and efficient hybrid mamba-transformer models, 2025.arxiv.org/abs/2504.03624
  20. [20]NVIDIA. Nvidia nemotron 3: Efficient and open intelligence, 2025.arxiv.org/abs/2512.20856
  21. [21]Destiny Okpekpe and Antonio Orvieto. Revisiting associative recall in modern recurrent models, 2025.arxiv.org/abs/2508.19029
  22. [22]Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, Ben Mann, Amanda Askell, Yuntao Bai, Anna Chen, Tom Conerly, Dawn Drain, Deep Ganguli, Zac Hatfield-Dodds, Danny Hernandez, Scott Johnston, Andy Jones, Jackson Kernion, Liane Lovitt, Kamal Ndousse, Dario Amodei, Tom Brown, Jack Clark, Jared Kaplan, Sam McCandlish, and Chris Olah. In-context learning and induction heads. Transformer Circuits Thread, 2022.arxiv.org/abs/2209.11895
  23. [23]Binghui Peng, Srini Narayanan, and Christos Papadimitriou. On limitations of the transformer architecture. In First Conference on Language Modeling, 2024.arxiv.org/abs/2402.08164
  24. [24]Reiner Pope, Sholto Douglas, Akanksha Chowdhery, Jacob Devlin, James Bradbury, Jonathan Heek, Kefan Xiao, Shivani Agrawal, and Jeff Dean. Efficiently scaling transformer inference. In D. Song, M. Carbin, and T. Chen, editors, Proceedings of Machine Learning and Systems, volume 5, pages 606–624. Curan, 2023.arxiv.org/abs/2211.05102
  25. [25]Zihan Qiu, Zekun Wang, Xiao Li, Yanpeng Li, Yang Xu, Yixuan Wang, Huaqing Zhang, Rui Men, Bochao Mao, Chengruidong Zhang, Fan Zhou, Hao Luo, Haofeng Huang, Haoran Lian, Haoyan Huang, Hongqing Chen, Jianwei Zhang, Jing Xu, Junjie Wang, Langshi Chen, Liangyu Wang, Linlang Jiang, Man Yuan, Minmin Sun, Peng Jin, Siqi Zhang, Siyu Wang, Xingzhang Ren, Yakai Wang, Yi Zhang, Yiming Dong, Yizhong Cao, Yubo Ma, Yunfei Mao, Bo Zheng, and Dayiheng Liu. On the design of qwen3.8-next architecture: Evaluation, efficiency, and training stability, 2026.arxiv.org/abs/2608.30320
  26. [26]Qwen Team. Qwen3-next-80b-a3b-instruct. https://huggingface.co/Qwen/Qwen3-Next-80B-A3B-Instruct, 2025. Model card. Accessed 2026-09-08.
  27. [27]Tim Roughgarden. Communication complexity (for algorithm designers). Foundations and Trends in Theoretical Computer Science, 11(3-4):217–404, 2016.
  28. [28]Clayton Sanford, Daniel Hsu, and Matus Telgarsky. Transformers, parallel computation, and logarithmic depth. In Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 43276–43327. PMLR, 21–27 Jul 2024.arxiv.org/abs/2402.09268
  29. [29]Roger Waleffe, Wonmin Byeon, Duncan Riach, Brandon Norick, Vijay Korthikanti, Tri Dao, Albert Gu, Ali Hatamizada, Sudhakar Singh, Deepak Narayanan, Garvit Kulshreshtha, Vartika Singh, Jared Casper, Jan Kautz, Mohammad Shoeybi, and Bryan Catanzaro. An empirical study of mamba-based language models, 2024.arxiv.org/abs/2406.07887
  30. [30]Dustin Wang, Rui-Jie Zhu, Steven Abreu, Yong Shan, Taylor Kergan, Yuqi Pan, Yuhong Chou, Zheng Li, Jibin Wu, Ge Zhang, Wenhao Huang, and Jason Eshraghian. A systematic analysis of hybrid linear attention, 2026.arxiv.org/abs/2507.06457
  31. [31]Xiaojie Xia, Huigang Zhang, Chaoliang Zhong, Jun Sun, and Yusuke Oishi. Distill-then-replace: Efficient task-specific hybrid attention model construction, 2026.arxiv.org/abs/2601.11667
  32. [32]Songlin Yang, Jan Kautz, and Ali Hatamizadeh. Gated delta networks: Improving mamba2 with delta rule. In The Thirteenth International Conference on Learning Representations, 2025.arxiv.org/abs/2412.06464

Paper details

vlnc:W_c8cdjvgd
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 2

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

GPT-5.6 Sol (bare), GPT-6 Astra (bare), generative AI tools

View statement
Looking for related papers…
Contents