Skip to content

Commit eef3d65

Browse files
yao-matrixgithub-actions[bot]DN6
authored
enable 2 test cases on XPU (#11332)
* enable 2 test cases on XPU Signed-off-by: YAO Matrix <matrix.yao@intel.com> * Apply style fixes --------- Signed-off-by: YAO Matrix <matrix.yao@intel.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
1 parent ee6ad51 commit eef3d65

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

tests/quantization/bnb/test_mixed_int8.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,13 +523,15 @@ def test_pipeline_cuda_placement_works_with_mixed_int8(self):
523523
torch_dtype=torch.float16,
524524
device_map=torch_device,
525525
)
526+
526527
# CUDA device placement works.
528+
device = torch_device if torch_device != "rocm" else "cuda"
527529
pipeline_8bit = DiffusionPipeline.from_pretrained(
528530
self.model_name,
529531
transformer=transformer_8bit,
530532
text_encoder_3=text_encoder_3_8bit,
531533
torch_dtype=torch.float16,
532-
).to("cuda")
534+
).to(device)
533535

534536
# Check if inference works.
535537
_ = pipeline_8bit("table", max_sequence_length=20, num_inference_steps=2)

tests/quantization/utils.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
from diffusers.utils import is_torch_available
2+
from diffusers.utils.testing_utils import (
3+
backend_empty_cache,
4+
backend_max_memory_allocated,
5+
backend_reset_peak_memory_stats,
6+
torch_device,
7+
)
28

39

410
if is_torch_available():
@@ -30,9 +36,9 @@ def forward(self, input, *args, **kwargs):
3036
@torch.no_grad()
3137
@torch.inference_mode()
3238
def get_memory_consumption_stat(model, inputs):
33-
torch.cuda.reset_peak_memory_stats()
34-
torch.cuda.empty_cache()
39+
backend_reset_peak_memory_stats(torch_device)
40+
backend_empty_cache(torch_device)
3541

3642
model(**inputs)
37-
max_memory_mem_allocated = torch.cuda.max_memory_allocated()
38-
return max_memory_mem_allocated
43+
max_mem_allocated = backend_max_memory_allocated(torch_device)
44+
return max_mem_allocated

0 commit comments

Comments
 (0)