"vscode:/vscode.git/clone" did not exist on "35e2d9a375a83214912b7a5a11d6d9116720ba3e"
Unverified Commit b2ca39c8 authored by Sayak Paul's avatar Sayak Paul Committed by GitHub
Browse files

[tests] test `encode_prompt()` in isolation (#10438)

* poc encode_prompt() tests

* fix

* updates.

* fixes

* fixes

* updates

* updates

* updates

* revert

* updates

* updates

* updates

* updates

* remove SDXLOptionalComponentsTesterMixin.

* remove tests that directly leveraged encode_prompt() in some way or the other.

* fix imports.

* remove _save_load

* fixes

* fixes

* fixes

* fixes
parent 53217126
...@@ -356,3 +356,9 @@ class HunyuanDiTPAGPipelineFastTests(PipelineTesterMixin, unittest.TestCase): ...@@ -356,3 +356,9 @@ class HunyuanDiTPAGPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
pag_layers = ["blocks.0", r"blocks\.1"] pag_layers = ["blocks.0", r"blocks\.1"]
pipe._set_pag_attn_processor(pag_applied_layers=pag_layers, do_classifier_free_guidance=False) pipe._set_pag_attn_processor(pag_applied_layers=pag_layers, do_classifier_free_guidance=False)
assert len(pipe.pag_attn_processors) == 2 assert len(pipe.pag_attn_processors) == 2
@unittest.skip(
"Test not supported as `encode_prompt` is called two times separately which deivates from about 99% of the pipelines we have."
)
def test_encode_prompt_works_in_isolation(self):
pass
...@@ -252,3 +252,6 @@ class KolorsPAGPipelineFastTests( ...@@ -252,3 +252,6 @@ class KolorsPAGPipelineFastTests(
def test_inference_batch_single_identical(self): def test_inference_batch_single_identical(self):
self._test_inference_batch_single_identical(expected_max_diff=3e-3) self._test_inference_batch_single_identical(expected_max_diff=3e-3)
def test_encode_prompt_works_in_isolation(self):
return super().test_encode_prompt_works_in_isolation(atol=1e-3, rtol=1e-3)
...@@ -47,7 +47,6 @@ from ..test_pipelines_common import ( ...@@ -47,7 +47,6 @@ from ..test_pipelines_common import (
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineTesterMixin, PipelineTesterMixin,
SDXLOptionalComponentsTesterMixin,
) )
...@@ -59,7 +58,6 @@ class StableDiffusionPAGPipelineFastTests( ...@@ -59,7 +58,6 @@ class StableDiffusionPAGPipelineFastTests(
IPAdapterTesterMixin, IPAdapterTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
SDXLOptionalComponentsTesterMixin,
unittest.TestCase, unittest.TestCase,
): ):
pipeline_class = StableDiffusionPAGPipeline pipeline_class = StableDiffusionPAGPipeline
...@@ -278,6 +276,13 @@ class StableDiffusionPAGPipelineFastTests( ...@@ -278,6 +276,13 @@ class StableDiffusionPAGPipelineFastTests(
max_diff = np.abs(image_slice.flatten() - expected_slice).max() max_diff = np.abs(image_slice.flatten() - expected_slice).max()
self.assertLessEqual(max_diff, 1e-3) self.assertLessEqual(max_diff, 1e-3)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -210,6 +210,13 @@ class StableDiffusionPAGImg2ImgPipelineFastTests( ...@@ -210,6 +210,13 @@ class StableDiffusionPAGImg2ImgPipelineFastTests(
max_diff = np.abs(image_slice.flatten() - expected_slice).max() max_diff = np.abs(image_slice.flatten() - expected_slice).max()
self.assertLessEqual(max_diff, 1e-3) self.assertLessEqual(max_diff, 1e-3)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -48,7 +48,6 @@ from ..test_pipelines_common import ( ...@@ -48,7 +48,6 @@ from ..test_pipelines_common import (
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineTesterMixin, PipelineTesterMixin,
SDXLOptionalComponentsTesterMixin,
) )
...@@ -60,7 +59,6 @@ class StableDiffusionPAGInpaintPipelineFastTests( ...@@ -60,7 +59,6 @@ class StableDiffusionPAGInpaintPipelineFastTests(
IPAdapterTesterMixin, IPAdapterTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
SDXLOptionalComponentsTesterMixin,
unittest.TestCase, unittest.TestCase,
): ):
pipeline_class = StableDiffusionPAGInpaintPipeline pipeline_class = StableDiffusionPAGInpaintPipeline
...@@ -244,6 +242,13 @@ class StableDiffusionPAGInpaintPipelineFastTests( ...@@ -244,6 +242,13 @@ class StableDiffusionPAGInpaintPipelineFastTests(
max_diff = np.abs(image_slice.flatten() - expected_slice).max() max_diff = np.abs(image_slice.flatten() - expected_slice).max()
assert max_diff < 1e-3, f"output is different from expected, {image_slice.flatten()}" assert max_diff < 1e-3, f"output is different from expected, {image_slice.flatten()}"
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict, atol=1e-3, rtol=1e-3)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -47,7 +47,6 @@ from ..test_pipelines_common import ( ...@@ -47,7 +47,6 @@ from ..test_pipelines_common import (
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineTesterMixin, PipelineTesterMixin,
SDXLOptionalComponentsTesterMixin,
) )
...@@ -59,7 +58,6 @@ class StableDiffusionXLPAGPipelineFastTests( ...@@ -59,7 +58,6 @@ class StableDiffusionXLPAGPipelineFastTests(
IPAdapterTesterMixin, IPAdapterTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
SDXLOptionalComponentsTesterMixin,
unittest.TestCase, unittest.TestCase,
): ):
pipeline_class = StableDiffusionXLPAGPipeline pipeline_class = StableDiffusionXLPAGPipeline
...@@ -193,9 +191,6 @@ class StableDiffusionXLPAGPipelineFastTests( ...@@ -193,9 +191,6 @@ class StableDiffusionXLPAGPipelineFastTests(
assert np.abs(out.flatten() - out_pag_disabled.flatten()).max() < 1e-3 assert np.abs(out.flatten() - out_pag_disabled.flatten()).max() < 1e-3
assert np.abs(out.flatten() - out_pag_enabled.flatten()).max() > 1e-3 assert np.abs(out.flatten() - out_pag_enabled.flatten()).max() > 1e-3
def test_save_load_optional_components(self):
self._test_save_load_optional_components()
def test_pag_applied_layers(self): def test_pag_applied_layers(self):
device = "cpu" # ensure determinism for the device-dependent torch.Generator device = "cpu" # ensure determinism for the device-dependent torch.Generator
components = self.get_dummy_components() components = self.get_dummy_components()
...@@ -288,6 +283,10 @@ class StableDiffusionXLPAGPipelineFastTests( ...@@ -288,6 +283,10 @@ class StableDiffusionXLPAGPipelineFastTests(
max_diff = np.abs(image_slice.flatten() - expected_slice).max() max_diff = np.abs(image_slice.flatten() - expected_slice).max()
self.assertLessEqual(max_diff, 1e-3) self.assertLessEqual(max_diff, 1e-3)
@unittest.skip("We test this functionality elsewhere already.")
def test_save_load_optional_components(self):
pass
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -58,7 +58,6 @@ from ..test_pipelines_common import ( ...@@ -58,7 +58,6 @@ from ..test_pipelines_common import (
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineTesterMixin, PipelineTesterMixin,
SDXLOptionalComponentsTesterMixin,
) )
...@@ -70,7 +69,6 @@ class StableDiffusionXLPAGImg2ImgPipelineFastTests( ...@@ -70,7 +69,6 @@ class StableDiffusionXLPAGImg2ImgPipelineFastTests(
IPAdapterTesterMixin, IPAdapterTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
SDXLOptionalComponentsTesterMixin,
unittest.TestCase, unittest.TestCase,
): ):
pipeline_class = StableDiffusionXLPAGImg2ImgPipeline pipeline_class = StableDiffusionXLPAGImg2ImgPipeline
...@@ -241,9 +239,6 @@ class StableDiffusionXLPAGImg2ImgPipelineFastTests( ...@@ -241,9 +239,6 @@ class StableDiffusionXLPAGImg2ImgPipelineFastTests(
assert np.abs(out.flatten() - out_pag_disabled.flatten()).max() < 1e-3 assert np.abs(out.flatten() - out_pag_disabled.flatten()).max() < 1e-3
assert np.abs(out.flatten() - out_pag_enabled.flatten()).max() > 1e-3 assert np.abs(out.flatten() - out_pag_enabled.flatten()).max() > 1e-3
def test_save_load_optional_components(self):
self._test_save_load_optional_components()
def test_pag_inference(self): def test_pag_inference(self):
device = "cpu" # ensure determinism for the device-dependent torch.Generator device = "cpu" # ensure determinism for the device-dependent torch.Generator
components = self.get_dummy_components(requires_aesthetics_score=True) components = self.get_dummy_components(requires_aesthetics_score=True)
...@@ -267,6 +262,10 @@ class StableDiffusionXLPAGImg2ImgPipelineFastTests( ...@@ -267,6 +262,10 @@ class StableDiffusionXLPAGImg2ImgPipelineFastTests(
max_diff = np.abs(image_slice.flatten() - expected_slice).max() max_diff = np.abs(image_slice.flatten() - expected_slice).max()
assert max_diff < 1e-3, f"output is different from expected, {image_slice.flatten()}" assert max_diff < 1e-3, f"output is different from expected, {image_slice.flatten()}"
@unittest.skip("We test this functionality elsewhere already.")
def test_save_load_optional_components(self):
pass
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -58,7 +58,6 @@ from ..test_pipelines_common import ( ...@@ -58,7 +58,6 @@ from ..test_pipelines_common import (
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineTesterMixin, PipelineTesterMixin,
SDXLOptionalComponentsTesterMixin,
) )
...@@ -70,7 +69,6 @@ class StableDiffusionXLPAGInpaintPipelineFastTests( ...@@ -70,7 +69,6 @@ class StableDiffusionXLPAGInpaintPipelineFastTests(
IPAdapterTesterMixin, IPAdapterTesterMixin,
PipelineLatentTesterMixin, PipelineLatentTesterMixin,
PipelineFromPipeTesterMixin, PipelineFromPipeTesterMixin,
SDXLOptionalComponentsTesterMixin,
unittest.TestCase, unittest.TestCase,
): ):
pipeline_class = StableDiffusionXLPAGInpaintPipeline pipeline_class = StableDiffusionXLPAGInpaintPipeline
...@@ -246,9 +244,6 @@ class StableDiffusionXLPAGInpaintPipelineFastTests( ...@@ -246,9 +244,6 @@ class StableDiffusionXLPAGInpaintPipelineFastTests(
assert np.abs(out.flatten() - out_pag_disabled.flatten()).max() < 1e-3 assert np.abs(out.flatten() - out_pag_disabled.flatten()).max() < 1e-3
assert np.abs(out.flatten() - out_pag_enabled.flatten()).max() > 1e-3 assert np.abs(out.flatten() - out_pag_enabled.flatten()).max() > 1e-3
def test_save_load_optional_components(self):
self._test_save_load_optional_components()
def test_pag_inference(self): def test_pag_inference(self):
device = "cpu" # ensure determinism for the device-dependent torch.Generator device = "cpu" # ensure determinism for the device-dependent torch.Generator
components = self.get_dummy_components(requires_aesthetics_score=True) components = self.get_dummy_components(requires_aesthetics_score=True)
...@@ -272,6 +267,10 @@ class StableDiffusionXLPAGInpaintPipelineFastTests( ...@@ -272,6 +267,10 @@ class StableDiffusionXLPAGInpaintPipelineFastTests(
max_diff = np.abs(image_slice.flatten() - expected_slice).max() max_diff = np.abs(image_slice.flatten() - expected_slice).max()
assert max_diff < 1e-3, f"output is different from expected, {image_slice.flatten()}" assert max_diff < 1e-3, f"output is different from expected, {image_slice.flatten()}"
@unittest.skip("We test this functionality elsewhere already.")
def test_save_load_optional_components(self):
pass
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -438,3 +438,11 @@ class PIAPipelineFastTests(IPAdapterTesterMixin, PipelineTesterMixin, PipelineFr ...@@ -438,3 +438,11 @@ class PIAPipelineFastTests(IPAdapterTesterMixin, PipelineTesterMixin, PipelineFr
max_diff = np.abs(to_np(output_with_offload) - to_np(output_without_offload)).max() max_diff = np.abs(to_np(output_with_offload) - to_np(output_without_offload)).max()
self.assertLess(max_diff, 1e-4, "XFormers attention should not affect the inference results") self.assertLess(max_diff, 1e-4, "XFormers attention should not affect the inference results")
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"num_images_per_prompt": 1,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
...@@ -413,6 +413,10 @@ class StableAudioPipelineFastTests(PipelineTesterMixin, unittest.TestCase): ...@@ -413,6 +413,10 @@ class StableAudioPipelineFastTests(PipelineTesterMixin, unittest.TestCase):
def test_sequential_offload_forward_pass_twice(self): def test_sequential_offload_forward_pass_twice(self):
pass pass
@unittest.skip("Test not supported because `rotary_embed_dim` doesn't have any sensible default.")
def test_encode_prompt_works_in_isolation(self):
pass
@nightly @nightly
@require_torch_gpu @require_torch_gpu
......
...@@ -307,6 +307,14 @@ class StableCascadeDecoderPipelineFastTests(PipelineTesterMixin, unittest.TestCa ...@@ -307,6 +307,14 @@ class StableCascadeDecoderPipelineFastTests(PipelineTesterMixin, unittest.TestCa
batch_size * prior_num_images_per_prompt * decoder_num_images_per_prompt batch_size * prior_num_images_per_prompt * decoder_num_images_per_prompt
) )
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"batch_size": 1,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -275,6 +275,10 @@ class StableCascadePriorPipelineFastTests(PipelineTesterMixin, unittest.TestCase ...@@ -275,6 +275,10 @@ class StableCascadePriorPipelineFastTests(PipelineTesterMixin, unittest.TestCase
assert np.abs(output_prompt.image_embeddings - output_prompt_embeds.image_embeddings).max() < 1e-5 assert np.abs(output_prompt.image_embeddings - output_prompt_embeds.image_embeddings).max() < 1e-5
@unittest.skip("Test not supported because dtype determination relies on text encoder.")
def test_encode_prompt_works_in_isolation(self):
pass
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -375,84 +375,6 @@ class StableDiffusionPipelineFastTests( ...@@ -375,84 +375,6 @@ class StableDiffusionPipelineFastTests(
assert np.abs(image_slice_1.flatten() - image_slice_2.flatten()).max() < 1e-4 assert np.abs(image_slice_1.flatten() - image_slice_2.flatten()).max() < 1e-4
def test_stable_diffusion_prompt_embeds_no_text_encoder_or_tokenizer(self):
components = self.get_dummy_components()
sd_pipe = StableDiffusionPipeline(**components)
sd_pipe = sd_pipe.to(torch_device)
sd_pipe.set_progress_bar_config(disable=None)
inputs = self.get_dummy_inputs(torch_device)
inputs["negative_prompt"] = "this is a negative prompt"
# forward
output = sd_pipe(**inputs)
image_slice_1 = output.images[0, -3:, -3:, -1]
inputs = self.get_dummy_inputs(torch_device)
prompt = inputs.pop("prompt")
negative_prompt = "this is a negative prompt"
prompt_embeds, negative_prompt_embeds = sd_pipe.encode_prompt(
prompt,
torch_device,
1,
True,
negative_prompt=negative_prompt,
prompt_embeds=None,
negative_prompt_embeds=None,
)
inputs["prompt_embeds"] = prompt_embeds
inputs["negative_prompt_embeds"] = negative_prompt_embeds
sd_pipe.text_encoder = None
sd_pipe.tokenizer = None
# forward
output = sd_pipe(**inputs)
image_slice_2 = output.images[0, -3:, -3:, -1]
assert np.abs(image_slice_1.flatten() - image_slice_2.flatten()).max() < 1e-4
def test_stable_diffusion_prompt_embeds_with_plain_negative_prompt_list(self):
components = self.get_dummy_components()
sd_pipe = StableDiffusionPipeline(**components)
sd_pipe = sd_pipe.to(torch_device)
sd_pipe = sd_pipe.to(torch_device)
sd_pipe.set_progress_bar_config(disable=None)
inputs = self.get_dummy_inputs(torch_device)
negative_prompt = 3 * ["this is a negative prompt"]
inputs["negative_prompt"] = negative_prompt
inputs["prompt"] = 3 * [inputs["prompt"]]
# forward
output = sd_pipe(**inputs)
image_slice_1 = output.images[0, -3:, -3:, -1]
inputs = self.get_dummy_inputs(torch_device)
inputs["negative_prompt"] = negative_prompt
prompt = 3 * [inputs.pop("prompt")]
text_inputs = sd_pipe.tokenizer(
prompt,
padding="max_length",
max_length=sd_pipe.tokenizer.model_max_length,
truncation=True,
return_tensors="pt",
)
text_inputs = text_inputs["input_ids"].to(torch_device)
prompt_embeds = sd_pipe.text_encoder(text_inputs)[0]
inputs["prompt_embeds"] = prompt_embeds
# forward
output = sd_pipe(**inputs)
image_slice_2 = output.images[0, -3:, -3:, -1]
assert np.abs(image_slice_1.flatten() - image_slice_2.flatten()).max() < 1e-4
def test_stable_diffusion_ddim_factor_8(self): def test_stable_diffusion_ddim_factor_8(self):
device = "cpu" # ensure determinism for the device-dependent torch.Generator device = "cpu" # ensure determinism for the device-dependent torch.Generator
...@@ -850,6 +772,13 @@ class StableDiffusionPipelineFastTests( ...@@ -850,6 +772,13 @@ class StableDiffusionPipelineFastTests(
pipe = StableDiffusionPipeline.from_pretrained(sd_repo_id, unet=customised_unet) pipe = StableDiffusionPipeline.from_pretrained(sd_repo_id, unet=customised_unet)
assert pipe.unet.config.sample_size == sample_size assert pipe.unet.config.sample_size == sample_size
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -391,6 +391,13 @@ class StableDiffusionImg2ImgPipelineFastTests( ...@@ -391,6 +391,13 @@ class StableDiffusionImg2ImgPipelineFastTests(
# they should be the same # they should be the same
assert torch.allclose(intermediate_latent, output_interrupted, atol=1e-4) assert torch.allclose(intermediate_latent, output_interrupted, atol=1e-4)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -394,6 +394,13 @@ class StableDiffusionInpaintPipelineFastTests( ...@@ -394,6 +394,13 @@ class StableDiffusionInpaintPipelineFastTests(
) )
return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice) return super().test_ip_adapter(expected_pipe_slice=expected_pipe_slice)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict, atol=1e-3, rtol=1e-3)
class StableDiffusionSimpleInpaintPipelineFastTests(StableDiffusionInpaintPipelineFastTests): class StableDiffusionSimpleInpaintPipelineFastTests(StableDiffusionInpaintPipelineFastTests):
pipeline_class = StableDiffusionInpaintPipeline pipeline_class = StableDiffusionInpaintPipeline
......
...@@ -312,6 +312,13 @@ class StableDiffusion2PipelineFastTests( ...@@ -312,6 +312,13 @@ class StableDiffusion2PipelineFastTests(
def test_inference_batch_single_identical(self): def test_inference_batch_single_identical(self):
super().test_inference_batch_single_identical(expected_max_diff=3e-3) super().test_inference_batch_single_identical(expected_max_diff=3e-3)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_accelerator @require_torch_accelerator
......
...@@ -204,6 +204,13 @@ class StableDiffusionAttendAndExcitePipelineFastTests( ...@@ -204,6 +204,13 @@ class StableDiffusionAttendAndExcitePipelineFastTests(
def test_from_pipe_consistent_forward_pass_cpu_offload(self): def test_from_pipe_consistent_forward_pass_cpu_offload(self):
super().test_from_pipe_consistent_forward_pass_cpu_offload(expected_max_diff=5e-3) super().test_from_pipe_consistent_forward_pass_cpu_offload(expected_max_diff=5e-3)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@require_torch_accelerator @require_torch_accelerator
@nightly @nightly
......
...@@ -369,6 +369,13 @@ class StableDiffusionDepth2ImgPipelineFastTests( ...@@ -369,6 +369,13 @@ class StableDiffusionDepth2ImgPipelineFastTests(
def test_inference_batch_single_identical(self): def test_inference_batch_single_identical(self):
super().test_inference_batch_single_identical(expected_max_diff=7e-3) super().test_inference_batch_single_identical(expected_max_diff=7e-3)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
...@@ -291,6 +291,13 @@ class StableDiffusionDiffEditPipelineFastTests( ...@@ -291,6 +291,13 @@ class StableDiffusionDiffEditPipelineFastTests(
max_diff = np.abs(image_slice.flatten() - expected_slice).max() max_diff = np.abs(image_slice.flatten() - expected_slice).max()
self.assertLessEqual(max_diff, 1e-3) self.assertLessEqual(max_diff, 1e-3)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@require_torch_gpu @require_torch_gpu
@nightly @nightly
......
...@@ -152,6 +152,13 @@ class StableDiffusion2InpaintPipelineFastTests( ...@@ -152,6 +152,13 @@ class StableDiffusion2InpaintPipelineFastTests(
def test_inference_batch_single_identical(self): def test_inference_batch_single_identical(self):
super().test_inference_batch_single_identical(expected_max_diff=3e-3) super().test_inference_batch_single_identical(expected_max_diff=3e-3)
def test_encode_prompt_works_in_isolation(self):
extra_required_param_value_dict = {
"device": torch.device(torch_device).type,
"do_classifier_free_guidance": self.get_dummy_inputs(device=torch_device).get("guidance_scale", 1.0) > 1.0,
}
return super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment