Skip to content

Commit a2aa752

Browse files
committed
fixes
2 parents eb5a8b2 + 7667cfc commit a2aa752

File tree

64 files changed

+5405
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+5405
-83
lines changed

.github/workflows/push_tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ jobs:
165165
group: gcp-ct5lp-hightpu-8t
166166
container:
167167
image: diffusers/diffusers-flax-tpu
168-
options: --shm-size "16gb" --ipc host --privileged ${{ vars.V5_LITEPOD_8_ENV}} -v /mnt/hf_cache:/mnt/hf_cache defaults:
168+
options: --shm-size "16gb" --ipc host --privileged ${{ vars.V5_LITEPOD_8_ENV}} -v /mnt/hf_cache:/mnt/hf_cache
169+
defaults:
169170
run:
170171
shell: bash
171172
steps:

docs/source/en/_toctree.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@
157157
title: Getting Started
158158
- local: quantization/bitsandbytes
159159
title: bitsandbytes
160+
- local: quantization/torchao
161+
title: torchao
160162
title: Quantization Methods
161163
- sections:
162164
- local: optimization/fp16
@@ -270,6 +272,8 @@
270272
title: FluxTransformer2DModel
271273
- local: api/models/hunyuan_transformer2d
272274
title: HunyuanDiT2DModel
275+
- local: api/models/hunyuan_video_transformer_3d
276+
title: HunyuanVideoTransformer3DModel
273277
- local: api/models/latte_transformer3d
274278
title: LatteTransformer3DModel
275279
- local: api/models/lumina_nextdit2d
@@ -316,6 +320,8 @@
316320
title: AutoencoderKLAllegro
317321
- local: api/models/autoencoderkl_cogvideox
318322
title: AutoencoderKLCogVideoX
323+
- local: api/models/autoencoder_kl_hunyuan_video
324+
title: AutoencoderKLHunyuanVideo
319325
- local: api/models/autoencoderkl_ltx_video
320326
title: AutoencoderKLLTXVideo
321327
- local: api/models/autoencoderkl_mochi
@@ -394,6 +400,8 @@
394400
title: Flux
395401
- local: api/pipelines/hunyuandit
396402
title: Hunyuan-DiT
403+
- local: api/pipelines/hunyuan_video
404+
title: HunyuanVideo
397405
- local: api/pipelines/i2vgenxl
398406
title: I2VGen-XL
399407
- local: api/pipelines/pix2pix

docs/source/en/api/attnprocessor.md

Lines changed: 115 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,143 @@ specific language governing permissions and limitations under the License.
1515
An attention processor is a class for applying different types of attention mechanisms.
1616

1717
## AttnProcessor
18+
1819
[[autodoc]] models.attention_processor.AttnProcessor
1920

20-
## AttnProcessor2_0
2121
[[autodoc]] models.attention_processor.AttnProcessor2_0
2222

23+
<<<<<<< HEAD
2324
## FusedAttnProcessor2_0
2425
[[autodoc]] models.attention_processor.FusedAttnProcessor2_0
2526

2627
## XFormersAttnProcessor
2728
[[autodoc]] models.attention_processor.XFormersAttnProcessor
2829

2930
## AttnAddedKVProcessor
31+
=======
32+
>>>>>>> main
3033
[[autodoc]] models.attention_processor.AttnAddedKVProcessor
3134

32-
## AttnAddedKVProcessor2_0
3335
[[autodoc]] models.attention_processor.AttnAddedKVProcessor2_0
3436

37+
<<<<<<< HEAD
3538
## XFormersAttnAddedKVProcessor
3639
[[autodoc]] models.attention_processor.XFormersAttnAddedKVProcessor
3740

