{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/q-diffusion-quantizing-diffusion-models","title":"Q-Diffusion: Quantizing Diffusion Models","arxiv_id":"2302.04304","date":"2023-02-08","proceeding":"ICCV 2023 1","authors":["Xiuyu Li","Yijiang Liu","Long Lian","Huanrui Yang","Zhen Dong","Daniel Kang","Shanghang Zhang","Kurt Keutzer"],"abstract":"Diffusion models have achieved great success in image synthesis through iterative noise estimation using deep neural networks. However, the slow inference, high memory consumption, and computation intensity of the noise estimation model hinder the efficient adoption of diffusion models. Although post-training quantization (PTQ) is considered a go-to compression method for other tasks, it does not work out-of-the-box on diffusion models. We propose a novel PTQ method specifically tailored towards the unique multi-timestep pipeline and model architecture of the diffusion models, which compresses the noise estimation network to accelerate the generation process. We identify the key difficulty of diffusion model quantization as the changing output distributions of noise estimation networks over multiple time steps and the bimodal activation distribution of the shortcut layers within the noise estimation network. We tackle these challenges with timestep-aware calibration and split shortcut quantization in this work. Experimental results show that our proposed method is able to quantize full-precision unconditional diffusion models into 4-bit while maintaining comparable performance (small FID change of at most 2.34 compared to >100 for traditional PTQ) in a training-free manner. Our approach can also be applied to text-guided image generation, where we can run stable diffusion in 4-bit weights with high generation quality for the first time.","url_abs":"https://arxiv.org/abs/2302.04304v3","url_pdf":"https://arxiv.org/pdf/2302.04304v3.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"q-diffusion-quantizing-diffusion-models","repo_url":"https://github.com/Xiuyu-Li/q-diffusion","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"image-generation","task_name":"Image Generation"},{"task_slug":"noise-estimation","task_name":"Noise Estimation"},{"task_slug":"quantization","task_name":"Quantization"}],"methods":[{"method_slug":"diffusion","method_name":"Diffusion"},{"method_slug":"speed","method_name":"SPEED"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2302.04304","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2302.04304"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/Xiuyu-Li/q-diffusion","reach":null}],"summary":{"ran":1,"ran_draft_wrong":1,"unverified":11},"by_repo_kind":{"official":{"samples":13,"ran":2,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"b1f777eef42a5751","entry":"UniformAffineQuantizer","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b1f777eef42a5751"}},{"code_sha256_prefix":"636ef4c5379e7a36","entry":"cross_attn_forward","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"636ef4c5379e7a36"}},{"code_sha256_prefix":"dad79c1a08cbe8d8","entry":"BaseQuantBlock","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"dad79c1a08cbe8d8"}},{"code_sha256_prefix":"d406d4870faffc99","entry":"QuantAttentionBlock","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"d406d4870faffc99"}},{"code_sha256_prefix":"e991182a9dc84857","entry":"QuantAttnBlock","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e991182a9dc84857"}},{"code_sha256_prefix":"b9cdfa2e3669f486","entry":"QuantBasicTransformerBlock","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b9cdfa2e3669f486"}},{"code_sha256_prefix":"3c9100bc42b81ec4","entry":"QuantModel","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3c9100bc42b81ec4"}},{"code_sha256_prefix":"aef5c9cd9fed32b2","entry":"QuantModule","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"aef5c9cd9fed32b2"}},{"code_sha256_prefix":"6b043f103278e7f6","entry":"QuantQKMatMul","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"6b043f103278e7f6"}},{"code_sha256_prefix":"b62b76ac8c39127e","entry":"QuantResBlock","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b62b76ac8c39127e"}},{"code_sha256_prefix":"377acce7bef4d383","entry":"QuantResnetBlock","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"377acce7bef4d383"}},{"code_sha256_prefix":"e7511e8abc27d090","entry":"QuantSMVMatMul","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e7511e8abc27d090"}},{"code_sha256_prefix":"79c9744c0f2f7be1","entry":"get_specials","repo":"Xiuyu-Li/q-diffusion","repo_kind":"official","path":"qdiff/quant_model.py","file_url":"https://github.com/Xiuyu-Li/q-diffusion/blob/HEAD/qdiff/quant_model.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"79c9744c0f2f7be1"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}