From 7862e702116f53d712177bf8901a76cacc85f4fa Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Wed, 11 Mar 2026 14:19:18 +0000 Subject: [PATCH] fix: lowercase remote Hugging Face model IDs in ModelConfig and routes to prevent caching mismatches with Unsloth --- .gitignore | 3 +++ studio/backend/routes/models.py | 4 ++++ studio/backend/utils/models/model_config.py | 12 +++++++++--- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d89fdb9693..a9ebfcf1b7 100755 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ environment.yaml unsloth_compiled_cache/ # ML artifacts (large files) +feature/ outputs/ exports/ /datasets/ @@ -71,3 +72,5 @@ studio/backend/tests/ log_rtx.txt log.txt setup_leo.sh +server.pid +*.log diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py index a371338703..0315d0c31e 100644 --- a/studio/backend/routes/models.py +++ b/studio/backend/routes/models.py @@ -290,6 +290,10 @@ async def get_model_config( This endpoint wraps the backend load_model_defaults function. """ try: + from utils.models.model_config import is_local_path + if not is_local_path(model_name): + model_name = model_name.lower() + logger.info(f"Getting model config for: {model_name}") from utils.models.model_config import detect_audio_type # Load model defaults from backend diff --git a/studio/backend/utils/models/model_config.py b/studio/backend/utils/models/model_config.py index 5d50654ce8..59b3bc2f6e 100644 --- a/studio/backend/utils/models/model_config.py +++ b/studio/backend/utils/models/model_config.py @@ -374,7 +374,7 @@ MODEL_NAME_MAPPING = { _REVERSE_MODEL_MAPPING = {} for canonical_file, model_names in MODEL_NAME_MAPPING.items(): for model_name in model_names: - _REVERSE_MODEL_MAPPING[model_name] = canonical_file + _REVERSE_MODEL_MAPPING[model_name.lower()] = canonical_file def load_model_config(model_name: str, use_auth: bool = False, token: Optional[str] = None): """ @@ -1234,8 +1234,8 @@ def load_model_defaults(model_name: str) -> Dict[str, Any]: defaults_dir = script_dir / "assets" / "configs" / "model_defaults" # First, check if model is in the mapping - if model_name in _REVERSE_MODEL_MAPPING: - canonical_file = _REVERSE_MODEL_MAPPING[model_name] + if model_name.lower() in _REVERSE_MODEL_MAPPING: + canonical_file = _REVERSE_MODEL_MAPPING[model_name.lower()] # Search in subfolders and root for config_path in defaults_dir.rglob(canonical_file): if config_path.is_file(): @@ -1400,6 +1400,12 @@ class ModelConfig: identifier = f"unsloth/{identifier}" path = identifier + # Enforce lowercase for remote Hugging Face identifiers to prevent cache duplication + # Hugging Face Hub APIs are case-insensitive remotely, but case-sensitive locally (repo_folder_name). + if not is_local: + identifier = identifier.lower() + path = path.lower() + # Auto-detect GGUF models (check before LoRA/vision detection) if is_local: gguf_file = detect_gguf_model(path)