You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .ai/references/testing.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,8 +30,8 @@ Follow the style introduced in [#14113](https://github.com/huggingface/diffusers
30
30
-`MemoryTesterMixin` — CPU offload, group offload, layerwise casting.
31
31
- Cache mixins — `PyramidAttentionBroadcastTesterMixin`, `FasterCacheTesterMixin`, `FirstBlockCacheTesterMixin`, `TaylorSeerCacheTesterMixin`, `MagCacheTesterMixin`. Guidance-distilled models override the cache config (e.g. `FASTER_CACHE_CONFIG = {... "is_guidance_distilled": True}`). Don't introduce caching related tests in the first iteration. These tests are added on a case-by-case basis.
32
32
- In the first pass, just add tests related to `PipelineTesterMixin` and `MemoryTesterMixin`.
33
-
- **Declare a component that can't be offloaded — don't hand-write a skip.** Leaf-level offloading hooks only the supported leaf types (`nn.Linear`, `nn.Conv*`, `nn.Embedding` — see `_GO_LC_SUPPORTED_PYTORCH_LAYERS` in `src/diffusers/hooks/_common.py`) and onloads each on its own `forward`, so any code that reads a leaf's `.weight` instead of calling the leaf bypasses that leaf's hook and computes against offloaded weights. Which fix applies depends on who owns the component. For a diffusers model, set `_supports_group_offloading = False` on the `ModelMixin` subclass (as `HunyuanDiT2DModel` does) — both offload mixins honor the flag and skip themselves, so the gap is declared on the model instead of buried in a test file. For a third-party component you can't annotate, such as a `transformers` encoder, list it in `group_offloading_leaf_level_exclude_modules` on the config class; `enable_group_offload` keeps excluded components on the accelerator, so every other component stays covered — including the VAE, which the component-scoped `test_group_offloading_inference` leaves out. Block-level offloading is usually unaffected, hence the level in the name — a component that fails at both levels does need a skip.
34
-
-`torch.nn.MultiheadAttention` is the common instance: it passes `self.out_proj.weight` straight to `torch.nn.functional.multi_head_attention_forward` instead of calling `self.out_proj`, so the hook on `out_proj` never fires. `SiglipVisionModel`'s attention pooling head wraps one — see `tests/pipelines/hunyuan_video/test_hunyuan_video_framepack.py`, whose `image_encoder` is excluded for this reason.
33
+
- **Declare a component that can't be offloaded — don't hand-write a skip.** For a diffusers model, set `_supports_group_offloading = False` on the `ModelMixin` subclass (as `HunyuanDiT2DModel` does); for a third-party component you can't annotate, such as a `transformers` encoder, name it in `group_offloading_leaf_level_exclude_modules` or `group_offloading_block_level_exclude_modules` on the config class. **Every `nn.Module` component is group offloaded unless the list for that level names it**, and the two levels fail on opposite hazards: leaf-level when compute reads a leaf's `.weight` instead of calling the leaf, block-level when a component re-enters submodules without going through the group leader's `forward` (VAE decode paths, hence the `vae` / `image_encoder` defaults). A component that fails at both goes in both, and a name matching no component fails the test as a typo. **Each level's test runs twice, with and without `use_stream`** — a subclass overriding one must re-declare `@MemoryTesterMixin._USE_STREAM`, or the override collapses to a single un-parametrized test that errors on the missing argument and reports as a green `xfail`.
34
+
-`torch.nn.MultiheadAttention` is the common leaf-level instance: it passes `self.out_proj.weight` straight to `torch.nn.functional.multi_head_attention_forward` instead of calling `self.out_proj`, so the hook on `out_proj` never fires. `SiglipVisionModel`'s attention pooling head wraps one — see `tests/pipelines/hunyuan_video/test_hunyuan_video_framepack.py`, whose `image_encoder` is excluded for this reason.
35
35
-`HunyuanDiTAttentionPool` (`src/diffusers/models/embeddings.py`) shows the same failure without an MHA module: a plain `nn.Module` that hands its `q_proj` / `k_proj` / `v_proj` / `c_proj` weights to `torch.nn.functional.multi_head_attention_forward`, so all four projections stay offloaded rather than just one. `HunyuanDiT2DModel` opts out of group offloading entirely with `_supports_group_offloading = False`.
36
36
- Before adding a skip or an exclusion, confirm the failure still reproduces — several existing skips are stale, having outlived the upstream cause.
37
37
-**A migration that surfaces a `src/` gap marks the test `xfail`, it does not patch the pipeline.** Give the marker a module-level name and a `reason` naming the exact gap (`PNDM_*` in `tests/pipelines/pndm/test_pndm.py` is the worked example), and prefer `strict=True` so the marker reports XPASS — and gets deleted — the day the pipeline is fixed. Use `strict=False` only when one mark covers a group whose members do not all fail. Marking a whole test class keeps the mixin's own marks (`@is_memory`, `@require_accelerator`) intact; overriding individual inherited tests drops the decorators they were declared with, so re-declare those too.
Copy file name to clipboardExpand all lines: src/diffusers/pipelines/deprecated/stable_diffusion_variants/pipeline_onnx_stable_diffusion_inpaint_legacy.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@
10
10
from ....schedulersimportDDIMScheduler, LMSDiscreteScheduler, PNDMScheduler
11
11
from ....utilsimportdeprecate, logging
12
12
from ...onnx_utilsimportORT_TO_NP_TYPE, OnnxRuntimeModel
13
-
from ...pipeline_utilsimportDiffusionPipeline
13
+
from ...pipeline_utilsimportDeprecatedPipelineMixin, DiffusionPipeline
14
14
from ...stable_diffusion.pipeline_outputimportStableDiffusionPipelineOutput
0 commit comments