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.

move use_modelscope to _utils (#1938)

Kareem7a1199cf0bfd
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py
index 03eb21f4ebc..25fa7880998 100644
--- a/unsloth/models/_utils.py
+++ b/unsloth/models/_utils.py
@@ -25,6 +25,7 @@ __all__ = [
"__version__",
"HAS_FLASH_ATTENTION",
"HAS_FLASH_ATTENTION_SOFTCAPPING",
+ "USE_MODELSCOPE",
"platform_system",
"patch_tokenizer",
"get_statistics",
@@ -1271,3 +1272,10 @@ for j, function in enumerate(functions):
try: exec(f"EMPTY_LOGITS.{function} = raise_{j}", globals(), locals())
except: continue
pass
+
+USE_MODELSCOPE = os.environ.get("UNSLOTH_USE_MODELSCOPE", "0") == "1"
+if USE_MODELSCOPE:
+ if importlib.util.find_spec("modelscope") is None:
+ raise ImportError(f'You are using the modelscope hub, please install modelscope by `pip install modelscope -U`')
+ pass
+pass
diff --git a/unsloth/models/loader.py b/unsloth/models/loader.py
index 800c016cc8b..6eee360d25f 100644
--- a/unsloth/models/loader.py
+++ b/unsloth/models/loader.py
@@ -12,7 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ._utils import is_bfloat16_supported, HAS_FLASH_ATTENTION, HAS_FLASH_ATTENTION_SOFTCAPPING
+from ._utils import (
+ is_bfloat16_supported,
+ HAS_FLASH_ATTENTION,
+ HAS_FLASH_ATTENTION_SOFTCAPPING,
+ USE_MODELSCOPE,
+)
from .granite import FastGraniteModel
from .llama import FastLlamaModel, logger
from .mistral import FastMistralModel
@@ -36,14 +41,6 @@ pass
from huggingface_hub import HfFileSystem
import importlib.util
-# [TODO] Move USE_MODELSCOPE to utils
-USE_MODELSCOPE = os.environ.get("UNSLOTH_USE_MODELSCOPE", "0") == "1"
-if USE_MODELSCOPE:
- if importlib.util.find_spec("modelscope") is None:
- raise ImportError(f'You are using the modelscope hub, please install modelscope by `pip install modelscope -U`')
- pass
-pass
-
# https://github.com/huggingface/transformers/pull/26037 allows 4 bit loading!
from unsloth_zoo.utils import Version, _get_dtype
transformers_version = Version(transformers_version)