Skip to content
Python

added max lora to reserved mem slider

DeepBeepMeep1a140b17fd2f
diff --git a/README.md b/README.md
index 23749fc..86d8a62 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ WanGP supports the Wan (and derived models), Hunyuan Video and LTV Video models
- **LTX 2 - SUPER VRAM OPTIMIZATIONS**
-*With WanGP 10.20 HD 720p Video Gens of 10s just need now 8GB of VRAM!*
+*With WanGP 10.21 HD 720p Video Gens of 10s just need now 8GB of VRAM!*
LTX Team said this video gen was for 4k. So I had no choice but to squeeze more VRAM for further optimizations.
@@ -59,6 +59,9 @@ Use a *Control Video* to transfer *Pose*, *Depth*, *Canny Edges*. I have added s
- **Start Image Strength**: if you set values lower than 1 you may to reduce the static image effect, you get sometime with LTX2 i2v
+- **Max Loras Pinned Slider**: Some users (with usually PC with less than 64 GB of RAM) have reported Out Of Memory although the model seemed to load just fine when starting a gen with Loras. This is sometime related to WanGP attempting (and failing due to unsufficient reserved RAM) to pin the Loras to Reserved Memory for faster gen. I have added a Slider at the bottom of the *Configuration* / *Performance* tab that you can use to prevent WanGP from Pinning Loras (to do so set it to 0). This may solve the oom crashes with *LTX2 Default (non distilled)*
+
+*update 10.21*: added slider Loras Max Pinning slider
### January 9st 2026: WanGP v10.11, Spoiled again
diff --git a/models/ltx2/ltx_core/text_encoders/gemma/encoders/base_encoder.py b/models/ltx2/ltx_core/text_encoders/gemma/encoders/base_encoder.py
index 5968ed0..1e157b6 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
@@ -11,6 +11,9 @@ from ....loader.module_ops import ModuleOps
from ..embeddings_connector import Embeddings1DConnector
from ..feature_extractor import GemmaFeaturesExtractorProjLinear
from ..tokenizer import LTXVGemmaTokenizer
+from shared.utils import files_locator as fl
+from .....ltx2_handler import _GEMMA_FOLDER
+
import os
class GemmaTextEncoderModelBase(torch.nn.Module):
@@ -316,14 +319,14 @@ def _find_merged_gemma_file(gemma_root: str) -> str | None:
def module_ops_from_gemma_root(gemma_root: str) -> tuple[ModuleOps, ...]:
gemma_path = gemma_root
gemma_root = os.path.dirname(gemma_root)
- tokenizer_path = _find_matching_dir(gemma_root, "tokenizer.model")
+ tokenizer_path = fl.locate_file(_GEMMA_FOLDER, "tokenizer.model")
def load_gemma(module: GemmaTextEncoderModelBase) -> GemmaTextEncoderModelBase:
- config_path = Path(gemma_root) / "config.json"
+ config_path = fl.locate_file(_GEMMA_FOLDER, "config.json")
module.model = offload.fast_load_transformers_model(
gemma_path,
modelClass=Gemma3ForConditionalGeneration,
- defaultConfigPath=str(config_path) if config_path.is_file() else None,
+ defaultConfigPath=config_path,
writable_tensors=False,
)
module._gemma_root = module._gemma_root or gemma_root
diff --git a/plugins/wan2gp-configuration/plugin.py b/plugins/wan2gp-configuration/plugin.py
index 17d8536..718febf 100644
--- a/plugins/wan2gp-configuration/plugin.py
+++ b/plugins/wan2gp-configuration/plugin.py
@@ -156,6 +156,13 @@ class ConfigTabPlugin(WAN2GPPlugin):
self.boost_choice = gr.Dropdown(choices=[("ON", 1), ("OFF", 2)], value=self.boost, label="Boost (~10% speedup for ~1GB VRAM)")
self.profile_choice = gr.Dropdown(choices=self.memory_profile_choices, value=self.default_profile, label="Memory Profile (Advanced)")
self.preload_in_VRAM_choice = gr.Slider(0, 40000, value=self.server_config.get("preload_in_VRAM", 0), step=100, label="VRAM (MB) for Preloaded Models (0=profile default)")
+ self.max_reserved_loras_choice = gr.Slider(
+ -1,
+ 10000,
+ value=self.server_config.get("max_reserved_loras", -1),
+ step=1,
+ label="Max Amount of Loras (in MB) to be Pinned To Reserved Memory (set it to 0-500MB if Out of Memory when starting Gen, -1= No limit)"
+ )
self.release_RAM_btn = gr.Button("Force Unload Models from RAM")
with gr.Tab("Extensions"):
@@ -214,7 +221,7 @@ class ConfigTabPlugin(WAN2GPPlugin):
self.quantization_choice, self.transformer_dtype_policy_choice, self.mixed_precision_choice,
self.text_encoder_quantization_choice, self.VAE_precision_choice, self.compile_choice,
self.depth_anything_v2_variant_choice, self.vae_config_choice, self.boost_choice,
- self.profile_choice, self.preload_in_VRAM_choice,
+ self.profile_choice, self.preload_in_VRAM_choice, self.max_reserved_loras_choice,
self.enhancer_enabled_choice, self.enhancer_mode_choice, self.mmaudio_mode_choice, self.mmaudio_persistence_choice,
self.video_output_codec_choice, self.image_output_codec_choice, self.audio_output_codec_choice,
self.metadata_choice, self.embed_source_images_choice,
@@ -263,7 +270,7 @@ class ConfigTabPlugin(WAN2GPPlugin):
quantization_choice, transformer_dtype_policy_choice, mixed_precision_choice,
text_encoder_quantization_choice, VAE_precision_choice, compile_choice,
depth_anything_v2_variant_choice, vae_config_choice, boost_choice,
- profile_choice, preload_in_VRAM_choice,
+ profile_choice, preload_in_VRAM_choice, max_reserved_loras_choice,
enhancer_enabled_choice, enhancer_mode_choice, mmaudio_mode_choice, mmaudio_persistence_choice,
video_output_codec_choice, image_output_codec_choice, audio_output_codec_choice,
metadata_choice, embed_source_images_choice,
@@ -298,6 +305,7 @@ class ConfigTabPlugin(WAN2GPPlugin):
"notification_sound_volume": notification_sound_volume_choice,
"max_frames_multiplier": max_frames_multiplier_choice, "display_stats": display_stats_choice,
"enable_4k_resolutions": enable_4k_resolutions_choice,
+ "max_reserved_loras": max_reserved_loras_choice,
"video_output_codec": video_output_codec_choice, "image_output_codec": image_output_codec_choice,
"audio_output_codec": audio_output_codec_choice,
"model_hierarchy_type": model_hierarchy_type_choice,
@@ -329,7 +337,7 @@ class ConfigTabPlugin(WAN2GPPlugin):
"metadata_type", "clear_file_list", "fit_canvas", "depth_anything_v2_variant",
"notification_sound_enabled", "notification_sound_volume", "mmaudio_mode",
"mmaudio_persistence", "mmaudio_enabled",
- "max_frames_multiplier", "display_stats", "enable_4k_resolutions", "video_output_codec", "video_container",
+ "max_frames_multiplier", "display_stats", "enable_4k_resolutions", "max_reserved_loras", "video_output_codec", "video_container",
"embed_source_images", "image_output_codec", "audio_output_codec", "checkpoints_paths",
"model_hierarchy_type", "UI_theme", "queue_color_scheme"
]
diff --git a/requirements.txt b/requirements.txt
index 678d758..4fa9024 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -57,7 +57,7 @@ pydantic==2.10.6
# Math & modeling
torchdiffeq>=0.2.5
tensordict>=0.6.1
-mmgp==3.6.11
+mmgp==3.6.12
peft==0.15.0
matplotlib
diff --git a/wgp.py b/wgp.py
index e3dfb53..1391f5a 100644
--- a/wgp.py
+++ b/wgp.py
@@ -84,8 +84,8 @@ AUTOSAVE_PATH = AUTOSAVE_FILENAME
AUTOSAVE_TEMPLATE_PATH = AUTOSAVE_FILENAME
CONFIG_FILENAME = "wgp_config.json"
PROMPT_VARS_MAX = 10
-target_mmgp_version = "3.6.11"
-WanGP_version = "10.20"
+target_mmgp_version = "3.6.12"
+WanGP_version = "10.21"
settings_version = 2.42
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
@@ -2141,6 +2141,7 @@ if not Path(config_load_filename).is_file():
"boost" : 1,
"clear_file_list" : 5,
"enable_4k_resolutions": 0,
+ "max_reserved_loras": -1,
"vae_config": 0,
"profile" : profile_type.LowRAM_LowVRAM,
"preload_model_policy": [],
@@ -2740,6 +2741,7 @@ if not "video_output_codec" in server_config: server_config["video_output_codec"
if not "video_container" in server_config: server_config["video_container"]= "mp4"
if not "embed_source_images" in server_config: server_config["embed_source_images"]= False
if not "enable_4k_resolutions" in server_config: server_config["enable_4k_resolutions"]= 0
+if not "max_reserved_loras" in server_config: server_config["max_reserved_loras"]= -1
if not "image_output_codec" in server_config: server_config["image_output_codec"]= "jpeg_95"
preload_model_policy = server_config.get("preload_model_policy", [])
@@ -5424,6 +5426,7 @@ def generate_video(
activate_all_loras=True,
preprocess_sd=get_loras_preprocessor(preprocess_target, base_model_type),
pinnedLora=pinnedLora,
+ maxReservedLoras=server_config.get("max_reserved_loras", -1),
split_linear_modules_map=split_linear_modules_map,
)
errors = trans_lora._loras_errors