TL;DR
DiffSparse is a novel framework designed to significantly accelerate Diffusion Transformers (DiTs) by learning exactly which "tokens" (image patches) are essential to compute and which can be safely reused from previous steps. By replacing manual heuristics with a learnable cost predictor and a dynamic programming solver, DiffSparse cuts computational costs by over 50% while maintaining—and sometimes even improving—the quality of generated images and videos.
The Bottleneck in Diffusion Transformers
Diffusion models, the engines behind state-of-the-art generation tools, are computationally heavy because they generate images through dozens of iterative denoising steps. Recently, the field has shifted from U-Net architectures to Diffusion Transformers (DiTs), which scale better but are even more resource-intensive.
To speed up inference, researchers often employ "token caching." Because images do not change drastically between adjacent denoising steps, redundant computations can be skipped by reusing previous tokens. However, existing caching methods suffer from two major flaws:
- Manual Tuning: Engineers must hand-craft "sparsity schedules," guessing which layers need more computation at specific timesteps.
- The "Full-Step" Bottleneck: Most methods periodically force a "full" computation step (where no caching occurs) to prevent errors from accumulating. This severely limits the maximum possible speedup.
The DiffSparse Framework
To overcome these limitations, the authors introduce DiffSparse, a differentiable framework that automates the sparsity allocation logic end-to-end.
The framework consists of three main components:
- Token Selector: This module ranks tokens based on their importance. It evaluates self-attention influence (how much a token affects others), cross-attention (how much it relates to the text prompt), and how long it has been since that token was last updated.
- Learnable Sparsity Cost Predictor: Instead of relying on human intuition to set a computational budget, a small neural network predicts a "cost matrix." This matrix estimates the quality loss associated with different levels of sparsity for every layer at every timestep.
- Dynamic Programming (DP) Solver: The solver takes the predicted cost matrix and finds the mathematically optimal configuration of sparsity across the entire denoising trajectory, ensuring it fits within a target computational budget (e.g., using only 45% of total tokens).
Additionally, DiffSparse utilizes a Two-Stage Training Strategy. First, the system is initialized to understand the temporal patterns of the model. Then, it is fine-tuned using Perceptual Distillation (LPIPS loss), where the sparse "student" model learns to match the high-quality output of the original "teacher" model. This distillation process eliminates the need for mandatory "full-computation" steps, unlocking greater efficiency.
Key Insights
- Sparsity as a Regularizer: Surprisingly, DiffSparse often achieves better FID scores (a standard measure of image quality) than the original, uncompressed model. By skipping "unimportant" token computations, the model may effectively filter out noise or redundant information.
- Resolution Transferability: A sparsity pattern learned at a lower resolution (e.g., 256x256) can be successfully applied to higher resolutions (e.g., 512x512) without retraining, making the method highly practical for real-world deployment.
- Layer-Specific Sensitivity: The optimization reveals that different layers have vastly different tolerances for sparsity. For example, early-step MLP layers can be heavily sparsified, while late-step cross-attention layers (which align the image with the text prompt) require more computation to ensure accuracy.
Performance and Results
The researchers validated DiffSparse across a wide variety of models and tasks, including text-to-image generation (PixArt-$\alpha$, FLUX.1-schnell) and text-to-video generation (Wan2.1-1.3B).
- PixArt-$\alpha$: DiffSparse achieved a 1.91x speedup (a 54% reduction in computational tokens) while actually improving the FID score from 28.20 to 27.79.
- FLUX.1-schnell: On this state-of-the-art distilled model, the framework reached a 1.81x speedup with no measurable drop in generation quality.
- Video Generation (Wan2.1): DiffSparse achieved a 2.05x speedup, outperforming previous state-of-the-art methods like DuCa in both speed and visual consistency.
- Search Efficiency: Compared to traditional search methods like Genetic Algorithms, which can take over 16 hours to find a viable sparsity schedule, DiffSparse’s differentiable approach converges on a superior schedule in just about 4 hours.
Limitations and Future Work
While highly effective, DiffSparse has a few limitations. The learned sparsity cost predictor is tied to the specific architecture (number of layers and timesteps) it was trained on; significant architectural changes require re-running the optimization. Furthermore, while the allocation of sparsity is learned, the ranking of specific tokens still relies on predefined heuristics. Future work could focus on making the token selection process fully learnable and optimizing low-level hardware kernels to ensure theoretical FLOP reductions translate perfectly to wall-clock speedups on mobile and edge devices.
Summary updated