Learning-to-Cache: Accelerating Diffusion Transformer via Layer Caching

Authors: xinyin  ma
gongfan  fang
michael bi mi
xinchao  wang
Venue: NeurIPS_cc_2024_Conference
Published: 2024-05-03 10:22:44

Abstract: Diffusion Transformers have recently demonstrated unprecedented generative capabilities for various tasks. The encouraging results, however, come with the cost of slow inference, since each denoising step requires inference on a transformer model with a large scale of parameters. In this study, we make an interesting and somehow surprising observation: the computation of a large proportion of layers in the diffusion transformer, through introducing a caching mechanism, can be readily removed even without updating the model parameters. In the case of U-ViT-H/2, for example, we may remove up to 93.68% of the computation in the cache steps (46.84% for all steps), with less than 0.01 drop in FID. To achieve this, we introduce a novel scheme, named Learning-to-Cache (L2C), that learns to conduct caching in a dynamic manner for diffusion transformers. Specifically, by leveraging the identical structure of layers in transformers and the sequential nature of diffusion, we explore redundant computations between timesteps by treating each layer as the fundamental unit for caching. To address the challenge of the exponential search space in deep models for identifying layers to cache and remove, we propose a novel differentiable optimization objective. An input-invariant yet timestep-variant router is then optimized, which can finally produce a static computation graph. Experimental results show that L2C largely outperforms samplers such as DDIM and DPM-Solver, alongside prior cache-based methods at the same inference speed.

Main paper: 
 introduction: 
 In recent years, diffusion models [60, 59, 19] have achieved remarkable performance as powerful generative models for image generation [49, 10] . Among the various backbone designs for diffusion models, transformers [62] have emerged as a strong contender, showing its exceptional capabilities not only in synthesizing high-fidelity images [46, 3] but also in video generation [38, 7, 4 ], text-tospeech synthesis [33, 21, 61] and 3D generation [41, 5] . The diffusion transformer, while benefiting greatly from the great property of scalability of the transformer architecture, however, also brings about significant challenges in efficiency, including high deployment costs and slow inference speed.Since the cost of sampling increases proportionally with the number of timesteps and the model size per timestep, naturally, current methods for increasing the sampling efficiency entail two branches: reducing the sampling steps [57, 19, 34, 2] or reducing the inference cost per step [16, 67] . The methods to reduce the number of timesteps include distilling the trajectory into fewer steps [52, 58, 39] , discretizing the reverse-time SDE or the probability flow ODE [57, 73, 37] . Methods in another branch are mainly about compressing the model size [25, 30] or using a low-precision data format [18, 53] . A new method in the dynamic inference of diffusion is a special cache mechanism in the denoising process [40, 64] . These methods leverage the high similarity between the two steps and the special property of U-Net to cache some of the computations, which would be directly used in the next step. Some other dynamic inference methods employ a spectrum of diffusion models and allocate different networks for different steps [65, 44] .Previous approaches, especially those aimed at reducing model size, have predominantly targeted the compression of the U-Net architecture [50] . Our objective is to explore a paradigm for inference acceleration that is more suitable for transformer-based diffusion models. Unlike other architectures, transformers are distinctively composed of several layers with consistent structure. Based on this property, previous compression work on transformers mainly focuses on layer pruning [71] and random layer dropping [14, 48] , as optimizing at the layer level tends to achieve higher speedup ratios compared to width pruning [24, 15, 8] . However, for diffusion transformers, we observed that dropping layers without retraining is not feasible. Removing even a few layers significantly degrades image quality (see Section 4.3) . This observation highlights that the redundancy among layers at varying depths is not evident in DiT. Therefore, we consider another perspective of redundancy: the redundancy across layers situated at the same depths but occurring at different timesteps.Motivated by cache-based methods [40, 64, 28] , we aim to explore the existence and limitations of layer redundancy between timesteps within the diffusion transformer. A straightforward approach involves an exhaustive search where each layer is either cached or not, resulting in an exponentially growing search space with the depth of the layers. Additionally, heuristic-based layer selection cannot adequately address the mutual dependencies between layers. To overcome these challenges, we designed a framework that makes the problem of layer selection differentiable. Specifically, we interpolate predictions between two adjacent steps. This interpolation spans two extremes: a fast configuration where all layers are cached at the expense of image quality, and a slow configuration where all layers are retained, achieving optimal performance. We then search this interpolation space to identify an optimal caching scheme, optimizing a specialized router. This router is time-dependent but input-invariant, allowing the creation of a static computation graph for inference. We train this router by formulating an optimization problem that does not require updating model parameters, making it both cost-effective and easy to optimize.Our results indicate that different percentages of layers can be cached in DiT [41] and U-ViT [3] . Notably, for U-ViT-H/2 on ImageNet, approximately 93.68% of layers are cacheable in the cache step, whereas for DiT-XL/2, the cacheable ratio is 47.43%, both with an almost negligible performance loss (∆FID < 0.01). By comparison, with the same acceleration ratio, a sampler with fewer steps would compromise image quality. Our method L2C can significantly outperform the fast sampler, as well as previous cache-based methods. Additionally, we observed distinct sparsity patterns for layers between these two models, suggesting significant behavioral variations between different architecture designs for diffusion transformers.In summary, our contribution is the proposal of a novel acceleration method, learning-to-cache (L2C), specifically for diffusion transformers. We convert the non-differentiable layer selection problem into a differentiable optimization problem by interpolation, facilitating the learning of layer caching. Our results demonstrate that a large proportion of layers in the diffusion trans-former can be cached without compromising performance. Furthermore, our approach significantly outperforms samplers with fewer steps and other cache-based methods. The code is available at https://github.com/horseee/learning-to-cacheQuestion: Do the main claims made in the abstract and introduction accurately reflect the paper's contributions and scope?Answer: [Yes] Justification: The abstract and introduction clearly state the claims made.Guidelines:• The answer NA means that the abstract and introduction do not include the claims made in the paper. • The abstract and/or introduction should clearly state the claims made, including the contributions made in the paper and important assumptions and limitations. A No or NA answer to this question will not be perceived well by the reviewers. • The claims made should match theoretical and experimental results, and reflect how much the results can be expected to generalize to other settings. • It is fine to include aspirational goals as motivation as long as it is clear that these goals are not attained by the paper. 
