BiDM: Pushing the Limit of Quantization for Diffusion Models

Diffusion models (DMs) have been significantly developed and widely used in various applications due to their excellent generative qualities. However, the expensive computation and massive parameters of DMs hinder their practical use in resource-constrained scenarios. As one of the effective compression approaches, quantization allows DMs to achieve storage saving and inference acceleration by reducing bit-width while maintaining generation performance. However, as the most extreme quantization form, 1-bit binarization causes the generation performance of DMs to face severe degradation or even collapse. This paper proposes a novel method, namely BiDM, for fully binarizing weights and activations of DMs, pushing quantization to the 1-bit limit. From a temporal perspective, we introduce the Timestep-friendly Binary Structure (TBS), which uses learnable activation binarizers and cross-timestep feature connections to address the highly timestep-correlated activation features of DMs. From a spatial perspective, we propose Space Patched Distillation (SPD) to address the difficulty of matching binary features during distillation, focusing on the spatial locality of image generation tasks and noise estimation networks. As the first work to fully binarize DMs, the W1A1 BiDM on the LDM-4 model for LSUN-Bedrooms 256$\times$256 achieves a remarkable FID of 22.74, significantly outperforming the current state-of-the-art general binarization methods with an FID of 59.44 and invalid generative samples, and achieves up to excellent 28.0 times storage and 52.7 times OPs savings. The code is available at https://github.com/Xingyu-Zheng/BiDM .

Paper

Similar papers

Peer review

Reviewer AtKg5/10 · confidence 4/52024-06-27

Summary

This paper proposes BiDM, which focuses on quantizing both weights and activations of diffusion models (DMs). Specifically, the authors introduce: - Cross-timestep feature connection to enhance the accuracy of noise prediction in binarized DMs. - Space-patched distillation, a novel variant of distillation loss that emphasizes spatial locality.

Strengths

- Binarization of diffusion models (DMs) represents a promising research area aimed at accelerating sampling processes, and this work appears to be the first to fully binarize DMs to W1A1 to the best of my knowledge. - The introduction of cross-timestep information connection is innovative in enhancing the performance of binarized DMs. - The experimental results on LSUN-Bedrooms, LSUN-Churches, and FFHQ effectively demonstrate the effectiveness of BiDM and XNOR techniques.

Weaknesses

- The experimental results lack sufficient conviction. Tables 1 and 2 compare BiDM primarily with works focused on quantizing discriminative models, which may not be the most appropriate choice of baseline. It would be more informative to include comparisons with quantization methods designed specifically for diffusion models, such as EfficientDM [cite], given its open-sourced nature and compatibility under W1A1 settings. This comparison is crucial for a comprehensive evaluation. - Figure.4 may not effectively demonstrate the advantages of paying attention to local information. To better illustrate the effectiveness of Space-Patched Distillation (SPD), the authors should compare experimental results with those obtained using vanilla distillation loss (Mean Squared Error between outputs of a full precision model and a binarized model). - The proposed binarization method introduces additional convolution computations between two matrices in floating-point, which may not be efficient for hardware deployment. Moreover, the dynamic calculation of matrix $A$ during inference introduces memory access overhead that could be significant in practical deployment scenarios. - During inference, matrix multiplications (MMs) in the attention mechanism typically consume considerable time. It appears that this work retains these MMs in floating-point arithmetic, which could impact efficiency. **minor issues** - Line 93: The citation for BinaryDM is incorrectly linked. - In Figure 4, the caption states "Ours denotes the self-attention," but in the figure, it's labeled as "SPD." - The term "self-attention" in Section 3.3 is confusing; perhaps using an alternative term would be clearer.

Questions

- Are the Q, K, V in the attention modules binarized during inference? - During inference, is $A$ in Equation 9 calculated from the inputs? - In Line 224, the authors claim that "conventional $l_2$ loss makes it difficult for binary DMs to achieve direct matching." Could you provide evidence or reference existing works that have verified this claim? - Figure 3 is somewhat confusing. Why is $L^{t-1}$ a linear scaling up of $B^{t-1}$? Is this relationship depicted by Equation 12?

Rating

5

Confidence

4

Soundness

2

Presentation

3

Contribution

2

Limitations

This paper includes a discussion of limitations.

Authorsrebuttal2024-08-12

