huggingface / huggingface/diffusers

[Feature Request] Add native ResilPhase cache support for FLUX and HunyuanVideo

Offen
#14,378 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

## Motivation

[ResilPhase](https://github.com/zqc214/ResilPhase) is a training-free diffusion acceleration method that predicts the residual produced by the transformer block stack with barycentric Lagrange interpolation on a normalized phase axis. I would like to integrate it with the existing Diffusers cache Hook/`CacheMixin` APIs instead of replacing model `forward` methods.

## Proposed integration

- Add `ResilPhaseCacheConfig` and `apply_resilphase_cache`.
- Register a stateful head/middle/tail block Hook over the existing transformer block registry.
- Keep conditional and unconditional histories isolated through `cache_context`.
- Support balanced and Chebyshev phase mappings.
- Initially cover `FluxTransformer2DModel` and `HunyuanVideoTransformer3DModel`.
- Fall back to full block computation when FLUX ControlNet residuals are supplied, because those residuals are injected between blocks.
- Expose the method through `transformer.enable_cache(...)` / `disable_cache()`.

Proposed usage:

```python
from diffusers import FluxPipeline, ResilPhaseCacheConfig

pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev")
pipe.transformer.enable_cache(
ResilPhaseCacheConfig(
cache_interval=6,
warmup_steps=3,
max_order=1,
mapping_method="balanced",
)
)
```

## Validation prepared

A prototype is available on [`zqc214:add-resilphase-cache`](https://github.com/zqc214/diffusers/tree/add-resilphase-cache). It includes:

- numerical tests for balanced and Chebyshev barycentric prediction;
- Hook scheduling, context isolation, refresh, and ControlNet fallback tests;
- model-level tests for FLUX and HunyuanVideo;
- small pipeline inference tests for both pipelines;
- API and optimization documentation;
- passing `make quality`.

Would this scope and Hook-based approach be acceptable for an upstream PR?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der Prüfung des Prototyps im Branch zqc214:add-resilphase-cache und der vorhandenen Diffusers Hook/CacheMixin APIs. Überprüfe die numerischen, Scheduling-, Kontextisolierungs-, ControlNet-Fallback-, Modellebene- und Pipeline-Tests und führe anschließend make quality aus. Als abgeschlossen gilt die Aufgabe, wenn die vorgeschlagene FLUX- und HunyuanVideo-Integration sowie die Dokumentation der API und der Optimierungen den Erwartungen des Upstream-Projekts entsprechen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python, pytorch
Bereich
machine-learning, performance
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.