Skip to content

Commit c2787c1

Browse files
authored
Fixes for Float16 inference Fast CUDA Tests (huggingface#5097)
* wip * fix tests
1 parent 79a3f39 commit c2787c1

14 files changed

+67
-3
lines changed

tests/pipelines/controlnet/test_controlnet_inpaint_sdxl.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,6 @@ def test_controlnet_sdxl_guess(self):
299299
# TODO(Patrick, Sayak) - skip for now as this requires more refiner tests
300300
def test_save_load_optional_components(self):
301301
pass
302+
303+
def test_float16_inference(self):
304+
super().test_float16_inference(expected_max_diff=5e-1)

tests/pipelines/kandinsky/test_kandinsky_combined.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ def test_offloads(self):
133133
def test_inference_batch_single_identical(self):
134134
super().test_inference_batch_single_identical(expected_max_diff=1e-2)
135135

136+
def test_float16_inference(self):
137+
super().test_float16_inference(expected_max_diff=1e-1)
138+
136139
def test_dict_tuple_outputs_equivalent(self):
137140
super().test_dict_tuple_outputs_equivalent(expected_max_difference=5e-4)
138141

@@ -236,6 +239,9 @@ def test_offloads(self):
236239
def test_inference_batch_single_identical(self):
237240
super().test_inference_batch_single_identical(expected_max_diff=1e-2)
238241

242+
def test_float16_inference(self):
243+
super().test_float16_inference(expected_max_diff=5e-1)
244+
239245
def test_dict_tuple_outputs_equivalent(self):
240246
super().test_dict_tuple_outputs_equivalent(expected_max_difference=5e-4)
241247

@@ -339,5 +345,8 @@ def test_offloads(self):
339345
def test_inference_batch_single_identical(self):
340346
super().test_inference_batch_single_identical(expected_max_diff=1e-2)
341347

348+
def test_float16_inference(self):
349+
super().test_float16_inference(expected_max_diff=5e-1)
350+
342351
def test_dict_tuple_outputs_equivalent(self):
343352
super().test_dict_tuple_outputs_equivalent(expected_max_difference=5e-4)

tests/pipelines/kandinsky/test_kandinsky_inpaint.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ def test_offloads(self):
290290
assert np.abs(image_slices[0] - image_slices[1]).max() < 1e-3
291291
assert np.abs(image_slices[0] - image_slices[2]).max() < 1e-3
292292

293+
def test_float16_inference(self):
294+
super().test_float16_inference(expected_max_diff=5e-1)
295+
293296

294297
@nightly
295298
@require_torch_gpu

tests/pipelines/kandinsky_v22/test_kandinsky.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ def test_kandinsky(self):
215215
np.abs(image_from_tuple_slice.flatten() - expected_slice).max() < 1e-2
216216
), f" expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}"
217217

218+
def test_float16_inference(self):
219+
super().test_float16_inference(expected_max_diff=1e-1)
220+
218221

219222
@slow
220223
@require_torch_gpu

tests/pipelines/kandinsky_v22/test_kandinsky_combined.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def test_offloads(self):
137137
def test_inference_batch_single_identical(self):
138138
super().test_inference_batch_single_identical(expected_max_diff=1e-2)
139139

140+
def test_float16_inference(self):
141+
super().test_float16_inference(expected_max_diff=1e-1)
142+
140143
def test_dict_tuple_outputs_equivalent(self):
141144
super().test_dict_tuple_outputs_equivalent(expected_max_difference=5e-4)
142145

@@ -243,6 +246,9 @@ def test_offloads(self):
243246
def test_inference_batch_single_identical(self):
244247
super().test_inference_batch_single_identical(expected_max_diff=1e-2)
245248

249+
def test_float16_inference(self):
250+
super().test_float16_inference(expected_max_diff=1e-1)
251+
246252
def test_dict_tuple_outputs_equivalent(self):
247253
super().test_dict_tuple_outputs_equivalent(expected_max_difference=5e-4)
248254

@@ -349,6 +355,9 @@ def test_offloads(self):
349355
def test_inference_batch_single_identical(self):
350356
super().test_inference_batch_single_identical(expected_max_diff=1e-2)
351357

358+
def test_float16_inference(self):
359+
super().test_float16_inference(expected_max_diff=5e-1)
360+
352361
def test_dict_tuple_outputs_equivalent(self):
353362
super().test_dict_tuple_outputs_equivalent(expected_max_difference=5e-4)
354363

tests/pipelines/kandinsky_v22/test_kandinsky_controlnet.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ def test_kandinsky_controlnet(self):
218218
np.abs(image_from_tuple_slice.flatten() - expected_slice).max() < 1e-2
219219
), f" expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}"
220220

221+
def test_float16_inference(self):
222+
super().test_float16_inference(expected_max_diff=1e-1)
223+
221224

222225
@nightly
223226
@require_torch_gpu

tests/pipelines/kandinsky_v22/test_kandinsky_controlnet_img2img.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ def test_kandinsky_controlnet_img2img(self):
228228
def test_inference_batch_single_identical(self):
229229
super().test_inference_batch_single_identical(expected_max_diff=1.75e-3)
230230

231+
def test_float16_inference(self):
232+
super().test_float16_inference(expected_max_diff=2e-1)
233+
231234

232235
@slow
233236
@require_torch_gpu

tests/pipelines/kandinsky_v22/test_kandinsky_img2img.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ def test_kandinsky_img2img(self):
232232
np.abs(image_from_tuple_slice.flatten() - expected_slice).max() < 1e-2
233233
), f" expected_slice {expected_slice}, but got {image_from_tuple_slice.flatten()}"
234234

235+
def test_float16_inference(self):
236+
super().test_float16_inference(expected_max_diff=2e-1)
237+
235238

236239
@slow
237240
@require_torch_gpu

tests/pipelines/kandinsky_v22/test_kandinsky_inpaint.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ def test_kandinsky_inpaint(self):
240240
def test_inference_batch_single_identical(self):
241241
super().test_inference_batch_single_identical(expected_max_diff=3e-3)
242242

243+
def test_float16_inference(self):
244+
super().test_float16_inference(expected_max_diff=5e-1)
245+
243246
def test_model_cpu_offload_forward_pass(self):
244247
super().test_inference_batch_single_identical(expected_max_diff=5e-4)
245248

tests/pipelines/stable_diffusion/test_stable_diffusion_img2img.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ def test_attention_slicing_forward_pass(self):
254254
def test_inference_batch_single_identical(self):
255255
super().test_inference_batch_single_identical(expected_max_diff=3e-3)
256256

257+
def test_float16_inference(self):
258+
super().test_float16_inference(expected_max_diff=5e-1)
259+
257260

258261
@slow
259262
@require_torch_gpu

0 commit comments

Comments
 (0)