related work: 
 Transformers in Diffusion Models. Diffusion models have demonstrated broad applicability across various domains [13, 4, 69] . Transformer [62] is applied in diffusion models as an alternative to UNet [50] . GenViT [68] integrates the ViT [12] architecture into DDPM. U-ViT [3] employs the long skip connections between shallow and deep layers. DiT [46] shows the scalability of diffusion transformers and is further used as a general architecture for text-to-video generation [4, 38] , speech synthesis [33] and 3D generation [5] .Acceleration of Diffusion Models. Generating images by diffusion models requires several rounds of model evaluation which is time-expensive. Some works focus on reducing the number of sampling steps in a training-free manner. DDIM [57] extends the original DDPM to non-Markovian cases. DPM-Solver [36, 37] further approximates the solution of diffusion ODES by the exponential integrators. EDM [23] finds that the Heun'2 2nd order method provides an excellent tradeoff between truncation error and NFE. More works try to solve either SDEs [60, 22, 11] or ODEs [34, 73, 72] in a more accurate and fast way. Other training-based methods [52, 31] distill and half the sampling steps. [58, 39] learns to map any point on the ODE trajectory to its origin. Another line of work reduces the workload per step. The model per step is compressed by reducing the parameter size [16, 6, 71, 63] , using reduced precision [29, 18] and re-design the structure of the diffusion model [67, 30, 75, 25, 35] . In addition to static model inference, dynamic model inference has also been extensively explored within diffusion models, which employs different models for inference at varying steps. [32, 45] switch between different sizes of models in a model zoo. [42] designs a time-dependent exit schedule to skip a subset of parameters. Other works focus on denoising diffusion models in parallel [9] , either through iterative optimization [54] or image splitting [27] . In addition to inference acceleration, some works also show how to train a diffusion model more efficiently by employing different training paradigm [17, 76] or from the data perspective [47] .Cache [55] is used in computer systems to hold temporarily those portions of contents in the main memory which is believed to be used in a short time. Recently, [40, 64, 1] explores the cache mechanism in diffusion models. Based on the observations that the similarities of high-level features [70] is typically very high in consecutive steps, they propose to reuse the feature maps. By utilizing the computation flow of U-Net, [40] reuse the high-level features while updating the low-level features. [64, 28] further discovers the better position in U-Net to be cached. [20] proposes to reuse the attention map. [64, 56, 40] adjust the lifetime for each caching features and [64] further scales and shifts the reused features. [74] finds the cross-attention is redundant in the fidelity-improving stage and can be cached. [66] hashes and caches the images rendered from camera positions and diffusion timesteps to improve the efficiency of 3D generative modeling.Question: Does the paper discuss the limitations of the work performed by the authors?Answer: [Yes]Justification: Section 5 discuss the limitation.Guidelines:• The answer NA means that the paper has no limitation while the answer No means that the paper has limitations, but those are not discussed in the paper. • The authors are encouraged to create a separate "Limitations" section in their paper.• The paper should point out any strong assumptions and how robust the results are to violations of these assumptions (e.g., independence assumptions, noiseless settings, model well-specification, asymptotic approximations only holding locally). The authors should reflect on how these assumptions might be violated in practice and what the implications would be. • The authors should reflect on the scope of the claims made, e.g., if the approach was only tested on a few datasets or with a few runs. In general, empirical results often depend on implicit assumptions, which should be articulated. • The authors should reflect on the factors that influence the performance of the approach.For example, a facial recognition algorithm may perform poorly when image resolution is low or images are taken in low lighting. Or a speech-to-text system might not be used reliably to provide closed captions for online lectures because it fails to handle technical jargon. • The authors should discuss the computational efficiency of the proposed algorithms and how they scale with dataset size. • If applicable, the authors should discuss possible limitations of their approach to address problems of privacy and fairness. • While the authors might fear that complete honesty about limitations might be used by reviewers as grounds for rejection, a worse outcome might be that reviewers discover limitations that aren't acknowledged in the paper. The authors should use their best judgment and recognize that individual actions in favor of transparency play an important role in developing norms that preserve the integrity of the community. Reviewers will be specifically instructed to not penalize honesty concerning limitations. 
preliminary: 
 The forward diffusion process starts at the starting point x 0 , where x 0 is sampled from the data distribution q(x 0 ) to be learned. x 0 is degenerated with gradually added Gaussian noise, with:EQUATIONwhere α t and σ t is the noise coefficient. We can quickly sample x t at arbitrary timestep by reparameterization trick. And for the reverse process, given two timesteps s and t, where s > 0 and t < s, x t is calculated as [36] :EQUATIONwhere λ t = log (α t /σ t ). t λ (λ) is the inverse function of λ t that satisfies t λ (λ t ) = t. ϵ θ (•) often represents the learned model, which, in our case, is the diffusion transformer. Previous methods In contrast, when a layer is disabled, the computation of the non-residual path is bypassed, and the results from the previous step are utilized instead. The router β smoothly controls the transition between two endpoints ϵ θ (x s , s) and ϵ θ (x m , m).show that this integral term can be approximated by adopting Taylor expansion at λ s , adopting the first-order [57] or higher-order approximation of this [36] . Take the first-order one as an example, the update of x t would be:EQUATION3.2 Approximating ϵ θ (•)with a lightweight substituteThe question falls into how to efficiently calculate the term λt λs e -λ εθ x t λ (λ) , t λ (λ) dλ. Our core idea is that we want to keep more updates between s and t while the overall inference time would not increase too much. Suppose that we have three timesteps: s and t and one step m between s and t, the calculation of x t , in the case of Eq.3, would become:EQUATION) If we directly set ϵ θ (x m , m) = ϵ θ (x s , s), it would be equivalent to the results in Equation 3 if we take a step directly from s to t (see the derivation in Appendix A.1). This approach results in faster computation, as it eliminates the need to compute ϵ θ (x m , m); however, it compromises the quality of the resulting image. In contrast, another time-consuming but optimal way is to calculate ϵ θ (x m , m) as usual, which necessitates a full model evaluation but yields superior image quality.Recognizing that ϵ θ (x s , s) represents a rapid yet suboptimal solution and ϵ θ (x m , m) represents a slower but optimal solution when calculating x t , we want to find a model ε(x m , m), which is the interpolation of these two models. We first define the interpolation as follows:EQUATIONwhere εθ (x m , m) is controlled by a set of variables β, functioning as a slider that can smoothly transition between the two endpoints ϵ θ (x s , s) and ϵ θ (x m , m). εθ (x m , m) needs to meet two criteria: it should approximate the output of ϵ θ (x m , m) and be faster for inference compared to ϵ θ (x m , m). By creating the interpolation I, we generate a large collection of models, allowing us to search within this set to find if there exists an εθ (x m , m) that satisfies our requirements.In this section, we specifically define an interpolation I and explore the possibility of the existence of εθ (x m , m) within it. Given the transformer architecture, we propose an interpolation schema Here we take the computation of DiT [46] as an illustrative example. The transformer model can be decomposed into a sequence of basic layersL i (h, t) D i=1 , where L i (h, t) = h + g(t) * f i (h, t), consisting of a residual connection. Here, h is the input feature, and D denotes the depth of the model. t is the time condition. f i (h, t) can represent either a multi-head self-attention (MHSA) block or a pointwise feedforward block, and g(t) is a time-conditioned scalar. We omit the condition t in f i (h, t) for simplicity. Then we can construct a linear interpolation within the layers, and this interpolation of layer satisfies the model interpolationEQUATION) where h s i and h m i is the input to the block L i at timestep s and m respectively. β i is a coefficient in layer i to control the proximity to f (h m i ) or f (x s i ) and α i is to used as an control for the input. Both of these variables are constrained within the range [0, 1].This interpolation provides a special mechanism for inference. If β i in layer i is set to 0, the output can be directly taken from the layer in the previous timestep, allowing the computation cost in this layer to be skipped. Non-zero β i would trigger the original computation of layer i. A discretized β i can be seen as a router, which selects the layers to be activated or disabled. And for α i , it can be set to any value since there is almost no computation cost for a combination of h m i and h s i and we choose α i = 0. By setting more β i in different layers to 0, the acceleration ratio can be cumulative. Therefore, we can calculate the total computational cost based on the number of non-zero β i , and our goal εθ (x m , m) can be interpreted as finding as many zeros in {β i } D i=1 as possible with the minimal approximation error between εθ (x m , m) and ϵ θ (x m , m).One key observation. One greedy way for finding the β i in each layer is taking the approximation error of each layer into account:EQUATIONand takingβ i in those layer with smallest |g(m)| • ||f (h m i ) -f (h s i )|| 2 2 to be 0. In Figure 3, we analyze ||f (h m i ) -f (h s i )|| 2 2in two types of models: DiT and U-ViT. We find that performance varies significantly across different timesteps, even at the same layer. Particularly in the DiT model, the error is markedly higher in the later steps compared to the early denoising steps. Additionally, the performance of multi-head self-attention differs substantially from that of feedforward layers. Based on this, we assign each timestep with its own {β i } D i=1 . Thus, β becomes time-variant, where β = {β ij | i = 1, 2, . . . , T ; j = 1, 2, . . . , D} and T is the total denoising steps.In addition, we directly use this metric as the criterion for β ij and employ it during inference. From the experimental results in 4, we observe that it cannot effectively handle a combination of layers. This limitation arises because the approximation error for each layer is influenced by changes in the preceding layer. However, exhaustively evaluating all possible configurations is impractical, as the number of trials increases exponentially with the depth of the model.To address this, we propose the following method: Learning to Cache. Recall that our goal is to find a εθ (x m , m) that is (1) as close as ϵ θ (x m , m) and ( 2) with minimal computation cost. We can reformulate this as an optimization problem as: where C is the constraint for the total cost. δ βij 1 is the Kronecker delta function, which is 1 if β ij = 1. Though β ij in the final solution needs to be discrete, β ij is designed to be continuous to make the computation differentiable when optimized. And when inference, a threshold θ would be set to discretize the β ij to be either 0 or 1, where β ij turned to become a router. The only trained variables in our algorithm are β. Thus, the parameters in the diffusion model would remain unchanged. With the help of Lagrange duality to transform the optimization problem into an unconstrained one, the loss would be:arg min β ||ε(x m , m; β) -ϵ(x m , m)|| 2 2 s.t. D i=1 δ βij 1 ≤ C (8)EQUATION)where λ is the Lagrangian multiplier that governs the regularization. We show the algorithm for training and inference in Algorithm 1 and 2. To ensure β remains within the range [0, 1], a sigmoid operation is performed before β is passed into the model. In these algorithms, we adopt layer caching every two steps, representing that only half of the steps would inference in a faster speed. For simplicity, the image encoder and decoder are omitted.Question: For each theoretical result, does the paper provide the full set of assumptions and a complete (and correct) proof?Answer: [Yes]Answer: [Yes] Justification: We would release the code and the code is submitted in the supplemental material Guidelines:• The answer NA means that paper does not include experiments requiring code. • Providing as much information as possible in supplemental material (appended to the paper) is recommended, but including URLs to data and code is permitted. 
