SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2302.04304 · ICCV · 2023

Q-Diffusion: Quantizing Diffusion Models

Kurt Keutzer, Shanghang Zhang, Huanrui Yang, Long Lian, Zhen Dong, Xiuyu Li, Daniel Kang, Yijiang Liu

arXiv · PDF · Open in the Atlas

Code that ran

2 of 13 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 1 failure of our instrument; 11 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2302.04304.json · badge: /api/ran/2302.04304.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
Xiuyu-Li/q-diffusion marked official in Papers with Code
Papers with Code archive
2 ran · 11 no recorded run
FunctionStatusWhere it lives
UniformAffineQuantizer Ran
ran on a synthesized input · constructed an object; no result was computed
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("b1f777eef42a5751")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, UniformAffineQuantizer: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'n_bits': 8,
    'symmetric': False,
    'channel_wise': False,
    'scale_method': 'max',
    'leaf_param': False,
    'always_zero': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type UniformAffineQuantizer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a UniformAffineQuantizer output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
cross_attn_forward Ran
ran; our contract draft was wrong, not the code
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("636ef4c5379e7a36")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 3, dtype family float, shape (2, 3, 16) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch import einsum
from einops import rearrange, repeat

torch.manual_seed(0)

# Build the minimal CrossAttention module that satisfies the function's usage
class CrossAttentionModule(nn.Module):
    def __init__(self, dim=16, heads=2, use_act_quant=False):
        super().__init__()
        self.heads = heads
        self.dim_head = dim // heads
        self.scale = (dim // heads) ** -0.5
        self.use_act_quant = use_act_quant
        
        # Linear projections
        self.to_q = nn.Linear(dim, dim)
        self.to_k = nn.Linear(dim, dim)
        self.to_v = nn.Linear(dim, dim)
        self.to_out = nn.Linear(dim, dim)
        
        # Quantizers if needed
        if use_act_quant:
            self.act_quantizer_q = nn.Identity()  # Pass-through for testing
            self.act_quantizer_k = nn.Identity()
            self.act_quantizer_w = nn.Identity()
            self.act_quantizer_v = nn.Identity()

# Create an instance of the module
cross_attn = CrossAttentionModule(dim=16, heads=2, use_act_quant=False)

# Create test tensors
batch_size = 2
seq_len_x = 3
seq_len_context = 5
dim = 16

x = torch.randn(batch_size, seq_len_x, dim)
context = torch.randn(batch_size, seq_len_context, dim)
mask = torch.ones(batch_size, seq_len_context, dtype=torch.bool)

# Map all parameters to values
ARGS = {
    'self': cross_attn,
    'x': x,
    'context': context,
    'mask': mask
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 3, 16) — shape (2, 3, 16) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
BaseQuantBlock Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("dad79c1a08cbe8d8")
How it ran

no invocation recorded.

QuantAttentionBlock Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("d406d4870faffc99")
How it ran

no invocation recorded.

QuantAttnBlock Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("e991182a9dc84857")
How it ran

no invocation recorded.

QuantBasicTransformerBlock Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("b9cdfa2e3669f486")
How it ran

no invocation recorded.

QuantModel Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("3c9100bc42b81ec4")
How it ran

no invocation recorded.

QuantModule Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("aef5c9cd9fed32b2")
How it ran

no invocation recorded.

QuantQKMatMul Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("6b043f103278e7f6")
How it ran

no invocation recorded.

QuantResBlock Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("b62b76ac8c39127e")
How it ran

no invocation recorded.

QuantResnetBlock Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("377acce7bef4d383")
How it ran

no invocation recorded.

QuantSMVMatMul Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("e7511e8abc27d090")
How it ran

no invocation recorded.

get_specials Not yet run
unverified (harvested, no recorded run)
Xiuyu-Li/q-diffusion/qdiff/quant_model.py
code served (permissive licence) · get_code("79c9744c0f2f7be1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 7 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 7 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
BaseQuantBlock
brick of this paper's assembly: helper
3 other papers
3 later
2307.10554 (2023-07)
EMQ: Evolving Training-free Proxies for Automated Mixed Precision Quantization
2405.16005 (2024-05)
PTQ4DiT: Post-training Quantization for Diffusion Transformers
2506.22463 (2025-06)
Modulated Diffusion: Accelerating Generative Modeling with Modulated Quantization
QuantAttentionBlock
brick of this paper's assembly: model
1 other paper
1 later
2506.22463 (2025-06)
Modulated Diffusion: Accelerating Generative Modeling with Modulated Quantization
QuantBasicTransformerBlock
brick of this paper's assembly: model
1 other paper
1 later
2506.22463 (2025-06)
Modulated Diffusion: Accelerating Generative Modeling with Modulated Quantization
QuantResBlock
brick of this paper's assembly: model
1 other paper
1 later
2506.22463 (2025-06)
Modulated Diffusion: Accelerating Generative Modeling with Modulated Quantization
QuantResnetBlock
brick of this paper's assembly: helper
1 other paper
1 later
2506.22463 (2025-06)
Modulated Diffusion: Accelerating Generative Modeling with Modulated Quantization
cross_attn_forward
brick of this paper's assembly: helper
1 other paper
1 later
2403.19140 (2024-03)
QNCD: Quantization Noise Correction for Diffusion Models
get_specials
brick of this paper's assembly: helper
1 other paper
1 later
2506.22463 (2025-06)
Modulated Diffusion: Accelerating Generative Modeling with Modulated Quantization

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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 multitimestep 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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2302.04304")
get_code_for_paper("2302.04304")
have("2302.04304")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2302.04304.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2302.04304.svg)](https://syntology.ai/paper/2302.04304)

Connect an agent — have() is free.