TL;DR
Transformer models are notoriously compute-heavy because they treat every input token—whether it's a complex object or a blurry background patch—with the same amount of processing power. This paper introduces Adaptive Computation Modules (ACMs), which allow models to dynamically adjust their "width" (computational effort) on a per-token basis. By replacing standard layers with a sequence of parallelizable "learners" and a smart gating mechanism, the authors achieve significant inference speedups with negligible impact on accuracy.
What Problem Does This Paper Address?
State-of-the-art neural networks, particularly Transformers, have ballooned in size, leading to high latency and energy consumption. The authors observe a fundamental inefficiency: the full representational capacity of a layer is often only needed for a small subset of "hard" tokens. For example, in an image of a bird, the patches containing the bird require deep processing, while the clear blue sky patches are computationally "easy."
Existing conditional computation methods have drawbacks. Early Exiting usually stops processing for the entire input at once, lacking granularity. Token Dropping removes information entirely, which can be risky. Mixture-of-Experts (MoE) often allocates a fixed amount of compute per token regardless of difficulty. ACMs aim for a "Goldilocks" solution: granular, per-token width adaptation that is both flexible and hardware-efficient.
Methods
The core of the proposal is the Adaptive Computation Module (ACM). Instead of one large static layer (like an MLP), an ACM consists of $N$ smaller, homogeneous "learners."
- Architecture: A small gating network $g$ looks at an input token $z$ and predicts $k$, the number of learners needed to process it. The final output is the sum of the first $k$ learners. Crucially, once $k$ is determined, these learners can be executed in parallel.
- Smart Initialization: To avoid training from scratch, the authors "ACMize" pre-trained models. They use a three-phase approach:
- Module-wise Distillation: Learners are trained to reconstruct the output of the original static layer.
- Gating Pre-training: The gate is trained using artificial labels derived from the reconstruction error of the learners.
- End-to-End Fine-tuning: The entire model is refined using a combination of task loss and auxiliary losses that encourage computational diversity and adherence to a target FLOP budget.
Datasets
The authors evaluated their method across two distinct domains:
- Computer Vision: ImageNet-1k for standard classification and ImageNet-C for testing robustness to distribution shifts (like blur or noise). They used a Vision Transformer (ViT-B) as the base.
- Speech-to-Text: The CommonVoice-es dataset using a pre-trained XLS-R-300M (Wav2Vec2) model.
Key Insights and Ideas
- Width vs. Depth: While many adaptive methods focus on skipping layers (depth), ACM focuses on adjusting the "effective width" of each layer. The authors argue this is a more granular way to handle token-level difficulty.
- Learner Redundancy: The paper demonstrates that for a majority of tokens, the same transformation can be achieved by just two or three learners instead of the full module, justifying the adaptive approach.
- Hardware Efficiency: Unlike unstructured sparsity, which is hard to accelerate on GPUs, ACMs are designed for efficiency. By sorting tokens by their predicted $k$ value, the model can use standard, highly-optimized matrix multiplication kernels.
- Emergent Specialization: Through auxiliary losses, the model naturally learns to allocate more compute to semantically meaningful regions (like objects in images or actual speech in audio) without being explicitly told to do so.
Key Results
- Pareto Dominance: In vision tasks, ACM-based ViT-B models consistently outperformed baselines like A-ViT and MoEfication, especially at lower computational budgets (below 12.5 GFLOPs).
- Speech Performance: For speech recognition, ACMs achieved a lower Word Error Rate (WER) across all evaluated FLOP budgets compared to MoEfication.
- Real-world Speedup: Using custom Triton kernels, the authors showed that ACMs have negligible overhead. The wall-clock inference time decreases linearly with the average number of executed learners, proving that the theoretical FLOP savings translate to actual hardware speedups.
Limitations and Future Work
- Scope of Adaptation: Currently, ACMs replace MLP blocks and linear projections. The self-attention mechanism itself remains static, which could be a target for future adaptive modules.
- Pruning Synergy: The authors suggest that the relationship between ACMs and weight pruning remains an open question—combining the two could lead to even leaner models.
- Quantization: The training procedure replaces individual modules, suggesting that one could potentially use quantized learners (e.g., 8-bit or 4-bit) to further drive down the inference cost.
Summary updated