Skip to content

Commit 2b81f83

Browse files
committed
enable kandinsky2_2 integration test cases on XPU
Signed-off-by: Yao Matrix <[email protected]>
1 parent c5c34a4 commit 2b81f83

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

tests/pipelines/kandinsky2_2/test_kandinsky_controlnet.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828
VQModel,
2929
)
3030
from diffusers.utils.testing_utils import (
31+
backend_empty_cache,
3132
enable_full_determinism,
3233
floats_tensor,
3334
load_image,
3435
load_numpy,
3536
nightly,
3637
numpy_cosine_similarity_distance,
38+
require_torch_accelerator,
3739
require_torch_gpu,
40+
torch_device,
3841
)
3942

4043
from ..test_pipelines_common import PipelineTesterMixin
@@ -226,19 +229,19 @@ def test_inference_batch_single_identical(self):
226229

227230

228231
@nightly
229-
@require_torch_gpu
232+
@require_torch_accelerator
230233
class KandinskyV22ControlnetPipelineIntegrationTests(unittest.TestCase):
231234
def setUp(self):
232235
# clean up the VRAM before each test
233236
super().setUp()
234237
gc.collect()
235-
torch.cuda.empty_cache()
238+
backend_empty_cache(torch_device)
236239

237240
def tearDown(self):
238241
# clean up the VRAM after each test
239242
super().tearDown()
240243
gc.collect()
241-
torch.cuda.empty_cache()
244+
backend_empty_cache(torch_device)
242245

243246
def test_kandinsky_controlnet(self):
244247
expected_image = load_numpy(

tests/pipelines/kandinsky2_2/test_kandinsky_controlnet_img2img.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@
2929
VQModel,
3030
)
3131
from diffusers.utils.testing_utils import (
32+
backend_empty_cache,
3233
enable_full_determinism,
3334
floats_tensor,
3435
load_image,
3536
load_numpy,
3637
nightly,
3738
numpy_cosine_similarity_distance,
39+
require_torch_accelerator,
3840
require_torch_gpu,
41+
torch_device,
3942
)
4043

4144
from ..test_pipelines_common import PipelineTesterMixin
@@ -233,19 +236,19 @@ def test_float16_inference(self):
233236

234237

235238
@nightly
236-
@require_torch_gpu
239+
@require_torch_accelerator
237240
class KandinskyV22ControlnetImg2ImgPipelineIntegrationTests(unittest.TestCase):
238241
def setUp(self):
239242
# clean up the VRAM before each test
240243
super().setUp()
241244
gc.collect()
242-
torch.cuda.empty_cache()
245+
backend_empty_cache(torch_device)
243246

244247
def tearDown(self):
245248
# clean up the VRAM after each test
246249
super().tearDown()
247250
gc.collect()
248-
torch.cuda.empty_cache()
251+
backend_empty_cache(torch_device)
249252

250253
def test_kandinsky_controlnet_img2img(self):
251254
expected_image = load_numpy(
@@ -309,4 +312,4 @@ def test_kandinsky_controlnet_img2img(self):
309312
assert image.shape == (512, 512, 3)
310313

311314
max_diff = numpy_cosine_similarity_distance(expected_image.flatten(), image.flatten())
312-
assert max_diff < 1e-4
315+
assert max_diff < 5e-4

0 commit comments

Comments
 (0)