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.

fixup qwen3

Dattu Sharma26cf05957485
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index e60881fa9c2..282aa993347 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -248,7 +248,7 @@ model_architectures = ["llama", "mistral", "gemma", "gemma2", "qwen2", "granite"
for model_name in model_architectures:
config_filepath = f"transformers.models.{model_name}.configuration_{model_name}"
model_filepath = f"transformers.models.{model_name}.modeling_{model_name}"
- config_filename = f"{model_name.title()}Config"
+ config_filename = f"{model_name.title().replace('_','')}Config" # qwen3 arch folder is qwen3_moe but config is Qwen3Config. Need to remove underscore(_) for now
exec(f"from {config_filepath} import {config_filename}", globals())
try:
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 722b50d27af..9c218d3e7db 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -2487,6 +2487,8 @@ class FastLlamaModel:
elif model_type == "gemma2": apply_lora_mlp = apply_lora_mlp_geglu_approx
elif model_type == "cohere": apply_lora_mlp = apply_lora_mlp_swiglu
elif model_type == "granite": apply_lora_mlp = apply_lora_mlp_swiglu
+ elif model_type == "qwen3": apply_lora_mlp = apply_lora_mlp_swiglu
+ elif model_type == "qwen3moe": apply_lora_mlp = apply_lora_mlp_swiglu
else:
raise NotImplementedError(f"Unsloth: {model_type} is not yet implemented!")
pass
diff --git a/unsloth/models/qwen3.py b/unsloth/models/qwen3.py
index aa99aa88dbe..9d658cf8493 100644
--- a/unsloth/models/qwen3.py
+++ b/unsloth/models/qwen3.py
@@ -216,7 +216,7 @@ class FastQwen3Model(FastLlamaModel):
# https://github.com/huggingface/transformers/pull/27931
# https://github.com/huggingface/transformers/blob/v4.37.2/src/transformers/models/llama/modeling_llama.py
import transformers.models.qwen3.modeling_qwen3
- transformers.models.Qwen3.modeling_qwen3.Qwen3RotaryEmbedding = LlamaRotaryEmbedding
+ transformers.models.qwen3.modeling_qwen3.Qwen3RotaryEmbedding = LlamaRotaryEmbedding
return
pass