From 7398ad1c090363f87bcd65b76c2622975a2c904e Mon Sep 17 00:00:00 2001 From: jeromeku Date: Mon, 31 Mar 2025 09:45:15 -0700 Subject: [PATCH] add QwenQVQ to registry --- unsloth/registry/_qwen.py | 33 ++++++++++++++++++++++++++++----- unsloth/registry/registry.py | 8 +++++--- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/unsloth/registry/_qwen.py b/unsloth/registry/_qwen.py index a00d2d5729..0b902e3130 100644 --- a/unsloth/registry/_qwen.py +++ b/unsloth/registry/_qwen.py @@ -34,7 +34,17 @@ class QwenQwQModelInfo(ModelInfo): key = cls.append_quant_type(key, quant_type) return key -# Qwen Model Meta +class QwenQVQPreviewModelInfo(ModelInfo): + @classmethod + def construct_model_name( + cls, base_name, version, size, quant_type, instruct_tag + ): + key = f"{base_name}-{size}B-Preview" + key = cls.append_instruct_tag(key, instruct_tag) + key = cls.append_quant_type(key, quant_type) + return key + +# Qwen2.5 Model Meta QwenMeta = ModelMeta( org="Qwen", base_name="Qwen", @@ -46,7 +56,7 @@ QwenMeta = ModelMeta( quant_types=[QuantType.NONE, QuantType.BNB, QuantType.UNSLOTH], ) -# Qwen VL Model Meta +# Qwen2.5 VL Model Meta QwenVLMeta = ModelMeta( org="Qwen", base_name="Qwen", @@ -70,25 +80,38 @@ QwenQwQMeta = ModelMeta( quant_types=[QuantType.NONE, QuantType.BNB, QuantType.UNSLOTH, QuantType.GGUF], ) +# Qwen QVQ Preview Model Meta +QwenQVQPreviewMeta = ModelMeta( + org="Qwen", + base_name="QVQ", + instruct_tags=[None], + model_version="", + model_sizes=["72"], + model_info_cls=QwenQVQPreviewModelInfo, + is_multimodal=True, + quant_types=[QuantType.NONE, QuantType.BNB], +) + def register_qwen_models(include_original_model: bool = False): global _IS_QWEN_REGISTERED if _IS_QWEN_REGISTERED: return - _register_models(QwenMeta, include_original_model) + _register_models(QwenMeta, include_original_model=include_original_model) _IS_QWEN_REGISTERED = True def register_qwen_vl_models(include_original_model: bool = False): global _IS_QWEN_VL_REGISTERED if _IS_QWEN_VL_REGISTERED: return - _register_models(QwenVLMeta, include_original_model) + _register_models(QwenVLMeta, include_original_model=include_original_model) _IS_QWEN_VL_REGISTERED = True def register_qwen_qwq_models(include_original_model: bool = False): global _IS_QWEN_QWQ_REGISTERED if _IS_QWEN_QWQ_REGISTERED: return - _register_models(QwenQwQMeta, include_original_model) + _register_models(QwenQwQMeta, include_original_model=include_original_model) + _register_models(QwenQVQPreviewMeta, include_original_model=include_original_model) _IS_QWEN_QWQ_REGISTERED = True # register_qwen_models() diff --git a/unsloth/registry/registry.py b/unsloth/registry/registry.py index e7a2be0876..869a7efb5d 100644 --- a/unsloth/registry/registry.py +++ b/unsloth/registry/registry.py @@ -5,10 +5,11 @@ from enum import Enum class QuantType(Enum): BNB = "bnb" - UNSLOTH = "unsloth" + UNSLOTH = "unsloth" # dynamic 4-bit quantization GGUF = "GGUF" NONE = "none" +# Tags for Hugging Face model paths BNB_QUANTIZED_TAG = "bnb-4bit" UNSLOTH_DYNAMIC_QUANT_TAG = "unsloth" + "-" + BNB_QUANTIZED_TAG GGUF_TAG = "GGUF" @@ -18,9 +19,9 @@ QUANT_TAG_MAP = { QuantType.UNSLOTH: UNSLOTH_DYNAMIC_QUANT_TAG, QuantType.GGUF: GGUF_TAG, QuantType.NONE: None, -} - +} +# NOTE: models registered with org="unsloth" and QUANT_TYPE.NONE are aliases of QUANT_TYPE.UNSLOTH @dataclass class ModelInfo: org: str @@ -152,6 +153,7 @@ def _register_models(model_meta: ModelMeta, include_original_model: bool = False else: _quant_types = quant_types for quant_type in _quant_types: + # NOTE: models registered with org="unsloth" and QUANT_TYPE.NONE are aliases of QUANT_TYPE.UNSLOTH _org = "unsloth" # unsloth models -- these are all quantized versions of the original model register_model( model_info_cls=model_info_cls,