[tests] Pipeline test refactor#14113
Conversation
|
/diffusers-bot pytest tests/pipelines/flux/test_pipeline_flux.py::TestFluxPipeline::test_float16_inference |
|
❌ |
| @@ -1,9 +1,15 @@ | |||
| import contextlib | |||
There was a problem hiding this comment.
Changes here are migrating to pytest.
|
|
||
|
|
||
| @is_staging_test | ||
| class PipelinePushToHubTester(unittest.TestCase): |
There was a problem hiding this comment.
Moved to tests/pipelines/test_pipeline_utils.py
|
All the failing tests are quite unrelated |
| @require_torch_accelerator | ||
| @slow | ||
| class Base4bitTests(unittest.TestCase): | ||
| class Base4bitTests: |
There was a problem hiding this comment.
For pipeline quantization tests, why not use the Mixin approach that we have with models? Or is that planned for a follow up?
| from diffusers import FluxPipeline, FluxTransformer2DModel, QuantoConfig | ||
| from diffusers.models.attention_processor import Attention | ||
| from diffusers.utils import is_optimum_quanto_available, is_torch_available | ||
| from diffusers.utils import is_torch_available |
There was a problem hiding this comment.
Think we can just remove the quanto test entirely and fully deprecate support. Can be done in a separate PR, but just flagging.
|
|
||
|
|
||
| class SanaTransformerFP8WeightsTest(ModelOptBaseTesterMixin, unittest.TestCase): | ||
| class TestSanaTransformerFP8Weights(ModelOptBaseTesterMixin): |
There was a problem hiding this comment.
These would all be removed yes? Because they are model level tests, and should actually be run through the sana model test file?
| if hasattr(module, "_keep_in_fp32_modules") and module._keep_in_fp32_modules is not None: | ||
| for name, param in module.named_parameters(): | ||
| if any( | ||
| module_to_keep_in_fp32 in name.split(".") | ||
| for module_to_keep_in_fp32 in module._keep_in_fp32_modules | ||
| ): | ||
| param.data = param.data.to(torch_device).to(torch.float32) | ||
| else: | ||
| param.data = param.data.to(torch_device).to(torch.float16) | ||
| for name, buf in module.named_buffers(): | ||
| if not buf.is_floating_point(): | ||
| buf.data = buf.data.to(torch_device) | ||
| elif any( | ||
| module_to_keep_in_fp32 in name.split(".") | ||
| for module_to_keep_in_fp32 in module._keep_in_fp32_modules | ||
| ): | ||
| buf.data = buf.data.to(torch_device).to(torch.float32) | ||
| else: | ||
| buf.data = buf.data.to(torch_device).to(torch.float16) |
There was a problem hiding this comment.
We can probably move this into a utilty function.
There was a problem hiding this comment.
Keeping it inline for better readability.
|
@DN6 I believe I have resolved all your comments. PTAL. |
Notes
generate_pipeline_level_tests.pyscript. Will be done in subsequent PRs once other mixins, such as LoRA, are added.pytestfeatures as much as possible. This is particularly reflected in the use of custom fixtures. For example,base_pipe_output. This way, we don't have to compute it for every test that requires it.I have only refactored the Flux pipeline tests to use the new mixin, as we do in other PRs. Will open subsequent PRs for other pipelines and involve the community.