Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Silence peft target_parameters RuntimeWarning for MoE models (#4008)

Daniel Han4f5de9ba934a
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index c1e91107599..89c25e73168 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -3072,7 +3072,14 @@ class FastLlamaModel:
gc.collect()
clean_gpu_cache()
- model = _get_peft_model(model, lora_config)
+ import warnings as _w
+
+ with _w.catch_warnings():
+ _w.filterwarnings(
+ "ignore",
+ message = ".*target_parameters.*were set but no parameter was matched.*",
+ )
+ model = _get_peft_model(model, lora_config)
# Fix LoraConfig.auto_mapping is None
fix_lora_auto_mapping(model)
diff --git a/unsloth/models/vision.py b/unsloth/models/vision.py
index 2c1371a4a26..735c28d917a 100644
--- a/unsloth/models/vision.py
+++ b/unsloth/models/vision.py
@@ -1209,7 +1209,14 @@ class FastBaseModel:
model,
use_gradient_checkpointing = use_gradient_checkpointing,
)
- model = _get_peft_model(model, lora_config)
+ import warnings as _w
+
+ with _w.catch_warnings():
+ _w.filterwarnings(
+ "ignore",
+ message = ".*target_parameters.*were set but no parameter was matched.*",
+ )
+ model = _get_peft_model(model, lora_config)
# Apply QAT + LoRA if specified
if qat_scheme is not None:
print("Unsloth: Applying QAT to mitigate quantization degradation")