HarmoniCa: Harmonizing Training and Inference for Better Feature Cache in Diffusion Transformer Acceleration

Yushi Huang, Zining Wang, Ruihao Gong, Jing Liu, Xinjie Zhang, Jun Zhang · Submission to ICLR 2025 · Rejected

TL;DR

HarmoniCa is a training-based feature caching framework that accelerates Diffusion Transformers (DiTs) without requiring training images. By reconciling the discrepancies between training and inference across full denoising trajectories, it achieves speedups of up to $1.68\times$ on resolutions up to $2048 \times 2048$ while preserving or even improving generation quality.

What Problem Does This Paper Address?

Diffusion Transformers (DiTs) achieve state-of-the-art visual generation but suffer from heavy inference latency due to their scale and multi-step iterative denoising. Because internal representations change slowly between adjacent timesteps, feature caching—storing intermediate block outputs to reuse in subsequent steps—can skip redundant computations.

While early caching methods relied on hand-crafted heuristic rules, recent learning-based methods train a routing matrix to decide when to cache. However, existing learnable routers suffer from two major training-inference discrepancies:

  1. Prior Timestep Disregard: Prior methods train routers at isolated timesteps sampled at random using artificially noised real images (akin to standard DDPM training), ignoring how earlier cache reuse alters features and error accumulation down the trajectory.
  2. Objective Mismatch: The training loss minimizes intermediate single-step noise prediction error (MSE), which diverges from the true inference goal of generating high-fidelity final images ($x_0$).

Methods

HarmoniCa addresses these discrepancies through two key components:

  • Step-Wise Denoising Training (SDT): Instead of isolated timesteps, SDT rolls out the entire $T$-step denoising process. Operating in a student-teacher setup, the student uses the feature cache while the teacher computes full features without caching. The student passes its output to the next step, explicitly capturing cumulative error drifts and realistic cache states across time.
  • Image Error Proxy-Guided Objective (IEPO): Backpropagating through all $T$ steps to calculate final image loss directly requires prohibitive memory ($~5\times$) and compute ($~10\times$). HarmoniCa instead computes a lightweight proxy weight $\lambda^{(t)} = \|x_0 - x_0^{(t)}\|_F^2$, where $x_0^{(t)}$ is an image generated with caching disabled only at step $t$. Updated via gradient-free rollouts every $C$ iterations, $\lambda^{(t)}$ dynamically scales the step-wise noise loss: steps with a large impact on the final image are penalized more heavily for caching.
  • Image-Free Pipeline: Because SDT generates images from random Gaussian noise ($x_T \sim \mathcal{N}(0, I)$), HarmoniCa requires zero training images, drastically lowering training overhead.
       Trajectory Training: x_T (Noise) ──► ... ──► x_t ──► ... ──► x_0
Student (w/ Cache):     [ DiT ] ──► [ Cached DiT ] ──► Output
Teacher (No Cache):     [ DiT ] ─────────────────────► Target
                                                        ▲
Loss:   L = λ^(t) * MSE(Student, Teacher) + β * Sparsity(Router)
             │
             └─ Proxy for final image error impact at step t

Datasets

  • Class-Conditional Generation: ImageNet at $256 \times 256$ and $512 \times 512$ (evaluated using DiT-XL/2).
  • Text-to-Image (T2I) Generation: MS-COCO prompts at $256 \times 256$, $512 \times 512$, and $1024 \times 1024$ (evaluated on PixArt-$\alpha$ and PixArt-$\Sigma$), extending up to $2048 \times 2048$ resolution.
  • Additional Evaluation Benchmarks: MJHQ-30K and sDCI datasets for high-resolution image-reward and perceptual similarity evaluations.

(Note: HarmoniCa uses labels or text prompts for conditioning during router training, but uses zero training images.)

Key Insights and Ideas

  • Early timesteps are deceptively critical: During early denoising steps (large $t$), single-step noise prediction error is small, but its downstream impact on image structure ($\lambda^{(t)}$) is enormous. Naive MSE objectives cause models to aggressively cache early steps, hurting global composition. HarmoniCa's proxy forces the router to compute early steps fully and cache aggressively in later steps where fine details settle.
  • Trajectory continuity prevents drift: Modeling the full sequential rollout aligns the training distribution with the actual inference distribution, mitigating exposure bias and distortion build-up.
  • Extreme compute efficiency: Eliminating the dataset pipeline reduces training time by roughly 25% compared to prior learning-based routers like Learning-to-Cache, requiring only ~1.6 GPU hours for a DiT-XL/2 model on 4 H800 GPUs.

Key Results

  • Higher Speedups with Better Quality: On ImageNet $256 \times 256$ (10-step DDIM), HarmoniCa achieves an FID of 13.35 and IS of 151.83 with a $1.23\times$ speedup, outperforming Learning-to-Cache (FID 14.59, IS 145.09).
  • First 1.5× Acceleration on 2K DiTs: On PixArt-$\Sigma$ at $2048 \times 2048$, HarmoniCa achieves a $1.51\times$ speedup (cutting latency from 14.2s to 9.4s) while maintaining competitive FID (23.88 vs. 23.61) and improved CLIP score (31.36 vs. 31.19).
  • Orthogonality to Quantization: Combining HarmoniCa with 8-bit post-training quantization (EfficientDM) on PixArt-$\alpha$ accelerates generation from $1.18\times$ to $1.77\times$ with an FID increase of only 0.16.

Limitations and Future Work

  • Sampler Dependency: A router optimized for one sampler (e.g., DPM-Solver++) experiences performance drops if evaluated with a different sampler (e.g., SA-Solver). Sampler trajectories must match between training and inference.
  • Hyperparameter Sensitivity: The trade-off between latency and image quality depends on the regularization weight $\beta$, which currently requires manual selection. The authors identify autonomous scheduling of $\beta$ as a direction for future work.

Summary updated

BibTeX
@inproceedings{huang2025harmonica,
  author = {Yushi Huang and Zining Wang and Ruihao Gong and Jing Liu and Xinjie Zhang and Jun Zhang},
  title = {{HarmoniCa: Harmonizing Training and Inference for Better Feature Cache in Diffusion Transformer Acceleration}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=NQyqpK6d72},
}
Figure