Skip to content

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

Open

Description

@moon-bot-app

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

cc @sayakpaul


Requested by Sayak Paul - Slack thread - Agent trace

Activity

  1. self-assigned this
    on Nov 17, 2026
  2. sayakpaul commented on Nov 17, 2026

    @sayakpaul
    Member

    Somewhat related #14900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions