Python
added official NVFP4 support
DeepBeepMeepb1512b70f416
diff --git a/README.md b/README.mdindex fc92f7b..affe740 100644--- a/README.md+++ b/README.md@@ -20,22 +20,23 @@ WanGP supports the Wan (and derived models), Hunyuan Video and LTV Video models**Follow DeepBeepMeep on Twitter/X to get the Latest News**: https://x.com/deepbeepmeep-------### You have your choice of Dark or Light Theme+## 🔥 Latest Updates :+### January 15th 2026: WanGP v10.30, The Need for Speed ...-<img width="1895" height="1023" alt="Screenshot 2025-10-23 210313" src="https://github.com/user-attachments/assets/3778ae4e-6a95-4752-ba47-bb160c653310" />+- **LTX Distilled VAE Upgrade**: *Kijai* has observed that the Distilled VAE produces images that were less sharp that the VAE of the Non Distilled model. I have used this as an opportunity to repackage all the LTX 2 checkpoints and reduce their overal HD footprint since they all share around 5GB.-------<img width="1899" height="1020" alt="Screenshot 2025-10-23 210500" src="https://github.com/user-attachments/assets/5e524260-ad24-4203-acf2-6622676a83bb" />+**So dont be surprised if the old checkpoints are deleted and new are downloaded !!!**.-------+- **LTX2 Multi Passes Loras multipliers**: *LTX2* supports now loras multiplier that depend on the Pass No. For instance "1;0.5" means 1 will the strength for the first LTX2 pass and 0.5 will be the strength for the second pass.------+- **New Profile 3.5**: here is the lost kid of *Profile 3* & *Profile 5*, you got tons of VRAM, but little RAM ? Profile 3.5 will be your new friend as it will no longer use Reserved RAM to accelerate transfers. Use Profile 3.5 only if you can fit entirely a *Diffusion / Transformer* model in VRAM, otherwise the gen may be much slower.++- **NVFP4 Quantization for LTX 2 & Flux 2**: you will now be able to load *NV FP4* model checkpoints in WanGP. On top of *Wan NV4* which was added recently, we now have *LTX 2 (non distilled)* & *Flux 2* support. NV FP4 uses slightly less VRAM and up to 30% less RAM.++To enjoy fully the NV FP4 checkpoints (**at least 30% faster gens**), you will need a RTX 50xx and to upgrade to *Pytorch 2.9.1 / Cuda 13* with the latest version of *lightx2v kernels* (check *docs/INSTALLATION.md*). To observe the speed gain, you have to make sure the workload is quite high (high res, long video).-## 🔥 Latest Updates :### January 13th 2026: WanGP v10.24, When there is no VRAM left there is still some VRAM left ...@@ -53,8 +54,6 @@ After much suffering I have managed to reduce by at least 1/3 the VRAM requireme3K/4K resolutions will be available only if you enable them in the *Config* / *General* tab.-- **LTX Distilled VAE Upgrade**: *Kijai* has observed that the Distilled VAE produces images that were less sharp that the VAE of the Non Distilled model. I have used this as an opportunity to repackage all the LTX 2 checkpoints and reduce their overal HD footprint since they all share around 5GB. So dont be surprised if the old checkpoints are deleted and new are downloaded.-- **Ic Loras support**: Use a *Control Video* to transfer *Pose*, *Depth*, *Canny Edges*. I have added some extra tweaks: with WanGP you can restrict the transfer to a *masked area*, define a *denoising strength* (how much the control video is going to be followed) and a *masking strength* (how much unmasked area is impacted)- **Start Image Strength**: This new slider will appear below a *Start Image* or Source *Video*. If you set it to values lower than 1 you may to reduce the static image effect, you get sometime with LTX2 i2v@@ -67,8 +66,7 @@ After much suffering I have managed to reduce by at least 1/3 the VRAM requireme*update 10.21*: added slider Loras Max Pinning slider\*update 10.22*: added support for custom Ltx2 Text Encoder + Auto Recovery mode if Lora Pinning failed\-*update 10.23*: Fixed text prompt ignore in profile 1 & 2 (this created random output videos)\-*update 10.24*: Replaced LTX 2 Distilled VAE by sharper non Distilled VAE+*update 10.23*: Fixed text prompt ignore in profile 1 & 2 (this created random output videos)### January 9st 2026: WanGP v10.11, Spoiled again@@ -354,10 +352,9 @@ See full changelog: **[Changelog](docs/CHANGELOG.md)**## 🚀 Quick Start**One-click installation:**-- Get started instantly with [Pinokio App](https://pinokio.computer/)\+Get started instantly with [Pinokio App](https://pinokio.computer/)\It is recommended to use in Pinokio the Community Scripts *wan2gp* or *wan2gp-amd* by **Morpheus** rather than the official Pinokio install.-- Use Redtash1 [One Click Install with Sage](https://github.com/Redtash1/Wan2GP-Windows-One-Click-Install-With-Sage)**Manual installation:**```bashdiff --git a/defaults/flux2_dev_nvfp4.json b/defaults/flux2_dev_nvfp4.jsonnew file mode 100644index 0000000..e4ff6df--- /dev/null+++ b/defaults/flux2_dev_nvfp4.json@@ -0,0 +1,15 @@+{+ "model": {+ "name": "Flux 2 Dev NVFP4",+ "architecture": "flux2_dev",+ "description": "NVFP4-quantized Flux 2 Dev checkpoint (mixed).",+ "URLs": [+ "C:\\temp\\flux2-dev-nvfp4-mixed.safetensors"+ ]+ },+ "prompt": "draw a hat on top of a hat inside a hat",+ "resolution": "1024x1024",+ "batch_size": 1,+ "embedded_guidance_scale": 4,+ "sampling_steps": 30+}diff --git a/defaults/ltx2_19B_nvfp4.json b/defaults/ltx2_19B_nvfp4.jsonnew file mode 100644index 0000000..ce32c8a--- /dev/null+++ b/defaults/ltx2_19B_nvfp4.json@@ -0,0 +1,19 @@+{+ "model": {+ "name": "LTX-2 Dev 19B NVFP4",+ "architecture": "ltx2_19B",+ "description": "NVFP4-quantized LTX-2 Dev 19B weights. For full speed, a sm120+ GPU is needed (RTX 50xx) and the comfy-kitchen NVFP4 kernels must be installed.",+ "URLs": [+ "https://huggingface.co/DeepBeepMeep/LTX-2/resolve/main/ltx-2-19b-dev-fp4_diffusion_model.safetensors"+ ],+ "preload_URLs": "ltx2_19B",+ "loras": [+ "https://huggingface.co/DeepBeepMeep/LTX-2/resolve/main/ltx-2-19b-distilled-lora-384.safetensors"+ ],+ "loras_multipliers": ["0;1"]+ },+ "prompt": "A warm sunny backyard. The camera starts in a tight cinematic close-up of a woman and a man in their 30s, facing each other with serious expressions. The woman, emotional and dramatic, says softly, \"That's it... Dad's lost it. And we've lost Dad.\"The man exhales, slightly annoyed: \"Stop being so dramatic, Jess.\"A beat. He glances aside, then mutters defensively, \"He's just having fun.\"The camera slowly pans right, revealing the grandfather in the garden wearing enormous butterfly wings, waving his arms in the air like he's trying to take off.He shouts, \"Wheeeew!\" as he flaps his wings with full commitment.The woman covers her face, on the verge of tears. The tone is deadpan, absurd, and quietly tragic.",+ "num_inference_steps": 40,+ "video_length": 241,+ "guidance_scale": 4.0+}diff --git a/defaults/pi_flux2_nvfp4.json b/defaults/pi_flux2_nvfp4.jsonnew file mode 100644index 0000000..cfc96fe--- /dev/null+++ b/defaults/pi_flux2_nvfp4.json@@ -0,0 +1,21 @@+{+ "model": {+ "name": "pi-FLUX.2 Dev NVFP4",+ "architecture": "pi_flux2",+ "description": "pi-FLUX.2 using the NVFP4 Flux 2 Dev checkpoint.",+ "URLs": "flux2_dev_nvfp4",+ "modules": [+ [+ "https://huggingface.co/DeepBeepMeep/Flux2/resolve/main/pi_flux2_heads_bf16.safetensors"+ ]+ ],+ "preload_URLs": [+ "https://huggingface.co/DeepBeepMeep/Flux2/resolve/main/gmflux2_k8_piid_4step_lora.safetensors"+ ]+ },+ "prompt": "a beautiful sunset over the ocean with vibrant colors",+ "resolution": "1024x1024",+ "batch_size": 1,+ "embedded_guidance_scale": 4,+ "num_inference_steps": 4+}diff --git a/defaults/z_image_control2_1_8s.json b/defaults/z_image_control2_1_8s.jsonindex e1f2ea9..5698474 100644--- a/defaults/z_image_control2_1_8s.json+++ b/defaults/z_image_control2_1_8s.json@@ -1,10 +1,10 @@{"model": {- "name": "Z-Image Turbo Fun ControlNet v2.1 8 Steps 6B",+ "name": "Z-Image Turbo Fun ControlNet v2.1 8 Steps YYY 6B","architecture": "z_image_control2_1","modules": [[- "https://huggingface.co/DeepBeepMeep/Z-Image/resolve/main/Z-Image-Turbo-Fun-Controlnet-Union2.1-8steps_bf16.safetensors",+ "https://huggingface.co/DeepBeepMeep/Z-Image/resolve/main/Z-Image-Turbo-Fun-Controlnet-Tile-2.1-2601-8_steps_bf16.safetensors","https://huggingface.co/DeepBeepMeep/Z-Image/resolve/main/Z-Image-Turbo-Fun-Controlnet-Union2.1-8steps_quanto_bf16_int8.safetensors"]],diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.mdindex cc76485..0208936 100644--- a/docs/INSTALLATION.md+++ b/docs/INSTALLATION.md@@ -21,8 +21,10 @@ This guide covers installation for different GPU generations and operating syste## Installation for Nvidia GTX 10XX - RTX QUADRO - 50XX (Stable)This installation uses PyTorch 2.6.0, Cuda 12.6 for GTX 10XX - RTX 30XX & PyTorch 2.7.1, Cuda 12.8 for RTX 40XX - 50XX which are well-tested and stable.+Unless you need absolutely to use Pytorch compilation (with RTX 50xx), it is not recommeneded to use PytTorch 2.8.0 as some System RAM memory leaks have been observed when switching models.+If you want to use the NV FP4 optimized kernels for RTX 50xx, you will need PyTorch 2.9.1 with Cuda 13.0## Download Repo and Setup Conda Environment@@ -125,6 +127,24 @@ pip install https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-pip install -r requirements.txt```+## Installation for 50XX Only PyTorch 2.9.1 Cuda 13.. for NVFP4 optimized kernels++#### Windows Install PyTorch 2.9.1 with CUDA 13.0 for RTX 50XX Only+```+pip install torch==2.9.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130+```+#### Windows Install Triton for RTX 50XX Only+```+pip install -U "triton-windows<3.4"+```+#### Windows Install Sage2 Attention for RTX 50XX Only+```+pip install https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-windows.post4/sageattention-2.2.0+cu130torch2.9.0andhigher.post4-cp39-abi3-win_amd64.whl+```+#### Windows Install requirements.txt for RTX 50XX Only+```+pip install -r requirements.txt+```## Optional### Flash Attention@@ -259,8 +279,8 @@ pip install flash-attn==2.7.2.post1- RTX 10XX: SDPA- RTX 20XX: SPDA, Sage1-- RTX 30XX, 40XX: SDPA, Flash Attention, Xformers, Sage1, Sage2-- RTX 50XX: SDPA, Flash Attention, Xformers, Sage2+- RTX 30XX, 40XX: SDPA, Flash Attention, Xformers, Sage1, Sage2/Sage2+++- RTX 50XX: SDPA, Flash Attention, Xformers, Sage2/Sage2++ / Sage3## Performance Profiles@@ -292,14 +312,40 @@ If Sage attention doesn't work:For more troubleshooting, see [TROUBLESHOOTING.md](TROUBLESHOOTING.md)-## Quantization Kernels Wheels for Windows / Python 3.10 / Pytorch 2.70-- Light2xv (WAN-FP4)+## Optional Kernels for INT4 / FP4 quantized support+These kernels will offer optimized INT4 / FP4 dequantization.++**Please Note FP4 support is hardware dependent and will work only with RTX 50xx / sm120+ GPUs**+++### Light2xv NVP4 Kernels Wheels for Windows / Python 3.10 / Pytorch 2.9.1 / Cuda 13.8 (RTX 50xx / sm120+ only !)+- Windows+ ```+ pip install https://github.com/deepbeepmeep/kernels/releases/download/Light2xv/lightx2v_kernel-0.0.1+torch2.9.1-cp39-abi3-win_amd64.whl```- pip install https://github.com/deepbeepmeep/kernels/releases/download/WAN_NVP4/lightx2v_kernel-0.0.1-cp39-abi3-win_amd64.whl++- Linux+ ```+ pip install https://github.com/deepbeepmeep/kernels/releases/download/Light2xv/lightx2v_kernel-0.0.1+torch2.9.1cu130-cp39-abi3-linux_x86_64.whl```-- Nunchaku+++### Nunchaku INT4/FP4 Kernels Wheels for Python 3.10+- Windows (Pytorch 2.7.1 / Cuda 12.8)+ ```+pip install https://github.com/deepbeepmeep/kernels/releases/download/v1.2.0_Nunchaku/nunchaku-1.2.0+torch2.7-cp310-cp310-win_amd64.whl+ ```+- Windows (Pytorch 2.9.1 / Cuda 13)```- pip install https://github.com/deepbeepmeep/kernels/releases/download/Nunchaku/nunchaku-1.1.0+torch2.7-cp310-cp310-win_amd64.whl+ pip install https://github.com/deepbeepmeep/kernels/releases/download/v1.2.0_Nunchaku/nunchaku-1.2.0+torch2.9-cp310-cp310-win_amd64.whl```+- Linux (Pytorch 2.7.1 / Cuda 12.8)+ ```+ pip install https://github.com/deepbeepmeep/kernels/releases/download/v1.2.0_Nunchaku/nunchaku-1.2.0+torch2.7-cp310-cp310-linux_x86_64.whl+ ```+- Windows (Pytorch 2.9.1 / Cuda 13)+ ```+ pip install https://github.com/deepbeepmeep/kernels/releases/download/v1.2.0_Nunchaku/nunchaku-1.2.0+torch2.9-cp310-cp310-linux_x86_64.whl+ ```\ No newline at end of filediff --git a/models/chatterbox/chatterbox_handler.py b/models/chatterbox/chatterbox_handler.pyindex 8ed571f..ecb51d1 100644--- a/models/chatterbox/chatterbox_handler.py+++ b/models/chatterbox/chatterbox_handler.py@@ -117,7 +117,7 @@ class family_handler:mixed_precision_transformer=False,save_quantized=False,submodel_no_list=None,- override_text_encoder = None,+ text_encoder_filename = None,):from .pipeline import ChatterboxPipelinediff --git a/models/flux/flux_handler.py b/models/flux/flux_handler.pyindex bea796c..603727e 100644--- a/models/flux/flux_handler.py+++ b/models/flux/flux_handler.py@@ -262,7 +262,7 @@ class family_handler():return ret@staticmethod- def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, override_text_encoder = None):+ def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, text_encoder_filename = None):from .flux_main import model_factoryflux_model = model_factory(@@ -271,7 +271,7 @@ class family_handler():model_type = model_type,model_def = model_def,base_model_type=base_model_type,- text_encoder_filename= get_flux_text_encoder_filename(text_encoder_quantization, base_model_type) if override_text_encoder is None else override_text_encoder,+ text_encoder_filename= get_flux_text_encoder_filename(text_encoder_quantization, base_model_type) if text_encoder_filename is None else text_encoder_filename,quantizeTransformer = quantizeTransformer,dtype = dtype,VAE_dtype = VAE_dtype,diff --git a/models/hyvideo/hunyuan_handler.py b/models/hyvideo/hunyuan_handler.pyindex 9986728..681c77f 100644--- a/models/hyvideo/hunyuan_handler.py+++ b/models/hyvideo/hunyuan_handler.py@@ -234,7 +234,7 @@ class family_handler():return download_def@staticmethod- def load_model(model_filename, model_type = None, base_model_type = None, model_def = None, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, override_text_encoder = None):+ def load_model(model_filename, model_type = None, base_model_type = None, model_def = None, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, text_encoder_filename = None):from .hunyuan import HunyuanVideoSamplerfrom mmgp import offload@@ -243,7 +243,7 @@ class family_handler():model_type = model_type,base_model_type = base_model_type,model_def = model_def,- text_encoder_filepath = get_hunyuan_text_encoder_filename(base_model_type, text_encoder_quantization) if override_text_encoder is None else override_text_encoder,+ text_encoder_filepath = get_hunyuan_text_encoder_filename(base_model_type, text_encoder_quantization) if text_encoder_filename is None else text_encoder_filename,dtype = dtype,quantizeTransformer = quantizeTransformer,VAE_dtype = VAE_dtype,diff --git a/models/kandinsky5/kandinsky_handler.py b/models/kandinsky5/kandinsky_handler.pyindex d651b65..d08b0f0 100644--- a/models/kandinsky5/kandinsky_handler.py+++ b/models/kandinsky5/kandinsky_handler.py@@ -277,7 +277,7 @@ class family_handler:mixed_precision_transformer=False,save_quantized=False,submodel_no_list=None,- override_text_encoder=None,+ text_encoder_filename=None,**kwargs,):from .kandinsky_main import model_factory@@ -288,7 +288,7 @@ class family_handler:model_type=model_type,model_def=model_def,base_model_type=base_model_type,- text_encoder_filename=override_text_encoder,+ text_encoder_filename=text_encoder_filename,quantizeTransformer=quantizeTransformer,dtype=dtype,VAE_dtype=VAE_dtype,diff --git a/models/longcat/longcat_handler.py b/models/longcat/longcat_handler.pyindex 2cba8ac..34fe081 100644--- a/models/longcat/longcat_handler.py+++ b/models/longcat/longcat_handler.py@@ -144,7 +144,7 @@ class family_handler:mixed_precision_transformer=False,save_quantized=False,submodel_no_list=None,- override_text_encoder=None,+ text_encoder_filename=None,**kwargs,):from .longcat_main import LongCatModel@@ -156,8 +156,8 @@ class family_handler:model_def=model_def,base_model_type=base_model_type,text_encoder_filename=get_longcat_text_encoder_filename(text_encoder_quantization)- if override_text_encoder is None- else override_text_encoder,+ if text_encoder_filename is None+ else text_encoder_filename,quantizeTransformer=quantizeTransformer,dtype=dtype,VAE_dtype=VAE_dtype,diff --git a/models/ltx2/ltx2.py b/models/ltx2/ltx2.pyindex 5998498..6d478ed 100644--- a/models/ltx2/ltx2.py+++ b/models/ltx2/ltx2.py@@ -391,7 +391,7 @@ class LTX2:model_def: dict,dtype: torch.dtype = torch.bfloat16,VAE_dtype: torch.dtype = torch.float32,- override_text_encoder: str | None = None,+ text_encoder_filename: str | None = None,text_encoder_filepath = None,checkpoint_paths: dict | None = None,) -> None:@@ -418,7 +418,7 @@ class LTX2:if not transformer_path:raise ValueError("Missing transformer path in checkpoint_paths.")- gemma_root = text_encoder_filepath if override_text_encoder is None else override_text_encoder+ gemma_root = text_encoder_filepath if text_encoder_filename is None else text_encoder_filenameif not gemma_root:raise ValueError("Missing Gemma text encoder path.")spatial_upsampler_path = fl.locate_file(_SPATIAL_UPSCALER_FILENAME)diff --git a/models/ltx2/ltx2_handler.py b/models/ltx2/ltx2_handler.pyindex 05eeaa0..64cec00 100644--- a/models/ltx2/ltx2_handler.py+++ b/models/ltx2/ltx2_handler.py@@ -4,7 +4,7 @@ from shared.utils import files_locator as fl_GEMMA_FOLDER = "gemma-3-12b-it-qat-q4_0-unquantized"-_GEMMA_MERGED_FILENAME = f"{_GEMMA_FOLDER}.safetensors"+_GEMMA_FILENAME = f"{_GEMMA_FOLDER}.safetensors"_GEMMA_QUANTO_FILENAME = f"{_GEMMA_FOLDER}_quanto_bf16_int8.safetensors"_SPATIAL_UPSCALER_FILENAME = "ltx-2-spatial-upscaler-x2-1.0.safetensors"_DISTILLED_LORA_FILENAME = "ltx-2-19b-distilled-lora-384.safetensors"@@ -58,7 +58,7 @@ class family_handler:@staticmethoddef get_text_encoder_filename(text_encoder_quantization):- text_encoder_filename = f"{_GEMMA_FOLDER}/{_GEMMA_MERGED_FILENAME}"+ text_encoder_filename = f"{_GEMMA_FOLDER}/{_GEMMA_FILENAME}"if text_encoder_quantization == "int8":text_encoder_filename = f"{_GEMMA_FOLDER}/{_GEMMA_QUANTO_FILENAME}"return fl.locate_file(text_encoder_filename, True)@@ -67,7 +67,12 @@ class family_handler:@staticmethoddef query_model_def(base_model_type, model_def):pipeline_kind = model_def.get("ltx2_pipeline", "two_stage")++ distilled = pipeline_kind == "distilled"+extra_model_def = {+ "text_encoder_folder": _GEMMA_FOLDER,+ "text_encoder_URLs": [_GEMMA_FILENAME, _GEMMA_QUANTO_FILENAME],"dtype": "bf16","fps": 24,"frames_minimum": 17,@@ -79,7 +84,7 @@ class family_handler:"audio_prompt_choices": True,"one_speaker_only": True,"audio_guide_label": "Audio Prompt (Soundtrack)",- "audio_scale_name": "Audio Strength (if Audio Prompt provided)",+ "audio_scale_name": "Prompt Audio Strength","audio_prompt_type_sources": {"selection": ["", "A"],"labels": {@@ -117,18 +122,16 @@ class family_handler:"window_step": 4,"window_default": 241,}- if pipeline_kind == "distilled":+ if distilled:extra_model_def.update({"lock_inference_steps": True,"no_negative_prompt": True,- "guidance_max_phases": 0,})- else:- extra_model_def["guidance_max_phases"] = 2- extra_model_def["virtual_higher_phases"] = True- extra_model_def["lock_guidance_phases"] = True+ extra_model_def["guidance_max_phases"] = 2+ extra_model_def["visible_phases"] = 0 if distilled else 1+ extra_model_def["lock_guidance_phases"] = Truereturn extra_model_def@staticmethod@@ -156,11 +159,10 @@ class family_handler:@staticmethoddef query_model_files(computeList, base_model_type, model_filename, text_encoder_quantization, model_def=None):- text_encoder_filename = family_handler.get_text_encoder_filename(text_encoder_quantization)gemma_files = ["added_tokens.json","chat_template.json",- "config.json",+ "config_light.json","generation_config.json","preprocessor_config.json","processor_config.json",@@ -168,7 +170,7 @@ class family_handler:"tokenizer.json","tokenizer.model","tokenizer_config.json",- ] + computeList(text_encoder_filename)+ ]file_list = [_SPATIAL_UPSCALER_FILENAME] + computeList(model_filename)for name in _get_multi_file_names(model_def).values():@@ -210,7 +212,7 @@ class family_handler:mixed_precision_transformer=False,save_quantized=False,submodel_no_list=None,- override_text_encoder=None,+ text_encoder_filename=None,**kwargs,):from .ltx2 import LTX2@@ -226,8 +228,8 @@ class family_handler:model_def=model_def,dtype=dtype,VAE_dtype=VAE_dtype,- override_text_encoder=override_text_encoder,- text_encoder_filepath = family_handler.get_text_encoder_filename(text_encoder_quantization),+ text_encoder_filename=text_encoder_filename,+ text_encoder_filepath = model_def.get("text_encoder_folder", os.path.dirname(text_encoder_filename)),checkpoint_paths=checkpoint_paths,)diff --git a/models/ltx2/ltx_core/model/video_vae/model_configurator.py b/models/ltx2/ltx_core/model/video_vae/model_configurator.pyindex be33189..a07fd45 100644--- a/models/ltx2/ltx_core/model/video_vae/model_configurator.py+++ b/models/ltx2/ltx_core/model/video_vae/model_configurator.py@@ -46,6 +46,7 @@ class VideoDecoderConfigurator(ModelConfigurator[VideoDecoder]):norm_layer_str = config.get("norm_layer", "pixel_norm")causal = config.get("causal_decoder", False)timestep_conditioning = config.get("timestep_conditioning", True)+ temporal_chunk_on_gpu = config.get("decode_temporal_chunk_on_gpu", True)return VideoDecoder(convolution_dimensions=convolution_dimensions,@@ -56,6 +57,7 @@ class VideoDecoderConfigurator(ModelConfigurator[VideoDecoder]):norm_layer=NormLayerType(norm_layer_str),causal=causal,timestep_conditioning=timestep_conditioning,+ temporal_chunk_on_gpu=temporal_chunk_on_gpu,decoder_spatial_padding_mode=decoder_spatial_padding_mode,)diff --git a/models/ltx2/ltx_core/model/video_vae/video_vae.py b/models/ltx2/ltx_core/model/video_vae/video_vae.pyindex 2fb17cf..5a71ed0 100644--- a/models/ltx2/ltx_core/model/video_vae/video_vae.py+++ b/models/ltx2/ltx_core/model/video_vae/video_vae.py@@ -431,6 +431,7 @@ class VideoDecoder(nn.Module):norm_layer: NormLayerType = NormLayerType.PIXEL_NORM,causal: bool = False,timestep_conditioning: bool = False,+ temporal_chunk_on_gpu: bool = True,decoder_spatial_padding_mode: PaddingModeType = PaddingModeType.REFLECT,):super().__init__()@@ -450,6 +451,7 @@ class VideoDecoder(nn.Module):out_channels = out_channels * patch_size**2self.causal = causalself.timestep_conditioning = timestep_conditioning+ self.temporal_chunk_on_gpu = temporal_chunk_on_gpuself._norm_num_groups = self._DEFAULT_NORM_NUM_GROUPS# Per-channel statistics for denormalizing latents@@ -458,6 +460,8 @@ class VideoDecoder(nn.Module):# Noise and timestep parameters for decoder conditioningself.decode_noise_scale = 0.025self.decode_timestep = 0.05+ self._mask_cache: dict[tuple[int, torch.device, torch.dtype], tuple[torch.Tensor, torch.Tensor]] = {}+ self._mask_cache_limit = 512# Compute initial feature_channels by going through blocks in reverse# This determines the channel width at the start of the decoder@@ -675,10 +679,13 @@ class VideoDecoder(nn.Module):temporal_groups = self._group_tiles_by_temporal_slice(tiles)- # Accumulate tiles on CPU to avoid VRAM spikes from large temporal buffers.- accumulation_device = latent.device- if accumulation_device.type == "cuda":- accumulation_device = torch.device("cpu")+ blend_device = latent.device+ if blend_device.type == "cuda":+ blend_device = torch.device("cpu")++ chunk_device = blend_device+ if self.temporal_chunk_on_gpu and latent.device.type == "cuda":+ chunk_device = latent.device# State for temporal overlap handlingprevious_chunk = None@@ -702,7 +709,7 @@ class VideoDecoder(nn.Module):buffer = torch.zeros(temporal_tile_buffer_shape.to_torch_shape(),- device=accumulation_device,+ device=chunk_device,dtype=latent.dtype,)@@ -715,6 +722,12 @@ class VideoDecoder(nn.Module):temporal_slice=curr_temporal_slice,total_frames=total_frames,)+ if chunk_device != blend_device:+ buffer_cpu = buffer.to(device=blend_device)+ curr_weights_cpu = curr_weights.to(device=blend_device)+ del buffer, curr_weights+ buffer = buffer_cpu+ curr_weights = curr_weights_cpu# Blend with previous temporal chunk if it existsif previous_chunk is not None:@@ -782,6 +795,28 @@ class VideoDecoder(nn.Module):stop = total_frames if temporal_slice.stop is None else temporal_slice.stopreturn slice(start, stop, temporal_slice.step)+ def _prepare_mask_1d(+ self,+ mask: torch.Tensor | None,+ length: int | None,+ device: torch.device,+ dtype: torch.dtype,+ ) -> torch.Tensor | None:+ if mask is None:+ return None+ cache_key = (id(mask), device, dtype)+ cached = self._mask_cache.get(cache_key)+ if cached is None or cached[0] is not mask or cached[1].numel() != mask.numel():+ if self._mask_cache_limit > 0 and len(self._mask_cache) >= self._mask_cache_limit:+ self._mask_cache.clear()+ converted = mask.to(device=device, dtype=dtype)+ self._mask_cache[cache_key] = (mask, converted)+ else:+ converted = cached[1]+ if length is not None and converted.numel() > length:+ return converted[:length]+ return converted+def _accumulate_temporal_group_into_buffer(self,group_tiles: List[Tile],@@ -797,11 +832,14 @@ class VideoDecoder(nn.Module):The buffer is local to the group and always starts at time 0; temporal coordinatesare rebased by subtracting temporal_slice.start."""- weights = torch.zeros_like(buffer)+ weights = torch.zeros(+ (1, 1, buffer.shape[2], buffer.shape[3], buffer.shape[4]),+ device=buffer.device,+ dtype=buffer.dtype,+ )for tile in group_tiles:decoded_tile = self.forward(latent[tile.in_coords], timestep, generator)- mask = tile.blend_mask.to(device=buffer.device, dtype=buffer.dtype)tile_temporal_slice = self._normalize_temporal_slice(tile.out_coords[2], total_frames)temporal_offset = tile_temporal_slice.start - temporal_slice.start# Use the tile's output coordinate length, not the decoded tile's length,@@ -822,14 +860,73 @@ class VideoDecoder(nn.Module):# Slice decoded_tile and mask to match the actual length we're writingdecoded_slice = decoded_tile[:, :, :actual_temporal_len, :, :]+ mask_t = self._prepare_mask_1d(+ tile.masks_1d[2],+ actual_temporal_len,+ decoded_slice.device,+ decoded_slice.dtype,+ )+ mask_h = self._prepare_mask_1d(+ tile.masks_1d[3],+ decoded_slice.shape[3],+ decoded_slice.device,+ decoded_slice.dtype,+ )+ mask_w = self._prepare_mask_1d(+ tile.masks_1d[4],+ decoded_slice.shape[4],+ decoded_slice.device,+ decoded_slice.dtype,+ )+ if mask_t is not None:+ decoded_slice *= mask_t.view(1, 1, -1, 1, 1)+ if mask_h is not None:+ decoded_slice *= mask_h.view(1, 1, 1, -1, 1)+ if mask_w is not None:+ decoded_slice *= mask_w.view(1, 1, 1, 1, -1)if decoded_slice.device != buffer.device or decoded_slice.dtype != buffer.dtype:decoded_slice = decoded_slice.to(device=buffer.device, dtype=buffer.dtype)+ decoded_h = decoded_slice.shape[3]+ decoded_w = decoded_slice.shape[4]del decoded_tile- mask_slice = mask[:, :, :actual_temporal_len, :, :] if mask.shape[2] > 1 else mask-- buffer[chunk_coords] += decoded_slice * mask_slice- weights[chunk_coords] += mask_slice+ buffer[chunk_coords] += decoded_slice+ del decoded_slice++ if mask_t is not None and (mask_t.device != buffer.device or mask_t.dtype != buffer.dtype):+ mask_t = self._prepare_mask_1d(tile.masks_1d[2], actual_temporal_len, buffer.device, buffer.dtype)+ if mask_h is not None and (mask_h.device != buffer.device or mask_h.dtype != buffer.dtype):+ mask_h = self._prepare_mask_1d(tile.masks_1d[3], decoded_h, buffer.device, buffer.dtype)+ if mask_w is not None and (mask_w.device != buffer.device or mask_w.dtype != buffer.dtype):+ mask_w = self._prepare_mask_1d(tile.masks_1d[4], decoded_w, buffer.device, buffer.dtype)++ weights_slice = weights[chunk_coords]+ if mask_h is not None and mask_w is not None:+ mask_hw = mask_h.view(-1, 1) * mask_w.view(1, -1)+ if mask_t is None:+ weights_slice += mask_hw.view(1, 1, 1, mask_hw.shape[0], mask_hw.shape[1])+ elif mask_t.numel() == 1:+ weights_slice += mask_hw.view(1, 1, 1, mask_hw.shape[0], mask_hw.shape[1]) * mask_t+ else:+ for t_idx in range(actual_temporal_len):+ weights_slice[:, :, t_idx, :, :] += mask_t[t_idx] * mask_hw+ del mask_hw+ else:+ if mask_t is None:+ if mask_h is None and mask_w is None:+ weights_slice += 1+ elif mask_h is not None:+ weights_slice += mask_h.view(1, 1, 1, -1, 1)+ else:+ weights_slice += mask_w.view(1, 1, 1, 1, -1)+ else:+ if mask_h is not None:+ weights_slice += mask_t.view(1, 1, -1, 1, 1) * mask_h.view(1, 1, 1, -1, 1)+ elif mask_w is not None:+ weights_slice += mask_t.view(1, 1, -1, 1, 1) * mask_w.view(1, 1, 1, 1, -1)+ else:+ weights_slice += mask_t.view(1, 1, -1, 1, 1)+ del mask_t, mask_h, mask_wreturn weightsdiff --git a/models/ltx2/ltx_core/text_encoders/gemma/encoders/base_encoder.py b/models/ltx2/ltx_core/text_encoders/gemma/encoders/base_encoder.pyindex af6aff2..332c7a8 100644--- a/models/ltx2/ltx_core/text_encoders/gemma/encoders/base_encoder.py+++ b/models/ltx2/ltx_core/text_encoders/gemma/encoders/base_encoder.py@@ -339,7 +339,7 @@ def build_gemma_text_encoder(raise FileNotFoundError(f"Gemma checkpoint not found: {gemma_root}")gemma_dir = os.path.dirname(gemma_path)tokenizer_path = fl.locate_folder(os.path.join(_GEMMA_FOLDER))- config_path = fl.locate_file(os.path.join(_GEMMA_FOLDER, "config.json"))+ config_path = fl.locate_file(os.path.join(_GEMMA_FOLDER, "config_light.json"))from accelerate import init_empty_weightswith init_empty_weights():text_encoder = GemmaTextEncoderModelBase(feature_extractor_linear=None, tokenizer=None, model=None, dtype=default_dtype)diff --git a/models/ltx_video/ltxv_handler.py b/models/ltx_video/ltxv_handler.pyindex 1f99c16..033bf60 100644--- a/models/ltx_video/ltxv_handler.py+++ b/models/ltx_video/ltxv_handler.py@@ -91,12 +91,12 @@ class family_handler():@staticmethod- def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, override_text_encoder = None):+ def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, text_encoder_filename = None):from .ltxv import LTXVltxv_model = LTXV(model_filepath = model_filename,- text_encoder_filepath = get_ltxv_text_encoder_filename(text_encoder_quantization) if override_text_encoder is None else override_text_encoder,+ text_encoder_filepath = get_ltxv_text_encoder_filename(text_encoder_quantization) if text_encoder_filename is None else text_encoder_filename,model_type = model_type,base_model_type = base_model_type,model_def = model_def,diff --git a/models/qwen/qwen_handler.py b/models/qwen/qwen_handler.pyindex e643ee7..ee7499f 100644--- a/models/qwen/qwen_handler.py+++ b/models/qwen/qwen_handler.py@@ -131,7 +131,7 @@ class family_handler():return download_def@staticmethod- def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, override_text_encoder = None, VAE_upsampling = None, **kwargs):+ def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized = False, submodel_no_list = None, text_encoder_filename = None, VAE_upsampling = None, **kwargs):from .qwen_main import model_factoryfrom mmgp import offload@@ -141,7 +141,7 @@ class family_handler():model_type = model_type,model_def = model_def,base_model_type=base_model_type,- text_encoder_filename= get_qwen_text_encoder_filename(text_encoder_quantization) if override_text_encoder is None else override_text_encoder,+ text_encoder_filename= get_qwen_text_encoder_filename(text_encoder_quantization) if text_encoder_filename is None else text_encoder_filename,quantizeTransformer = quantizeTransformer,dtype = dtype,VAE_dtype = VAE_dtype,diff --git a/models/wan/any2video.py b/models/wan/any2video.pyindex 57ad809..fc3e604 100644--- a/models/wan/any2video.py+++ b/models/wan/any2video.py@@ -104,7 +104,7 @@ class WanAny2V:dtype=config.t5_dtype,device=torch.device('cpu'),checkpoint_path=text_encoder_filename,- tokenizer_path=fl.locate_folder("umt5-xxl"),+ tokenizer_path=fl.locate_folder(model_def.get("text_encoder_folder", os.path.dirname(text_encoder_filename))),shard_fn= None)if hasattr(config, "clip_checkpoint") and not model_def.get("i2v_2_2", False) or base_model_type in ["animate"]:self.clip = CLIPModel(@@ -116,13 +116,18 @@ class WanAny2V:ignore_unused_weights = model_def.get("ignore_unused_weights", False)vae_upsampler_factor = 1vae_checkpoint2 = None- if model_def.get("wan_5B_class", False):+ vae_checkpoint = model_def.get("VAE_URLs", None )+ vae = WanVAE+ self.vae_stride = config.vae_stride+ if isinstance(vae_checkpoint, str):+ pass+ elif isinstance(vae_checkpoint, list) and len(vae_checkpoint):+ vae_checkpoint = vae_checkpoint[0]+ elif model_def.get("wan_5B_class", False):self.vae_stride = (4, 16, 16)vae_checkpoint = "Wan2.2_VAE.safetensors"vae = Wan2_2_VAEelse:- vae = WanVAE- self.vae_stride = config.vae_strideif VAE_upsampling is not None:vae_upsampler_factor = 2vae_checkpoint ="Wan2.1_VAE_upscale2x_imageonly_real_v1.safetensors"diff --git a/models/wan/df_handler.py b/models/wan/df_handler.pyindex 3c7f8b7..22d06e9 100644--- a/models/wan/df_handler.py+++ b/models/wan/df_handler.py@@ -91,7 +91,7 @@ class family_handler():return family_handler.query_model_files(computeList, base_model_type, model_filename, text_encoder_quantization)@staticmethod- def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized= False, submodel_no_list = None, override_text_encoder = None):+ def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized= False, submodel_no_list = None, text_encoder_filename = None):from .configs import WAN_CONFIGSfrom .wan_handler import family_handlercfg = WAN_CONFIGS['t2v-14B']@@ -103,7 +103,7 @@ class family_handler():model_type = model_type,model_def = model_def,base_model_type=base_model_type,- text_encoder_filename= family_handler.get_text_encoder_filename(text_encoder_quantization) if override_text_encoder is None else override_text_encoder,+ text_encoder_filename= family_handler.get_text_encoder_filename(text_encoder_quantization) if text_encoder_filename is None else text_encoder_filename,quantizeTransformer = quantizeTransformer,dtype = dtype,VAE_dtype = VAE_dtype,diff --git a/models/wan/ovi_handler.py b/models/wan/ovi_handler.pyindex b88ac7b..e769f6c 100644--- a/models/wan/ovi_handler.py+++ b/models/wan/ovi_handler.py@@ -101,7 +101,7 @@ class family_handler:mixed_precision_transformer=False,save_quantized=False,submodel_no_list=None,- override_text_encoder=None,+ text_encoder_filename=None,):from .ovi_fusion_engine import OviFusionEnginediff --git a/models/wan/wan_handler.py b/models/wan/wan_handler.pyindex c7b6f4a..be3bdc7 100644--- a/models/wan/wan_handler.py+++ b/models/wan/wan_handler.py@@ -195,7 +195,8 @@ class family_handler():if "URLs2" in model_def:extra_model_def["no_steps_skipping"] = Trueextra_model_def["compile"] = ["transformer","transformer2"]-+ extra_model_def["text_encoder_URLs"] = ["models_t5_umt5-xxl-enc-bf16.safetensors", "models_t5_umt5-xxl-enc-quanto_int8.safetensors"]+ extra_model_def["text_encoder_folder"] = "umt5-xxl"extra_model_def["i2v_class"] = i2v = test_class_i2v(base_model_type)extra_model_def["t2v_class"] = t2v = test_class_t2v(base_model_type)extra_model_def["multitalk_class"] = multitalk = test_multitalk(base_model_type)@@ -747,7 +748,7 @@ class family_handler():@staticmethod- def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized= False, submodel_no_list = None, override_text_encoder = None, VAE_upsampling = None, **kwargs):+ def load_model(model_filename, model_type, base_model_type, model_def, quantizeTransformer = False, text_encoder_quantization = None, dtype = torch.bfloat16, VAE_dtype = torch.float32, mixed_precision_transformer = False, save_quantized= False, submodel_no_list = None, text_encoder_filename = None, VAE_upsampling = None, **kwargs):from .configs import WAN_CONFIGSif test_class_i2v(base_model_type):@@ -764,7 +765,7 @@ class family_handler():model_type = model_type,model_def = model_def,base_model_type=base_model_type,- text_encoder_filename= family_handler.get_text_encoder_filename(text_encoder_quantization) if override_text_encoder is None else override_text_encoder,+ text_encoder_filename= text_encoder_filename,quantizeTransformer = quantizeTransformer,dtype = dtype,VAE_dtype = VAE_dtype,diff --git a/models/z_image/z_image_handler.py b/models/z_image/z_image_handler.pyindex 4b4a0e2..3c7e379 100644--- a/models/z_image/z_image_handler.py+++ b/models/z_image/z_image_handler.py@@ -117,13 +117,13 @@ class family_handler:mixed_precision_transformer=False,save_quantized=False,submodel_no_list=None,- override_text_encoder=None,+ text_encoder_filename=None,**kwargs,):from .z_image_main import model_factorytext_encoder_filename = (- override_text_encoder if override_text_encoder is not None else get_z_image_text_encoder_filename(text_encoder_quantization)+ text_encoder_filename if text_encoder_filename is not None else get_z_image_text_encoder_filename(text_encoder_quantization))# Detect if this is a control variant (v1 or v2)diff --git a/plugins/wan2gp-about/plugin.py b/plugins/wan2gp-about/plugin.pyindex f48656a..782d4c8 100644--- a/plugins/wan2gp-about/plugin.py+++ b/plugins/wan2gp-about/plugin.py@@ -39,7 +39,6 @@ class AboutPlugin(WAN2GPPlugin):gr.Markdown("<BR>Special thanks to the following people for their Contributions & Support:")gr.Markdown("- <B>Tophness</B> : Designed & developped the Queuing Framework, Edit Mode and WanGP PlugIns System")- gr.Markdown("- <B>Redtash1</B> : for designing the prototype of the RAM / VRAM Stats Viewer, its One Click Install and user support on Discord")gr.Markdown("- <B>Gunther-Schulz</B> : for adding image Start Image / Image Refs storing in Video metadata")gr.Markdown("- <B>Cocktail Peanuts</B> : QA and simple installation via Pinokio.computer")gr.Markdown("- <B>AmericanPresidentJimmyCarter</B> : added original support for Skip Layer Guidance")diff --git a/plugins/wan2gp-configuration/plugin.py b/plugins/wan2gp-configuration/plugin.pyindex 718febf..8f860f7 100644--- a/plugins/wan2gp-configuration/plugin.py+++ b/plugins/wan2gp-configuration/plugin.py@@ -150,7 +150,7 @@ class ConfigTabPlugin(WAN2GPPlugin):self.mixed_precision_choice = gr.Dropdown(choices=[("16-bit only (less VRAM)", "0"), ("Mixed 16/32-bit (better quality)", "1")], value=self.server_config.get("mixed_precision", "0"), label="Transformer Engine Precision")self.text_encoder_quantization_choice = gr.Dropdown(choices=[("16-bit (more RAM, better quality)", "bf16"), ("8-bit (less RAM, slightly lower quality)", "int8")], value=self.text_encoder_quantization, label="Text Encoder Precision")self.VAE_precision_choice = gr.Dropdown(choices=[("16-bit (faster, less VRAM)", "16"), ("32-bit (slower, better for sliding window)", "32")], value=self.server_config.get("vae_precision", "16"), label="VAE Encoding/Decoding Precision")- self.compile_choice = gr.Dropdown(choices=[("On (up to 20% faster, requires Triton)", "transformer"), ("Off", "")], value=self.compile, label="Compile Transformer Model", interactive=not self.args.lock_config)+ self.compile_choice = gr.Dropdown(choices=[("On (up to 20% faster, requires Triton)", "transformer"), ("Off", "")], value=self.compile, label="Compile Transformer Model (slight speed again, but first generation is slower and potential compatibility issues with some GPUs/Models)", interactive=not self.args.lock_config)self.depth_anything_v2_variant_choice = gr.Dropdown(choices=[("Large (more precise, slower)", "vitl"), ("Big (less precise, faster)", "vitb")], value=self.server_config.get("depth_anything_v2_variant", "vitl"), label="Depth Anything v2 VACE Preprocessor")self.vae_config_choice = gr.Dropdown(choices=[("Auto", 0), ("Disabled (fastest, high VRAM)", 1), ("256x256 Tiles (for >=8GB VRAM)", 2), ("128x128 Tiles (for >=6GB VRAM)", 3)], value=self.vae_config, label="VAE Tiling (to reduce VRAM usage)")self.boost_choice = gr.Dropdown(choices=[("ON", 1), ("OFF", 2)], value=self.boost, label="Boost (~10% speedup for ~1GB VRAM)")diff --git a/requirements.txt b/requirements.txtindex fa07ffe..4918a5d 100644--- a/requirements.txt+++ b/requirements.txt@@ -57,7 +57,7 @@ pydantic==2.10.6# Math & modelingtorchdiffeq>=0.2.5tensordict>=0.6.1-mmgp==3.6.14+mmgp==3.6.15peft==0.15.0matplotlibdiff --git a/shared/qtypes/nunchaku_fp4.py b/shared/qtypes/nunchaku_fp4.pyindex 256b60b..36991d2 100644--- a/shared/qtypes/nunchaku_fp4.py+++ b/shared/qtypes/nunchaku_fp4.py@@ -28,6 +28,7 @@ if _NUNCHAKU_FP4_QTYPE_NAME not in _quanto_qtypes:_NUNCHAKU_FP4_QTYPE = _quanto_qtypes[_NUNCHAKU_FP4_QTYPE_NAME]_NUNCHAKU_OPS = None_NUNCHAKU_FALLBACK_NOTICE = False+_NUNCHAKU_KERNEL_NOTICE = False_NUNCHAKU_SPLIT_FIELDS = {"qweight": 0,"wscales": 1,@@ -152,6 +153,18 @@ def _notify_nunchaku_fallback(reason):_NUNCHAKU_FALLBACK_NOTICE = True+def _notify_nunchaku_kernel_status(verboseLevel=1):+ global _NUNCHAKU_KERNEL_NOTICE+ if _NUNCHAKU_KERNEL_NOTICE:+ return+ ops = _load_nunchaku_ops()+ if ops:+ print("[nunchaku_fp4] Using Nunchaku kernels.")+ elif not _NUNCHAKU_FALLBACK_NOTICE:+ print("[nunchaku_fp4] Nunchaku kernels unavailable; using Python fallback.")+ _NUNCHAKU_KERNEL_NOTICE = True++def _is_float8_dtype(dtype):return "float8" in str(dtype).lower() or "f8" in str(dtype).lower()@@ -477,6 +490,55 @@ class NunchakuBaseWeightTensor(QTensor):def __init__(self, qtype, axis):super().__init__(qtype, axis)+ def __repr__(self):+ cls_name = self.__class__.__name__+ try:+ shape = tuple(self.shape)+ except Exception:+ shape = "<?>"+ try:+ dtype = str(self.dtype).replace("torch.", "")+ except Exception:+ dtype = "<?>"+ try:+ device = str(self.device)+ except Exception:+ device = "<?>"+ qtype = getattr(self, "_qtype", None)+ qtype_name = getattr(qtype, "name", None) or str(qtype) if qtype is not None else "<?>"+ parts = [+ f"shape={shape}",+ f"dtype={dtype}",+ f"device={device}",+ f"qtype={qtype_name}",+ ]+ group_size = getattr(self, "_group_size", None)+ if group_size is not None:+ parts.append(f"group_size={group_size}")+ field_parts = []+ for name in (+ "_qweight",+ "_wscales",+ "_wzeros",+ "_wtscale",+ "_wcscales",+ "_smooth_factor",+ "_proj_down",+ "_proj_up",+ ):+ if not hasattr(self, name):+ continue+ value = getattr(self, name)+ if torch.is_tensor(value):+ field_parts.append(f"{name[1:]}={tuple(value.shape)}:{value.dtype}")+ else:+ field_parts.append(f"{name[1:]}={value}")+ if field_parts:+ parts.append("fields={" + ", ".join(field_parts) + "}")+ return f"{cls_name}(" + ", ".join(parts) + ")"++ __str__ = __repr__+def get_quantized_subtensors(self):raise NotImplementedError@@ -660,8 +722,6 @@ class NunchakuSVDQWeightTensor(NunchakuBaseWeightTensor):return out.reshape(*input.shape[:-1], out_features)def _linear_cuda(self, input, bias=None):- if torch.compiler.is_compiling():- return self._linear_fallback(input, bias=bias)ops = _load_nunchaku_ops()if not ops:return self._linear_fallback(input, bias=bias)@@ -983,8 +1043,6 @@ class NunchakuAWQWeightTensor(NunchakuBaseWeightTensor):return out.reshape(*input.shape[:-1], weight.shape[0])def _linear_cuda(self, input, bias=None):- if torch.compiler.is_compiling():- return self._linear_fallback(input, bias=bias)ops = _load_nunchaku_ops()if not ops:return self._linear_fallback(input, bias=bias)@@ -1207,6 +1265,7 @@ class QLinearNunchakuFp4(QModuleMixin, torch.nn.Linear):def set_default_dtype(self, dtype):self._nunchaku_default_dtype = dtype+ @torch.compiler.disable()def forward(self, input: torch.Tensor) -> torch.Tensor:qweight = self.qweightif isinstance(qweight, NunchakuBaseWeightTensor):@@ -1521,6 +1580,7 @@ def convert_to_quanto(state_dict, default_dtype, verboseLevel=1, detection=None)specs = _collect_nunchaku_specs(state_dict)if not specs:return {"state_dict": state_dict, "quant_map": {}}+ _notify_nunchaku_kernel_status(verboseLevel=verboseLevel)quant_map = {spec["name"]: {"weights": "nunchaku_fp4", "activations": "none"} for spec in specs}return {"state_dict": state_dict, "quant_map": quant_map}diff --git a/shared/qtypes/nunchaku_int4.py b/shared/qtypes/nunchaku_int4.pyindex 241772b..0fb5f63 100644--- a/shared/qtypes/nunchaku_int4.py+++ b/shared/qtypes/nunchaku_int4.py@@ -28,6 +28,7 @@ if _NUNCHAKU_INT4_QTYPE_NAME not in _quanto_qtypes:_NUNCHAKU_INT4_QTYPE = _quanto_qtypes[_NUNCHAKU_INT4_QTYPE_NAME]_NUNCHAKU_OPS = None_NUNCHAKU_FALLBACK_NOTICE = False+_NUNCHAKU_KERNEL_NOTICE = False_NUNCHAKU_SPLIT_FIELDS = {"qweight": 0,"wscales": 1,@@ -135,6 +136,18 @@ def _notify_nunchaku_fallback(reason):_NUNCHAKU_FALLBACK_NOTICE = True+def _notify_nunchaku_kernel_status(verboseLevel=1):+ global _NUNCHAKU_KERNEL_NOTICE+ if _NUNCHAKU_KERNEL_NOTICE:+ return+ ops = _load_nunchaku_ops()+ if ops:+ print("[nunchaku_int4] Using Nunchaku kernels.")+ elif not _NUNCHAKU_FALLBACK_NOTICE:+ print("[nunchaku_int4] Nunchaku kernels unavailable; using Python fallback.")+ _NUNCHAKU_KERNEL_NOTICE = True++def _is_float8_dtype(dtype):return "float8" in str(dtype).lower() or "f8" in str(dtype).lower()@@ -395,6 +408,53 @@ class NunchakuBaseWeightTensor(QTensor):def __init__(self, qtype, axis):super().__init__(qtype, axis)+ def __repr__(self):+ cls_name = self.__class__.__name__+ try:+ shape = tuple(self.shape)+ except Exception:+ shape = "<?>"+ try:+ dtype = str(self.dtype).replace("torch.", "")+ except Exception:+ dtype = "<?>"+ try:+ device = str(self.device)+ except Exception:+ device = "<?>"+ qtype = getattr(self, "_qtype", None)+ qtype_name = getattr(qtype, "name", None) or str(qtype) if qtype is not None else "<?>"+ parts = [+ f"shape={shape}",+ f"dtype={dtype}",+ f"device={device}",+ f"qtype={qtype_name}",+ ]+ group_size = getattr(self, "_group_size", None)+ if group_size is not None:+ parts.append(f"group_size={group_size}")+ field_parts = []+ for name in (+ "_qweight",+ "_wscales",+ "_wzeros",+ "_smooth_factor",+ "_proj_down",+ "_proj_up",+ ):+ if not hasattr(self, name):+ continue+ value = getattr(self, name)+ if torch.is_tensor(value):+ field_parts.append(f"{name[1:]}={tuple(value.shape)}:{value.dtype}")+ else:+ field_parts.append(f"{name[1:]}={value}")+ if field_parts:+ parts.append("fields={" + ", ".join(field_parts) + "}")+ return f"{cls_name}(" + ", ".join(parts) + ")"++ __str__ = __repr__+def get_quantized_subtensors(self):raise NotImplementedError@@ -1059,6 +1119,7 @@ class QLinearNunchakuInt4(QModuleMixin, torch.nn.Linear):def set_default_dtype(self, dtype):self._nunchaku_default_dtype = dtype+ @torch.compiler.disable()def forward(self, input: torch.Tensor) -> torch.Tensor:qweight = self.qweightif isinstance(qweight, NunchakuBaseWeightTensor):@@ -1372,6 +1433,7 @@ def convert_to_quanto(state_dict, default_dtype, verboseLevel=1, detection=None)specs = _collect_nunchaku_specs(state_dict)if not specs:return {"state_dict": state_dict, "quant_map": {}}+ _notify_nunchaku_kernel_status(verboseLevel=verboseLevel)quant_map = {spec["name"]: {"weights": "nunchaku_int4", "activations": "none"} for spec in specs}return {"state_dict": state_dict, "quant_map": quant_map}diff --git a/shared/qtypes/nvfp4.py b/shared/qtypes/nvfp4.pyindex b772abb..2f1a2af 100644--- a/shared/qtypes/nvfp4.py+++ b/shared/qtypes/nvfp4.py@@ -130,10 +130,21 @@ def _nvfp4_note_kernel():def _nvfp4_note_fallback():global _NVFP4_FALLBACK_LOGGED+ global _NVFP4_KERNEL_LOGGEDif not _NVFP4_FALLBACK_LOGGED:- print("NVFP4: linear fallback (dequantize)")+ if _NVFP4_KERNEL_LOGGED:+ print("NVFP4: linear fallback needed on some weights")+ else:+ print("NVFP4: linear fallback")_NVFP4_FALLBACK_LOGGED = True+def _nvfp4_note_reset():+ global _NVFP4_FALLBACK_LOGGED+ global _NVFP4_KERNEL_LOGGED+ global _NVFP4_LOAD_LOGGED+ _NVFP4_KERNEL_LOGGED = False+ _NVFP4_FALLBACK_LOGGED = False+ _NVFP4_LOAD_LOGGED = Falsedef _nvfp4_note_load_backend():global _NVFP4_LOAD_LOGGED@@ -144,7 +155,7 @@ def _nvfp4_note_load_backend():label = _nvfp4_backend_label(_NVFP4_KERNEL_BACKEND) if _NVFP4_KERNEL_BACKEND else "unknown"print(f"NVFP4: kernels available ({label}); optimized path will be used when compatible.")else:- print("NVFP4: kernels unavailable; using dequantize fallback.")+ print("NVFP4: kernels unavailable; using fallback.")def _check_nvfp4_kernel_support(device, backend):@@ -591,6 +602,7 @@ def detect(state_dict, verboseLevel=1):def convert_to_quanto(state_dict, default_dtype, verboseLevel=1, detection=None):if detection is not None and not detection.get("matched", False):return {"state_dict": state_dict, "quant_map": {}}+ _nvfp4_note_reset()return convert_nvfp4_to_quanto(state_dict, default_dtype=default_dtype, verboseLevel=verboseLevel)diff --git a/shared/utils/files_locator.py b/shared/utils/files_locator.pyindex 5a319e4..407d428 100644--- a/shared/utils/files_locator.py+++ b/shared/utils/files_locator.py@@ -12,12 +12,19 @@ def set_checkpoints_paths(checkpoints_paths):_checkpoints_paths = [path.strip() for path in checkpoints_paths if len(path.strip()) > 0 ]if len(checkpoints_paths) == 0:_checkpoints_paths = default_checkpoints_paths-def get_download_location(file_name = None):+def get_download_location(file_name = None, force_path= None):if file_name is not None and os.path.isabs(file_name): return file_name+ if force_path is not None and isinstance(force_path, list) and len(force_path): force_path = force_path[0]if file_name is not None:- return os.path.join(_checkpoints_paths[0], file_name)+ if force_path is None:+ return os.path.join(_checkpoints_paths[0], file_name)+ else:+ return os.path.join(_checkpoints_paths[0], force_path, file_name)else:- return _checkpoints_paths[0]+ if force_path is None:+ return _checkpoints_paths[0]+ else:+ return os.path.join(_checkpoints_paths[0])def locate_folder(folder_name, error_if_none = True):searched_locations = []diff --git a/wgp.py b/wgp.pyindex 7c0ebde..f41bb46 100644--- a/wgp.py+++ b/wgp.py@@ -84,8 +84,8 @@ AUTOSAVE_PATH = AUTOSAVE_FILENAMEAUTOSAVE_TEMPLATE_PATH = AUTOSAVE_FILENAMECONFIG_FILENAME = "wgp_config.json"PROMPT_VARS_MAX = 10-target_mmgp_version = "3.6.14"-WanGP_version = "10.24"+target_mmgp_version = "3.6.15"+WanGP_version = "10.30"settings_version = 2.43max_source_video_frames = 3000prompt_enhancer_image_caption_model, prompt_enhancer_image_caption_processor, prompt_enhancer_llm_model, prompt_enhancer_llm_tokenizer = None, None, None, None@@ -2869,7 +2869,12 @@ def get_local_model_filename(model_filename, use_locator = True, extra_paths = Nelse:local_model_filename = model_filenameif use_locator:- local_model_filename = fl.locate_file(local_model_filename, error_if_none= False, extra_paths = extra_paths )+ if extra_paths is not None:+ if not isinstance(extra_paths, list): extra_paths = [extra_paths]+ for path in extra_paths:+ filename = fl.locate_file(os.path.join(path, local_model_filename), error_if_none= False)+ if filename is not None: return filename+ local_model_filename = fl.locate_file(local_model_filename, error_if_none= False )return local_model_filename@@ -2929,7 +2934,7 @@ def download_file(url,filename):urlretrieve(url,filename, create_progress_hook(filename))download_shared_done = False-def download_models(model_filename = None, model_type= None, module_type = False, submodel_no = 1):+def download_models(model_filename = None, model_type= None, file_type = 0, submodel_no = 1, force_path = None):def computeList(filename):if filename == None:return []@@ -2938,40 +2943,39 @@ def download_models(model_filename = None, model_type= None, module_type = Falsereturn [filename]+ if file_type == 0:+ shared_def = {+ "repoId" : "DeepBeepMeep/Wan2.1",+ "sourceFolderList" : [ "pose", "scribble", "flow", "depth", "mask", "wav2vec", "chinese-wav2vec2-base", "roformer", "pyannote", "det_align", "" ],+ "fileList" : [ ["dw-ll_ucoco_384.onnx", "yolox_l.onnx"],["netG_A_latest.pth"], ["raft-things.pth"],+ ["depth_anything_v2_vitl.pth","depth_anything_v2_vitb.pth"], ["sam_vit_h_4b8939_fp16.safetensors", "model.safetensors", "config.json"],+ ["config.json", "feature_extractor_config.json", "model.safetensors", "preprocessor_config.json", "special_tokens_map.json", "tokenizer_config.json", "vocab.json"],+ ["config.json", "pytorch_model.bin", "preprocessor_config.json"],+ ["model_bs_roformer_ep_317_sdr_12.9755.ckpt", "model_bs_roformer_ep_317_sdr_12.9755.yaml", "download_checks.json"],+ ["pyannote_model_wespeaker-voxceleb-resnet34-LM.bin", "pytorch_model_segmentation-3.0.bin"], ["detface.pt"], [ "flownet.pkl" ] ]+ }+ process_files_def(**shared_def)- shared_def = {- "repoId" : "DeepBeepMeep/Wan2.1",- "sourceFolderList" : [ "pose", "scribble", "flow", "depth", "mask", "wav2vec", "chinese-wav2vec2-base", "roformer", "pyannote", "det_align", "" ],- "fileList" : [ ["dw-ll_ucoco_384.onnx", "yolox_l.onnx"],["netG_A_latest.pth"], ["raft-things.pth"],- ["depth_anything_v2_vitl.pth","depth_anything_v2_vitb.pth"], ["sam_vit_h_4b8939_fp16.safetensors", "model.safetensors", "config.json"],- ["config.json", "feature_extractor_config.json", "model.safetensors", "preprocessor_config.json", "special_tokens_map.json", "tokenizer_config.json", "vocab.json"],- ["config.json", "pytorch_model.bin", "preprocessor_config.json"],- ["model_bs_roformer_ep_317_sdr_12.9755.ckpt", "model_bs_roformer_ep_317_sdr_12.9755.yaml", "download_checks.json"],- ["pyannote_model_wespeaker-voxceleb-resnet34-LM.bin", "pytorch_model_segmentation-3.0.bin"], ["detface.pt"], [ "flownet.pkl" ] ]- }- process_files_def(**shared_def)--- if server_config.get("enhancer_enabled", 0) == 1:- enhancer_def = {- "repoId" : "DeepBeepMeep/LTX_Video",- "sourceFolderList" : [ "Florence2", "Llama3_2" ],- "fileList" : [ ["config.json", "configuration_florence2.py", "model.safetensors", "modeling_florence2.py", "preprocessor_config.json", "processing_florence2.py", "tokenizer.json", "tokenizer_config.json"],["config.json", "generation_config.json", "Llama3_2_quanto_bf16_int8.safetensors", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json"] ]- }- process_files_def(**enhancer_def)+ if server_config.get("enhancer_enabled", 0) == 1:+ enhancer_def = {+ "repoId" : "DeepBeepMeep/LTX_Video",+ "sourceFolderList" : [ "Florence2", "Llama3_2" ],+ "fileList" : [ ["config.json", "configuration_florence2.py", "model.safetensors", "modeling_florence2.py", "preprocessor_config.json", "processing_florence2.py", "tokenizer.json", "tokenizer_config.json"],["config.json", "generation_config.json", "Llama3_2_quanto_bf16_int8.safetensors", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json"] ]+ }+ process_files_def(**enhancer_def)- elif server_config.get("enhancer_enabled", 0) == 2:- enhancer_def = {- "repoId" : "DeepBeepMeep/LTX_Video",- "sourceFolderList" : [ "Florence2", "llama-joycaption-beta-one-hf-llava" ],- "fileList" : [ ["config.json", "configuration_florence2.py", "model.safetensors", "modeling_florence2.py", "preprocessor_config.json", "processing_florence2.py", "tokenizer.json", "tokenizer_config.json"],["config.json", "llama_joycaption_quanto_bf16_int8.safetensors", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json"] ]- }- process_files_def(**enhancer_def)+ elif server_config.get("enhancer_enabled", 0) == 2:+ enhancer_def = {+ "repoId" : "DeepBeepMeep/LTX_Video",+ "sourceFolderList" : [ "Florence2", "llama-joycaption-beta-one-hf-llava" ],+ "fileList" : [ ["config.json", "configuration_florence2.py", "model.safetensors", "modeling_florence2.py", "preprocessor_config.json", "processing_florence2.py", "tokenizer.json", "tokenizer_config.json"],["config.json", "llama_joycaption_quanto_bf16_int8.safetensors", "special_tokens_map.json", "tokenizer.json", "tokenizer_config.json"] ]+ }+ process_files_def(**enhancer_def)- download_mmaudio()- global download_shared_done- download_shared_done = True+ download_mmaudio()+ global download_shared_done+ download_shared_done = Trueif model_filename is None: return@@ -2982,12 +2986,12 @@ def download_models(model_filename = None, model_type= None, module_type = Falseany_module_source = ("module_source2" if submodel_no ==2 else "module_source") in model_defmodel_type_handler = model_types_handlers[base_model_type]- if any_source and not module_type or any_module_source and module_type:+ if any_source and file_type==0 or any_module_source and file_type==1:model_filename = Noneelse:- local_model_filename = get_local_model_filename(model_filename)+ local_model_filename = get_local_model_filename(model_filename, extra_paths= force_path)if local_model_filename is None and len(model_filename) > 0:- local_model_filename = fl.get_download_location(os.path.basename(model_filename))+ local_model_filename = fl.get_download_location(os.path.basename(model_filename), force_path= force_path)url = model_filenameif not url.startswith("http"):@@ -2997,19 +3001,18 @@ def download_models(model_filename = None, model_type= None, module_type = Falseexcept Exception as e:if os.path.isfile(local_model_filename): os.remove(local_model_filename)raise Exception(f"'{url}' is invalid for Model '{model_type}' : {str(e)}'")- if module_type: return+ if file_type!=0: returnmodel_filename = None- text_encoder_path = None- if hasattr(model_type_handler, "get_text_encoder_filename"):- text_encoder_path = [os.path.dirname(model_type_handler.get_text_encoder_filename("bf16"))]- for prop, extra_paths in zip(["preload_URLs", "text_encoder_URLs"], [None, text_encoder_path ]):- preload_URLs = get_model_recursive_prop(model_type, prop, return_list= True)- if prop in ["text_encoder_URLs"]:- preload_URLs = [get_model_filename(model_type=model_type, quantization= text_encoder_quantization, dtype_policy = transformer_dtype_policy, URLs=preload_URLs)] if len(preload_URLs) > 0 else []+ for prop, recursive in zip(["preload_URLs", "VAE_URLs"], [True, False]):+ if recursive:+ preload_URLs = get_model_recursive_prop(model_type, prop, return_list= True)+ else:+ preload_URLs = model_def.get(prop, [])+ if isinstance(preload_URLs, str): preload_URLs = [preload_URLs]for url in preload_URLs:- filename = get_local_model_filename(url, extra_paths=extra_paths)+ filename = get_local_model_filename(url)if filename is None:filename = fl.get_download_location(os.path.basename(url))if not url.startswith("http"):@@ -3032,10 +3035,10 @@ def download_models(model_filename = None, model_type= None, module_type = Falseif os.path.isfile(filename): os.remove(filename)raise Exception(f"Lora URL '{url}' is invalid: {str(e)}'")- if module_type: return- model_files = model_type_handler.query_model_files(- computeList, base_model_type, model_filename, text_encoder_quantization, model_def- )+ if file_type != 0: return+ # model_filename should be None (deprecated) as query_model_files is no longer in charge of loading the transformer+ # likewise text_encoder_quantization is wont be used by coder_quantization since the text_encoder is loaded by load_models+ model_files = model_type_handler.query_model_files(computeList, base_model_type, model_filename, text_encoder_quantization, model_def)if not isinstance(model_files, list): model_files = [model_files]for one_repo in model_files:process_files_def(**one_repo)@@ -3180,6 +3183,9 @@ def init_pipe(pipe, kwargs, override_profile):if profile == 4.5:mmgp_profile = 4kwargs["asyncTransfers"] = False+ elif profile == 3.5:+ mmgp_profile = 3+ kwargs["pinnedMemory"] = Falseelse:mmgp_profile = profile@@ -3261,12 +3267,12 @@ def load_models(model_type, override_profile = -1, **model_kwargs):vram_safety_coefficient = args.vram_safety_coefficientmodel_file_list = [model_filename]model_type_list = [model_type]- module_type_list = [None]+ source_type_list = [0]model_submodel_no_list = [1]if model_filename2 != None:model_file_list += [model_filename2]model_type_list += [model_type]- module_type_list += [None]+ source_type_list += [0]model_submodel_no_list += [2]for module_type in modules:if isinstance(module_type,dict):@@ -3277,48 +3283,55 @@ def load_models(model_type, override_profile = -1, **model_kwargs):if URLs2 is None: raise Exception(f"No URL2s defined for Module {module_type}")model_file_list.append(get_model_filename(model_type, transformer_quantization, transformer_dtype, URLs = URLs2))model_type_list += [model_type] * 2- module_type_list += [True] * 2+ source_type_list += [1] * 2model_submodel_no_list += [1,2]else:model_file_list.append(get_model_filename(model_type, transformer_quantization, transformer_dtype, module_type= module_type))model_type_list.append(model_type)- module_type_list.append(True)+ source_type_list.append(True)model_submodel_no_list.append(0)+local_model_file_list= []- for filename, file_model_type, file_module_type, submodel_no in zip(model_file_list, model_type_list, module_type_list, model_submodel_no_list):+ for filename, file_model_type, file_source_type, submodel_no in zip(model_file_list, model_type_list, source_type_list, model_submodel_no_list):if len(filename) == 0: continue- download_models(filename, file_model_type, file_module_type, submodel_no)+ download_models(filename, file_model_type, file_source_type, submodel_no)local_file_name = get_local_model_filename(filename )local_model_file_list.append( os.path.basename(filename) if local_file_name is None else local_file_name )if len(local_model_file_list) == 0:- download_models("", model_type, "", -1)+ download_models("", model_type, 0, -1)VAE_dtype = torch.float16 if server_config.get("vae_precision","16") == "16" else torch.floatmixed_precision_transformer = server_config.get("mixed_precision","0") == "1"transformer_type = None- for module_type, filename in zip(module_type_list, local_model_file_list):- if module_type is None:++ for source_type, filename in zip(source_type_list, local_model_file_list):+ if source_type==0:print(f"Loading Model '{filename}' ...")- else:+ elif source_type==1:print(f"Loading Module '{filename}' ...")+model_type_handler = model_types_handlers[base_model_type]- override_text_encoder = get_model_recursive_prop(model_type, "text_encoder_URLs", return_list= True)- if len( override_text_encoder) > 0:- override_text_encoder = get_model_filename(model_type=model_type, quantization= text_encoder_quantization, dtype_policy = transformer_dtype_policy, URLs=override_text_encoder) if len(override_text_encoder) > 0 else None- if override_text_encoder is not None:- text_encoder_path = None- if hasattr(model_type_handler, "get_text_encoder_filename"):- text_encoder_path = [os.path.dirname(model_type_handler.get_text_encoder_filename("bf16"))]- override_text_encoder = get_local_model_filename(override_text_encoder, extra_paths=text_encoder_path)- if override_text_encoder is not None:- print(f"Loading Text Encoder '{override_text_encoder}' ...")+ text_encoder_URLs= get_model_recursive_prop(model_type, "text_encoder_URLs", return_list= True)+ text_encoder_filename = None+ if text_encoder_URLs is None or len(text_encoder_URLs) == 0:+ if hasattr(model_type_handler, "get_text_encoder_filename"):+ text_encoder_filename = model_type_handler.get_text_encoder_filename(text_encoder_quantization)+else:- override_text_encoder = None+ text_encoder_filename = get_model_filename(model_type=model_type, quantization= text_encoder_quantization, dtype_policy = transformer_dtype_policy, URLs=text_encoder_URLs)+ if text_encoder_filename is not None:+ text_encoder_folder = model_def.get("text_encoder_folder", None)+ if text_encoder_filename is not None:+ download_models(text_encoder_filename, file_model_type, 2, -1, force_path =text_encoder_folder)+ text_encoder_filename = get_local_model_filename(text_encoder_filename, extra_paths=text_encoder_folder)+ print(f"Loading Text Encoder '{text_encoder_filename}' ...")++torch.set_default_device('cpu')wan_model, pipe = model_type_handler.load_model(local_model_file_list, model_type, base_model_type, model_def, quantizeTransformer = quantizeTransformer, text_encoder_quantization = text_encoder_quantization,- dtype = transformer_dtype, VAE_dtype = VAE_dtype, mixed_precision_transformer = mixed_precision_transformer, save_quantized = save_quantized, submodel_no_list = model_submodel_no_list, override_text_encoder = override_text_encoder, **model_kwargs )+ dtype = transformer_dtype, VAE_dtype = VAE_dtype, mixed_precision_transformer = mixed_precision_transformer, save_quantized = save_quantized, submodel_no_list = model_submodel_no_list, text_encoder_filename = text_encoder_filename, **model_kwargs )kwargs = {}if "pipe" in pipe:@@ -3925,18 +3938,21 @@ def select_video(state, current_gallery_tab, input_file_list, file_selected, audvideo_guidance_phases = configs.get("guidance_phases", 0)video_embedded_guidance_scale = configs.get("embedded_guidance_scale", None)video_guidance_label = "Guidance"+ visible_phases = model_def.get("visible_phases", video_guidance_phases)if model_def.get("embedded_guidance", False):video_guidance_scale = video_embedded_guidance_scalevideo_guidance_label = "Embedded Guidance Scale"+ elif video_guidance_phases == 0 or visible_phases ==0:+ video_guidance_scale = Noneelif video_guidance_phases > 0:- if video_guidance_phases == 1 or model_def.get("virtual_higher_phases", False):+ if video_guidance_phases == 1 and visible_phases >=1:video_guidance_scale = f"{video_guidance_scale}"- elif video_guidance_phases == 2:+ elif video_guidance_phases == 2 and visible_phases >=2:if multiple_submodels:video_guidance_scale = f"{video_guidance_scale} (High Noise), {video_guidance2_scale} (Low Noise) with Switch at Noise Level {video_switch_threshold}"else:video_guidance_scale = f"{video_guidance_scale}, {video_guidance2_scale}" + ("" if video_switch_threshold ==0 else " with Guidance Switch at Noise Level {video_switch_threshold}")- else:+ elif visible_phases >=3:video_guidance_scale = f"{video_guidance_scale}, {video_guidance2_scale} & {video_guidance3_scale} with Switch at Noise Levels {video_switch_threshold} & {video_switch_threshold2}"if multiple_submodels:video_guidance_scale += f" + Model Switch at {video_switch_threshold if video_model_switch_phase ==1 else video_switch_threshold2}"@@ -7383,15 +7399,15 @@ def prepare_inputs_dict(target, inputs, model_type = None, model_filename = Noneguidance_max_phases = model_def.get("guidance_max_phases", 0)guidance_phases = inputs.get("guidance_phases", 1)- virtual_higher_phases = model_def.get("virtual_higher_phases", False)+ visible_phases = model_def.get("visible_phases", guidance_phases)- if guidance_max_phases < 1:+ if guidance_max_phases < 1 or visible_phases < 1:pop += ["guidance_scale", "guidance_phases"]- if guidance_max_phases < 2 or guidance_phases < 2 or virtual_higher_phases:+ if guidance_max_phases < 2 or guidance_phases < 2 or visible_phases < 2:pop += ["guidance2_scale", "switch_threshold"]- if guidance_max_phases < 3 or guidance_phases < 3 or virtual_higher_phases:+ if guidance_max_phases < 3 or guidance_phases < 3 or visible_phases < 3:pop += ["guidance3_scale", "switch_threshold2", "model_switch_phase"]if not model_def.get("flow_shift", False):@@ -8682,15 +8698,16 @@ def get_max_frames(nb):def change_guidance_phases(state, guidance_phases):model_type = get_state_model_type(state)model_def = get_model_def(model_type)- virtual_higher_phases = model_def.get("virtual_higher_phases", False)+ visible_phases = model_def.get("visible_phases", guidance_phases)multiple_submodels = model_def.get("multiple_submodels", False)label ="Phase 1-2" if guidance_phases ==3 else ( "Model / Guidance Switch Threshold" if multiple_submodels else "Guidance Switch Threshold" )- return gr.update(visible= guidance_phases >=3 and multiple_submodels) , gr.update(visible= guidance_phases >=2 and not virtual_higher_phases), gr.update(visible= guidance_phases >=2, label = label), gr.update(visible= guidance_phases >=3), gr.update(visible= guidance_phases >=2 and not virtual_higher_phases), gr.update(visible= guidance_phases >=3 and not virtual_higher_phases)+ return gr.update(visible= guidance_phases >=3 and visible_phases >=3 and multiple_submodels) , gr.update(visible= guidance_phases >=2 and visible_phases >=2), gr.update(visible= guidance_phases >=2 and visible_phases >=2, label = label), gr.update(visible= guidance_phases >=3 and visible_phases >=3), gr.update(visible= guidance_phases >=2 and visible_phases >=2), gr.update(visible= guidance_phases >=3 and visible_phases >=3)memory_profile_choices= [ ("Profile 1, HighRAM_HighVRAM: at least 64 GB of RAM and 24 GB of VRAM, the fastest for short videos with a RTX 3090 / RTX 4090", 1),("Profile 2, HighRAM_LowVRAM: at least 64 GB of RAM and 12 GB of VRAM, the most versatile profile with high RAM, better suited for RTX 3070/3080/4070/4080 or for RTX 3090 / RTX 4090 with large pictures batches or long videos", 2),("Profile 3, LowRAM_HighVRAM: at least 32 GB of RAM and 24 GB of VRAM, adapted for RTX 3090 / RTX 4090 with limited RAM for good speed short video",3),+ ("Profile 3+, VeryLowRAM_HighVRAM: at least 32 GB of RAM and 24 GB of VRAM, variant of Profile 3 that won't used Reserved Memory to reduce RAM usage",3.5),("Profile 4, LowRAM_LowVRAM (Recommended): at least 32 GB of RAM and 12 GB of VRAM, if you have little VRAM or want to generate longer videos",4),("Profile 4+, LowRAM_LowVRAM+: at least 32 GB of RAM and 12 GB of VRAM, variant of Profile 4, slightly slower but needs less VRAM",4.5),("Profile 5, VerylowRAM_LowVRAM (Fail safe): at least 24 GB of RAM and 10 GB of VRAM, if you don't have much it won't be fast but maybe it will work",5)]@@ -9355,7 +9372,7 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Nonguidance_phases_value = model_def.get("guidance_max_phases", 0)else:guidance_phases_value = ui_get("guidance_phases")- virtual_higher_phases = model_def.get("virtual_higher_phases", False)+ visible_phases = model_def.get("visible_phases", 3)guidance_phases = gr.Dropdown(choices=[("One Phase", 1),@@ -9363,10 +9380,10 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Non("Three Phases", 3)],value= guidance_phases_value,label="Guidance Phases",- visible= guidance_max_phases >=2 and not virtual_higher_phases,+ visible= guidance_max_phases >=2 and visible_phases>=2,interactive = not model_def.get("lock_guidance_phases", False))- with gr.Row(visible = guidance_phases_value >=2 and not virtual_higher_phases) as guidance_phases_row:+ with gr.Row(visible = guidance_phases_value >=2 and visible_phases>=2) as guidance_phases_row:multiple_submodels = model_def.get("multiple_submodels", False)model_switch_phase = gr.Dropdown(choices=[@@ -9379,10 +9396,10 @@ def generate_video_tab(update_form = False, state_dict = None, ui_defaults = Nonlabel ="Phase 1-2" if guidance_phases_value ==3 else ( "Model / Guidance Switch Threshold" if multiple_submodels else "Guidance Switch Threshold" )switch_threshold = gr.Slider(0, 1000, value=ui_get("switch_threshold"), step=1, label = label, visible= guidance_max_phases >= 2 and guidance_phases_value >= 2, show_reset_button= False)switch_threshold2 = gr.Slider(0, 1000, value=ui_get("switch_threshold2"), step=1, label="Phase 2-3", visible= guidance_max_phases >= 3 and guidance_phases_value >= 3, show_reset_button= False)- with gr.Row(visible = guidance_max_phases >=1 ) as guidance_row:- guidance_scale = gr.Slider(1.0, 20.0, value=ui_get("guidance_scale"), step=0.1, label="Guidance (CFG)", visible=guidance_max_phases >=1, show_reset_button= False )- guidance2_scale = gr.Slider(1.0, 20.0, value=ui_get("guidance2_scale"), step=0.1, label="Guidance2 (CFG)", visible= guidance_max_phases >=2 and guidance_phases_value >= 2 and not virtual_higher_phases, show_reset_button= False)- guidance3_scale = gr.Slider(1.0, 20.0, value=ui_get("guidance3_scale"), step=0.1, label="Guidance3 (CFG)", visible= guidance_max_phases >=3 and guidance_phases_value >= 3 and not virtual_higher_phases, show_reset_button= False)+ with gr.Row(visible = guidance_max_phases >=1 and visible_phases>=1 ) as guidance_row:+ guidance_scale = gr.Slider(1.0, 20.0, value=ui_get("guidance_scale"), step=0.1, label="Guidance (CFG)", visible=guidance_max_phases >=1 and visible_phases>=1, show_reset_button= False)+ guidance2_scale = gr.Slider(1.0, 20.0, value=ui_get("guidance2_scale"), step=0.1, label="Guidance2 (CFG)", visible= guidance_max_phases >=2 and guidance_phases_value >= 2 and visible_phases>= 2, show_reset_button= False)+ guidance3_scale = gr.Slider(1.0, 20.0, value=ui_get("guidance3_scale"), step=0.1, label="Guidance3 (CFG)", visible= guidance_max_phases >=3 and guidance_phases_value >= 3 and visible_phases>= 3, show_reset_button= False)any_audio_guidance = model_def.get("audio_guidance", False)any_embedded_guidance = model_def.get("embedded_guidance", False)