Skip to content

Fix modular pipeline stateful cache reset and TaylorSeer/FBC context crash#27

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-e53f
Draft

Fix modular pipeline stateful cache reset and TaylorSeer/FBC context crash#27
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-e53f

Conversation

@cursor

@cursor cursor Bot commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Fixes two cache-related correctness bugs:

  1. Modular pipelines never reset stateful caches between runsModularPipeline.__call__ now calls _reset_stateful_caches() on all components after each invocation (in a finally block), matching the cache-reset behavior in DiffusionPipeline.maybe_free_model_hooks(). Without this, inference caches (PAB, FasterCache, MagCache, etc.) retain stale iteration/step_index/cached tensors from run N and corrupt run N+1.

  2. TaylorSeer and FirstBlockCache crash without cache_context — Both hooks now auto-set an "inference" context when none is provided, consistent with MagCache. Previously StateManager.get_state() raised ValueError on the first forward when pipelines omitted cache_context.

Validation

  • pytest tests/modular_pipelines/test_modular_pipeline_cache_reset.py tests/hooks/test_taylorseer_cache_context.py (3 tests, all pass)
  • Minor utils/check_copies.py change: invoke ruff via python -m ruff so copy-check hooks work when ruff is not on PATH.
Open in Web View Automation 

ModularPipeline.__call__ now resets stateful inference caches on all
components after each run, matching DiffusionPipeline.maybe_free_model_hooks.
Without this, PAB/FasterCache/MagCache hook state from run N corrupts run N+1.

TaylorSeer and FirstBlockCache hooks auto-set an inference context when none
is provided, consistent with MagCache, so enable_cache() does not crash on
denoise paths that omit cache_context.

Co-authored-by: Simon Lynch <srlynch1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant