|
24 | 24 | QwenImageTransformer2DModel, |
25 | 25 | ) |
26 | 26 |
|
27 | | -from ...testing_utils import assert_tensors_close, torch_device |
| 27 | +from ...testing_utils import assert_tensors_close, require_accelerator_memory, torch_device |
28 | 28 | from ..testing_utils import ( |
29 | 29 | BasePipelineTesterConfig, |
30 | 30 | MemoryTesterMixin, |
@@ -170,6 +170,15 @@ def test_vae_tiling(self, expected_diff_max: float = 0.2): |
170 | 170 | "VAE tiling should not affect the inference results." |
171 | 171 | ) |
172 | 172 |
|
| 173 | + # The condition image is always resized to ~1 megapixel before it is encoded, so the VAE attention runs over |
| 174 | + # 65k tokens no matter how small the dummy inputs are. On GPUs without bf16 SDPA support that attention falls |
| 175 | + # back to the math backend, which materializes the full attention matrix (~16GB). |
| 176 | + @require_accelerator_memory(24) |
| 177 | + @pytest.mark.skipif(torch_device not in ["cuda", "xpu"], reason="half-precision inference requires CUDA or XPU") |
| 178 | + @pytest.mark.parametrize("dtype", [torch.float16, torch.bfloat16], ids=str) |
| 179 | + def test_half_precision_inference_no_nan(self, dtype): |
| 180 | + super().test_half_precision_inference_no_nan(dtype) |
| 181 | + |
173 | 182 | @pytest.mark.xfail(condition=True, reason="Preconfigured embeddings need to be revisited.", strict=True) |
174 | 183 | def test_encode_prompt_works_in_isolation(self, extra_required_param_value_dict=None, atol=1e-4, rtol=1e-4): |
175 | 184 | super().test_encode_prompt_works_in_isolation(extra_required_param_value_dict, atol, rtol) |
@@ -200,4 +209,7 @@ def test_true_cfg_without_negative_prompt_embeds_mask(self): |
200 | 209 |
|
201 | 210 |
|
202 | 211 | class TestQwenImageEditPipelineMemory(QwenImageEditPipelineTesterConfig, MemoryTesterMixin): |
203 | | - pass |
| 212 | + # Runs the pipeline in bf16, see the note on `test_half_precision_inference_no_nan` above. |
| 213 | + @require_accelerator_memory(24) |
| 214 | + def test_layerwise_casting_inference(self): |
| 215 | + super().test_layerwise_casting_inference() |
0 commit comments