Cache hooks: add `cache_context` to all official pipelines + TaylorSeer fallback when no context is set

Aperta
#15,321 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sayakpaul ci sta già lavorando.

Dal 17/11/2026.

  • #15328 di @sayakpaul — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Follow-up from the review discussion on #14923 (comment) by @yiyixuxu, related to #14922.

Context

Stateful cache hooks get their per-call state from StateManager.context (src/diffusers/hooks/hooks.py). If the denoiser runs outside model.cache_context(...), it raises:

ValueError: No cache context is set. Wrap the denoiser call in `model.cache_context(name, ...)` before calling it.

Right now only some pipelines wrap their transformer calls (for example, pipeline_flux.py uses "cond" / "uncond"). The other Flux pipelines don't, so pipe.transformer.enable_cache(TaylorSeerCacheConfig(...)) fails on them (#14922).

Proposal

There are two parts, and they can be done separately:

  1. Add cache_context to all officially supported pipelines. CacheContext now carries more than the name (step_index, num_inference_steps, timestep, sigma), so pipelines should pass that loop information through the context manager in a consistent way.

    • Use accurate names. For example, distilled pipelines with a single model call per step shouldn't label it "cond". They should either leave the name out or use a name that matches what the call actually is.
  2. TaylorSeer should work without a context manager. TaylorSeer doesn't actually need any context, so TaylorSeerCacheConfig should fall back to a default/single state when no cache_context is set, instead of raising. Then it works on any pipeline or a bare model call, whether or not part 1 is done.

Related

  • #14922 (Enable TaylorSeer for all Flux pipelines)
  • #14923 (wraps Flux pipeline transformer calls in cache_context)

cc @sayakpaul


Requested by Sayak Paul - Slack thread - Agent trace

Lingua principale
Python
Stelle
34.9k
Fork
7.5k
Merge medio
3g 16h
PR unite (30g)
65

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di huggingface/diffusers

Tutte le issue di huggingface/diffusers

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.