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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Load Qwen2.5-Omni checkpoints that name Qwen2_5OmniModel (#13087)
Daniel Han9656b589717e
diff --git a/tests/test_omni_auto_class_resolution.py b/tests/test_omni_auto_class_resolution.pyindex d963536097b..6c8ed70275f 100644--- a/tests/test_omni_auto_class_resolution.py+++ b/tests/test_omni_auto_class_resolution.py@@ -233,3 +233,47 @@ def test_a_normal_model_still_gets_its_hook():model = _tiny(Normal)model.enable_input_require_grads()assert model.embed._forward_hooks, "the input-gradient hook must be registered"+++class _Routed(Exception):+ pass+++def _route(tmp_path, monkeypatch, config):+ import json+ import unsloth.models.loader as loader++ (tmp_path / "config.json").write_text(json.dumps(config.to_dict()))++ def capture(*args, **kwargs):+ raise _Routed(kwargs.get("auto_model"))++ monkeypatch.setattr(loader.FastBaseModel, "from_pretrained", staticmethod(capture))+ # Its pinned host buffer needs an accelerator; CPU CI has none.+ monkeypatch.setattr(loader, "apply_unsloth_gradient_checkpointing", lambda value, *args: value)+ with pytest.raises(_Routed) as routed:+ loader.FastModel.from_pretrained(str(tmp_path), load_in_4bit = False)+ return routed.value.args[0]+++ "architecture", ["Qwen2_5OmniModel", "Qwen2_5OmniForConditionalGeneration"]+)+def test_qwen2_5_omni_routes_to_a_multimodal_class(tmp_path, monkeypatch, architecture):+ """Qwen/Qwen2.5-Omni-3B / -7B name `Qwen2_5OmniModel` and nest vision under thinker_config (#2325)."""+ config_class = getattr(transformers, "Qwen2_5OmniConfig", None)+ if config_class is None:+ pytest.skip("this transformers has no Qwen2.5-Omni")+ config = config_class()+ config.architectures = [architecture]+ auto_model = _route(tmp_path, monkeypatch, config)+ assert auto_model is not transformers.AutoModelForCausalLM+ assert resolve_model_class(auto_model, config) is not None+++def test_a_text_checkpoint_still_routes_to_causal_lm(tmp_path, monkeypatch):+ config = transformers.Qwen2Config(+ hidden_size = 8, num_hidden_layers = 1, num_attention_heads = 1, intermediate_size = 8+ )+ config.architectures = ["Qwen2ForCausalLM"]+ assert _route(tmp_path, monkeypatch, config) is transformers.AutoModelForCausalLMdiff --git a/unsloth/models/loader.py b/unsloth/models/loader.pyindex 29e75e194d7..fd3ef675b90 100644--- a/unsloth/models/loader.py+++ b/unsloth/models/loader.py@@ -622,6 +622,13 @@ def _built_by_unsloth_compiler(cls):return False+def _has_vision_config(config):+ # Qwen2.5-Omni checkpoints name `Qwen2_5OmniModel` (no ForConditionalGeneration) and nest vision under thinker_config.+ return any(+ hasattr(sub, "vision_config") for sub in (config, getattr(config, "thinker_config", None))+ )++def _resolve_omni_auto_model(model_config,trust_remote_code = None,@@ -2489,9 +2496,9 @@ class FastModel(FastBaseModel):# Keep the local checkpoint dir as tokenizer when self-sufficient; a VLM also needs local processor files, else fall back to the base repo so its cached processor loads._ckpt_arch = getattr(model_config, "architectures", None) or []- _ckpt_is_vlm = any(x.endswith("ForConditionalGeneration") for x in _ckpt_arch) or hasattr(- model_config, "vision_config"- )+ _ckpt_is_vlm = any(+ x.endswith("ForConditionalGeneration") for x in _ckpt_arch+ ) or _has_vision_config(model_config)# T5 / BART end in ForConditionalGeneration too but ship a tokenizer, not a processor._ckpt_is_vlm = _ckpt_is_vlm and not _is_text_seq2seq_config(model_config)tokenizer_name = _resolve_checkpoint_tokenizer_name(@@ -2523,7 +2530,7 @@ class FastModel(FastBaseModel):if architectures is None:architectures = []is_vlm = any(x.endswith("ForConditionalGeneration") for x in architectures)- is_vlm = is_vlm or hasattr(model_config, "vision_config")+ is_vlm = is_vlm or _has_vision_config(model_config)if (is_peftand not text_only