Skip to content

Commit 83b6253

Browse files
author
toilaluan
committed
add docs
1 parent 24267c7 commit 83b6253

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/source/en/optimization/cache.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,31 @@ config = FasterCacheConfig(
6666
tensor_format="BFCHW",
6767
)
6868
pipeline.transformer.enable_cache(config)
69+
```
70+
71+
## TaylorSeer Cache
72+
73+
[TaylorSeer Cache](https://huggingface.co/papers/2403.06923) accelerates diffusion inference by using Taylor series expansions to approximate and cache intermediate activations across denoising steps. This method predicts future outputs based on past computations, reusing them over specified intervals to reduce redundant calculations.
74+
75+
It supports selective module skipping (inactive mode), where certain modules return zero tensors during prediction steps to skip computations cheaply, and a lightweight "lite" mode for optimized memory usage with predefined patterns for skipping and caching.
76+
77+
Set up and pass a [`TaylorSeerCacheConfig`] to a pipeline's transformer to enable it. The `cache_interval` controls how many steps to reuse cached outputs before refreshing with a full forward pass. The `disable_cache_before_step` specifies the initial steps where full computations are performed to gather data for approximations. Higher `max_order` improves approximation accuracy but increases memory usage.
78+
79+
```python
80+
import torch
81+
from diffusers import FluxPipeline, TaylorSeerCacheConfig
82+
83+
pipe = FluxPipeline.from_pretrained(
84+
"black-forest-labs/FLUX.1-dev",
85+
torch_dtype=torch.bfloat16,
86+
)
87+
pipe.to("cuda")
88+
89+
config = TaylorSeerCacheConfig(
90+
cache_interval=5,
91+
max_order=1,
92+
disable_cache_before_step=10,
93+
taylor_factors_dtype=torch.bfloat16,
94+
)
95+
pipe.transformer.enable_cache(config)
6996
```

0 commit comments

Comments
 (0)