experimental setup: 
 Models and Datasets. We explore our methods on two commonly used transformer architectures in diffusion models: DiT [46] and U-ViT [3] . Specifically, we use DiT-XL/2 (256×256), DiT-XL/2 (512×512), DiT-L/2 and U-ViT-H/2. Except for DiT-L/2, we use the officially released models. We trained a DiT-L/2 for one million steps, which is used to investigate if layer redundancy exists in smaller models that may not be fully converged. Most of the results are presented under the resolution 256×256 and we also show the results on models that generate high resolution 512×512 images.Implementations. Since the parameters of the diffusion model would not be updated, the only parameters that require optimization are β, resulting in a very limited number of variables. For example, for DiT-XL-2 with 20 denoising steps, the number of trainable variables is 560. We take the training set of ImageNet to train β for 1 epoch. The learning rate is set to 0.01 and AdamW optimizer is used to optimize β. The training is conducted upon 8 A5000 GPUs with a global batch size equal to 64. To train with classifier-free guidance, we randomly drop some labels and assign a null token to the label. The dropping rates for labels follow the original training pipeline. Evaluation. We tested our method upon two samplers, DDIM [57] and DPM-Solver [36] , with sampling steps from 10 to 50. For the DiT model, we use the DDIM sampler. And for U-ViT, we use the DPM-Solver-2. All the experiments here use classifier-free guidance. To evaluate the image quality, 50k images are generated per trial. We measure the image quality with Frechet Inception Distance(FID) [43] , sFID [43] , Inception Score [51] , Precision and Recall [26] . Besides, we reported the total MACs and the latency to make a comparison of the acceleration ratio. The MACs is evaluated using pytorch-OpCounter2 , and the latency is tested when generating a batch of images(8 images) with classifier-free guidance on a single A5000, which we conducted five tests and took the average.We present the results of DiT in Tables 1 and 2 , comparing our algorithms with samplers of comparable inference speed. Our method requires more denoising steps, but each step takes less average time. In contrast, samplers require fewer steps, but each step takes more time. Our experiments demonstrate that our methods significantly outperform DDIM and DPM-Solver. For instance, with the 20-step DDIM on DiT-XL/2, our method achieves an FID of 3.46, nearly identical to the unaccelerated one. In comparison, the DDIM achieves an FID of 4.68. When generating high-resolution images, sampling with fewer steps, or using a relatively smaller model, our method still outperforms baselines. However, we observe that achieving nearly lossless compression under these conditions is challenging. We argue that this difficulty arises because layer redundancy is less apparent in these scenarios.Quality-Latency Tradeoff. We show the trade-off curve between FID and Latency in Figure 4 . These figures offer a more comprehensive comparison with two types of baselines: (1) Heuristic Methods for Selecting Layers. We designed several methods for selecting layers to cache, including rule-based approaches such as caching from top to bottom or from bottom to top, randomly selecting layers, and metric-based selection as described in Eq.7. We found that when the dependency between layers must be considered, they fail to select the optimal layers, leading to a degradation in image quality. In contrast, our method consistently achieves improved quality across various acceleration ratios. (2) Sampler with fewer steps. Our method significantly outperforms DDIM and DPM-Solver, as evidenced by the detailed comparison provided.Maximum Cacheable Layers for diffusion transformer. From the trade-off curve, we found that there exists an upper limit for the number of cacheable layers. Below this limit, image quality remains almost unaffected, as indicated by a FID degradation of less than 0.01. This limit is detailed in Table 4 . Notably, caching does not occur at every step: step s involves full model inference, while only step m caches layers. With a significant proportion of layers can be cached and the computation of these layers to be saved, notable differences emerge between the U-ViT and DiT models. For instance, in U-ViT, up to 94% of layers can be discarded for the cache step during the denoising process, whereas this proportion is considerably lower for DiT. Furthermore, we observed that the cacheable ratios for FFN and MHSA vary.We also compared our method with other cachebased methods. Notably, previous cache-based methods are strongly coupled to the U-Net structure and cannot be applied to models without the U-structure, such as DiT. To ensure a fair comparison, we selected U-ViT, which incorporates both the U-structure and transformers, to implement these methods as baselines alongside our method. Table 3 presents the comparison results. The findings demonstrate that our method achieves better quality than the baselines. The Learned Pattern of β We present the learned pattern in Figure 5 . The two different architectures produce distinct patterns. For U-ViT, the entire middle section is almost entirely cacheable, allowing it to be replaced with the results from the previous step's calculations. However, the computations at both ends of the model are crucial and cannot be discarded. This observation explains why DeepCache outperforms faster-diffusion on U-ViT, as the learned patterns resemble the manually designed approach of DeepCache. However, this phenomenon is not clearly observed in DiT-XL. Additionally, we found a consistent tendency across models to retain more computation in the later stages while discarding calculations in the earlier stages. This observation aligns with our findings in Figure 3 . When comparing the impact of different steps within the same layer, removing parts with smaller timestep has a greater effect on the changes in the output.Comparison between Layer Cache and Layer Dropout Layer dropout involves directly removing f i (•), retaining only the computation in the skip path. We compare our method with layer dropout, where the layers are either randomly dropped or optimized using our algorithm (named Learning-to-Drop). The results, presented in Latency(s) Choice of threshold We investigated the effect of different thresholds on the image quality. Results are shown in Figure 6 , where the model here is trained with six different λ (corresponding to 6 points on one curve). We show the effect of different λ in Appendix B.3. Our results reveal that for higher acceleration ratios, a larger threshold improves image quality. Conversely, for lower acceleration ratios, a smaller threshold is more effective. These also findings suggest that ranking layers by importance is not a reliable approach, since the selection of layers does not follow a strict sequential order. Otherwise, one threshold would win all. 
