Motivation
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:
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. 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?
Motivation
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/
CacheMixinAPIs instead of replacing modelforwardmethods.Proposed integration
ResilPhaseCacheConfigandapply_resilphase_cache.cache_context.FluxTransformer2DModelandHunyuanVideoTransformer3DModel.transformer.enable_cache(...)/disable_cache().Proposed usage:
Validation prepared
A prototype is available on
zqc214:add-resilphase-cache. It includes:make quality.Would this scope and Hook-based approach be acceptable for an upstream PR?