3841
## CrossFrameAttnProcessor
3942
[[autodoc]] pipelines.text_to_video_synthesis.pipeline_text_to_video_zero.CrossFrameAttnProcessor
43+
=======
44+
[[autodoc]] models.attention_processor.AttnProcessorNPU
45+
>>>>>>> main
46+
47+
[[autodoc]] models.attention_processor.FusedAttnProcessor2_0
48+
49+
## Allegro
50+
51+
[[autodoc]] models.attention_processor.AllegroAttnProcessor2_0
52+
53+
## AuraFlow
54+
55+
[[autodoc]] models.attention_processor.AuraFlowAttnProcessor2_0
56+
57+
[[autodoc]] models.attention_processor.FusedAuraFlowAttnProcessor2_0
58+
59+
## CogVideoX
60+
61+
[[autodoc]] models.attention_processor.CogVideoXAttnProcessor2_0
62+
63+
[[autodoc]] models.attention_processor.FusedCogVideoXAttnProcessor2_0
64+
65+
## CrossFrameAttnProcessor
66+
67+
[[autodoc]] pipelines.text_to_video_synthesis.pipeline_text_to_video_zero.CrossFrameAttnProcessor
68+
69+
## Custom Diffusion
4070

41-
## CustomDiffusionAttnProcessor
4271
[[autodoc]] models.attention_processor.CustomDiffusionAttnProcessor
4372

44-
## CustomDiffusionAttnProcessor2_0
4573
[[autodoc]] models.attention_processor.CustomDiffusionAttnProcessor2_0
4674

47-
## CustomDiffusionXFormersAttnProcessor
4875
[[autodoc]] models.attention_processor.CustomDiffusionXFormersAttnProcessor
4976

50-
## FusedAttnProcessor2_0
51-
[[autodoc]] models.attention_processor.FusedAttnProcessor2_0
77+
## Flux
78+
79+
[[autodoc]] models.attention_processor.FluxAttnProcessor2_0
80+
81+
[[autodoc]] models.attention_processor.FusedFluxAttnProcessor2_0
82+
83+
[[autodoc]] models.attention_processor.FluxSingleAttnProcessor2_0
84+
85+
## Hunyuan
86+
87+
[[autodoc]] models.attention_processor.HunyuanAttnProcessor2_0
88+
89+
[[autodoc]] models.attention_processor.FusedHunyuanAttnProcessor2_0
90+
91+
[[autodoc]] models.attention_processor.PAGHunyuanAttnProcessor2_0
92+
93+
[[autodoc]] models.attention_processor.PAGCFGHunyuanAttnProcessor2_0
94+
95+
## IdentitySelfAttnProcessor2_0
96+
97+
[[autodoc]] models.attention_processor.PAGIdentitySelfAttnProcessor2_0
98+
99+
[[autodoc]] models.attention_processor.PAGCFGIdentitySelfAttnProcessor2_0
100+
101+
## IP-Adapter
102+
103+
[[autodoc]] models.attention_processor.IPAdapterAttnProcessor
104+
105+
[[autodoc]] models.attention_processor.IPAdapterAttnProcessor2_0
106+
107+
## JointAttnProcessor2_0
108+
109+
[[autodoc]] models.attention_processor.JointAttnProcessor2_0
110+
111+
[[autodoc]] models.attention_processor.PAGJointAttnProcessor2_0
112+
113+
[[autodoc]] models.attention_processor.PAGCFGJointAttnProcessor2_0
114+
115+
[[autodoc]] models.attention_processor.FusedJointAttnProcessor2_0
116+
117+
## LoRA
118+
119+
[[autodoc]] models.attention_processor.LoRAAttnProcessor
120+
121+
[[autodoc]] models.attention_processor.LoRAAttnProcessor2_0
122+
123+
[[autodoc]] models.attention_processor.LoRAAttnAddedKVProcessor
124+
125+
[[autodoc]] models.attention_processor.LoRAXFormersAttnProcessor
126+
127+
## Lumina-T2X
128+
129+
[[autodoc]] models.attention_processor.LuminaAttnProcessor2_0
130+
131+
## Mochi
132+
133+
[[autodoc]] models.attention_processor.MochiAttnProcessor2_0
134+
135+
[[autodoc]] models.attention_processor.MochiVaeAttnProcessor2_0
136+
137+
## Sana
138+
139+
[[autodoc]] models.attention_processor.SanaLinearAttnProcessor2_0
140+
141+
[[autodoc]] models.attention_processor.SanaMultiscaleAttnProcessor2_0
142+
143+
[[autodoc]] models.attention_processor.PAGCFGSanaLinearAttnProcessor2_0
144+
145+
[[autodoc]] models.attention_processor.PAGIdentitySanaLinearAttnProcessor2_0
146+
147+
## Stable Audio
148+
149+
[[autodoc]] models.attention_processor.StableAudioAttnProcessor2_0
52150