limitation: 
 The primary limitation of this work arises from its dependence on the trained diffusion models. For instance, when applied to DiT-XL/2 at a resolution of 512, our method encounters a slight drop in FID. Although it still surpasses the baseline, this indicates that the lossless caching of the layers does not uniformly exist across all models. It highlights significant variations between different models, and thus our method is strongly dependent on the structure design of the trained diffusion models. Another limitation of our method is that the acceleration is capped at 2× because every two steps consist of one full model inference step and one cheaper step. This inherently restricts the maximum achievable acceleration ratio. However, we believe that this approach can be expanded to more than two steps, potentially improving the overall efficiency. 
conclusion: 
 In this paper, we propose a novel acceleration method for diffusion transformers. By interpolating between the computationally inexpensive solution but suboptimal model, and the optimal solution but expensive model, we find there exist some models which would infer much faster and also produce high-fidelity images. To find this we train the router which is continuous when training and would be discretized when inference. Experiments show that our method largely outperforms baselines such as DDIM, DPM-Solver and other cache-based methods.Question: Does the paper specify all the training and test details (e.g., data splits, hyperparameters, how they were chosen, type of optimizer, etc.) necessary to understand the results?Answer: [Yes] Justification: In Section 4.1 and Appendix Guidelines:• The answer NA means that the paper does not include experiments.• The experimental setting should be presented in the core of the paper to a level of detail that is necessary to appreciate the results and make sense of them. • The full details can be provided either with the code, in appendix, or as supplemental material. 
