Skip to content

[tests] Pipeline test refactor - #14113

Merged
sayakpaul merged 42 commits into
mainfrom
pipeline-test-refactor
Jul 17, 2026
Merged

[tests] Pipeline test refactor#14113
sayakpaul merged 42 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 added a commit that referenced this pull request Sep 1, 2026
* refactor c* pipeline tests.

Migrate the remaining `tests/pipelines/` directories starting with C to the config class +
composable pytest mixins introduced in #14113: chroma, chronoedit, cogview3, consisid,
consistency_models, controlnet, controlnet_flux, controlnet_hunyuandit, controlnet_sd3 and
cosmos. cogvideo and cogview4 were already migrated.

Notable points beyond the mechanical conversion:

- Expected slices switch from the `"np"` layout (`[0, -3:, -3:, -1]`) to the `"pt"` one
  (`[0, -1, -3:, -3:]`); the values themselves are unchanged.
- The Cosmos `safety_checker` overrides (save/load, variants, dtype dict, encode_prompt)
  were duplicated across five files and now live in a shared
  `CosmosSafetyCheckerTesterMixin` in `tests/pipelines/cosmos/testing_utils.py`.
- chroma and controlnet_flux import `FluxIPAdapterTesterMixin` from `..flux.testing_utils`
  rather than the old `..test_pipelines_common` one.
- `PipelineTesterMixin.test_save_load_float16` now passes the non-deprecated `dtype=` to
  `from_pretrained` instead of `torch_dtype=`, which the Cosmos2.5 `from_pretrained`
  wrappers read when casting the safety checker they inject.
- Dropped along the way, matching #14619: `PipelineLatentTesterMixin`,
  `PipelineKarrasSchedulerTesterMixin`, the attention-slicing and xformers tests, and the
  `test_ip_adapter` overrides that only supplied an `expected_pipe_slice`.

`pytest tests/pipelines/{chroma,chronoedit,cogview3,consisid,consistency_models,controlnet,controlnet_flux,controlnet_hunyuandit,controlnet_sd3,cosmos}`
gives 14 failed, 1014 passed, 82 skipped. All 14 failures are in cosmos and reproduce
unchanged on main: `DummyCosmosSafetyChecker` is a parameter-less `ModelMixin` with a single
non-persistent buffer, so accelerate does not hook it for sequential offload and a reloaded
pipeline gets a fresh fp32 one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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