Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ai/references/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Follow the style introduced in [#14113](https://github.com/huggingface/diffusers
- Set `pipeline_class`, `required_input_params_in_call_signature` (params that must appear in `__call__`'s signature), and `batch_input_params` (params that get batched). Use the canonical sets in `..pipeline_params` where one fits, or an inline `frozenset([...])`.
- Set `output_shape` — the per-sample output shape for `get_dummy_inputs()`, i.e. `(channels, height, width)` for an image pipeline and `(num_frames, channels, height, width)` for a video one. Assert against `self.output_shape` in pipeline-specific tests instead of repeating the literal.
- Implement `get_dummy_components(...)` — build every sub-module from the **real classes** at tiny config, each preceded by `torch.manual_seed(0)`.
- Implement `get_dummy_inputs()` — **no `device` / `seed` arguments** (unlike the old style). Use `self.get_generator(0)` for the generator, keep sizes tiny, and set `output_type="pt"` so tests compare torch tensors directly with `assert_tensors_close` (no numpy round-trip). Remember `"pt"` images are `(batch, channels, height, width)`.
- Implement `get_dummy_inputs()` — **no `device` / `seed` arguments** (unlike the old style). Use `self.get_generator(0)` for the generator, keep sizes tiny, and set `output_type="pt"` so tests compare torch tensors directly with `assert_tensors_close` (no numpy round-trip). Remember `"pt"` images are `(batch, channels, height, width)` and videos `(batch, num_frames, channels, height, width)`, unlike `"np"` outputs which are `(batch, height, width, channels)`.
- **Compose the config with one mixin per concern**, one test class each, named `Test<Pipeline>...`. Add only the mixins that apply:
- `PipelineTesterMixin` — core save/load, dict-vs-tuple equivalence, batching, dtype/device, callbacks. Put pipeline-specific tests as methods on this class.
- `MemoryTesterMixin` — CPU offload, group offload, layerwise casting.
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/ace_step/test_ace_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ def get_dummy_inputs(self):
"num_inference_steps": 2,
"generator": self.get_generator(0),
"max_text_length": 32,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/allegro/test_allegro.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def get_dummy_inputs(self):
"width": 16,
"num_frames": 8,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/animatediff/test_animatediff.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def get_dummy_inputs(self):
"generator": self.get_generator(0),
"num_inference_steps": 2,
"guidance_scale": 7.5,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/animatediff/test_animatediff_controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def get_dummy_inputs(self, num_frames: int = 2):
"num_inference_steps": 2,
"num_frames": num_frames,
"guidance_scale": 7.5,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/animatediff/test_animatediff_sdxl.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ def get_dummy_inputs(self):
"generator": self.get_generator(0),
"num_inference_steps": 2,
"guidance_scale": 7.5,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/animatediff/test_animatediff_sparsectrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def get_dummy_inputs(self, num_frames: int = 2):
"num_inference_steps": 2,
"num_frames": num_frames,
"guidance_scale": 7.5,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def get_dummy_inputs(self, num_frames: int = 2):
"generator": self.get_generator(0),
"num_inference_steps": 2,
"guidance_scale": 7.5,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def get_dummy_inputs(self, num_frames: int = 2):
"generator": self.get_generator(0),
"num_inference_steps": 2,
"guidance_scale": 7.5,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/anyflow/test_anyflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def get_dummy_inputs(self):
"width": 16,
"num_frames": 9,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/anyflow/test_anyflow_far.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def get_dummy_inputs(self):
"width": 16,
"num_frames": 9,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/audioldm2/test_audioldm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ def get_dummy_inputs(self):
"generator": self.get_generator(0),
"num_inference_steps": 2,
"guidance_scale": 6.0,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/aura_flow/test_pipeline_aura_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def get_dummy_inputs(self):
"guidance_scale": 5.0,
"height": None,
"width": None,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/bria/test_pipeline_bria.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def get_dummy_inputs(self):
"height": 16,
"width": 16,
"max_sequence_length": 48,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/bria_fibo/test_pipeline_bria_fibo.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def get_dummy_inputs(self):
"guidance_scale": 5.0,
"height": 32,
"width": 32,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def get_dummy_inputs(self):
"guidance_scale": 5.0,
"height": 192,
"width": 336,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}
inputs["image"] = Image.new("RGB", (336, 192), (255, 255, 255))
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cogvideo/test_cogvideox.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def get_dummy_inputs(self):
"width": 16,
"num_frames": 8,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cogvideo/test_cogvideox_fun_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def get_dummy_inputs(self):
"height": height,
"width": width,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cogvideo/test_cogvideox_image2video.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ def get_dummy_inputs(self):
"width": image_width,
"num_frames": 8,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}
return inputs
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/cogview4/test_cogview4.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def get_dummy_inputs(self):
"height": 16,
"width": 16,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/ddim/test_ddim.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def get_dummy_inputs(self):
"batch_size": 1,
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/ddpm/test_ddpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def get_dummy_inputs(self):
"batch_size": 1,
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/deepfloyd_if/test_if.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def get_dummy_inputs(self):
"prompt": "A painting of a squirrel eating a burger",
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/deepfloyd_if/test_if_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def get_dummy_inputs(self):
"image": image,
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def get_dummy_inputs(self):
"original_image": original_image,
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/deepfloyd_if/test_if_inpainting.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def get_dummy_inputs(self):
"mask_image": mask_image,
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def get_dummy_inputs(self):
"mask_image": mask_image,
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/deepfloyd_if/test_if_superresolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def get_dummy_inputs(self):
"image": image,
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/dit/test_dit.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def get_dummy_inputs(self):
"class_labels": [1],
"generator": self.get_generator(0),
"num_inference_steps": 2,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/dreamlite/test_pipeline_dreamlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def get_dummy_inputs(self):
"height": 64,
"width": 64,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ def get_dummy_inputs(self):
"height": 64,
"width": 64,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/easyanimate/test_easyanimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def get_dummy_inputs(self):
"height": 16,
"width": 16,
"num_frames": 5,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ def get_dummy_inputs(self):
"height": 8,
"width": 8,
"max_sequence_length": 48,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ def get_dummy_inputs(self):
"height": 8,
"width": 8,
"max_sequence_length": 48,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_control_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ def get_dummy_inputs(self):
"width": 8,
"max_sequence_length": 48,
"strength": 0.8,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_control_inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ def get_dummy_inputs(self):
"height": 8,
"width": 8,
"max_sequence_length": 48,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ def get_dummy_inputs(self):
"height": 32,
"width": 32,
"max_sequence_length": 48,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ def get_dummy_inputs(self):
"width": 8,
"max_sequence_length": 48,
"strength": 0.8,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ def get_dummy_inputs(self):
"width": 32,
"max_sequence_length": 48,
"strength": 0.8,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
}
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_kontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ def get_dummy_inputs(self):
"width": 8,
"max_area": 8 * 8,
"max_sequence_length": 48,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
"_auto_resize": False,
}
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux/test_pipeline_flux_kontext_inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def get_dummy_inputs(self):
"width": 32,
"max_sequence_length": 48,
"strength": 0.8,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
"_auto_resize": False,
}
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/flux/testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def _modify_inputs_for_ip_adapter_test(self, inputs: dict[str, Any]):
inputs["negative_prompt"] = ""
if "true_cfg_scale" in inspect.signature(self.pipeline_class.__call__).parameters:
inputs["true_cfg_scale"] = 4.0
# Request torch outputs so comparisons run on torch tensors directly (see `BasePipelineTesterConfig`).
inputs["output_type"] = "pt"
inputs["return_dict"] = False
return inputs
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux2/test_pipeline_flux2.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ def get_dummy_inputs(self):
"height": 8,
"width": 8,
"max_sequence_length": 8,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
"text_encoder_out_layers": (1,),
}
Expand Down
2 changes: 0 additions & 2 deletions tests/pipelines/flux2/test_pipeline_flux2_klein.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def get_dummy_inputs(self):
"height": 8,
"width": 8,
"max_sequence_length": 64,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
# Note `"pt"` images are `(batch, channels, height, width)`, unlike `"np"` (`(batch, h, w, c)`).
"output_type": "pt",
"text_encoder_out_layers": (1,),
}
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/flux2/test_pipeline_flux2_klein_inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def get_dummy_inputs(self):
"max_sequence_length": 64,
"strength": 0.8,
"text_encoder_out_layers": (1,),
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}
return inputs
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/flux2/test_pipeline_flux2_klein_kv.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def get_dummy_inputs(self):
"width": 8,
"max_sequence_length": 64,
"text_encoder_out_layers": (1,),
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}
return inputs
Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/glm_image/test_glm_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def get_dummy_inputs(self):
"height": 32,
"width": 32,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
1 change: 0 additions & 1 deletion tests/pipelines/helios/test_helios.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def get_dummy_inputs(self):
"width": 16,
"num_frames": 9,
"max_sequence_length": 16,
# Request torch outputs so tests compare torch tensors directly (see `BasePipelineTesterConfig`).
"output_type": "pt",
}

Expand Down
Loading
Loading