experiment statistical significance: 
 Question: Does the paper report error bars suitably and correctly defined or other appropriate information about the statistical significance of the experiments?Answer: [No] Justification: We don't report error bars.Guidelines:• The answer NA means that the paper does not include experiments.• The authors should answer "Yes" if the results are accompanied by error bars, confidence intervals, or statistical significance tests, at least for the experiments that support the main claims of the paper. • The factors of variability that the error bars are capturing should be clearly stated (for example, train/test split, initialization, random drawing of some parameter, or overall run with given experimental conditions). • The method for calculating the error bars should be explained (closed form formula, call to a library function, bootstrap, etc.) • The assumptions made should be given (e.g., Normally distributed errors).• It should be clear whether the error bar is the standard deviation or the standard error of the mean. Guidelines:• The answer NA means that the authors have not reviewed the NeurIPS Code of Ethics.• If the authors answer No, they should explain the special circumstances that require a deviation from the Code of Ethics. • The authors should make sure to preserve anonymity (e.g., if there is a special consideration due to laws or regulations in their jurisdiction). 
broader impacts: 
 Question: Does the paper discuss both potential positive societal impacts and negative societal impacts of the work performed?Answer: [Yes]Justification: We discuss it in Appendix C Guidelines:• The answer NA means that there is no societal impact of the work performed.• If the authors answer NA or No, they should explain why their work has no societal impact or why the paper does not address societal impact. • Examples of negative societal impacts include potential malicious or unintended uses (e.g., disinformation, generating fake profiles, surveillance), fairness considerations (e.g., deployment of technologies that could make decisions that unfairly impact specific groups), privacy considerations, and security considerations.• The conference expects that many papers will be foundational research and not tied to particular applications, let alone deployments. However, if there is a direct path to any negative applications, the authors should point it out. For example, it is legitimate to point out that an improvement in the quality of generative models could be used to generate deepfakes for disinformation. On the other hand, it is not needed to point out that a generic algorithm for optimizing neural networks could enable people to train models that generate Deepfakes faster. • The authors should consider possible harms that could arise when the technology is being used as intended and functioning correctly, harms that could arise when the technology is being used as intended but gives incorrect results, and harms following from (intentional or unintentional) misuse of the technology. • If there are negative societal impacts, the authors could also discuss possible mitigation strategies (e.g., gated release of models, providing defenses in addition to attacks, mechanisms for monitoring misuse, mechanisms to monitor how a system learns from feedback over time, improving the efficiency and accessibility of ML). 
