From 9843dc7ef452f734477e1acda6050c5bd5613dac Mon Sep 17 00:00:00 2001 From: yiyixuxu Date: Thu, 16 Jul 2026 19:56:35 +0000 Subject: [PATCH] Add not_params to ModularPipelineTesterMixin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pipelines sometimes deliberately drop a canonical param — e.g. guidance-distilled pipelines don't accept negative_prompt. Test classes can now declare these in not_params and test_pipeline_call_signature asserts they are absent from the pipeline's inputs, so reintroducing one by accident fails the test. Adopted in the flux2-klein test classes (negative_prompt). Co-Authored-By: Claude Fable 5 --- .../flux2/test_modular_pipeline_flux2_klein.py | 2 ++ tests/modular_pipelines/test_modular_pipelines_common.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/tests/modular_pipelines/flux2/test_modular_pipeline_flux2_klein.py b/tests/modular_pipelines/flux2/test_modular_pipeline_flux2_klein.py index 6a6984428d5d..299809b02ca7 100644 --- a/tests/modular_pipelines/flux2/test_modular_pipeline_flux2_klein.py +++ b/tests/modular_pipelines/flux2/test_modular_pipeline_flux2_klein.py @@ -49,6 +49,7 @@ class TestFlux2KleinModularPipelineFast(ModularPipelineTesterMixin): params = frozenset(["prompt", "height", "width"]) batch_params = frozenset(["prompt"]) + not_params = frozenset(["negative_prompt"]) expected_workflow_blocks = FLUX2_KLEIN_WORKFLOWS def get_dummy_inputs(self, seed=0): @@ -94,6 +95,7 @@ class TestFlux2KleinImageConditionedModularPipelineFast(ModularPipelineTesterMix params = frozenset(["prompt", "height", "width", "image"]) batch_params = frozenset(["prompt", "image"]) + not_params = frozenset(["negative_prompt"]) expected_workflow_blocks = FLUX2_KLEIN_IMAGE_CONDITIONED_WORKFLOWS def get_dummy_inputs(self, seed=0): diff --git a/tests/modular_pipelines/test_modular_pipelines_common.py b/tests/modular_pipelines/test_modular_pipelines_common.py index 223a25e436fa..5f2004fa31de 100644 --- a/tests/modular_pipelines/test_modular_pipelines_common.py +++ b/tests/modular_pipelines/test_modular_pipelines_common.py @@ -69,6 +69,10 @@ class ModularPipelineTesterMixin: # of the type of pipeline. They are always optional and have common # sense default values. optional_params = frozenset(["num_inference_steps", "num_images_per_prompt", "latents", "output_type"]) + # Parameters the pipeline deliberately does NOT accept — e.g. `negative_prompt` on a + # guidance-distilled pipeline. `test_pipeline_call_signature` asserts they are absent, + # so accidentally (re)introducing one fails the test. + not_params = frozenset() # this is modular specific: generator needs to be a intermediate input because it's mutable intermediate_params = frozenset(["generator"]) # Output type for the pipeline (e.g., "images" for image pipelines, "videos" for video pipelines) @@ -176,6 +180,11 @@ def _check_for_parameters(parameters, expected_parameters, param_type): _check_for_parameters(self.params, input_parameters, "input") _check_for_parameters(self.optional_params, optional_parameters, "optional") + unsupported_parameters = {param for param in self.not_params if param in input_parameters} + assert len(unsupported_parameters) == 0, ( + f"Parameters declared in `not_params` unexpectedly present in the pipeline inputs: {unsupported_parameters}" + ) + def test_inference_batch_consistent(self, batch_sizes=[2], batch_generator=True): pipe = self.get_pipeline().to(torch_device)