53151
## SlicedAttnProcessor
152+
54153
[[autodoc]] models.attention_processor.SlicedAttnProcessor
55154

56-
## SlicedAttnAddedKVProcessor
57155
[[autodoc]] models.attention_processor.SlicedAttnAddedKVProcessor
58156

59157
## IPAdapterAttnProcessor
@@ -140,3 +238,12 @@ An attention processor is a class for applying different types of attention mech
140238

141239
## CogVideoXAttnProcessor2_0
142240
[[autodoc]] models.attention_processor.CogVideoXAttnProcessor2_0
241+
## XFormersAttnProcessor
242+
243+
[[autodoc]] models.attention_processor.XFormersAttnProcessor
244+
245+
[[autodoc]] models.attention_processor.XFormersAttnAddedKVProcessor
246+
247+
## XLAFlashAttnProcessor2_0
248+
249+
[[autodoc]] models.attention_processor.XLAFlashAttnProcessor2_0

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ LoRA is a fast and lightweight training method that inserts and trains a signifi
1717
- [`StableDiffusionLoraLoaderMixin`] provides functions for loading and unloading, fusing and unfusing, enabling and disabling, and more functions for managing LoRA weights. This class can be used with any model.
1818
- [`StableDiffusionXLLoraLoaderMixin`] is a [Stable Diffusion (SDXL)](../../api/pipelines/stable_diffusion/stable_diffusion_xl) version of the [`StableDiffusionLoraLoaderMixin`] class for loading and saving LoRA weights. It can only be used with the SDXL model.
1919
- [`SD3LoraLoaderMixin`] provides similar functions for [Stable Diffusion 3](https://huggingface.co/blog/sd3).
20+
- [`FluxLoraLoaderMixin`] provides similar functions for [Flux](https://huggingface.co/docs/diffusers/main/en/api/pipelines/flux).
21+
- [`CogVideoXLoraLoaderMixin`] provides similar functions for [CogVideoX](https://huggingface.co/docs/diffusers/main/en/api/pipelines/cogvideox).
22+
- [`Mochi1LoraLoaderMixin`] provides similar functions for [Mochi](https://huggingface.co/docs/diffusers/main/en/api/pipelines/mochi).
2023
- [`AmusedLoraLoaderMixin`] is for the [`AmusedPipeline`].
2124
- [`LoraBaseMixin`] provides a base class with several utility methods to fuse, unfuse, unload, LoRAs and more.
2225

@@ -38,6 +41,18 @@ To learn more about how to load LoRA weights, see the [LoRA](../../using-diffuse
3841

3942
[[autodoc]] loaders.lora_pipeline.SD3LoraLoaderMixin
4043

44+
## FluxLoraLoaderMixin
45+
46+
[[autodoc]] loaders.lora_pipeline.FluxLoraLoaderMixin
47+
48+
## CogVideoXLoraLoaderMixin
49+
50+
[[autodoc]] loaders.lora_pipeline.CogVideoXLoraLoaderMixin
51+
52+
## Mochi1LoraLoaderMixin
53+
54+
[[autodoc]] loaders.lora_pipeline.Mochi1LoraLoaderMixin
55+
4156
## AmusedLoraLoaderMixin
4257

4358
[[autodoc]] loaders.lora_pipeline.AmusedLoraLoaderMixin
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!-- Copyright 2024 The HuggingFace Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License. -->
11+
12+
# AutoencoderKLHunyuanVideo
13+
14+
The 3D variational autoencoder (VAE) model with KL loss used in [HunyuanVideo](https://github.com/Tencent/HunyuanVideo/), which was introduced in [HunyuanVideo: A Systematic Framework For Large Video Generative Models](https://huggingface.co/papers/2412.03603) by Tencent.
15+
16+
The model can be loaded with the following code snippet.
17+
18+
```python
19+
from diffusers import AutoencoderKLHunyuanVideo
20+
21+
vae = AutoencoderKLHunyuanVideo.from_pretrained("tencent/HunyuanVideo", torch_dtype=torch.float16)
22+
```
23+
24+
## AutoencoderKLHunyuanVideo
25+
26+
[[autodoc]] AutoencoderKLHunyuanVideo
27+
- decode
28+
- all
29+
30+
## DecoderOutput
31+
32+
[[autodoc]] models.autoencoders.vae.DecoderOutput
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!-- Copyright 2024 The HuggingFace Team. All rights reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
4+
the License. You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
9+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
10+
specific language governing permissions and limitations under the License. -->
11+
12+
# HunyuanVideoTransformer3DModel
13+
14+
A Diffusion Transformer model for 3D video-like data was introduced in [HunyuanVideo: A Systematic Framework For Large Video Generative Models](https://huggingface.co/papers/2412.03603) by Tencent.
15+
16+
The model can be loaded with the following code snippet.
17+
18+
```python
19+
from diffusers import HunyuanVideoTransformer3DModel
20+
21+
transformer = HunyuanVideoTransformer3DModel.from_pretrained("tencent/HunyuanVideo", torch_dtype=torch.bfloat16)
22+
```
23+
24+
## HunyuanVideoTransformer3DModel
25+
26+
[[autodoc]] HunyuanVideoTransformer3DModel
27+
28+
## Transformer2DModelOutput
29+
30+
[[autodoc]] models.modeling_outputs.Transformer2DModelOutput
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!-- Copyright 2024 The HuggingFace Team. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License. -->
14+
15+
# HunyuanVideo
16+
17+
[HunyuanVideo](https://www.arxiv.org/abs/2412.03603) by Tencent.
18+
19+
*Recent advancements in video generation have significantly impacted daily life for both individuals and industries. However, the leading video generation models remain closed-source, resulting in a notable performance gap between industry capabilities and those available to the public. In this report, we introduce HunyuanVideo, an innovative open-source video foundation model that demonstrates performance in video generation comparable to, or even surpassing, that of leading closed-source models. HunyuanVideo encompasses a comprehensive framework that integrates several key elements, including data curation, advanced architectural design, progressive model scaling and training, and an efficient infrastructure tailored for large-scale model training and inference. As a result, we successfully trained a video generative model with over 13 billion parameters, making it the largest among all open-source models. We conducted extensive experiments and implemented a series of targeted designs to ensure high visual quality, motion dynamics, text-video alignment, and advanced filming techniques. According to evaluations by professionals, HunyuanVideo outperforms previous state-of-the-art models, including Runway Gen-3, Luma 1.6, and three top-performing Chinese video generative models. By releasing the code for the foundation model and its applications, we aim to bridge the gap between closed-source and open-source communities. This initiative will empower individuals within the community to experiment with their ideas, fostering a more dynamic and vibrant video generation ecosystem. The code is publicly available at [this https URL](https://github.com/Tencent/HunyuanVideo).*
20+
21+
<Tip>
22+
23+
Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers.md) to learn how to explore the tradeoff between scheduler speed and quality, and see the [reuse components across pipelines](../../using-diffusers/loading.md#reuse-a-pipeline) section to learn how to efficiently load the same components into multiple pipelines.
24+
25+
</Tip>
26+
27+
Recommendations for inference:
28+
- Both text encoders should be in `torch.float16`.
29+
- Transformer should be in `torch.bfloat16`.
30+
- VAE should be in `torch.float16`.
31+
- `num_frames` should be of the form `4 * k + 1`, for example `49` or `129`.
32+
- For smaller resolution images, try lower values of `shift` (between `2.0` to `5.0`) in the [Scheduler](https://huggingface.co/docs/diffusers/main/en/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler.shift). For larger resolution images, try higher values (between `7.0` and `12.0`). The default value is `7.0` for HunyuanVideo.
33+
- For more information about supported resolutions and other details, please refer to the original repository [here](https://github.com/Tencent/HunyuanVideo/).
34+
35+
## HunyuanVideoPipeline
36+
37+
[[autodoc]] HunyuanVideoPipeline
38+
- all
39+
- __call__
40+
41+
## HunyuanVideoPipelineOutput
42+
43+
[[autodoc]] pipelines.hunyuan_video.pipeline_output.HunyuanVideoPipelineOutput

docs/source/en/api/pipelines/ltx_video.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,38 @@ import torch
3131
from diffusers import AutoencoderKLLTXVideo, LTXImageToVideoPipeline, LTXVideoTransformer3DModel
3232

3333
single_file_url = "https://huggingface.co/Lightricks/LTX-Video/ltx-video-2b-v0.9.safetensors"
34-
transformer = LTXVideoTransformer3DModel.from_single_file(single_file_url, torch_dtype=torch.bfloat16)
34+
transformer = LTXVideoTransformer3DModel.from_single_file(
35+
single_file_url, torch_dtype=torch.bfloat16
36+
)
3537
vae = AutoencoderKLLTXVideo.from_single_file(single_file_url, torch_dtype=torch.bfloat16)
36-
pipe = LTXImageToVideoPipeline.from_pretrained("Lightricks/LTX-Video", transformer=transformer, vae=vae, torch_dtype=torch.bfloat16)
38+
pipe = LTXImageToVideoPipeline.from_pretrained(
39+
"Lightricks/LTX-Video", transformer=transformer, vae=vae, torch_dtype=torch.bfloat16
40+
)
3741

3842
# ... inference code ...
3943
```
4044

41-
Alternatively, the pipeline can be used to load the weights with [~FromSingleFileMixin.from_single_file`].
45+
Alternatively, the pipeline can be used to load the weights with [`~FromSingleFileMixin.from_single_file`].
4246

4347
```python
4448
import torch
4549
from diffusers import LTXImageToVideoPipeline
4650
from transformers import T5EncoderModel, T5Tokenizer
4751

4852
single_file_url = "https://huggingface.co/Lightricks/LTX-Video/ltx-video-2b-v0.9.safetensors"
49-
text_encoder = T5EncoderModel.from_pretrained("Lightricks/LTX-Video", subfolder="text_encoder", torch_dtype=torch.bfloat16)
50-
tokenizer = T5Tokenizer.from_pretrained("Lightricks/LTX-Video", subfolder="tokenizer", torch_dtype=torch.bfloat16)
51-
pipe = LTXImageToVideoPipeline.from_single_file(single_file_url, text_encoder=text_encoder, tokenizer=tokenizer, torch_dtype=torch.bfloat16)
53+
text_encoder = T5EncoderModel.from_pretrained(
54+
"Lightricks/LTX-Video", subfolder="text_encoder", torch_dtype=torch.bfloat16
55+
)
56+
tokenizer = T5Tokenizer.from_pretrained(
57+
"Lightricks/LTX-Video", subfolder="tokenizer", torch_dtype=torch.bfloat16
58+
)
59+
pipe = LTXImageToVideoPipeline.from_single_file(
60+
single_file_url, text_encoder=text_encoder, tokenizer=tokenizer, torch_dtype=torch.bfloat16
61+
)
5262
```
5363

64+
Refer to [this section](https://huggingface.co/docs/diffusers/main/en/api/pipelines/cogvideox#memory-optimization) to learn more about optimizing memory consumption.
65+
5466
## LTXPipeline
5567

5668
[[autodoc]] LTXPipeline

0 commit comments

Comments
 (0)