safeguards: 
 Question: Does the paper describe safeguards that have been put in place for responsible release of data or models that have a high risk for misuse (e.g., pretrained language models, image generators, or scraped datasets)?Answer: [NA]Justification: We have no new models/datasets.Guidelines:• The answer NA means that the paper poses no such risks.• Released models that have a high risk for misuse or dual-use should be released with necessary safeguards to allow for controlled use of the model, for example by requiring that users adhere to usage guidelines or restrictions to access the model or implementing safety filters. • Datasets that have been scraped from the Internet could pose safety risks. The authors should describe how they avoided releasing unsafe images. • We recognize that providing effective safeguards is challenging, and many papers do not require this, but we encourage authors to take this into account and make a best faith effort.12. Licenses for existing assets Question: Are the creators or original owners of assets (e.g., code, data, models), used in the paper, properly credited and are the license and terms of use explicitly mentioned and properly respected?Answer: [Yes] Justification: All assets used in our paper is cited or marked in the code.Guidelines:• The answer NA means that the paper does not use existing assets.• The authors should cite the original paper that produced the code package or dataset.• The authors should state which version of the asset is used and, if possible, include a URL. • The name of the license (e.g., CC-BY 4.0) should be included for each asset.• For scraped data from a particular source (e.g., website), the copyright and terms of service of that source should be provided. • If assets are released, the license, copyright information, and terms of use in the package should be provided. For popular datasets, paperswithcode.com/datasets has curated licenses for some datasets. Their licensing guide can help determine the license of a dataset. • For existing datasets that are re-packaged, both the original license and the license of the derived asset (if it has changed) should be provided. 
 
 Appendix: A.1 Two equivalent solutions to obtain x tTo got the solution of x t , the following two approaches yield equivalent results:1. Directly update x t from x s . By the definition, the solution at time t would be:EQUATION2. First compute x m from x s , and then compute x t from x m with ϵ θ (x m , m) = ϵ θ (x s , s)Proof. First, we consider the solution of x m from x s :EQUATIONAnd for the calculation of x t with ϵ θ (x m , m) = ϵ θ (x s , s), we haveEQUATIONNote that λ t = log (α t /σ t ). We obtain:EQUATIONWe next show that the following interpolation of the layer would satisfy the interpolation I between ϵ θ (x s , s) and ϵ θ (x m , m) as we define:EQUATIONTo prove this, we need to show these three things: (1) Interpolation condition, where the function passes through the given two models ϵ θ (x s , s) and ϵ θ (x m , m); (2) Continuity, where the interpolation function is continuous and (3) Differentiability, where the function is differentiable. Since β i and α i are continuous and the model also satisfies these conditions, the only thing that needs to be proved is the first property.Proof. We show Eq.14 satisfies the interpolation condition of I• With {α i } D i=1 and {β i } D i=1 set to 0, the output of the transformer would be ϵ θ (x s , s)EQUATIONThe output of the transformer after D layer is given by:EQUATIONTherefor, we get ϵ θ (x s , s), one of the endpoint in the interpolation I. • With {α i } D i=1 and {β i } D i=1 set to 1, the output would be ϵ θ (x m , m).EQUATIONThe same as above, we would get ϵ θ (x m , m), the other endpoint in the interpolation I.B.1 Shifted cache step for DPM-Solver Here we present further comparisons between layer dropout and layer caching. As illustrated in Figure 7 , layer caching significantly outperforms layer dropout, maintaining pixel-wise consistency with the original pipeline. Conversely, when the layers to be dropped are selected by our algorithm, the model can still generate images with correct semantics. However, randomly dropping layers severely compromises the model's ability to produce acceptable images. Table 7 demonstrates that even a small proportion of layer dropout (around 10%) results in a substantial performance degradation. We find in our experiments that the router we learned is not sensitive to the hyper-parameters, including the learning rate, the training epoch, and the hyperparameters in the optimizer. The only one that would affect is the λ for training and the threshold θ for inference. We list in Table 8 the λ we use that could reproduce the results in Table 1 . Here the difference between DiT and U-ViT for λ comes from the difference in implementation.The results of using different λ values are presented in Table 9 . Note that λ serves as the regularization strength to control the sparsity of the router, and thus there would not exist an optimal λ for all settings. It functions as a trade-off between latency and quality, balancing the speed of inference with the fidelity of the generated images.The acceleration of diffusion transformers provides several positive social impacts, such as reducing the latency and resources required for deploying diffusion models. This enhancement improves the real-time applicability of diffusion transformers and promotes environmental sustainability. By making diffusion models more efficient, our method reduces the computational power needed for both training and inference, leading to lower energy consumption and a reduced carbon footprint. However, it is important to note that our method does not address privacy concerns, nor does it mitigate issues related to bias and fairness in diffusion models. These challenges remain when applying our method.NeurIPS Paper Checklisthttps://github.com/Lyken17/pytorch-OpCounter 


Decision: The paper presents Learning-to-Cache (L2C), a method to accelerate diffusion transformers' inference by caching redundant computations across timesteps. Particularly, by leveraging the repetitive structure of transformer layers and the sequential nature of diffusion, L2C dynamically caches the computations in diffusion transformers for saving computational load. The main concerns were well addressed during rebuttal. I recommend to accept the manuscript and the authors should incorporate the discussions in the final version.

