Skip to content
Python

added scaled fp8 support, palangenesis finetunes, merged accelerators / non accelerators loras

DeepBeepMeep798ad52e3f92
diff --git a/README.md b/README.md
index a022d3f..c4ea1f9 100644
--- a/README.md
+++ b/README.md
@@ -20,12 +20,12 @@ 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
## 🔥 Latest Updates :
-### October 3 2025: WanGP v8.992 - One Last Thing before the Big Unknown ...
+### October 5 2025: WanGP v8.993 - One Last Thing before the Big Unknown ...
This new version hasn't any new model...
...but temptation to upgrade will be high as it contains a few Loras related features that may change your Life:
-- **Ready to use Loras Accelerators Profiles** per type of model that you can apply on your current *Generation Settings*. Next time I will recommend a *Lora Accelerator*, it will be only one click away. And best of all of the required Loras will be downloaded automatically. When you apply an *Accelerator Profile*, input fields like the *Number of Denoising Steps* *Activated Loras*, *Loras Multipliers* (such as "1;0 0;1" ...) will be automatically filled. However your video specific fields will be preserved, so it will be easy to switch between Profiles to experiment.
+- **Ready to use Loras Accelerators Profiles** per type of model that you can apply on your current *Generation Settings*. Next time I will recommend a *Lora Accelerator*, it will be only one click away. And best of all of the required Loras will be downloaded automatically. When you apply an *Accelerator Profile*, input fields like the *Number of Denoising Steps* *Activated Loras*, *Loras Multipliers* (such as "1;0 0;1" ...) will be automatically filled. However your video specific fields will be preserved, so it will be easy to switch between Profiles to experiment. With *WanGP 8.993*, the *Accelerator Loras* are now merged with *Non Accelerator Loras". Things are getting too easy...
- **Embedded Loras URL** : WanGP will now try to remember every Lora URLs it sees. For instance if someone sends you some settings that contain Loras URLs or you extract the Settings of Video generated by a friend with Loras URLs, these URLs will be automatically added to *WanGP URL Cache*. Conversely everything you will share (Videos, Settings, Lset files) will contain the download URLs if they are known. You can also download directly a Lora in WanGP by using the *Download Lora* button a the bottom. The Lora will be immediatly available and added to WanGP lora URL cache. This will work with *Hugging Face* as a repository. Support for CivitAi will come as soon as someone will nice enough to post a GitHub PR ...
@@ -33,10 +33,15 @@ This new version hasn't any new model...
I have created the new Discord Channel **share-your-settings** where you can post your *Settings* or *Lset files*. I will be pleased to add new Loras Accelerators in the list of WanGP *Accelerators Profiles if you post some good ones there.
+*With the 8.993 update*, I have added out support for **Scaled FP8 format**. As a sample case, I have created finetunes for the **Wan 2.2 PalinGenesis** Finetune which is quite popular recently. You will find it in 3 flavors : *t2v*, *i2v* and *Lightning Accelerated for t2v*.
+
+The *Scaled FP8 format* is very popular as it the format used by ... *ComfyUI*. So I except a flood of Finetunes in the *share-your-finetune* channel. If not it means this feature was useless and I will remove it 😈😈😈
+
Last but not least the Lora's documentation has been updated.
*update 8.991*: full power of *Vace Lynx* unleashed with new combinations such as Landscape + Face / Clothes + Face / Injectd Frame (Start/End frames/...) + Face
-*update 8.992*: optimized gen with Lora, should be 10% if many loras
+*update 8.992*: optimized gen with Lora, should be 10% faster if many loras
+*update 8.993*: Support for *Scaled FP8* format and samples *Paligenesis* finetunes, merged Loras Accelerators and Non Accelerators
### September 30 2025: WanGP v8.9 - Combinatorics
diff --git a/defaults/vace_14B_cocktail_2_2.json b/defaults/vace_14B_cocktail_2_2.json
index 6a831d2..5783922 100644
--- a/defaults/vace_14B_cocktail_2_2.json
+++ b/defaults/vace_14B_cocktail_2_2.json
@@ -14,7 +14,7 @@
"https://huggingface.co/DeepBeepMeep/Wan2.1/resolve/main/loras_accelerators/Wan21_AccVid_T2V_14B_lora_rank32_fp16.safetensors",
"https://huggingface.co/DeepBeepMeep/Wan2.1/resolve/main/loras_accelerators/Wan21_T2V_14B_MoviiGen_lora_rank32_fp16.safetensors"
],
- "settings_dir": [ "" ],
+ "profiles_dir": [ "" ],
"loras_multipliers": [1, 0.2, 0.5, 0.5],
"group": "wan2_2"
},
diff --git a/defaults/vace_14B_fusionix.json b/defaults/vace_14B_fusionix.json
index 1c6fa72..95639f4 100644
--- a/defaults/vace_14B_fusionix.json
+++ b/defaults/vace_14B_fusionix.json
@@ -6,7 +6,7 @@
"vace_14B"
],
"description": "Vace control model enhanced using multiple open-source components and LoRAs to boost motion realism, temporal consistency, and expressive detail.",
- "settings_dir": [ "" ],
+ "profiles_dir": [ "" ],
"URLs": "t2v_fusionix"
},
"negative_prompt": "",
diff --git a/defaults/vace_fun_14B_cocktail_2_2.json b/defaults/vace_fun_14B_cocktail_2_2.json
index c587abd..0a73438 100644
--- a/defaults/vace_fun_14B_cocktail_2_2.json
+++ b/defaults/vace_fun_14B_cocktail_2_2.json
@@ -17,6 +17,7 @@
0.5,
0.5
],
+ "profiles_dir": [""],
"group": "wan2_2"
},
"guidance_phases": 2,
diff --git a/docs/LORAS.md b/docs/LORAS.md
index dc0caaa..f17b51f 100644
--- a/docs/LORAS.md
+++ b/docs/LORAS.md
@@ -196,7 +196,9 @@ There are three ways to setup Loras accelerators:
Some models Finetunes such as *Vace FusioniX* or *Vace Coctail* have the Loras Accelerators already set up in their own definition and you won't have to do anything as they will be downloaded with the Finetune.
2) **Accelerators Profiles**
-Predefined *Accelerator Profiles* can be selected using the *Settings* Dropdown box at the top. The choices of Accelerators will depend on the models. No accelerator will be offered if the finetune / model is already accelerated. Just click *Apply* and the Accelerators Loras will be setup in the Loras tab at the bottom. Any missing Lora will be downloaded automatically the first time you try to generate a Video. Be aware that when applying an *Accelerator Profile*, inputs such as *Activated Loras*, *Number of Inference Steps*, ... will bo overwritten wheras other inputs will be preserved so that you can easily switch between profiles.
+Predefined *Accelerator Profiles* can be selected using the *Settings* Dropdown box at the top. The choices of Accelerators will depend on the models. No accelerator will be offered if the finetune / model is already accelerated. Just click *Apply* and the Accelerators Loras will be setup in the Loras tab at the bottom. Any missing Lora will be downloaded automatically the first time you try to generate a Video. Be aware that when applying an *Accelerator Profile*, inputs such as *Activated Loras*, *Number of Inference Steps*, ... will be updated. However if you have already existing Loras set up (that are non Loras Accelerators) they will be preserved so that you can easily switch between Accelerators Profiles.
+
+You will see the "|" character at the end of the Multipliers text input associated to Loras Accelerators. It plays the same role than the Space character to separate Multipliers except it tells WanGP where the Loras Accelerators multipliers end so that it can merge Loras Accelerators with Non Loras Accelerators.
3) **Manual Install**
- Download the Lora
diff --git a/loras/wan/Text2Video Cocktail - 10 Steps.json b/loras/profiles_wan/Text2Video Cocktail - 10 Steps.json
similarity index 100%
rename from loras/wan/Text2Video Cocktail - 10 Steps.json
rename to loras/profiles_wan/Text2Video Cocktail - 10 Steps.json
diff --git a/loras/wan/Text2Video FusioniX - 10 Steps.json b/loras/profiles_wan/Text2Video FusioniX - 10 Steps.json
similarity index 100%
rename from loras/wan/Text2Video FusioniX - 10 Steps.json
rename to loras/profiles_wan/Text2Video FusioniX - 10 Steps.json
diff --git a/loras/wan/Text2Video Lightx2v Cfg Step Distill Rank32 - 4 Steps.json b/loras/profiles_wan/Text2Video Lightx2v Cfg Step Distill Rank32 - 4 Steps.json
similarity index 100%
rename from loras/wan/Text2Video Lightx2v Cfg Step Distill Rank32 - 4 Steps.json
rename to loras/profiles_wan/Text2Video Lightx2v Cfg Step Distill Rank32 - 4 Steps.json
diff --git a/loras/profiles_wan2_2/Fun Inp HPS2 Reward 2 Phases - 4 Steps.json b/loras/profiles_wan2_2/Fun Inp HPS2 Reward 2 Phases - 4 Steps.json
new file mode 100644
index 0000000..1b58ec7
--- /dev/null
+++ b/loras/profiles_wan2_2/Fun Inp HPS2 Reward 2 Phases - 4 Steps.json
@@ -0,0 +1,14 @@
+{
+ "num_inference_steps": 8,
+ "guidance_scale": 1,
+ "guidance2_scale": 1,
+ "model_switch_phase": 1,
+ "switch_threshold": 876,
+ "guidance_phases": 2,
+ "flow_shift": 3,
+ "activated_loras": [
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Fun-A14B-InP-high-noise-HPS2.1.safetensors",
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Fun-A14B-InP-low-noise-HPS2.1.safetensors"
+ ],
+ "loras_multipliers": "1;0 0;1"
+}
\ No newline at end of file
diff --git a/loras/profiles_wan2_2/Fun Inp MPS Reward 2 Phases - 4 Steps.json b/loras/profiles_wan2_2/Fun Inp MPS Reward 2 Phases - 4 Steps.json
new file mode 100644
index 0000000..cc57422
--- /dev/null
+++ b/loras/profiles_wan2_2/Fun Inp MPS Reward 2 Phases - 4 Steps.json
@@ -0,0 +1,14 @@
+{
+ "num_inference_steps": 4,
+ "guidance_scale": 1,
+ "guidance2_scale": 1,
+ "model_switch_phase": 1,
+ "switch_threshold": 876,
+ "guidance_phases": 2,
+ "flow_shift": 3,
+ "activated_loras": [
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Fun-A14B-InP-high-noise-MPS.safetensors",
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Fun-A14B-InP-low-noise-MPS.safetensors"
+ ],
+ "loras_multipliers": "1;0 0;1"
+}
\ No newline at end of file
diff --git a/loras/wan2_2/Lightning v1.0 2 Phases - 4 Steps.json b/loras/profiles_wan2_2/Lightning v1.0 2 Phases - 4 Steps.json
similarity index 95%
rename from loras/wan2_2/Lightning v1.0 2 Phases - 4 Steps.json
rename to loras/profiles_wan2_2/Lightning v1.0 2 Phases - 4 Steps.json
index e7aeeda..51c903b 100644
--- a/loras/wan2_2/Lightning v1.0 2 Phases - 4 Steps.json
+++ b/loras/profiles_wan2_2/Lightning v1.0 2 Phases - 4 Steps.json
@@ -6,7 +6,7 @@
"switch_threshold": 876,
"guidance_phases": 2,
"flow_shift": 3,
- "loras": [
+ "activated_loras": [
"https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors",
"https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors"
],
diff --git a/loras/wan2_2/Lightning v1.0 3 Phases - 8 Steps.json b/loras/profiles_wan2_2/Lightning v1.0 3 Phases - 8 Steps.json
similarity index 97%
rename from loras/wan2_2/Lightning v1.0 3 Phases - 8 Steps.json
rename to loras/profiles_wan2_2/Lightning v1.0 3 Phases - 8 Steps.json
index 681cf30..a308344 100644
--- a/loras/wan2_2/Lightning v1.0 3 Phases - 8 Steps.json
+++ b/loras/profiles_wan2_2/Lightning v1.0 3 Phases - 8 Steps.json
@@ -9,7 +9,7 @@
"model_switch_phase": 2,
"flow_shift": 3,
"sample_solver": "euler",
- "loras": [
+ "activated_loras": [
"https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_HIGH_fp16.safetensors",
"https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan2.2-Lightning_T2V-v1.1-A14B-4steps-lora_LOW_fp16.safetensors"
],
diff --git a/loras/wan2_2/Lightning v2025-09-28 - 4 Steps.json b/loras/profiles_wan2_2/Lightning v2025-09-28 - 4 Steps.json
similarity index 100%
rename from loras/wan2_2/Lightning v2025-09-28 - 4 Steps.json
rename to loras/profiles_wan2_2/Lightning v2025-09-28 - 4 Steps.json
diff --git a/loras/profiles_wan2_2/Lightning v2025-09-28 2 Phases - 4 Steps.json b/loras/profiles_wan2_2/Lightning v2025-09-28 2 Phases - 4 Steps.json
new file mode 100644
index 0000000..31e4f0d
--- /dev/null
+++ b/loras/profiles_wan2_2/Lightning v2025-09-28 2 Phases - 4 Steps.json
@@ -0,0 +1,14 @@
+{
+ "num_inference_steps": 4,
+ "guidance_scale": 1,
+ "guidance2_scale": 1,
+ "switch_threshold": 876,
+ "model_switch_phase": 1,
+ "guidance_phases": 2,
+ "flow_shift": 3,
+ "loras_multipliers": "1;0 0;1",
+ "activated_loras": [
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan22_A14B_T2V_HIGH_Lightning_4steps_lora_250928_rank128_fp16.safetensors",
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan22_A14B_T2V_LOW_Lightning_4steps_lora_250928_rank64_fp16.safetensors"
+ ]
+}
\ No newline at end of file
diff --git a/loras/profiles_wan2_2/Lightning v2025-09-28 3 Phases - 8 Steps.json b/loras/profiles_wan2_2/Lightning v2025-09-28 3 Phases - 8 Steps.json
new file mode 100644
index 0000000..839e056
--- /dev/null
+++ b/loras/profiles_wan2_2/Lightning v2025-09-28 3 Phases - 8 Steps.json
@@ -0,0 +1,18 @@
+{
+ "num_inference_steps": 8,
+ "guidance_scale": 3.5,
+ "guidance2_scale": 1,
+ "guidance3_scale": 1,
+ "switch_threshold": 965,
+ "switch_threshold2": 800,
+ "guidance_phases": 3,
+ "model_switch_phase": 2,
+ "flow_shift": 3,
+ "sample_solver": "euler",
+ "activated_loras": [
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan22_A14B_T2V_HIGH_Lightning_4steps_lora_250928_rank128_fp16.safetensors",
+ "https://huggingface.co/DeepBeepMeep/Wan2.2/resolve/main/loras_accelerators/Wan22_A14B_T2V_LOW_Lightning_4steps_lora_250928_rank64_fp16.safetensors"
+ ],
+ "loras_multipliers": "0;1;0 0;0;1",
+ "help": "This finetune uses the Lightning 250928 4 steps Loras Accelerator for Wan 2.2 but extend them to 8 steps in order to insert a CFG phase before the 2 accelerated phases with no Guidance. The ultimate goal is reduce the slow motion effect of these Loras Accelerators."
+}
\ No newline at end of file
diff --git a/loras/wan2_2/Text2Video FusioniX - 10 Steps.json b/loras/profiles_wan2_2/Text2Video FusioniX - 10 Steps.json
similarity index 91%
rename from loras/wan2_2/Text2Video FusioniX - 10 Steps.json
rename to loras/profiles_wan2_2/Text2Video FusioniX - 10 Steps.json
index 3695bec..1ad921b 100644
--- a/loras/wan2_2/Text2Video FusioniX - 10 Steps.json
+++ b/loras/profiles_wan2_2/Text2Video FusioniX - 10 Steps.json
@@ -7,5 +7,6 @@
"num_inference_steps": 10,
"guidance_scale": 1,
"guidance2_scale": 1,
+ "guidance_phases": 2,
"flow_shift": 2
}
diff --git a/loras/wan2_2_5B/FastWan 3 Steps.json b/loras/profiles_wan2_2_5B/FastWan 3 Steps.json
similarity index 100%
rename from loras/wan2_2_5B/FastWan 3 Steps.json
rename to loras/profiles_wan2_2_5B/FastWan 3 Steps.json
diff --git a/loras_i2v/wan/Image2Video FusioniX - 10 Steps.json b/loras_i2v/profiles_wan/Image2Video FusioniX - 10 Steps.json
similarity index 100%
rename from loras_i2v/wan/Image2Video FusioniX - 10 Steps.json
rename to loras_i2v/profiles_wan/Image2Video FusioniX - 10 Steps.json
diff --git a/loras_qwen/qwen/Lightning v1.0 - 4 Steps.json b/loras_qwen/profiles_qwen/Lightning v1.0 - 4 Steps.json
similarity index 100%
rename from loras_qwen/qwen/Lightning v1.0 - 4 Steps.json
rename to loras_qwen/profiles_qwen/Lightning v1.0 - 4 Steps.json
diff --git a/loras_qwen/qwen/Lightning v1.1 - 8 Steps.json b/loras_qwen/profiles_qwen/Lightning v1.1 - 8 Steps.json
similarity index 100%
rename from loras_qwen/qwen/Lightning v1.1 - 8 Steps.json
rename to loras_qwen/profiles_qwen/Lightning v1.1 - 8 Steps.json
diff --git a/models/wan/any2video.py b/models/wan/any2video.py
index 0ad61e6..01c2cd8 100644
--- a/models/wan/any2video.py
+++ b/models/wan/any2video.py
@@ -93,7 +93,6 @@ class WanAny2V:
checkpoint_path=text_encoder_filename,
tokenizer_path=os.path.join(checkpoint_dir, "umt5-xxl"),
shard_fn= None)
-
# base_model_type = "i2v2_2"
if hasattr(config, "clip_checkpoint") and not base_model_type in ["i2v_2_2", "i2v_2_2_multitalk"] or base_model_type in ["animate"]:
self.clip = CLIPModel(
@@ -103,6 +102,7 @@ class WanAny2V:
config.clip_checkpoint),
tokenizer_path=os.path.join(checkpoint_dir , "xlm-roberta-large"))
+ ignore_unused_weights = model_def.get("ignore_unused_weights", False)
if base_model_type in ["ti2v_2_2", "lucy_edit"]:
self.vae_stride = (4, 16, 16)
@@ -134,10 +134,11 @@ class WanAny2V:
source2 = model_def.get("source2", None)
module_source = model_def.get("module_source", None)
module_source2 = model_def.get("module_source2", None)
+ kwargs= { "ignore_unused_weights": ignore_unused_weights, "writable_tensors": False, "default_dtype": dtype }
if module_source is not None:
- self.model = offload.fast_load_transformers_model(model_filename[:1] + [module_source], modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, writable_tensors= False, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath)
+ self.model = offload.fast_load_transformers_model(model_filename[:1] + [module_source], modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, **kwargs)
if module_source2 is not None:
- self.model2 = offload.fast_load_transformers_model(model_filename[1:2] + [module_source2], modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, writable_tensors= False, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath)
+ self.model2 = offload.fast_load_transformers_model(model_filename[1:2] + [module_source2], modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, **kwargs)
if source is not None:
self.model = offload.fast_load_transformers_model(source, modelClass=WanModel, writable_tensors= False, forcedConfigPath= base_config_file)
if source2 is not None:
@@ -153,17 +154,17 @@ class WanAny2V:
if 0 in submodel_no_list[2:]:
shared_modules= {}
- self.model = offload.fast_load_transformers_model(model_filename[:1], modules = model_filename[2:], modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, writable_tensors= False, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, return_shared_modules= shared_modules)
- self.model2 = offload.fast_load_transformers_model(model_filename[1:2], modules = shared_modules, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, writable_tensors= False, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath)
+ self.model = offload.fast_load_transformers_model(model_filename[:1], modules = model_filename[2:], modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, return_shared_modules= shared_modules, **kwargs)
+ self.model2 = offload.fast_load_transformers_model(model_filename[1:2], modules = shared_modules, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, **kwargs)
shared_modules = None
else:
modules_for_1 =[ file_name for file_name, submodel_no in zip(model_filename[2:],submodel_no_list[2:] ) if submodel_no ==1 ]
modules_for_2 =[ file_name for file_name, submodel_no in zip(model_filename[2:],submodel_no_list[2:] ) if submodel_no ==2 ]
- self.model = offload.fast_load_transformers_model(model_filename[:1], modules = modules_for_1, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, writable_tensors= False, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath)
- self.model2 = offload.fast_load_transformers_model(model_filename[1:2], modules = modules_for_2, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, writable_tensors= False, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath)
+ self.model = offload.fast_load_transformers_model(model_filename[:1], modules = modules_for_1, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, **kwargs)
+ self.model2 = offload.fast_load_transformers_model(model_filename[1:2], modules = modules_for_2, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, **kwargs)
else:
- self.model = offload.fast_load_transformers_model(model_filename, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, writable_tensors= False, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath)
+ self.model = offload.fast_load_transformers_model(model_filename, modelClass=WanModel,do_quantize= quantizeTransformer and not save_quantized, defaultConfigPath=base_config_file , forcedConfigPath= forcedConfigPath, **kwargs)
if self.model is not None:
diff --git a/models/wan/diffusion_forcing.py b/models/wan/diffusion_forcing.py
index 5d5e42f..09d7315 100644
--- a/models/wan/diffusion_forcing.py
+++ b/models/wan/diffusion_forcing.py
@@ -365,7 +365,7 @@ class DTT2V:
timestep[:, valid_interval_start:predix_video_latent_length] = timestep_for_noised_condition
kwrags.update({
"t" : timestep,
- "current_step" : i,
+ "current_step_no" : i,
})
# with torch.autocast(device_type="cuda"):
diff --git a/requirements.txt b/requirements.txt
index a17efd1..cfe61c5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -48,7 +48,7 @@ pydantic==2.10.6
# Math & modeling
torchdiffeq>=0.2.5
tensordict>=0.6.1
-mmgp==3.6.1
+mmgp==3.6.2
peft==0.15.0
matplotlib
diff --git a/shared/utils/loras_mutipliers.py b/shared/utils/loras_mutipliers.py
index e0cec6a..8ba456d 100644
--- a/shared/utils/loras_mutipliers.py
+++ b/shared/utils/loras_mutipliers.py
@@ -1,3 +1,6 @@
+from typing import List, Tuple, Dict, Callable
+
+
def preparse_loras_multipliers(loras_multipliers):
if isinstance(loras_multipliers, list):
return [multi.strip(" \r\n") if isinstance(multi, str) else multi for multi in loras_multipliers]
@@ -6,7 +9,7 @@ def preparse_loras_multipliers(loras_multipliers):
loras_mult_choices_list = loras_multipliers.replace("\r", "").split("\n")
loras_mult_choices_list = [multi.strip() for multi in loras_mult_choices_list if len(multi)>0 and not multi.startswith("#")]
loras_multipliers = " ".join(loras_mult_choices_list)
- return loras_multipliers.split(" ")
+ return loras_multipliers.replace("|"," ").split(" ")
def expand_slist(slists_dict, mult_no, num_inference_steps, model_switch_step, model_switch_step2 ):
def expand_one(slist, num_inference_steps):
@@ -33,6 +36,10 @@ def expand_slist(slists_dict, mult_no, num_inference_steps, model_switch_step, m
return expand_one(phase1, model_switch_step) + expand_one(phase2, model_switch_step2 - model_switch_step) + expand_one(phase3, num_inference_steps - model_switch_step2)
def parse_loras_multipliers(loras_multipliers, nb_loras, num_inference_steps, merge_slist = None, nb_phases = 2, model_switch_step = None, model_switch_step2 = None):
+ if "|" in loras_multipliers:
+ pos = loras_multipliers.find("|")
+ if "|" in loras_multipliers[pos+1:]: return "", "", "There can be only one '|' character in Loras Multipliers Sequence"
+
if model_switch_step is None:
model_switch_step = num_inference_steps
if model_switch_step2 is None:
@@ -125,3 +132,288 @@ def get_model_switch_steps(timesteps, guide_phases, model_switch_phase, switch_t
if guide_phases > 2 and model_switch_step2 < total_num_steps:
phases_description += f", Phase 3 = {model_switch_step2 +1}:{ total_num_steps}"
return model_switch_step, model_switch_step2, phases_description
+
+
+
+from typing import List, Tuple, Dict, Callable
+
+_ALWD = set(":;,.0123456789")
+
+# ---------------- core parsing helpers ----------------
+
+def _find_bar(s: str) -> int:
+ com = False
+ for i, ch in enumerate(s):
+ if ch in ('\n', '\r'):
+ com = False
+ elif ch == '#':
+ com = True
+ elif ch == '|' and not com:
+ return i
+ return -1
+
+def _spans(text: str) -> List[Tuple[int, int]]:
+ res, com, in_tok, st = [], False, False, 0
+ for i, ch in enumerate(text):
+ if ch in ('\n', '\r'):
+ if in_tok: res.append((st, i)); in_tok = False
+ com = False
+ elif ch == '#':
+ if in_tok: res.append((st, i)); in_tok = False
+ com = True
+ elif not com:
+ if ch in _ALWD:
+ if not in_tok: in_tok, st = True, i
+ else:
+ if in_tok: res.append((st, i)); in_tok = False
+ if in_tok: res.append((st, len(text)))
+ return res
+
+def _choose_sep(text: str, spans: List[Tuple[int, int]]) -> str:
+ if len(spans) >= 2:
+ a, b = spans[-2][1], spans[-1][0]
+ return '\n' if ('\n' in text[a:b] or '\r' in text[a:b]) else ' '
+ return '\n' if ('\n' in text or '\r' in text) else ' '
+
+def _ends_in_comment_line(text: str) -> bool:
+ ln = text.rfind('\n')
+ seg = text[ln + 1:] if ln != -1 else text
+ return '#' in seg
+
+def _append_tokens(text: str, k: int, sep: str) -> str:
+ if k <= 0: return text
+ t = text
+ if _ends_in_comment_line(t) and (not t.endswith('\n')): t += '\n'
+ parts = []
+ if t and not t[-1].isspace(): parts.append(sep)
+ parts.append('1')
+ for _ in range(k - 1):
+ parts.append(sep); parts.append('1')
+ return t + ''.join(parts)
+
+def _erase_span_and_one_sep(text: str, st: int, en: int) -> str:
+ n = len(text)
+ r = en
+ while r < n and text[r] in (' ', '\t'): r += 1
+ if r > en: return text[:st] + text[r:]
+ l = st
+ while l > 0 and text[l-1] in (' ', '\t'): l -= 1
+ if l < st: return text[:l] + text[en:]
+ return text[:st] + text[en:]
+
+def _trim_last_tokens(text: str, spans: List[Tuple[int, int]], drop: int) -> str:
+ if drop <= 0: return text
+ new_text = text
+ for st, en in reversed(spans[-drop:]):
+ new_text = _erase_span_and_one_sep(new_text, st, en)
+ while new_text and new_text[-1] in (' ', '\t'):
+ new_text = new_text[:-1]
+ return new_text
+
+def _enforce_count(text: str, target: int) -> str:
+ sp = _spans(text); cur = len(sp)
+ if cur == target: return text
+ if cur > target: return _trim_last_tokens(text, sp, cur - target)
+ sep = _choose_sep(text, sp)
+ return _append_tokens(text, target - cur, sep)
+
+def _strip_bars_outside_comments(s: str) -> str:
+ com, out = False, []
+ for ch in s:
+ if ch in ('\n', '\r'): com = False; out.append(ch)
+ elif ch == '#': com = True; out.append(ch)
+ elif ch == '|' and not com: continue
+ else: out.append(ch)
+ return ''.join(out)
+
+def _replace_tokens(text: str, repl: Dict[int, str]) -> str:
+ if not repl: return text
+ sp = _spans(text)
+ for idx in sorted(repl.keys(), reverse=True):
+ if 0 <= idx < len(sp):
+ st, en = sp[idx]
+ text = text[:st] + repl[idx] + text[en:]
+ return text
+
+def _drop_tokens_by_indices(text: str, idxs: List[int]) -> str:
+ if not idxs: return text
+ out = text
+ for idx in sorted(set(idxs), reverse=True):
+ sp = _spans(out) # recompute spans after each deletion
+ if 0 <= idx < len(sp):
+ st, en = sp[idx]
+ out = _erase_span_and_one_sep(out, st, en)
+ return out
+
+# ---------------- identity for dedupe ----------------
+
+def _default_path_key(p: str) -> str:
+ s = p.strip().replace('\\', '/')
+ while '//' in s: s = s.replace('//', '/')
+ if len(s) > 1 and s.endswith('/'): s = s[:-1]
+ return s
+
+# ---------------- new-set splitter (FIX) ----------------
+
+def _select_new_side(
+ loras_new: List[str],
+ mult_new: str,
+ mode: str, # "merge before" | "merge after"
+) -> Tuple[List[str], str]:
+ """
+ Split mult_new on '|' (outside comments) and split loras_new accordingly.
+ Return ONLY the side relevant to `mode`. Extras loras (if any) are appended to the selected side.
+ """
+ bi = _find_bar(mult_new)
+ if bi == -1:
+ return loras_new, _strip_bars_outside_comments(mult_new)
+
+ left, right = mult_new[:bi], mult_new[bi + 1:]
+ nL, nR = len(_spans(left)), len(_spans(right))
+ L = len(loras_new)
+
+ # Primary allocation by token counts
+ b_count = min(nL, L)
+ rem = max(0, L - b_count)
+ a_count = min(nR, rem)
+ extras = max(0, L - (b_count + a_count))
+
+ if mode == "merge before":
+ # take BEFORE loras + extras
+ l_sel = loras_new[:b_count] + (loras_new[b_count + a_count : b_count + a_count + extras] if extras else [])
+ m_sel = left
+ else:
+ # take AFTER loras + extras
+ start_after = b_count
+ l_sel = loras_new[start_after:start_after + a_count] + (loras_new[start_after + a_count : start_after + a_count + extras] if extras else [])
+ m_sel = right
+
+ return l_sel, _strip_bars_outside_comments(m_sel)
+
+# ---------------- public API ----------------
+
+def merge_loras_settings(
+ loras_old: List[str],
+ mult_old: str,
+ loras_new: List[str],
+ mult_new: str,
+ mode: str = "merge before",
+ path_key: Callable[[str], str] = _default_path_key,
+) -> Tuple[List[str], str]:
+ """
+ Merge settings with full formatting/comment preservation and correct handling of `mult_new` with '|'.
+ Dedup rule: when merging AFTER (resp. BEFORE), if a new lora already exists in preserved BEFORE (resp. AFTER),
+ update that preserved multiplier and drop the duplicate from the replaced side.
+ """
+ assert mode in ("merge before", "merge after")
+
+ # Old split & alignment
+ bi_old = _find_bar(mult_old)
+ before_old, after_old = (mult_old[:bi_old], mult_old[bi_old + 1:]) if bi_old != -1 else ("", mult_old)
+ orig_had_bar = (bi_old != -1)
+
+ sp_b_old, sp_a_old = _spans(before_old), _spans(after_old)
+ n_b_old = len(sp_b_old)
+ total_old = len(loras_old)
+
+ if n_b_old <= total_old:
+ keep_b = n_b_old
+ keep_a = total_old - keep_b
+ before_old_aligned = before_old
+ after_old_aligned = _enforce_count(after_old, keep_a)
+ else:
+ keep_b = total_old
+ keep_a = 0
+ before_old_aligned = _enforce_count(before_old, keep_b)
+ after_old_aligned = _enforce_count(after_old, 0)
+
+ # NEW: choose the relevant side of the *new* set (fix for '|' in mult_new)
+ loras_new_sel, mult_new_sel = _select_new_side(loras_new, mult_new, mode)
+ mult_new_aligned = _enforce_count(mult_new_sel, len(loras_new_sel))
+ sp_new = _spans(mult_new_aligned)
+ new_tokens = [mult_new_aligned[st:en] for st, en in sp_new]
+
+ if mode == "merge after":
+ # Preserve BEFORE; replace AFTER (with dedupe/update)
+ preserved_loras = loras_old[:keep_b]
+ preserved_text = before_old_aligned
+ preserved_spans = _spans(preserved_text)
+ pos_by_key: Dict[str, int] = {}
+ for i, lp in enumerate(preserved_loras):
+ k = path_key(lp)
+ if k not in pos_by_key: pos_by_key[k] = i
+
+ repl_map: Dict[int, str] = {}
+ drop_idxs: List[int] = []
+ for i, lp in enumerate(loras_new_sel):
+ j = pos_by_key.get(path_key(lp))
+ if j is not None and j < len(preserved_spans):
+ repl_map[j] = new_tokens[i] if i < len(new_tokens) else "1"
+ drop_idxs.append(i)
+
+ before_text = _replace_tokens(preserved_text, repl_map)
+ after_text = _drop_tokens_by_indices(mult_new_aligned, drop_idxs)
+ loras_keep = [lp for i, lp in enumerate(loras_new_sel) if i not in set(drop_idxs)]
+ loras_out = preserved_loras + loras_keep
+
+ else:
+ # Preserve AFTER; replace BEFORE (with dedupe/update)
+ preserved_loras = loras_old[keep_b:]
+ preserved_text = after_old_aligned
+ preserved_spans = _spans(preserved_text)
+ pos_by_key: Dict[str, int] = {}
+ for i, lp in enumerate(preserved_loras):
+ k = path_key(lp)
+ if k not in pos_by_key: pos_by_key[k] = i
+
+ repl_map: Dict[int, str] = {}
+ drop_idxs: List[int] = []
+ for i, lp in enumerate(loras_new_sel):
+ j = pos_by_key.get(path_key(lp))
+ if j is not None and j < len(preserved_spans):
+ repl_map[j] = new_tokens[i] if i < len(new_tokens) else "1"
+ drop_idxs.append(i)
+
+ after_text = _replace_tokens(preserved_text, repl_map)
+ before_text = _drop_tokens_by_indices(mult_new_aligned, drop_idxs)
+ loras_keep = [lp for i, lp in enumerate(loras_new_sel) if i not in set(drop_idxs)]
+ loras_out = loras_keep + preserved_loras
+
+ # Compose, preserving explicit "before-only" bar when appropriate
+ has_before = len(_spans(before_text)) > 0
+ has_after = len(_spans(after_text)) > 0
+ if has_before and has_after:
+ mult_out = f"{before_text}|{after_text}"
+ elif has_before:
+ mult_out = before_text + ('|' if (mode == 'merge before' or orig_had_bar) else '')
+ else:
+ mult_out = after_text
+
+ return loras_out, mult_out
+
+# ---------------- extractor ----------------
+
+def extract_loras_side(
+ loras: List[str],
+ mult: str,
+ which: str = "before",
+) -> Tuple[List[str], str]:
+ assert which in ("before", "after")
+ bi = _find_bar(mult)
+ before_txt, after_txt = (mult[:bi], mult[bi + 1:]) if bi != -1 else ("", mult)
+
+ sp_b = _spans(before_txt)
+ n_b = len(sp_b)
+ total = len(loras)
+
+ if n_b <= total:
+ keep_b = n_b
+ keep_a = total - keep_b
+ else:
+ keep_b = total
+ keep_a = 0
+
+ if which == "before":
+ return loras[:keep_b], _enforce_count(before_txt, keep_b)
+ else:
+ return loras[keep_b:keep_b + keep_a], _enforce_count(after_txt, keep_a)
diff --git a/wgp.py b/wgp.py
index 090bcce..ff82489 100644
--- a/wgp.py
+++ b/wgp.py
@@ -62,8 +62,8 @@ global_queue_ref = []
AUTOSAVE_FILENAME = "queue.zip"
PROMPT_VARS_MAX = 10
-target_mmgp_version = "3.6.1"
-WanGP_version = "8.992"
+target_mmgp_version = "3.6.2"
+WanGP_version = "8.993"
settings_version = 2.39
max_source_video_frames = 3000
prompt_enhancer_image_caption_model, prompt_enhancer_image_caption_processor, prompt_enhancer_llm_model, prompt_enhancer_llm_tokenizer = None, None, None, None
@@ -5843,8 +5843,8 @@ def compute_lset_choices(model_type, loras_presets):
if model_type is not None:
top_dir = get_lora_dir(model_type)
model_def = get_model_def(model_type)
- settings_dir = get_model_recursive_prop(model_type, "settings_dir", return_list=False)
- if settings_dir is None or len(settings_dir) == 0: settings_dir = [get_model_family(model_type, True)]
+ settings_dir = get_model_recursive_prop(model_type, "profiles_dir", return_list=False)
+ if settings_dir is None or len(settings_dir) == 0: settings_dir = ["profiles_" + get_model_family(model_type, True)]
for dir in settings_dir:
if len(dir) == "": continue
cur_path = os.path.join(top_dir, dir)
@@ -5936,6 +5936,8 @@ def save_lset(state, lset_name, loras_choices, loras_mult_choices, prompt, save_
lset = collect_current_model_settings(state)
extension = ".json"
else:
+ from shared.utils.loras_mutipliers import extract_loras_side
+ loras_choices, loras_mult_choices = extract_loras_side(loras_choices, loras_mult_choices, "after")
lset = {"loras" : loras_choices, "loras_mult" : loras_mult_choices}
if save_lset_prompt_cbox!=1:
prompts = prompt.replace("\r", "").split("\n")
@@ -6046,6 +6048,7 @@ def refresh_lora_list(state, lset_name, loras_choices):
def update_lset_type(state, lset_name):
return 1 if lset_name.endswith(".lset") else 2
+from shared.utils.loras_mutipliers import merge_loras_settings
def apply_lset(state, wizard_prompt_activated, lset_name, loras_choices, loras_mult_choices, prompt):
@@ -6057,10 +6060,11 @@ def apply_lset(state, wizard_prompt_activated, lset_name, loras_choices, loras_m
return wizard_prompt_activated, loras_choices, loras_mult_choices, prompt, gr.update(), gr.update(), gr.update(), gr.update()
else:
current_model_type = state["model_type"]
+ ui_settings = get_current_model_settings(state)
+ old_activated_loras, old_loras_multipliers = ui_settings.get("activated_loras", []), ui_settings.get("loras_multipliers", ""),
if lset_name.endswith(".lset"):
loras = state["loras"]
loras_choices, loras_mult_choices, preset_prompt, full_prompt, error = extract_preset(current_model_type, lset_name, loras)
- loras_choices = update_loras_url_cache(get_lora_dir(current_model_type), loras_choices)
if full_prompt:
prompt = preset_prompt
elif len(preset_prompt) > 0:
@@ -6068,6 +6072,9 @@ def apply_lset(state, wizard_prompt_activated, lset_name, loras_choices, loras_m
prompts = [prompt for prompt in prompts if len(prompt)>0 and not prompt.startswith("#")]
prompt = "\n".join(prompts)
prompt = preset_prompt + '\n' + prompt
+ loras_choices, loras_mult_choices = merge_loras_settings(old_activated_loras, old_loras_multipliers, loras_choices, loras_mult_choices, "merge after")
+ loras_choices = update_loras_url_cache(get_lora_dir(current_model_type), loras_choices)
+ loras_choices = [os.path.basename(lora) for lora in loras_choices]
gr.Info(f"Lora Preset '{lset_name}' has been applied")
state["apply_success"] = 1
wizard_prompt_activated = "on"
@@ -6076,7 +6083,8 @@ def apply_lset(state, wizard_prompt_activated, lset_name, loras_choices, loras_m
else:
# lset_path = os.path.join("settings", lset_name) if len(Path(lset_name).parts)>1 else os.path.join(get_lora_dir(current_model_type), lset_name)
lset_path = os.path.join(get_lora_dir(current_model_type), lset_name)
- configs, _ = get_settings_from_file(state,lset_path , True, True, True, min_settings_version=2.38)
+ configs, _ = get_settings_from_file(state,lset_path , True, True, True, min_settings_version=2.38, merge_loras = "merge after" if len(Path(lset_name).parts)<=1 else "merge before" )
+
if configs == None:
gr.Info("File not supported")
return [gr.update()] * 8
@@ -6085,7 +6093,6 @@ def apply_lset(state, wizard_prompt_activated, lset_name, loras_choices, loras_m
gr.Info(f"Settings File '{lset_name}' has been applied")
help = configs.get("help", None)
if help is not None: gr.Info(help)
-
if model_type == current_model_type:
set_model_settings(state, current_model_type, configs)
return *[gr.update()] * 4, gr.update(), gr.update(), gr.update(), get_unique_id()
@@ -6625,7 +6632,7 @@ def update_loras_url_cache(lora_dir, loras_selected):
base_name = os.path.basename(lora)
local_name = os.path.join(lora_dir, base_name)
url = loras_url_cache.get(local_name, base_name)
- if lora.startswith("http:") or lora.startswith("https:") and url != lora:
+ if (lora.startswith("http:") or lora.startswith("https:")) and url != lora:
loras_url_cache[local_name]=lora
update = True
new_loras_selected.append(url)
@@ -6636,7 +6643,7 @@ def update_loras_url_cache(lora_dir, loras_selected):
return new_loras_selected
-def get_settings_from_file(state, file_path, allow_json, merge_with_defaults, switch_type_if_compatible, min_settings_version = 0):
+def get_settings_from_file(state, file_path, allow_json, merge_with_defaults, switch_type_if_compatible, min_settings_version = 0, merge_loras = None):
configs = None
any_image_or_video = False
if file_path.endswith(".json") and allow_json:
@@ -6687,16 +6694,28 @@ def get_settings_from_file(state, file_path, allow_json, merge_with_defaults, sw
model_type = current_model_type
if switch_type_if_compatible and are_model_types_compatible(model_type,current_model_type):
model_type = current_model_type
+ old_loras_selected = old_loras_multipliers = None
if merge_with_defaults:
defaults = get_model_settings(state, model_type)
defaults = get_default_settings(model_type) if defaults == None else defaults
+ if merge_loras is not None and model_type == current_model_type:
+ old_loras_selected, old_loras_multipliers = defaults.get("activated_loras", []), defaults.get("loras_multipliers", ""),
defaults.update(configs)
configs = defaults
- loras_selected =configs.get("activated_loras", None)
- if loras_selected is not None:
- configs["activated_loras"]= update_loras_url_cache(get_lora_dir(model_type), loras_selected)
+ loras_selected =configs.get("activated_loras", [])
+ loras_multipliers = configs.get("loras_multipliers", "")
+ if loras_selected is not None and len(loras_selected) > 0:
+ loras_selected = update_loras_url_cache(get_lora_dir(model_type), loras_selected)
+ if old_loras_selected is not None:
+ if len(old_loras_selected) == 0 and "|" in loras_multipliers:
+ pass
+ else:
+ old_loras_selected = update_loras_url_cache(get_lora_dir(model_type), old_loras_selected)
+ loras_selected, loras_multipliers = merge_loras_settings(old_loras_selected, old_loras_multipliers, loras_selected, loras_multipliers, merge_loras )
+ configs["activated_loras"]= loras_selected or []
+ configs["loras_multipliers"] = loras_multipliers
fix_settings(model_type, configs, min_settings_version)
configs["model_type"] = model_type