Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

For compatibility with Stable Diffusion (#2191)

Wang, Chang8884cac8b8cc
diff --git a/auto_round/utils/model.py b/auto_round/utils/model.py
index 907d3bc90..758fc466b 100644
--- a/auto_round/utils/model.py
+++ b/auto_round/utils/model.py
@@ -915,7 +915,12 @@ def diffusion_load_model(
pipe.config[k] = v
pipe = _to_model_dtype(pipe, model_dtype)
- model = pipe.transformer
+ if hasattr(pipe, "unet"):
+ # Stable Diffusion pipelines (e.g., SD and SDXL) use a UNet denoiser.
+ model = pipe.unet
+ else:
+ # DiT-based pipelines (e.g., Flux and SD3) use a Transformer denoiser.
+ model = pipe.transformer
# Attach custom pipeline function for models that need special API calls
_attach_diffusion_pipeline_fn(pipe)