TL;DR
DyRA (Dynamic Residual Approximation) is a novel inference-time technique that significantly improves the efficiency of large neural networks by dynamically correcting errors in matrix multiplication. Unlike traditional methods that only approximate model weights, DyRA adapts to specific input activations on the fly, achieving up to a 1.5x GPU speedup while maintaining much higher accuracy than static weight-only baselines.
What Problem Does This Paper Address?
Modern AI relies heavily on massive foundation models, but their size makes inference—the process of running the model—incredibly expensive. The primary bottleneck is dense matrix multiplication ($XW$).
To speed things up, researchers often use "structured weight approximations," replacing heavy weight matrices with lighter, structured versions (like low-rank or block-diagonal forms). However, these methods are weight-centric: they try to make the approximate weights look like the original weights without considering the data ($X$) the model actually sees during use.
The authors point out a critical flaw: even a tiny error in the weight space can be amplified by input activations, leading to massive errors in the output. As shown in the feature visualizations below, weight-only approximations can turn semantically organized features into noisy, degraded messes.
Methods
DyRA introduces Dynamic Residual Approximation. Instead of just settling for an approximate weight matrix $\hat{W}$, it adds a dynamic "correction" term at inference time to account for the residual error ($W_{res} = W - \hat{W}$).
The core idea is to approximate the residual product $XW_{res}$ as a low-rank product $LR$. The challenge is doing this without actually calculating the expensive $XW_{res}$ first. DyRA solves this using Alternating Least Squares (ALS):
- Offline Preparation: A portion of the calculation is precomputed based on the known residual weights and a fixed initialization.
- Inference-Time Correction: For every new input $X$, the model performs a single, highly efficient ALS iteration to find the optimal $L$ and $R$ factors that best capture the output error for that specific input.
- Fusion: To keep things fast, the authors implemented custom Triton kernels that fuse the base projection, bias addition, and this dynamic correction into a single GPU operation, minimizing slow memory accesses.
Datasets
The authors validated DyRA across a wide range of domains and architectures:
- Vision: ImageNet-1K (classification), ADE20K (semantic segmentation), and NYUv2 (depth estimation) using ViT-L and DINOv3.
- Speech: LibriSpeech (automatic speech recognition) using Wav2Vec 2.0.
- Language: HumanEval (coding) and GSM8K (math) using the LLaDA-8B diffusion model and LLaMA-7B. They also tested perplexity on WikiText, PG-19, and C4.
Key Insights and Ideas
- Input-Adaptivity is Essential: The "aha moment" is that the optimal approximation subspace depends on the input. By optimizing for the output of the layer rather than the weights, DyRA captures the information that actually matters for the model's prediction.
- One Step is Enough: While ALS is an iterative optimization, the authors found that a single iteration is sufficient to capture the vast majority of the residual error. This makes the overhead low enough to be practical for real-time inference.
- Better than "Just Adding Rank": The paper mathematically proves that DyRA is more effective than simply increasing the rank of a static approximation. Because DyRA's right-hand factor ($R$) is optimized for the current input $X$, it constructs a tailored subspace that static methods simply cannot match.
Key Results
DyRA consistently outperforms static baselines across all tested tasks:
- Vision Accuracy: On ImageNet, at a 55% FLOPs reduction, a standard BLAST approximation loses 17.4% accuracy. Adding DyRA reduces that loss to just 1.6%.
- Dense Prediction: For semantic segmentation (DINOv3) at 60% FLOPs reduction, DyRA limits the performance drop to 1.7 mIoU points, whereas the weight-only baseline collapses by 54.1 points.
- Practical Speedups: On an NVIDIA A40 GPU, DyRA achieved a 1.52x end-to-end speedup for DINOv3 depth estimation while maintaining significantly higher accuracy than faster, static alternatives.
- Language Modeling: In LLaDA-8B, DyRA improved performance on reasoning tasks by over 20 percentage points compared to FLOPs-matched low-rank baselines.
Limitations and Future Work
- Workload Specificity: DyRA is most effective for "large matrix-matrix" multiplications. This makes it ideal for vision models and the "prefill" stage of LLMs (where the whole prompt is processed at once).
- Autoregressive Decoding: It is currently less suited for the token-by-token generation phase of LLMs, where the workload is "vector-matrix" and doesn't offer the same mathematical leverage for low-rank approximation.
- Future Directions: The authors suggest exploring adaptive rank allocation, where the model could dynamically decide how much correction is needed based on the complexity of the input or the available power budget.
Summary updated