Abstract
Transformers have become the standard for natural language and speech processing but suffer from quadratic computational complexity relative to sequence length. While linear-complexity architectures like Mamba and Linformer offer a solution, they lack the extensive pretrained weight libraries available for standard Transformers. This paper introduces Cross-Architecture Layerwise Distillation (CALD), a framework that converts pretrained Transformers into efficient linear models during the fine-tuning stage. By leveraging parameter transfer and layerwise distillation, CALD enables the creation of high-performing linear models without the prohibitive cost of pretraining from scratch.
Introduction
The "quadratic bottleneck" of the Transformer's attention mechanism ($O(N^2)$) limits its scalability for long-sequence tasks such as document analysis or high-resolution audio processing. Although alternative architectures with linear complexity ($O(N)$) have emerged, they face a significant "cold start" problem: the most powerful pretrained models (e.g., RoBERTa, Wav2Vec2) are built on quadratic attention. Pretraining linear models to comparable performance levels requires massive computational resources. CALD addresses this by "inheriting" knowledge from existing Transformer weights, bridging the gap between established pretraining and efficient inference.
Methodology: Cross-Architecture Layerwise Distillation
CALD employs a two-pronged approach to model conversion:
- Parameter Transfer: The non-attention components of the Transformer—such as Feed-Forward networks (FFN) and Layer Normalization—are retained. Only the quadratic attention layers are replaced with linear-complexity substitutes, such as Mamba mixers or Linformer projections.
- Layerwise Distillation: To align the new "student" model with the original "teacher," the framework minimizes the Mean Squared Error (MSE) between their intermediate hidden states.
The authors propose four guidance modes to manage the distillation process:
- Target Guided: Distillation from a teacher already fine-tuned on the target task.
- Trajectory Guided: Simultaneous fine-tuning of the teacher and student, forcing the student to mimic the teacher's learning path.
- Waypoint Guided: A resource-efficient alternative using saved teacher checkpoints.
- Hybrid: Initial distillation followed by standard fine-tuning to allow for task-specific specialization.
Architecture-Aware Conversion
Converting bidirectional models (like Wav2Vec2) to unidirectional ones (like Mamba) requires structural adjustments. For speech tasks, the authors implemented a bidirectional Mamba setup using both forward and backward mixers to maintain representation parity.
Experimental Evaluation
The framework was validated across three domains: NLP (RoBERTa to Linformer), Language Modeling (Pythia to Mamba), and Speech Processing (Wav2Vec2 to Mamba2).
Key Findings
- Trajectory Guidance Efficacy: In NLP tasks, Trajectory Guided CALD allowed a converted Linformer to outperform a version pretrained from scratch by 0.2% on average. This suggests that mimicking the teacher's learning evolution helps retain general knowledge.
- Speech Model Dynamics: Speech models exhibit more significant internal representation shifts during fine-tuning than text models. Consequently, the Hybrid mode—distilling initially then allowing the model to deviate—proved most effective for speech.
- Performance Recovery: In ASR, unguided conversion resulted in a poor 11.29% Word Error Rate (WER). CALD successfully recovered performance to 6.41% WER, nearly matching the original Transformer's 6.24%.
Efficiency and Limitations
CALD offers dramatic efficiency gains. Converting Wav2Vec2-large to Mamba2 for ASR required only 1.6 days on a single RTX 3090, whereas the original pretraining took over 5 days on 128 high-end GPUs.
However, limitations remain. Trajectory guidance increases training overhead as it requires running two models simultaneously. Additionally, while CALD significantly improves performance on small data subsets for language modeling, a gap persists compared to full pretraining when data is extremely scarce. Future work will explore scaling CALD to models exceeding 70B parameters.
Conclusion
CALD provides a viable path for transitioning from quadratic Transformers to linear-complexity architectures. By integrating distillation into the fine-tuning phase, it democratizes access to efficient, high-performance models, bypassing the need for massive pretraining budgets.
Summary updated