Griffin (RG-LRU) Hybrid Language Model
- Griffin (RG-LRU) is a hybrid language model that combines Real-Gated Linear Recurrent Units with sliding-window local multi-query attention for efficient long-sequence processing.
- It alternates RG-LRU and local attention blocks within a residual framework to achieve competitive performance with fewer training tokens and improved throughput.
- Optimized for hardware efficiency, Griffin employs techniques like Megatron-style sharding and bfloat16 operations to deliver lower latency and up to 2× training throughput.
Griffin is a hybrid neural language modeling architecture integrating Real-Gated Linear Recurrent Units (RG-LRU) with sliding-window local multi-query attention. Designed for high hardware efficiency and superior long-sequence processing, Griffin achieves competitive or superior results compared to state-of-the-art Transformer models such as Llama-2, while requiring significantly fewer training tokens and delivering enhanced inference throughput and lower latency. The core innovation lies in the alternation of RG-LRU-based temporal-mixing blocks with local attention within a residual framework, enabling both effective sequence modeling and efficient scaling for large model deployments (De et al., 2024).
1. Architectural Layout and Temporal Mixing
Griffin consists of a stack of residual blocks configured in a pre-normalization sequence. Each residual block is composed of two sub-layers:
- A temporal-mixing sub-layer for aggregating time-dependent information,
- A feed-forward sub-layer implemented with a gated GeLU expansion and projection.
Both sub-layers utilize a structure of RMSNorm applied to the input, followed by the operator and a skip connection. Griffin alternates between two mechanisms for temporal mixing:
- Recurrent blocks based on RG-LRU,
- Local multi-query attention (MQA) blocks with a sliding window.
The canonical cycle is as follows:
| Block Position | Temporal-Mixing Component | Sub-Layer Sequence |
|---|---|---|
| (a) | RG-LRU | RG-LRU → MLP |
| (b) | RG-LRU | RG-LRU → MLP |
| (c) | Local MQA (window size ≈ 1024) | MQA → MLP |
This triadic pattern is repeated times. Every temporal-mixing operator (RG-LRU or MQA) is immediately followed by RMSNorm, a gated MLP, and a residual connection.
2. Mathematical Formulation of the RG-LRU
The RG-LRU, or Real-Gated Linear Recurrent Unit, is a recurrent architecture supporting efficient sequence modeling with stable, trainable gating and parallelism over sequence position. For each timestep , given input and hidden state :
- Recurrence gate:
- Input gate:
- Recurrence weight: (learned)
- Powered gate:
- Update rule:
- Output: 0
Here, the gates 1 and 2 depend exclusively on 3, enabling parallel time computation. Recurrence weights 4 are sigmoid-constrained (a=σ(Λ)) for stability. In practice, 5 is computed in log-space for numerical stability using 6. Projection matrices 7 are often block-diagonal, supporting efficient sharding. This design allows interpolation between pure LRU-like recurrences and state preservation.
3. Residual Block Integration: RG-LRU and Local MQA
Within each residual block:
- Input 8 undergoes RMSNorm.
- If RG-LRU:
- Linear₁ projects 9 to 0,
- Channel-wise separable Conv1D (width=4) produces 1,
- RG-LRU scan computes 2,
- Linear₂ with GeLU and element-wise multiplication: 3, 4,
- Linear₃ projects 5 to 6.
- If local attention:
- Multi-Query Attention over window 7, with RoPE positional encoding.
The output is the sum of the input and 8 (residual branch), followed by RMSNorm, a gated-MLP, and an additional residual connection. This structure is used in all RG-LRU and MQA blocks, preserving a uniform interface for distributed and efficient layer application.
4. Scaling, Sharding, and Hardware Efficiency
Griffin is engineered for scalable model and data parallelism:
- Megatron-style tensor slicing with a single all-reduce per layer for MLPs and attention,
- Attention heads sharded across devices,
- RG-LRU weights (9, 0) block-diagonalized (e.g., 16 blocks per device), with separable Conv1D per channel, eliminating the need for inter-device communication in RG-LRU layers,
- Optimizer states and model parameters are sharded with ZeRO,
- Computations in bfloat16 for both parameters and activations.
On TPU-v3, a custom "Pallas" fused linear-scan kernel for RG-LRU maintains hidden states in fast local memory (VMEM) and batches memory accesses, resulting in a 3× speedup over JAX's scan and a 10–20% overall speedup for the Griffin and Hawk architectures. Associative prefix-sum scans and convolutions were empirically slower and did not decrease memory traffic.
For long sequences (1k), Griffin's temporal-mixing complexity is 2, compared to the Transformer's 3. For 4k at 7B scale, Griffin's training throughput per step is up to 2× higher than MQA baselines. In decoder (generation) mode, Griffin requires only streaming of parameters and a small recurrent state (5), while Transformers must stream parameters and the full 6 key-value cache. For 7k, 8, Griffin/Hawk achieves 9 lower latency and 2–3× higher throughput (tokens/sec per TPU-core).
5. Empirical Results and Sequence Extrapolation
Griffin’s empirical benchmarks demonstrate its efficacy across scale and context length:
- Scaling curves: On MassiveText, from 100M to 14B parameters, Griffin outperforms MQA Transformer baselines by approximately 0.1 bits/token at every scale; through higher budgets, its performance approaches that of the pure Hawk (RG-LRU) model.
- Downstream evaluation (on models trained 300B tokens):
- Mamba-3B (600B tokens): 58.5
- Llama-2-7B/13B (2T tokens): 65.3 / 69.3
- Griffin-3B: 60.7
- Griffin-7B: 65.8 (matches Llama-2-7B with 7× fewer tokens)
- Griffin-14B: 69.5 (matches Llama-2-13B with ∼7× fewer tokens)
- Hawk-3B surpasses Mamba-3B despite half the training tokens.
- Long-context extrapolation: When evaluated on held-out Books and ArXiv after training with 0, Transformer loss plateaus or degrades past 2k tokens, whereas Hawk and Griffin retain improvements up to 32k tokens. Training with 1 further boosts Griffin's performance for 2k (at the expense of very short contexts).
- Copy and retrieval tasks: On synthetic "Selective Copy", Griffin matches Transformer learning speed, while Hawk is slower. In "Induction Heads" generalization (train 3, test 4), Griffin and Hawk extrapolate perfectly. For phonebook lookup, Griffin retrieves up to the local window (1024), gracefully degrading after, while Transformer and Hawk fail beyond their respective context limits (De et al., 2024).
6. Relationship to Related Architectures and Importance
Griffin’s hybrid approach interpolates between the sequential processing strengths of recurrent models and the global contextualization of attention mechanisms. Unlike pure Transformers, which are quadratic in sequence length for temporal-mixing, Griffin's 5 complexity enables substantial benefits for long-context tasks and high-throughput inference. Unlike models relying exclusively on attention or recurrence, Griffin’s interleaving of RG-LRU and local attention is central to its capacity for extrapolation, token efficiency, and hardware-aligned deployment at scale.
A plausible implication is that Griffin offers a template for future efficient LLM designs targeting longer context windows, hardware efficiency, and scalable distributed training, while closing the performance gap with well-known large-scale Transformer baselines (De et al., 2024).