Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions auto_round/compressors/diffusion/compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,20 @@ def calib(self, nsamples, bs):
total = nsamples if not hasattr(self.dataloader, "len") else min(nsamples, len(self.dataloader))
if self.pipe.dtype != self.model.dtype:
self.pipe.to(self.model.dtype)

if (
hasattr(self.model, "hf_device_map")
and len(self.model.hf_device_map) > 0
and self.pipe.device != self.model.device
and torch.device(self.model.device).type in ["cuda", "xpu"]
Copy link
Contributor

@wenhuach21 wenhuach21 Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use not to support other devices in the future

not in ["cpu","hpu"]

):
logger.error(
"Diffusion model is activated sequential model offloading, it will crash during moving to GPU/XPU. "
"Please use model path for quantization or "
"move the pipeline object to GPU/XPU before passing them into API."
)
exit(-1)

if self.pipe.device != self.model.device:
self.pipe.to(self.model.device)
with tqdm(range(1, total + 1), desc="cache block inputs") as pbar:
Expand Down
2 changes: 1 addition & 1 deletion test/test_cuda/test_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def tearDownClass(self):
@require_optimum
def test_diffusion_tune(self):
## load the model
pipe = AutoPipelineForText2Image.from_pretrained(self.model_name)
pipe = AutoPipelineForText2Image.from_pretrained(self.model_name).to("cuda")
model = pipe.transformer

layer_config = {}
Expand Down