Dear Reviewer AtKg, Thank you for your thorough review of our work, BiDM, during the review stage. We have carefully considered your concerns during the rebuttal stage and made revisions to the relevant sections of the manuscript. We are looking forward you to reviewing our response and we are also willing to answer any further questions. Best regards, Authors

Reviewer AtKg2024-08-13

Thanks for the responses.

Thanks for the authors' response. My concerns regarding **Q1, Q2, Q4, Q5, Q6, Q8** have been satisfactorily addressed. Nonetheless, I remain uncertain about the deployment efficiency, particularly given that practical inference speeds often diverge from theoretical operations per second (OPs). The dynamic *min-max* operations, despite their minimal theoretical OPs, may introduce substantial latency in practical deployment, especially with smaller model sizes where matrix multiplications are less significant. I am keen to know if there are effective tools available to verify this. Regarding **Q3**, could you elaborate on the computations in Eq.(9)? Specifically, how is the convolution between $A$ and $ k\alpha $ executed efficiently?

Authorsrebuttal2024-08-13

Re: Further response (2/2)

> Q11: Regarding **Q3**, could you elaborate on the computations in Eq.(9)? Specifically, how is the convolution between A and kα executed efficiently? Yes, in our response to `Q10`, we provided a detailed breakdown of the computation sequence in Eq.(9), including the pre-computed $k'$ and $\alpha$, and the calculations (1)~(6) that need to be performed during inference. For the convolution between $ A $ and $ k\alpha $, the following calculations are involved: - (a) Pre-computation before inference, which does not need to be repeated during inference. This includes: - The divisor $ c $ (the channel dimension) involved in calculating the mean of $ A^{1,h,w} $ from $ I^{c,h,w} $ in a single convolution - $ \alpha^{n,1,1,1} $ obtained from $ W^{n,c,h,w} $ - $ k'^{1,1,3,3} = \frac{k^{1,1,3,3}}{c} $ - (b) As mentioned in `Q10` (4): - Perform the convolution between full-precision $ A^{1,32,32} $ and $ k'^{1,1,3,3} $ to obtain $ O_1^{1,32,32} $ - (c) $ \alpha $ needs to be used in the operation in `Q10` (6): $ O_2^{448,32,32} \odot \alpha^{448,1,1,1} $ The efficiency of our operators (as in XNOR-Net) is reflected in the following: - The operations in (a) can be pre-computed before inference, which means: - Step (3) in `Q10` does not involve high-cost multiplication or division operations. - Step (6) in `Q10` does not require computing $ \alpha $ during inference. - The convolution performed in part (b) has a channel count of only 1. - Step (5) and (6) in `Q10` are point-wise multiplications rather than matrix multiplications, resulting in a lower computational burden. In terms of actual inference time, the inference efficiency of our operators is only 0.19x slower than that of a fully binarized convolution in a Baseline without any full-precision scaling factors, even though we use full-precision inference components, consistent with XNOR-Net, to achieve viewable generative performance.

Reviewer AtKg2024-08-13

Thanks for the Response

My concerns are well addressed and I would like to raise my score by 1 point. Thanks for the authors' detailed responses.

Authorsrebuttal2024-08-13

Re: Further response (1/2)

