Skip to content

[tests] Pipeline test refactor#14113

Open
sayakpaul wants to merge 32 commits into
mainfrom
pipeline-test-refactor
Open

[tests] Pipeline test refactor#14113
sayakpaul wants to merge 32 commits into
mainfrom
pipeline-test-refactor

Conversation

@sayakpaul

@sayakpaul sayakpaul commented Jul 3, 2026

Copy link
Copy Markdown
Member

Notes

  • The PR doesn't have LoRA-related tests refactored yet. That will be a big change, and I want to do it in a different PR to keep the reviewing scope manageable.
  • I haven't yet added a generate_pipeline_level_tests.py script. Will be done in subsequent PRs once other mixins, such as LoRA, are added.
  • There were a lot of overlaps between the pipeline-level and model-level quantization tests. So, I have removed redundancy as much as possible by keeping only the pipeline-level quantization tests that genuinely require pipeline-level specs.
  • I have used pytest features 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.

@github-actions github-actions Bot added tests size/L PR with diff > 200 LOC labels Jul 3, 2026
@sayakpaul

Copy link
Copy Markdown
Member Author

/diffusers-bot pytest tests/pipelines/flux/test_pipeline_flux.py::TestFluxPipeline::test_float16_inference

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

pytest tests/pipelines/flux/test_pipeline_flux.py::TestFluxPipeline::test_float16_inference failed on GPU — view logs.

@@ -1,9 +1,15 @@
import contextlib

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes here are migrating to pytest.



@is_staging_test
class PipelinePushToHubTester(unittest.TestCase):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to tests/pipelines/test_pipeline_utils.py

@sayakpaul sayakpaul marked this pull request as ready for review July 6, 2026 03:07
@sayakpaul sayakpaul requested review from DN6, dg845 and yiyixuxu July 6, 2026 03:07
@sayakpaul

Copy link
Copy Markdown
Member Author

All the failing tests are quite unrelated

Comment thread tests/pipelines/testing_utils/common.py Outdated
Comment thread tests/pipelines/testing_utils/utils.py Outdated
Comment thread tests/pipelines/testing_utils/utils.py Outdated
Comment thread tests/pipelines/testing_utils/common.py Outdated
Comment thread tests/pipelines/flux/test_pipeline_flux.py Outdated
Comment thread tests/pipelines/testing_utils/common.py Outdated
Comment thread tests/pipelines/testing_utils/common.py Outdated
Comment thread tests/pipelines/testing_utils/common.py Outdated
Comment thread tests/pipelines/testing_utils/common.py Outdated
@require_torch_accelerator
@slow
class Base4bitTests(unittest.TestCase):
class Base4bitTests:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For pipeline quantization tests, why not use the Mixin approach that we have with models? Or is that planned for a follow up?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup.

@sayakpaul sayakpaul requested a review from DN6 July 8, 2026 06:19
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These would all be removed yes? Because they are model level tests, and should actually be run through the sana model test file?

Comment thread tests/pipelines/testing_utils/ip_adapter.py Outdated
Comment thread tests/pipelines/testing_utils/ip_adapter.py Outdated
Comment thread tests/pipelines/testing_utils/ip_adapter.py Outdated
Comment thread tests/pipelines/testing_utils/cache.py
Comment thread tests/pipelines/testing_utils/cache.py Outdated
Comment thread tests/pipelines/testing_utils/cache.py Outdated
Comment thread tests/pipelines/testing_utils/cache.py Outdated
Comment on lines +401 to +419
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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably move this into a utilty function.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it inline for better readability.

@sayakpaul

Copy link
Copy Markdown
Member Author

@DN6 I believe I have resolved all your comments. PTAL.

@sayakpaul sayakpaul requested a review from DN6 July 10, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L PR with diff > 200 LOC tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants