Skip to content

Commit 72b489d

Browse files
committed
resolve conflicts.
2 parents e3e8b20 + c934720 commit 72b489d

File tree

13 files changed

+1168
-1519
lines changed

13 files changed

+1168
-1519
lines changed

docs/source/en/_toctree.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@
9292
title: API Reference
9393
title: Hybrid Inference
9494
- sections:
95-
- local: using-diffusers/cogvideox
96-
title: CogVideoX
9795
- local: using-diffusers/consisid
9896
title: ConsisID
9997
- local: using-diffusers/sdxl
@@ -178,6 +176,8 @@
178176
- sections:
179177
- local: optimization/fp16
180178
title: Accelerate inference
179+
- local: optimization/cache
180+
title: Caching
181181
- local: optimization/memory
182182
title: Reduce memory usage
183183
- local: optimization/xformers

docs/source/en/api/cache.md

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,71 +11,19 @@ specific language governing permissions and limitations under the License. -->
1111

1212
# Caching methods
1313

14-
## Pyramid Attention Broadcast
14+
Cache methods speedup diffusion transformers by storing and reusing intermediate outputs of specific layers, such as attention and feedforward layers, instead of recalculating them at each inference step.
1515

16-
[Pyramid Attention Broadcast](https://huggingface.co/papers/2408.12588) from Xuanlei Zhao, Xiaolong Jin, Kai Wang, Yang You.
17-
18-
Pyramid Attention Broadcast (PAB) is a method that speeds up inference in diffusion models by systematically skipping attention computations between successive inference steps and reusing cached attention states. The attention states are not very different between successive inference steps. The most prominent difference is in the spatial attention blocks, not as much in the temporal attention blocks, and finally the least in the cross attention blocks. Therefore, many cross attention computation blocks can be skipped, followed by the temporal and spatial attention blocks. By combining other techniques like sequence parallelism and classifier-free guidance parallelism, PAB achieves near real-time video generation.
19-
20-
Enable PAB with [`~PyramidAttentionBroadcastConfig`] on any pipeline. For some benchmarks, refer to [this](https://github.com/huggingface/diffusers/pull/9562) pull request.
21-
22-
```python
23-
import torch
24-
from diffusers import CogVideoXPipeline, PyramidAttentionBroadcastConfig
25-
26-
pipe = CogVideoXPipeline.from_pretrained("THUDM/CogVideoX-5b", torch_dtype=torch.bfloat16)
27-
pipe.to("cuda")
28-
29-
# Increasing the value of `spatial_attention_timestep_skip_range[0]` or decreasing the value of
30-
# `spatial_attention_timestep_skip_range[1]` will decrease the interval in which pyramid attention
31-
# broadcast is active, leader to slower inference speeds. However, large intervals can lead to
32-
# poorer quality of generated videos.
33-
config = PyramidAttentionBroadcastConfig(
34-
spatial_attention_block_skip_range=2,
35-
spatial_attention_timestep_skip_range=(100, 800),
36-
current_timestep_callback=lambda: pipe.current_timestep,
37-
)
38-
pipe.transformer.enable_cache(config)
39-
```
40-
41-
## Faster Cache
42-
43-
[FasterCache](https://huggingface.co/papers/2410.19355) from Zhengyao Lv, Chenyang Si, Junhao Song, Zhenyu Yang, Yu Qiao, Ziwei Liu, Kwan-Yee K. Wong.
44-
45-
FasterCache is a method that speeds up inference in diffusion transformers by:
46-
- Reusing attention states between successive inference steps, due to high similarity between them
47-
- Skipping unconditional branch prediction used in classifier-free guidance by revealing redundancies between unconditional and conditional branch outputs for the same timestep, and therefore approximating the unconditional branch output using the conditional branch output
48-
49-
```python
50-
import torch
51-
from diffusers import CogVideoXPipeline, FasterCacheConfig
52-
53-
pipe = CogVideoXPipeline.from_pretrained("THUDM/CogVideoX-5b", torch_dtype=torch.bfloat16)
54-
pipe.to("cuda")
55-
56-
config = FasterCacheConfig(
57-
spatial_attention_block_skip_range=2,
58-
spatial_attention_timestep_skip_range=(-1, 681),
59-
current_timestep_callback=lambda: pipe.current_timestep,
60-
attention_weight_callback=lambda _: 0.3,
61-
unconditional_batch_skip_range=5,
62-
unconditional_batch_timestep_skip_range=(-1, 781),
63-
tensor_format="BFCHW",
64-
)
65-
pipe.transformer.enable_cache(config)
66-
```
67-
68-
### CacheMixin
16+
## CacheMixin
6917

7018
[[autodoc]] CacheMixin
7119

72-
### PyramidAttentionBroadcastConfig
20+
## PyramidAttentionBroadcastConfig
7321

7422
[[autodoc]] PyramidAttentionBroadcastConfig
7523

7624
[[autodoc]] apply_pyramid_attention_broadcast
7725

78-
### FasterCacheConfig
26+
## FasterCacheConfig
7927

8028
[[autodoc]] FasterCacheConfig
8129

docs/source/en/api/loaders/lora.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ To learn more about how to load LoRA weights, see the [LoRA](../../using-diffuse
9898

9999
## LoraBaseMixin
100100

101-
[[autodoc]] loaders.lora_base.LoraBaseMixin
101+
[[autodoc]] loaders.lora_base.LoraBaseMixin
102+
103+
## WanLoraLoaderMixin
104+
105+
[[autodoc]] loaders.lora_pipeline.WanLoraLoaderMixin

0 commit comments

Comments
 (0)