Thank you for your prompt response. We are glad to clarify the inference efficiency of BiDM. > Q10: Thank you for the authors' response. My concerns regarding **Q1, Q2, Q4, Q5, Q6, Q8** have been satisfactorily addressed. Nonetheless, I remain uncertain about the deployment efficiency, particularly given that practical inference speeds often diverge from theoretical operations per second (OPs). The dynamic *min-max* operations, despite their minimal theoretical OPs, may introduce substantial latency in practical deployment, especially with smaller model sizes where matrix multiplications are less significant. I am keen to know if there are effective tools available to verify this. In BiDM, there are no dynamic *min-max* operations; instead, our design involves only basic arithmetic operations such as convolution, matrix multiplication, addition and summation, and matrix dot multiplication. Additionally, as stated in Eq.(9) of our manuscript and in our response to `Q3`, the operators in BiDM behave the same as those in XNOR-Net[1] during inference, which corresponds to Eq.(11) in the XNOR-Net's original paper. Following your suggestion, we expand upon the inference process described in `Eq.(9)` and provide a detailed explanation and testing. Since the divisor involved in calculating the mean of $ A^{1,h,w} $ from $ I^{c,h,w} $ (i.e., the channel dimension $ c $) can be integrated into $ k^{1,1,3,3} $ in advance, resulting in $ k'^{1,1,3,3} = \frac{k^{1,1,3,3}}{c} $. Additionally, $ \alpha^{n,1,1,1} $ derived from $ W^{n,c,h,w} $ can also be computed ahead of inference. Therefore, the actual operations involved during inference are as follows: [FP] Original full-precision convolution: - (0) Perform convolution between full-precision $I_f^{c=448,w=32,h=32}$ and full-precision $W_f^{n=448,c=448,w=32,h=32}$ to obtain the full-precision output $O_f^{448,32,32}$. [XNOR-Net/BiDM] The inference process for XNOR-Net/BiDM involves the following 6 steps: - Sign operation: - (1) Compute $I_b^{448,32,32} = \text{sign}(I_f^{448,32,32})$. - Binary operation: - (2) Perform convolution between the binary $I_b^{448,32,32}$ and the binary $W_b^{448,448,3,3}$ to obtain the full-precision output $O_f^{448,32,32}$. - Full-precision operations: - (3) Sum the full-precision $I_f^{448,32,32}$ across channels to obtain $A^{1,32,32}$. - (4) Perform convolution between full-precision $A^{1,32,32}$ and $k'^{1,1,3,3}$ to obtain $O_1^{1,32,32}$. - (5) Pointwise multiply $O_f^{448,32,32}$ by $O_1^{1,32,32}$ to obtain the full-precision output $O_2^{448,32,32}$ - (6) Pointwise multiply $O_2^{448,32,32}$ by $\alpha^{448,1,1}$ to obtain the final full-precision output $O^{448,32,32}$ We utilized the general deployment library Larq[2] on a Qualcomm Snapdragon 855 Plus to test the actual runtime efficiency of the aforementioned single convolution. The runtime results for a single inference are summarized in the table below. Due to limitations of the deployment library and hardware, Baseline achieved a 9.97x speedup, while XNOR-Net/BiDM achieved an 8.07x speedup. Besides, the improvement in generation performance brought by BiDM is even more significant, and we believe that it could achieve better acceleration results in a more optimized environment. | | (0) | (1)+(2) | (3) | (4) | (5) | (6) | Runtime($\mu s$/convolution) | FID$\downarrow$ | | :--------------: | :------: | :-----: | :----: | :----: | :--: | :--: | ---------------------------: | --------------: | | FP | 176371.0 | | | | | | 176371.0 | 2.99 | | Baseline(DoReFa) | | 17695.2 | | | | 4.3 | 17699.5 | 188.30 | | XNOR-Net / BiDM | | 17695.2 | 2948.8 | 1133.3 | 83.2 | 4.3 | 21864.8 | 22.74 | [1] Rastegari et al. Xnor-net: Imagenet classification using binary convolutional neural networks. ECCV 2016 [2] "LarQ". https://github.com/larq/larq

Reviewer cNoX7/10 · confidence 4/52024-07-09

Summary

The manuscript proposes a method for fully binarizing both the weights and activations of diffusion models, named BiDM. Structurally, it introduces an improved XNOR method for scaling factors of activations and high-level feature connections across time steps, based on observations of existing temporal phenomena. For optimization, the manuscript presents a patch-based attention mechanism distillation method, approached from the perspective of spatial features. Quantitative analysis and generated examples demonstrate that BiDM, as the first work to fully binarize diffusion models, surpasses existing binarization methods, showcasing the potential for deploying diffusion models in resource-constrained scenarios.

Strengths

1. This is the first work to fully binarize diffusion models, preventing them from collapsing in extreme scenarios and demonstrating acceptable generated samples. This is significant for exploring the compression potential of generative models. 2. The improvement to XNOR is not only applicable to diffusion models (DMs) but also has positive implications for the whole binarization field. Most papers and deployment frameworks, when replicating and implementing XNOR, have consistently followed the approach described in Equations 7 or 8 of this manuscript, rather than the method described in Equation 9. The authors have meticulously examined and adaptively improved the original XNOR approach within the DM field, prompting reconsideration in both DM compression and general binarization fields. 3. The cross-time step connection appears novel and well-suited to the inference structure of DMs. Unlike the cache design in DeepCache, which aims at inference efficiency, this manuscript uses connections to enhance information due to the inherently efficient nature of binarized models. These connections can be placed at multiple nodes within the model, with learnable coefficient factors providing greater adaptability. 4. Section 3.2 first designs TBS from the perspective of information enhancement and then provides further explanation from the perspective of error reduction in Figure 3, making the overall method design appear cohesive and intuitively clear. 5. The distillation strategy design is straightforward and effective, approaching patch division based on the inherent requirements of the generation task and the natural locality of the convolution module, and achieving excellent results.

Weaknesses

1. The description of the cross-time step connection during the training phase is somewhat vague. During the inference phase, the impact of this connection is iteratively attenuated. For example, when α is 0.3, the influence of step T on step T-2 is 0.3×0.3=0.09, rather than 0. However, upon reviewing the source code in the supplementary materials, I found that the authors only consider steps T-1 and T-2 during training. I would like to know if this affects the final accuracy. 2. The scenario assumed in Figure 3 is overly idealized. When only L^t changes, for instance, when L^t is at the lower right of L^(t-1), the weighted average might result in T^(t-1) being further from F^(t-1). How is this situation explained? 3. Although BiDM shows significant improvements over other binarization methods, there remains a substantial performance gap compared to full-precision models. This could still hinder its practical application.

Questions

See Weaknesses

Rating

7

Confidence

4

Soundness

3

Presentation

3

Contribution

3

Limitations

The manuscript only addresses diffusion models using a U-Net backbone primarily based on convolution. It appears to be inapplicable to diffusion models like DiT, which are primarily based on transformers and not related to U-Net.

Authorsrebuttal2024-08-12

Dear Reviewer cNoX, Thank you for your thorough review of our work, BiDM, during the review stage. We have carefully considered your concerns during the rebuttal stage and made revisions to the relevant sections of the manuscript. We are looking forward you to reviewing our response and we are also willing to answer any further questions. Best regards, Authors

Reviewer cNoX2024-08-13

Thank you for the detailed rebuttal and the additional results provided. I appreciate the effort in addressing the issues raised. Due to the novelty and potential broad applications, I am willing to vote for acceptance for this paper.

Reviewer 4HDt5/10 · confidence 3/52024-07-11

Summary

This paper aims to fully binarize weights and activations of diffusion models (DMs) to achieve storage saving and inference acceleration. To this end, the paper proposes timestep-friendly binary structure (TBS), which employs learnable activation binarizers and cross-timestep feature connections to capture the correlation of the activation features over the timesteps. In addition, the paper introduces space patched distillation (SPD) to match the spatial locality of binary features with the full-precision ones during training. The method is tested on some common image generation benchmarks such as LSUN and FFHQ 256x256, CIFAR-10.

Strengths

- The paper aims to tackle a challenging problem which is to fully binarize both weights and activations of diffusion models. - The paper is well-written. - The experimental results are promising. - The proposed methods of using timestep-friendly binary structure and space patched distillation are well-motivated.

Weaknesses

- The main weakness of the paper is that the proposed method, BiDM, increases the training time of DMS compared to the original process. This issue should be more precise in the paper. The authors should compare the convergence rates of the proposed method and its competitors in terms of wall-clock time and identify which components contribute to the increased training time by breaking down the complexity of all main components of the proposed model. - The chosen baselines are quite weak as all of them were originally designed for discriminative tasks such as image classification. The authors should consider stronger baselines dedicated to generative tasks such as [1] and the baselines therein. Ref: [1] Xia et al. Basic Binary Convolution Unit for Binarized Image Restoration Network. ICLR 2023

Questions

In Table 3, it is not clear why adding SPD alone makes the results worse, whereas combining it with TBS leads to improved performance. Do the authors have any explanation for this phenomenon? This point should be addressed to clarify the underlying reasons for the observed behavior and to provide a deeper understanding of the interaction between SPD and TBS in the proposed method.

Rating

5

Confidence

3

Soundness

2

Presentation

2

Contribution

2

Limitations

Yes

Authorsrebuttal2024-08-12

Dear Reviewer 4HDt, Thank you for your thorough review of our work, BiDM, during the review stage. We have carefully considered your concerns during the rebuttal stage and made revisions to the relevant sections of the manuscript. We are looking forward you to reviewing our response and we are also willing to answer any further questions. Best regards, Authors

Area Chair MBb72024-08-10

Rebuttal Discussion

Dear Reviewers, The authors have provided a response to the comments. Please respond to the rebuttal actively. Best, AC

Reviewer 4HDt2024-08-12

Official comment from Reviewer 4HDt

Thanks the author(s) for the rebuttal. As most of my concerns have been addressed, I will increase score by 1 point.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC