TL;DR
Oryx is a novel hybrid sequence model that dynamically switches between quadratic softmax attention and efficient linear recurrences (like Mamba-2) across a single token sequence. By sharing over 90% of its parameters through tied key-value projections, Oryx allows different token-mixing mechanisms to operate over a unified internal representation space, combining the high-fidelity retrieval of attention with the efficiency of linear models.
What Problem Does This Paper Address?
Transformers dominate modern large language models thanks to their softmax attention mechanism. However, attention suffers from quadratic computational complexity and linear memory growth (the key-value cache bottleneck) as sequences lengthen. Sub-quadratic alternatives like State Space Models (SSMs) and linear attention offer linear time complexity and constant memory, but they consistently lag behind on tasks requiring strong long-context retrieval or complex in-context learning.
To balance this trade-off, researchers typically build hybrid models. Existing hybrids follow two paradigms: inter-layer designs (stacking attention and linear layers on top of each other) or intra-layer designs (running them in parallel within the same block).
However, these approaches fix the compute budget per token statically at design time. They cannot adapt to the reality that different segments of a sequence—such as a massive background prompt versus a short reasoning trace—demand different modeling capacities.
Methods
The authors propose Oryx, a sequence-axis hybrid architecture. Instead of assigning a fixed mixer to an entire layer, Oryx allows the model to flexibly switch between attention and linear modes dynamically along the sequence dimension.
To make this possible, the attention and linear recurrent mechanisms must share a compatible state representation. Oryx achieves this by tying the key ($W^K$) and value ($W^V$) projections across both mixer modes. At each timestep, a single forward pass generates the keys and values, which simultaneously update both the attention KV cache and the linear recurrent state.
Crucially, the authors discovered that while keys and values can be shared, the query projections ($W^Q$) must remain mixer-specific to accommodate the fundamentally different readout requirements of attention versus RNNs.
To train Oryx to handle these switches smoothly during deployment, they introduce Chunked Mixed-Mode Training. Training sequences are partitioned into fixed-length chunks (e.g., 128 tokens), and each chunk is randomly assigned to either the attention or linear mode (using a balanced 1:3 attention-to-linear ratio).
Datasets
- Pretraining: The models were pretrained from scratch on 100B tokens of the FineWeb-Edu dataset.
- Language Modeling Evaluation: Standard downstream benchmarks including LAMBADA, HellaSwag, PIQA, ARC (Easy & Challenge), WinoGrande, and OpenBookQA.
- Retrieval Evaluation: Synthetic Needle-in-a-Haystack (NIAH) tests alongside real-world cloze-format retrieval datasets: SWDE, SQuAD, FDA, TriviaQA, Natural Questions (NQ), and DROP.
Key Insights and Ideas
- A Unified Representation Space: The most profound insight is that attention and linear recurrent models can share the same internal representation space. Despite completely different state parameterizations, tying the KV projections allows them to build a continuous, compatible memory.
- Sequence-Axis Adaptive Compute: This architecture unlocks a new dimension for inference optimization. A model can ingest a massive context prompt using the cheap linear recurrent mode (saving massive KV cache memory) and then switch to softmax attention during generation where precise retrieval is critical.
- The Necessity of Chunked Training: Training models on entirely uniform sequences (sequence-level hybrid training) fails to generalize; such models suffer from massive perplexity spikes when forced to switch modes. Randomly interleaving modes in small chunks during training forces the representations to remain aligned.
Key Results
- Language Modeling Performance: At the 1.4B parameter scale, both the attention and linear modes of Oryx variants (Oryx-TM with Mamba-2, Oryx-TG with Gated DeltaNet) outperform their respective pure single-mixer baselines by over 0.7 percentage points on average downstream tasks.
- Effective Mixed-Inference: When evaluating cross-mode retrieval (prefilling the context with the linear mixer and generating with attention), Oryx achieves performance comparable to a pure Transformer baseline while processing less than 10% of the tokens in attention mode.
- Linear Baseline Boost: In this mixed-inference mode, Oryx-TM outperformed its pure Mamba-2 baseline by 13.5 percentage points on real-world retrieval and 38.6 percentage points on NIAH tests.
Limitations and Future Work
- State Maintenance Overhead: To support flexible switching at any point during deployment, Oryx must maintain and update both the KV cache and the linear RNN state at each timestep. While the memory cost at long contexts is heavily dominated by the KV cache anyway, reducing this dual-state overhead remains an open challenge.
- Static vs. Learnable Routing: This work relies on a static, random chunk assignment during training. A compelling next step is developing learnable routers (similar to Mixture-of-Experts) that dynamically choose the optimal mixer per token based on input difficulty or task demands.
- Exploration of Training Dynamics: The optimization landscape of multi-mixer models with tied representations is unique and largely unexplored. Future work could investigate specialized training objectives or discriminative learning rates for different mixer components.
Summary updated