Reviews: review: paper_summary: paper_summary: The paper presents Learning-to-Cache (L2C), a method to accelerate diffusion transformers' inference by caching redundant computations across timesteps. A learnable router dynamically determines which layers can reuse calculations from previous timesteps. L2C can eliminate up to 93.68% of computations in specific steps (46.84% overall) in models like U-ViT-H/2 with minimal performance loss.
strength_weakness: strength_weakness: - The paper's contribution is incremental, primarily introducing a learnable router that determines what computations to reuse from previous timesteps. It would benefit from offering more innovations and deeper insights to significantly advance the field.
- The improvement in speed-up is very similar to DeepCache, which does not require any training.
There are some minor mistakes in the text, such as a typo in line 233 where "maximum" is misspelled as "mamimum."
questions: questions: - Step distillation techniques, which typically involve few or just one step, have successfully accelerated the diffusion process with minimal impact on output quality. Can the proposed model be integrated with distilled models to achieve additional speed-up on top of the improvements gained from distillation?
- You have proposed training only the router parameters while freezing the model parameters. Is there any benefit to fine-tuning and optimizing both the model parameters and the router parameters together?
- What are the implications if the diffusion main loss function is used to train the router?
limitations: limitations: Since the goal is to speed up inference, it should be discussed whether this method can be combined with other acceleration techniques, such as step distillation.
paper_summary: paper_summary: This paper introduces L2C, a novel approach that dynamically caches computations in diffusion transformers, significantly reducing the computational load. L2C leverages the repetitive structure of transformer layers and the sequential nature of diffusion, optimizing caching decisions to produce a static computation graph. Experimental results show that L2C outperforms existing methods like DDIM and DPM-Solver, as well as prior cache-based techniques, at the same inference speed.
strength_weakness: strength_weakness: I am not an expert in this area. There is no obvious weakness as far as I can tell
questions: questions: See Weaknesses
limitations: limitations: See Weaknesses
paper_summary: paper_summary: This paper proposes a method to accelerate DiT model inference using layer caching strategy. By utilizing feature interpolation, the non-differentiable layer selection problem is transformed into a differentiable optimization problem. The routing matrix $\beta$ is learned to indicate whether the features of a certain layer at the current timestep can be reused from the cached features of the same position in the previous timestep. Extensive experimental results demonstrate the effectiveness of this method in accelerating DiT model inference and also shed light on the redundancy of layers in current DiT models.
strength_weakness: strength_weakness: My main concern lies in the scalability of this method:
1. L2C requires training for different DiT models and diffusion schedulers, which limits the potential applications of this method;
2. This paper reports experimental results on DiT and U-ViT series models, but does not experiment on text-to-image models based on the DiT architecture (e.g., Pixart-$\alpha$[1]). Is it because training on large-scale text-image pairs dataset is too costly? 
3. The paper does not report specific training costs time;
4. Compared to the original inference process, will L2C increase additional memory due to routing matrix $\beta$ overhead and feature caching?

[1] Chen, Junsong, et al. "PixArt-$\alpha $: Fast Training of Diffusion Transformer for Photorealistic Text-to-Image Synthesis." arXiv preprint arXiv:2310.00426 (2023).
questions: questions: see weakness
limitations: limitations: Limitations are discussed briefly, but could be touched upon in more detail.

Comments: title: Increasing the Score
Official Comment by Reviewer NP2z
Rebuttal Discussion
comment: Thanks so much for the quite encouraging feedback. We will continue to polish our draft, following your advice. Thank you again for your time and effort in reviewing our submission
I have raised my score and I wish you good luck :)
Thank you for reviewing our paper and providing valuable feedback. We're glad our rebuttal addressed your concerns, and we'll include the suggested experiments in the revised manuscript. Thanks again for your time and effort.
I want to thank the authors for their rebuttal and answering my questions. I will raise my score to WA.
Thank you so much for your valuable update. We will follow your comments to revise our submission.
I appreciate the authors' rebuttal and extra experiments, most of my concerns have been resolved. I will keep my positive score.
Dear Reviewer NP2z,

We sincerely appreciate the time and effort you have dedicated to reviewing our work. We greatly appreciate your thoughtful review of our work and we are looking forward to hearing your feedback. 

To address your concerns regarding the scalability of our method, we have conducted additional experiments, including:

1. Experimental results on PixArt, alongside the comparison results with the few-step DPM-Solver.
2. Showing that the training cost for the router remains within an acceptable range.

We are grateful for your attention to our rebuttal and are committed to addressing any additional concerns you might have. 
Thank you once again for your thoughtful consideration.

Best regards,  
Authors of submission 1630
Dear Reviewer FT6Q:

Thank you for your valuable feedback on our work. Your constructive comments on our work are invaluable, and we genuinely hope to get feedback from you. 

Regarding the weaknesses you mentioned, we include the corresponding experiments as follows:

1. Experimental results when **applying Learning-to-Cache to 4-step LCM on PixArt**. 
2. Generation quality compared with other cache-based methods (DeepCache, Faster Diffusion)
3. Experimental results when optimizing both the model parameters and the router parameters
4. Experimental results using the original diffusion loss.

Your feedback is incredibly important to us, and we sincerely thank you for considering our rebuttal. We are more than happy to discuss them if you have any further concerns or questions.

Thank you again for your time and effort to review our work and looking forward to your response.

Best Regards,  
 Authors of submission 1630
Dear Reviewers,

This is your AC. The authors have provided a response to the comments. Please respond to the rebuttal actively.

Best, 
AC