diffusers
7c2bbfa0 - Implement inplace QKV fusion for the Wan-family transformers

Commit
57 days ago
Implement inplace QKV fusion for the Wan-family transformers All six `fuse_projections` overrides accepted `inplace` and ignored it, so `fuse_qkv_projections(inplace=True)` on a Wan model quietly did a non-inplace fusion and freed no memory. Two of them (SkyReelsV2, WanAnimate2) still had the old signature and raised `TypeError` even on the plain no-argument call. Each override now stores the split dims and drops the individual projections, matching the base implementation. `WanAttnProcessor` and friends guarded the image-context branch on `attn.add_k_proj is not None`, which breaks once that module is deleted; they read `attn.added_kv_proj_dim` instead, which is set from the config and always present. The `unfuse_projections` overrides are gone. The base implementation does the same removals and also reconstructs the split projections from the stored dims, so inheriting it is what makes the round trip work. `check_copies` compares only the body of a `# Copied from` block, not the `def` line, so the stale signature in wan_animate_2 never showed up as a mismatch. SkyReelsV2 also had no `AttentionTesterMixin` test class, so nothing exercised its fusion path at all; add one. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
Parents
Loading