mirror of
https://github.com/Wan-Video/Wan2.1.git
synced 2025-12-17 12:43:36 +00:00
RIFLEx support
This commit is contained in:
parent
3731ab70e1
commit
7a8dcbf63d
18
README.md
18
README.md
@ -45,25 +45,22 @@ It is an illustration on how one can set up on an existing model some fast and p
|
|||||||
|
|
||||||
For more information on how to use the mmpg module, please go to: https://github.com/deepbeepmeep/mmgp
|
For more information on how to use the mmpg module, please go to: https://github.com/deepbeepmeep/mmgp
|
||||||
|
|
||||||
You will find the original Hunyuan Video repository here: https://github.com/deepbeepmeep/Wan2GP
|
You will find the original Wan2.1 Video repository here: https://github.com/Wan-Video/Wan2.1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Installation Guide for Linux and Windows
|
## Installation Guide for Linux and Windows
|
||||||
|
|
||||||
We provide an `environment.yml` file for setting up a Conda environment.
|
|
||||||
Conda's installation instructions are available [here](https://docs.anaconda.com/free/miniconda/index.html).
|
|
||||||
|
|
||||||
This app has been tested on Python 3.10 / 2.6.0 / Cuda 12.4.\
|
This app has been tested on Python 3.10 / 2.6.0 / Cuda 12.4.\
|
||||||
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# 1 - conda. Prepare and activate a conda environment
|
# 0 Create a Python 3.10.9 environment or a venv using python
|
||||||
conda env create -f environment.yml
|
conda create -name Wan2GP python==3.10.9 #if you have conda
|
||||||
conda activate Wan2
|
|
||||||
|
|
||||||
# OR
|
# 1 Install pytorch 2.6.0
|
||||||
|
|
||||||
# 1 - venv. Alternatively create a python 3.10 venv and then do the following
|
|
||||||
pip install torch==2.6.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/test/cu124
|
pip install torch==2.6.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/test/cu124
|
||||||
|
|
||||||
|
|
||||||
@ -81,9 +78,6 @@ pip install -e .
|
|||||||
# 3.2 optional Flash attention support (easy to install on Linux but much harder on Windows)
|
# 3.2 optional Flash attention support (easy to install on Linux but much harder on Windows)
|
||||||
python -m pip install flash-attn==2.7.2.post1
|
python -m pip install flash-attn==2.7.2.post1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that *Flash attention* and *Sage attention* are quite complex to install on Windows but offers a better memory management (and consequently longer videos) than the default *sdpa attention*.
|
Note that *Flash attention* and *Sage attention* are quite complex to install on Windows but offers a better memory management (and consequently longer videos) than the default *sdpa attention*.
|
||||||
|
|||||||
@ -975,9 +975,9 @@ def create_demo():
|
|||||||
gr.Markdown("The VRAM requirements will depend greatly of the resolution and the duration of the video, for instance : 24 GB of VRAM (RTX 3090 / RTX 4090), the limits are as follows:")
|
gr.Markdown("The VRAM requirements will depend greatly of the resolution and the duration of the video, for instance : 24 GB of VRAM (RTX 3090 / RTX 4090), the limits are as follows:")
|
||||||
gr.Markdown("- 848 x 480 with a 14B model: 80 frames (5s) : 8 GB of VRAM")
|
gr.Markdown("- 848 x 480 with a 14B model: 80 frames (5s) : 8 GB of VRAM")
|
||||||
gr.Markdown("- 848 x 480 with the 1.3B model: 80 frames (5s) : 5 GB of VRAM")
|
gr.Markdown("- 848 x 480 with the 1.3B model: 80 frames (5s) : 5 GB of VRAM")
|
||||||
gr.Markdown("- 1280 x 720 with a 14B model: 192 frames (8s): 11 GB of VRAM")
|
gr.Markdown("- 1280 x 720 with a 14B model: 80 frames (5s): 11 GB of VRAM")
|
||||||
gr.Markdown("Note that the VAE stages (encoding / decoding at image2video ) or just the decoding at text2video will create a temporary VRAM peak (up to 12GB for 420P and 22 GB for 720P)")
|
gr.Markdown("Note that the VAE stages (encoding / decoding at image2video ) or just the decoding at text2video will create a temporary VRAM peaks (up to 12GB for 420P and 22 GB for 720P)")
|
||||||
gr.Markdown("It is not recommmended to generate a video longer than 8s even if there is still some VRAM left as some artifact may appear")
|
gr.Markdown("It is not recommmended to generate a video longer than 8s (128 frames) even if there is still some VRAM left as some artifact may appear")
|
||||||
gr.Markdown("Please note that if your turn on compilation, the first generation step of the first video generation will be slow due to the compilation. Therefore all your tests should be done with compilation turned off.")
|
gr.Markdown("Please note that if your turn on compilation, the first generation step of the first video generation will be slow due to the compilation. Therefore all your tests should be done with compilation turned off.")
|
||||||
|
|
||||||
|
|
||||||
@ -996,7 +996,7 @@ def create_demo():
|
|||||||
index = 0 if index ==0 else index
|
index = 0 if index ==0 else index
|
||||||
transformer_t2v_choice = gr.Dropdown(
|
transformer_t2v_choice = gr.Dropdown(
|
||||||
choices=[
|
choices=[
|
||||||
("WAN 2.1 1.3B Text to Video 16 bits - the small model for fast generations with low VRAM requirements", 0),
|
("WAN 2.1 1.3B Text to Video 16 bits (recommended)- the small model for fast generations with low VRAM requirements", 0),
|
||||||
("WAN 2.1 14B Text to Video 16 bits - the default engine in its original glory, offers a slightly better image quality but slower and requires more RAM", 1),
|
("WAN 2.1 14B Text to Video 16 bits - the default engine in its original glory, offers a slightly better image quality but slower and requires more RAM", 1),
|
||||||
("WAN 2.1 14B Text to Video quantized to 8 bits (recommended) - the default engine but quantized", 2),
|
("WAN 2.1 14B Text to Video quantized to 8 bits (recommended) - the default engine but quantized", 2),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -289,7 +289,7 @@ class WanI2V:
|
|||||||
# sample videos
|
# sample videos
|
||||||
latent = noise
|
latent = noise
|
||||||
|
|
||||||
freqs = self.model.get_rope_freqs(nb_latent_frames = int((frame_num - 1)/4 + 1), RIFLEx_k = 4 if enable_RIFLEx else None )
|
freqs = self.model.get_rope_freqs(nb_latent_frames = int((frame_num - 1)/4 + 1), RIFLEx_k = 6 if enable_RIFLEx else None )
|
||||||
|
|
||||||
arg_c = {
|
arg_c = {
|
||||||
'context': [context[0]],
|
'context': [context[0]],
|
||||||
|
|||||||
@ -655,7 +655,7 @@ class WanModel(ModelMixin, ConfigMixin):
|
|||||||
|
|
||||||
|
|
||||||
freqs = torch.cat([
|
freqs = torch.cat([
|
||||||
rope_params_riflex(1024, dim= d - 4 * (d // 6), L_test=nb_latent_frames, k = RIFLEx_k ), #44
|
rope_params_riflex(1024, dim= d - 4 * (d // 6), L_test=nb_latent_frames, k = RIFLEx_k ) if RIFLEx_k != None else rope_params(1024, dim= d - 4 * (d // 6)), #44
|
||||||
rope_params(1024, 2 * (d // 6)), #42
|
rope_params(1024, 2 * (d // 6)), #42
|
||||||
rope_params(1024, 2 * (d // 6)) #42
|
rope_params(1024, 2 * (d // 6)) #42
|
||||||
],dim=1)
|
],dim=1)
|
||||||
|
|||||||
@ -240,7 +240,7 @@ class WanT2V:
|
|||||||
# k, N_k = identify_k(10000, 44, 26)
|
# k, N_k = identify_k(10000, 44, 26)
|
||||||
# print(f"value nb latent frames={nf}, k={k}, n_k={N_k}")
|
# print(f"value nb latent frames={nf}, k={k}, n_k={N_k}")
|
||||||
|
|
||||||
freqs = self.model.get_rope_freqs(nb_latent_frames = int((frame_num - 1)/4 + 1), RIFLEx_k = 4 if enable_RIFLEx else None )
|
freqs = self.model.get_rope_freqs(nb_latent_frames = int((frame_num - 1)/4 + 1), RIFLEx_k = 6 if enable_RIFLEx else None )
|
||||||
|
|
||||||
arg_c = {'context': context, 'seq_len': seq_len, 'freqs': freqs, 'pipeline': self}
|
arg_c = {'context': context, 'seq_len': seq_len, 'freqs': freqs, 'pipeline': self}
|
||||||
arg_null = {'context': context_null, 'seq_len': seq_len, 'freqs': freqs, 'pipeline': self}
|
arg_null = {'context': context_null, 'seq_len': seq_len, 'freqs': freqs, 'pipeline': self}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user