TL;DR
Researchers have introduced Relaxed Recursive Transformers, a novel method to shrink Large Language Models (LLMs) by reusing a single block of layers multiple times (layer tying) while adding tiny, layer-specific LoRA adapters to maintain performance. By initializing these models from existing pretrained LLMs and utilizing a new "Continuous Depth-wise Batching" strategy, the authors achieve performance rivaling full-sized models alongside up to a 3x increase in inference throughput.
The Challenge: Deployment Costs and Parameter Sharing
Deploying modern LLMs is notoriously expensive due to their massive memory and computational footprints. While "parameter sharing"—using the same weights for multiple layers—is a classic technique to reduce model size, it has historically struggled to maintain the high performance required by modern LLMs.
This challenge is primarily two-fold:
- Capacity Loss: Forcing different depths of a model to use identical weights (strict layer tying) limits the model's ability to learn depth-specific features.
- Inference Inefficiency: Standard batching strategies do not play well with "early exiting" (where a model stops processing a token once it is confident in its prediction). This leads to idle hardware while the system waits for the slowest sequence in a batch to finish.
Methodology: Evolving the Transformer
To address these bottlenecks, the authors propose a two-step evolution of the standard Transformer architecture.
1. Recursive Transformers
Instead of using $N$ unique layers, the model uses a smaller block of $K$ layers repeated in a loop. To avoid the "cold start" problem of training from scratch, these shared layers are initialized using weights from a larger, pretrained "vanilla" model.
2. Relaxed Recursive Transformers
To fix the capacity loss inherent in strict layer tying, the authors introduce layer-wise LoRA (Low-Rank Adaptation) modules. Each iteration of the loop gets its own tiny set of unique weights, acting as a "relaxation" valve. At rank 0, the model is strictly recursive; at full rank, it effectively recovers the original vanilla model, allowing developers to precisely trade off memory and performance.
Initialization Strategies
The paper demonstrates that how a model is initialized matters more than how long it is trained. The authors compared three initialization strategies for the shared layers:
- Stepwise: Selecting layers at specific intervals.
- Average: Averaging weights across layers.
- Lower: Using only the first $K$ layers.
Crucially, they initialize the LoRA modules using Truncated SVD (T-SVD) to capture the "residual" difference between the original full-sized model's weights and the new shared weights. This SVD initialization significantly speeds up convergence and allows the model to "remember" the nuances of the original full-sized model.
Continuous Depth-wise Batching
Because the layers are shared, the model can theoretically process different samples at different "loop iterations" simultaneously. This breaks the traditional batching bottleneck: if one token exits early, the hardware can immediately start the first "loop" of a brand-new request, maximizing hardware utilization.
Experiments and Key Results
The researchers used Gemma 2B, TinyLlama 1.1B, and Pythia 1B as base models for conversion. The converted recursive models were then "uptrained" on 15B to 60B tokens from the SlimPajama dataset and evaluated across seven few-shot benchmarks (including LAMBADA, HellaSwag, PIQA, WinoGrande, ARC, and OpenBookQA).
- Performance Recovery: A recursive Gemma 1B model (converted from 2B) outperformed vanilla models of the same size (like TinyLlama 1.1B) and recovered most of the original 2B model's accuracy.
- Efficiency: By incorporating knowledge distillation and 60B tokens of uptraining, the Relaxed Recursive Gemma model achieved performance on par with the full-size Gemma 2B (which was originally trained on 3 trillion tokens).
- Throughput Gains: Theoretical analysis of Continuous Depth-wise Batching paired with early exiting suggests a 2-3x gain in throughput compared to standard vanilla Transformers.
Limitations and Future Work
While promising, the study focused on models up to 2B parameters; it remains to be seen if these gains scale to 7B, 70B, or larger models. Furthermore, implementing Continuous Depth-wise Batching in a real-world production environment requires complex management of the Key-Value (KV) cache for tokens at different stages of recursion. Finally, serving multiple LoRA adapters in a single batch currently lacks optimized CUDA kernels, which will be necessary to realize the theoretical speedups in practice.
Summary updated