-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Hunyuanvideo15 #12696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+5,170
−0
Merged
Hunyuanvideo15 #12696
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
8b7ea81
add
yiyixuxu 56d57c3
add first pipeline draft
yiyixuxu b282ac1
add text encoders to conversion script
yiyixuxu 5732d60
fix a bit more, remove print lines
yiyixuxu 76bb607
fix more, system prompt etc
yiyixuxu c739ee9
update conversion script
2f6914d
up up
a0b2fe0
update conversion script: remove dtype, always keep same precision as…
db0127c
fix
38c42b4
conversion scripts
090ceb5
remove dtype from the _get_ encodeing methods
e3301cb
add i2v pipeline
753d407
add image to video pipeline
0687a40
remove use_meanflow
c22915d
up up
f9cb82b
a few small fix: proprocess, cpu_offloading, attention backend
e319d72
simplify transformer
e194034
clean up a bit more pipelines
3980f97
Merge branch 'main' into hunyuanvideo15
yiyixuxu 5029dbf
style
8aa458e
copies
50abf50
add docs
7aeab3f
add to toctree
c3f4598
up
54f008e
Update docs/source/en/api/pipelines/hunyuan_video15.md
yiyixuxu 237d318
Apply suggestions from code review
yiyixuxu d7f399d
add a notes on the doc about attention backend
bdfab30
up
2c018f8
Update docs/source/en/api/pipelines/hunyuan_video15.md
yiyixuxu c715470
add a note on changing guidance_scale on doc
yiyixuxu 0dae8f9
Apply suggestions from code review
yiyixuxu 5989014
Update docs/source/en/api/pipelines/hunyuan_video15.md
yiyixuxu 404d3fa
Update docs/source/en/api/pipelines/hunyuan_video15.md
yiyixuxu 0869b22
tests for Hunyuan 1.5 (#12759)
sayakpaul 6bfb75a
Apply style fixes
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
docs/source/en/api/models/autoencoder_kl_hunyuan_video15.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <!-- Copyright 2025 The HuggingFace Team. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations under the License. --> | ||
|
|
||
| # AutoencoderKLHunyuanVideo15 | ||
|
|
||
| The 3D variational autoencoder (VAE) model with KL loss used in [HunyuanVideo1.5](https://github.com/Tencent/HunyuanVideo1-1.5) by Tencent. | ||
|
|
||
| The model can be loaded with the following code snippet. | ||
|
|
||
| ```python | ||
| from diffusers import AutoencoderKLHunyuanVideo15 | ||
|
|
||
| vae = AutoencoderKLHunyuanVideo15.from_pretrained("hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v", subfolder="vae", torch_dtype=torch.float32) | ||
|
|
||
| # make sure to enable tiling to avoid OOM | ||
| vae.enable_tiling() | ||
| ``` | ||
|
|
||
| ## AutoencoderKLHunyuanVideo15 | ||
|
|
||
| [[autodoc]] AutoencoderKLHunyuanVideo15 | ||
| - decode | ||
| - encode | ||
| - all | ||
|
|
||
| ## DecoderOutput | ||
|
|
||
| [[autodoc]] models.autoencoders.vae.DecoderOutput |
30 changes: 30 additions & 0 deletions
30
docs/source/en/api/models/hunyuan_video15_transformer_3d.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <!-- Copyright 2025 The HuggingFace Team. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
| an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations under the License. --> | ||
|
|
||
| # HunyuanVideo15Transformer3DModel | ||
|
|
||
| A Diffusion Transformer model for 3D video-like data used in [HunyuanVideo1.5](https://github.com/Tencent/HunyuanVideo1-1.5). | ||
|
|
||
| The model can be loaded with the following code snippet. | ||
|
|
||
| ```python | ||
| from diffusers import HunyuanVideo15Transformer3DModel | ||
|
|
||
| transformer = HunyuanVideo15Transformer3DModel.from_pretrained("hunyuanvideo-community/HunyuanVideo-1.5-Diffusers-480p_t2v" subfolder="transformer", torch_dtype=torch.bfloat16) | ||
| ``` | ||
|
|
||
| ## HunyuanVideo15Transformer3DModel | ||
|
|
||
| [[autodoc]] HunyuanVideo15Transformer3DModel | ||
|
|
||
| ## Transformer2DModelOutput | ||
|
|
||
| [[autodoc]] models.modeling_outputs.Transformer2DModelOutput |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| <!-- Copyright 2025 The HuggingFace Team. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. --> | ||
|
|
||
|
|
||
| # HunyuanVideo-1.5 | ||
|
|
||
| HunyuanVideo-1.5 is a lightweight yet powerful video generation model that achieves state-of-the-art visual quality and motion coherence with only 8.3 billion parameters, enabling efficient inference on consumer-grade GPUs. This achievement is built upon several key components, including meticulous data curation, an advanced DiT architecture with selective and sliding tile attention (SSTA), enhanced bilingual understanding through glyph-aware text encoding, progressive pre-training and post-training, and an efficient video super-resolution network. Leveraging these designs, we developed a unified framework capable of high-quality text-to-video and image-to-video generation across multiple durations and resolutions. Extensive experiments demonstrate that this compact and proficient model establishes a new state-of-the-art among open-source models. | ||
|
|
||
| You can find all the original HunyuanVideo checkpoints under the [Tencent](https://huggingface.co/tencent) organization. | ||
|
|
||
| > [!TIP] | ||
| > Click on the HunyuanVideo models in the right sidebar for more examples of video generation tasks. | ||
| > | ||
| > The examples below use a checkpoint from [hunyuanvideo-community](https://huggingface.co/hunyuanvideo-community) because the weights are stored in a layout compatible with Diffusers. | ||
|
|
||
| The example below demonstrates how to generate a video optimized for memory or inference speed. | ||
|
|
||
| <hfoptions id="usage"> | ||
| <hfoption id="memory"> | ||
|
|
||
| Refer to the [Reduce memory usage](../../optimization/memory) guide for more details about the various memory saving techniques. | ||
|
|
||
|
|
||
| ```py | ||
| import torch | ||
| from diffusers import AutoModel, HunyuanVideo15Pipeline | ||
| from diffusers.utils import export_to_video | ||
|
|
||
|
|
||
| pipeline = HunyuanVideo15Pipeline.from_pretrained( | ||
| "HunyuanVideo-1.5-Diffusers-480p_t2v", | ||
| torch_dtype=torch.bfloat16, | ||
| ) | ||
|
|
||
| # model-offloading and tiling | ||
| pipeline.enable_model_cpu_offload() | ||
| pipeline.vae.enable_tiling() | ||
|
|
||
| prompt = "A fluffy teddy bear sits on a bed of soft pillows surrounded by children's toys." | ||
| video = pipeline(prompt=prompt, num_frames=61, num_inference_steps=30).frames[0] | ||
| export_to_video(video, "output.mp4", fps=15) | ||
| ``` | ||
|
|
||
| ## Notes | ||
|
|
||
| - HunyuanVideo1.5 use attention masks with variable-length sequences. For best performance, we recommend using an attention backend that handles padding efficiently. | ||
|
|
||
| - **H100/H800:** `_flash_3_hub` or `_flash_varlen_3` | ||
| - **A100/A800/RTX 4090:** `flash_hub` or `flash_varlen` | ||
| - **Other GPUs:** `sage_hub` | ||
|
|
||
| Refer to the [Attention backends](../../optimization/attention_backends) guide for more details about using a different backend. | ||
|
|
||
|
|
||
| ```py | ||
| pipe.transformer.set_attention_backend("flash_hub") # or your preferred backend | ||
| ``` | ||
|
|
||
| - [`HunyuanVideo15Pipeline`] use guider and does not take `guidance_scale` parameter at runtime. | ||
|
|
||
| You can check the default guider configuration using `pipe.guider`: | ||
|
|
||
| ```py | ||
| >>> pipe.guider | ||
| ClassifierFreeGuidance { | ||
| "_class_name": "ClassifierFreeGuidance", | ||
| "_diffusers_version": "0.36.0.dev0", | ||
| "enabled": true, | ||
| "guidance_rescale": 0.0, | ||
| "guidance_scale": 6.0, | ||
| "start": 0.0, | ||
| "stop": 1.0, | ||
| "use_original_formulation": false | ||
| } | ||
|
|
||
| State: | ||
| step: None | ||
| num_inference_steps: None | ||
| timestep: None | ||
| count_prepared: 0 | ||
| enabled: True | ||
| num_conditions: 2 | ||
| ``` | ||
|
|
||
| To update guider configuration, you can run `pipe.guider = pipe.guider.new(...)` | ||
|
|
||
| ```py | ||
| pipe.guider = pipe.guider.new(guidance_scale=5.0) | ||
| ``` | ||
|
|
||
| Read more on Guider [here](../../modular_diffusers/guiders). | ||
|
|
||
|
|
||
|
|
||
| ## HunyuanVideo15Pipeline | ||
|
|
||
| [[autodoc]] HunyuanVideo15Pipeline | ||
| - all | ||
| - __call__ | ||
|
|
||
| ## HunyuanVideo15ImageToVideoPipeline | ||
|
|
||
| [[autodoc]] HunyuanVideo15ImageToVideoPipeline | ||
| - all | ||
| - __call__ | ||
|
|
||
| ## HunyuanVideo15PipelineOutput | ||
|
|
||
| [[autodoc]] pipelines.hunyuan_video1_5.pipeline_output.HunyuanVideo15PipelineOutput | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I will work on adding the Hub variant for FA3 varlen so that we can ease the user-experience a bit here.