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

Aberta
#15,321 1 comentário 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@sayakpaul já está trabalhando nisso.

Desde 17/11/2026.

  • #15328 de @sayakpaul — aberto

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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

Linguagem predominante
Python
Estrelas
34.9k
Forks
7.5k
Merge médio
3d 16h
PRs com merge (30d)
65

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de huggingface/diffusers

Todas as issues de huggingface/diffusers

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.