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
Studio: discover models installed through oMLX (#8937)
sts-changee2de76318a26
diff --git a/studio/backend/core/inference/local_model_resolver.py b/studio/backend/core/inference/local_model_resolver.pyindex 5c91ad6cd85..2bcd1bd9c1f 100644--- a/studio/backend/core/inference/local_model_resolver.py+++ b/studio/backend/core/inference/local_model_resolver.py@@ -866,6 +866,12 @@ def _build_index() -> dict[str, _LocalGgufEntry]:found += _scan_lmstudio_dir(lm_dir)except Exception as exc:logger.debug("auto-switch: LM Studio scan failed: %s", exc)+ try:+ from utils.paths import omlx_model_dirs+ for omlx_dir in omlx_model_dirs():+ found += _scan_hf_once(omlx_dir) + _scan_lmstudio_dir(omlx_dir, source = "omlx")+ except Exception as exc:+ logger.debug("auto-switch: oMLX scan failed: %s", exc)# Read-only like the LM Studio scan, so it is safe on the request path. This is the path Hermes# itself takes: it downloads the GGUF, then asks Unsloth for it by name.try:diff --git a/studio/backend/hub/schemas/inventory.py b/studio/backend/hub/schemas/inventory.pyindex 1518dec0bc0..909548ca065 100644--- a/studio/backend/hub/schemas/inventory.py+++ b/studio/backend/hub/schemas/inventory.py@@ -14,6 +14,9 @@ from core.inference.audio_workflows import inventory_audio_workflowsModelFormat = Literal["gguf", "safetensors", "adapter", "checkpoint", "unknown"]ModelRuntime = Literal["llama_cpp", "transformers", "adapter", "unknown"]+LocalModelSource = Literal[+ "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom"+]LocalArtifactKind = Literal["diffusers_pipeline","diffusers_modular_pipeline",@@ -183,7 +186,7 @@ class LocalModelInfo(BaseModel):default_factory = LocalModelCapabilities,description = "Declared capabilities for this inventory row",)- source: Literal["models_dir", "hf_cache", "lmstudio", "ollama", "hermes", "custom"] = Field(+ source: LocalModelSource = Field(...,description = "Discovery source",)diff --git a/studio/backend/hub/services/models/common.py b/studio/backend/hub/services/models/common.pyindex a1a5ee27dda..2de6dacf60a 100644--- a/studio/backend/hub/services/models/common.py+++ b/studio/backend/hub/services/models/common.py@@ -31,7 +31,9 @@ from utils.audio_tokens import detect_local_tts_audio_typefrom utils.paths.path_utils import drop_appledouble_metadata, is_appledouble_metadataModelType = Literal["text", "vision", "audio", "embeddings"]-LocalModelSource = Literal["models_dir", "hf_cache", "lmstudio", "ollama", "hermes", "custom"]+LocalModelSource = Literal[+ "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom"+]def _safe_is_dir(path) -> bool:diff --git a/studio/backend/hub/services/models/local_inventory.py b/studio/backend/hub/services/models/local_inventory.pyindex 7ffa8c09eed..8af73ab4500 100644--- a/studio/backend/hub/services/models/local_inventory.py+++ b/studio/backend/hub/services/models/local_inventory.py@@ -32,6 +32,7 @@ from hub.utils.paths import (lmstudio_model_dirs,normalize_path,ollama_model_dirs,+ omlx_model_dirs,outputs_root,path_is_same_or_child,studio_root,@@ -62,6 +63,7 @@ class _LocalInventorySources(NamedTuple):ollama_dirs: tuple[Path, ...]hermes_dirs: tuple[Path, ...]known_hf_caches: tuple[Path, ...]+ omlx_dirs: tuple[Path, ...] = ()_LocalInventoryKey = tuple[str, _LocalInventorySources, tuple[str, ...], int]@@ -82,6 +84,7 @@ class _LocalCacheChanged(RuntimeError):# Local aliases keep the extracted code close to the original implementation.+LocalModelSource = model_common.LocalModelSource_is_model_directory = model_common._is_model_directory_local_inventory_id = model_common._local_inventory_id_local_model_info = model_common._local_model_info@@ -337,6 +340,7 @@ def _local_inventory_sources() -> _LocalInventorySources:tuple(ollama_model_dirs()),tuple(hermes_model_dirs()),tuple(known_hf_hub_caches()),+ tuple(omlx_model_dirs()),)@@ -660,8 +664,14 @@ def _scan_hf_cache(return found-def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[LocalModelInfo]:- """Scan an LM Studio models dir (``publisher/model-name`` folders of GGUFs, or top-level standalone GGUFs)."""+def _scan_lmstudio_dir(+ lm_dir: Path,+ *,+ entry_limit: int | None = None,+ source: LocalModelSource = "lmstudio",+) -> List[LocalModelInfo]:+ """Scan a ``publisher/model-name`` tree (or top-level standalone GGUFs); LM Studio and oMLX+ share this layout, ``source`` names the app."""if not lm_dir.exists() or not lm_dir.is_dir():return []@@ -673,7 +683,7 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = Nonerows = _classify_local_path(lm_dir,- "lmstudio",+ source,updated_at = updated_at,)return _apply_payload_partial(lm_dir, rows)@@ -707,7 +717,7 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = Nonerows = _classify_local_path(child,- "lmstudio",+ source,updated_at = updated_at,)found.extend(_apply_payload_partial(child, rows))@@ -721,7 +731,7 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = Nonerows = _classify_local_path(child,- "lmstudio",+ source,updated_at = updated_at,)found.extend(_apply_payload_partial(child, rows))@@ -744,7 +754,7 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = Nonerows = _classify_local_path(model_dir,- "lmstudio",+ source,display_name = model_dir.name,model_id = model_id,updated_at = updated_at,@@ -761,7 +771,7 @@ def _scan_lmstudio_dir(lm_dir: Path, *, entry_limit: int | None = None) -> List[updated_at = Nonerows = _classify_local_path(model_dir,- "lmstudio",+ source,model_id = f"{child.name}/{model_dir.stem}",updated_at = updated_at,)@@ -952,6 +962,7 @@ async def _collect_models_from_default_sources(hermes_dirs: tuple[Path, ...],known_hf_caches: tuple[Path, ...],custom_folders: list[dict],+ omlx_dirs: tuple[Path, ...] = (),) -> List[LocalModelInfo]:local_models = await _scan_source("models directory", _scan_models_dir, models_root)hf_sources = [("HF cache", hf_cache_dir, True)]@@ -976,6 +987,12 @@ async def _collect_models_from_default_sources(continueseen_hf.add(key)hf_sources.append(("previous HF cache", previous_cache, False))+ # oMLX also serves models--* repos kept under its own roots.+ for omlx_dir in omlx_dirs:+ key = os.path.normcase(str(omlx_dir.resolve(strict = False)))+ if key not in seen_hf:+ seen_hf.add(key)+ hf_sources.append(("oMLX HF cache", omlx_dir, False))discovered_sources = []custom_sources = []@@ -1028,6 +1045,13 @@ async def _collect_models_from_default_sources(for lm_dir in lm_dirs:local_models += await _scan_source("LM Studio", _scan_lmstudio_dir, lm_dir)+ for omlx_dir in omlx_dirs:+ local_models += await _scan_source(+ "oMLX",+ lambda path: _scan_lmstudio_dir(path, source = "omlx"),+ omlx_dir,+ )+for ollama_dir in ollama_dirs:local_models += await _scan_source("Ollama", scan_ollama_dir, ollama_dir)@@ -1228,10 +1252,10 @@ async def _load_custom_folders() -> list[dict]:def _merge_custom_rows_listed_natively(custom_models: List[LocalModelInfo], native_models: List[LocalModelInfo]) -> tuple[list[LocalModelInfo], list[LocalModelInfo]]:- """A custom folder overlapping the models dir or LM Studio re-lists their models (#9164)."""+ """A custom folder overlapping the models dir, LM Studio or oMLX re-lists their models (#9164)."""native: dict[tuple[str, str], LocalModelInfo] = {}for model in native_models:- if model.source in ("models_dir", "lmstudio"):+ if model.source in ("models_dir", "lmstudio", "omlx"):native.setdefault((_inventory_physical_identity(model.path), model.model_format), model)if not native:return list(native_models), list(custom_models)@@ -1242,8 +1266,8 @@ def _merge_custom_rows_listed_natively(# A symlink below the scan root is a deliberate alias with its own settings (#10605), so it stays.if twin is None or _local_model_path_is_symlink(_custom_alias_key(model)):kept_custom.append(model)- elif twin.source == "lmstudio" and model.capabilities.can_train:- # The train picker refuses LM Studio rows, so the trainable custom row wins.+ elif twin.source in ("lmstudio", "omlx") and model.capabilities.can_train:+ # The train picker refuses LM Studio and oMLX rows, so the trainable custom row wins.replaced.add(id(twin))kept_custom.append(model)return [m for m in native_models if id(m) not in replaced], kept_custom@@ -1317,9 +1341,16 @@ async def _scan_local_models_response(models_dir: str, custom_folders: list[dict], sources: _LocalInventorySources) -> LocalModelListResponse:"""List local model candidates from every supported on-device source."""- hf_cache_dir, legacy_hf, hf_default, lm_dirs, ollama_dirs, hermes_dirs, known_hf_caches = (- sources- )+ (+ hf_cache_dir,+ legacy_hf,+ hf_default,+ lm_dirs,+ ollama_dirs,+ hermes_dirs,+ known_hf_caches,+ omlx_dirs,+ ) = sourcesallowed_roots: list[Path] = [Path("./models").resolve(), hf_cache_dir]if _safe_is_dir(legacy_hf):@@ -1344,6 +1375,7 @@ async def _scan_local_models_response(hermes_dirs,known_hf_caches,custom_folders,+ omlx_dirs = omlx_dirs,)models = await asyncio.to_thread(_filter_and_dedupe_local_models, local_models)return LocalModelListResponse(diff --git a/studio/backend/hub/utils/host_paths.py b/studio/backend/hub/utils/host_paths.pyindex 53cbf4d6636..ae2eef9d5f6 100644--- a/studio/backend/hub/utils/host_paths.py+++ b/studio/backend/hub/utils/host_paths.py@@ -115,7 +115,9 @@ HOST_PATH_ROW_IDENTITY_FIELDS = ("id", "load_id")HOST_PATH_ENCODED_IDENTITY_FIELD = "inventory_id"HOST_PATH_ROW_SOURCE_FIELD = "source"# `hf_cache` is absent: those rows are named by repo id, and otherwise value decides.-HOST_PATH_LOCAL_SOURCES = frozenset({"models_dir", "lmstudio", "ollama", "hermes", "custom"})+HOST_PATH_LOCAL_SOURCES = frozenset(+ {"models_dir", "lmstudio", "omlx", "ollama", "hermes", "custom"}+)def _row_identity_is_a_path(payload: Mapping) -> bool:diff --git a/studio/backend/hub/utils/paths.py b/studio/backend/hub/utils/paths.pyindex 96d319e5707..c17cd1aa941 100644--- a/studio/backend/hub/utils/paths.py+++ b/studio/backend/hub/utils/paths.py@@ -33,6 +33,7 @@ from utils.paths.storage_roots import (hf_default_cache_dir,lmstudio_model_dirs,ollama_model_dirs,+ omlx_model_dirs,well_known_model_dirs,)@@ -43,6 +44,7 @@ _REEXPORTED = (hermes_model_dirs,lmstudio_model_dirs,ollama_model_dirs,+ omlx_model_dirs,well_known_model_dirs,studio_root,cache_root,@@ -355,6 +357,7 @@ __all__ = ["lmstudio_model_dirs","normalize_path","ollama_model_dirs",+ "omlx_model_dirs","outputs_root","path_is_same_or_child","recipe_datasets_root",diff --git a/studio/backend/models/models.py b/studio/backend/models/models.pyindex 071b319baf6..37bdbfb6539 100644--- a/studio/backend/models/models.py+++ b/studio/backend/models/models.py@@ -251,13 +251,18 @@ class GgufVariantsResponse(BaseModel):)+LocalModelSource = Literal[+ "models_dir", "hf_cache", "lmstudio", "omlx", "ollama", "hermes", "custom"+]++class LocalModelInfo(BaseModel):"""Discovered local model candidate."""id: str = Field(..., description = "Identifier to use for loading/training")display_name: str = Field(..., description = "Display label")path: str = Field(..., description = "Local path where model data was discovered")- source: Literal["models_dir", "hf_cache", "lmstudio", "ollama", "hermes", "custom"] = Field(+ source: LocalModelSource = Field(...,description = "Discovery source",)diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.pyindex f6fa076f5df..7c6f411e390 100644--- a/studio/backend/routes/models.py+++ b/studio/backend/routes/models.py@@ -321,6 +321,7 @@ from models.models import (ExportSizeResponse,GgufVariantDetail,GgufVariantsResponse,+ LocalModelSource,ModelType,ScanFolderInfo,AddScanFolderRequest,@@ -645,9 +646,10 @@ def _dir_model_format(path: Path, recursive: bool = False) -> Optional[str]:return None-def _scan_lmstudio_dir(lm_dir: Path) -> List[LocalModelInfo]:- """Scan an LM Studio models directory: ``publisher/model-name`` folders of GGUF files, or- standalone GGUFs at the top level."""+def _scan_lmstudio_dir(+ lm_dir: Path, *, source: LocalModelSource = "lmstudio"+) -> List[LocalModelInfo]:+ """Scan a host-app model root; ``source`` names which app it belongs to."""if not lm_dir.exists() or not lm_dir.is_dir():return []@@ -662,7 +664,7 @@ def _scan_lmstudio_dir(lm_dir: Path) -> List[LocalModelInfo]:id = str(lm_dir),display_name = lm_dir.name,path = str(lm_dir),- source = "lmstudio",+ source = source,model_format = _dir_model_format(lm_dir),updated_at = updated_at,),@@ -686,7 +688,7 @@ def _scan_lmstudio_dir(lm_dir: Path) -> List[LocalModelInfo]:id = str(child),display_name = child.stem,path = str(child),- source = "lmstudio",+ source = source,model_format = "gguf",updated_at = updated_at,),@@ -704,7 +706,7 @@ def _scan_lmstudio_dir(lm_dir: Path) -> List[LocalModelInfo]:id = str(child),display_name = child.name,path = str(child),- source = "lmstudio",+ source = source,model_format = _dir_model_format(child),updated_at = updated_at,),@@ -735,7 +737,7 @@ def _scan_lmstudio_dir(lm_dir: Path) -> List[LocalModelInfo]:model_id = model_id,display_name = model_dir.name,path = str(model_dir),- source = "lmstudio",+ source = source,model_format = _dir_model_format(model_dir),updated_at = updated_at,),@@ -755,7 +757,7 @@ def _scan_lmstudio_dir(lm_dir: Path) -> List[LocalModelInfo]:model_id = f"{child.name}/{model_dir.stem}",display_name = model_dir.stem,path = str(model_dir),- source = "lmstudio",+ source = source,model_format = "gguf",updated_at = updated_at,),@@ -804,6 +806,7 @@ class _CompatLocalInventorySources(NamedTuple):known_hf_caches: tuple[Path, ...]hermes_dirs: tuple[Path, ...] = ()ollama_dirs: tuple[Path, ...] = ()+ omlx_dirs: tuple[Path, ...] = ()def _compat_local_inventory_sources() -> _CompatLocalInventorySources:@@ -813,6 +816,7 @@ def _compat_local_inventory_sources() -> _CompatLocalInventorySources:hf_default_cache_dir,legacy_hf_cache_dir,lmstudio_model_dirs,+ omlx_model_dirs,)from utils.hf_cache_settings import known_hf_hub_cachesreturn _CompatLocalInventorySources(@@ -823,6 +827,7 @@ def _compat_local_inventory_sources() -> _CompatLocalInventorySources:tuple(known_hf_hub_caches()),tuple(hermes_model_dirs()),tuple(ollama_model_dirs()),+ tuple(omlx_model_dirs()),)@@ -900,6 +905,8 @@ def collect_local_models(*sources.known_hf_caches,legacy_hf,hf_default,+ # oMLX also serves models--* repos kept under its own roots.+ *sources.omlx_dirs,):cache_real = _safe_resolve(cache_dir)if cache_real is None:@@ -957,9 +964,18 @@ def collect_local_models(except Exception as e:logger.warning("Error scanning Ollama directory %s: %s", ollama_dir, e)+ for omlx_dir in sources.omlx_dirs:+ try:+ local_models += _scan_lmstudio_dir(omlx_dir, source = "omlx")+ except Exception as e:+ logger.warning("Error scanning oMLX directory %s: %s", omlx_dir, e)+# Scan user-added custom folders (per-folder cap)._MAX_MODELS_PER_FOLDER = 200hermes_identities = {_compat_inventory_path_identity(str(d)) for d in sources.hermes_dirs}+ from hub.services.models.local_inventory import _local_model_path_is_symlink++ custom_identities: set[str] = set()for folder in custom_folders:folder_path = Path(folder["path"])try:@@ -1034,6 +1050,16 @@ def collect_local_models(record_scan_failure(str(folder.get("path", folder_path)), e)continuenote_scan_folder_scanned(str(folder.get("path", folder_path)), found = bool(custom_models))+ # Links below the scan root are distinct aliases (as in the Hub inventory), not twins.+ for m in custom_models:+ try:+ below_root = os.path.join(+ os.path.realpath(folder_path), os.path.relpath(m.path, folder_path)+ )+ except (OSError, ValueError):+ continue+ if not _local_model_path_is_symlink(below_root):+ custom_identities.add(_compat_inventory_path_identity(m.path))# Keep an already-attributed source: a registered ~/.ollama/models (or a folder shadowing the HF# cache) must not re-stamp its rows as generic custom entries.local_models += [@@ -1043,6 +1069,14 @@ def collect_local_models(for m in custom_models]+ # A registered oMLX root (the pre-scan workaround) lists its models as custom rows too; keep+ # those (the train picker refuses oMLX rows).+ local_models = [+ m+ for m in local_models+ if m.source != "omlx" or _compat_inventory_path_identity(m.path) not in custom_identities+ ]+# Deduplicate, but always keep custom folder entries (keyed by (id, source)) so they show in the# "Custom Folders" UI section even when the model is also in the HF cache.deduped: dict[str, LocalModelInfo] = {}diff --git a/studio/backend/tests/test_export_absolute_paths.py b/studio/backend/tests/test_export_absolute_paths.pyindex 4b8e9fe2089..a8e3ee74c79 100644--- a/studio/backend/tests/test_export_absolute_paths.py+++ b/studio/backend/tests/test_export_absolute_paths.py@@ -228,6 +228,7 @@ def _install_lightweight_backend_stubs(monkeypatch):):setattr(models_models, name, object)models_models.ModelType = str+ models_models.LocalModelSource = strmonkeypatch.setitem(sys.modules, "models.models", models_models)models_responses = types.ModuleType("models.responses")diff --git a/studio/backend/tests/test_omlx_model_discovery.py b/studio/backend/tests/test_omlx_model_discovery.pynew file mode 100644index 00000000000..32a25f11ecd--- /dev/null+++ b/studio/backend/tests/test_omlx_model_discovery.py@@ -0,0 +1,333 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.++"""oMLX (https://github.com/jundot/omlx) model roots reach both local inventories."""++import asyncio+import json+from pathlib import Path++import pytest++import hub.services.models.local_inventory as local_inventory+import hub.utils.paths as hub_paths+import routes.models as models_route+import utils.paths.storage_roots as storage_roots+++def _write_mlx_model(+ root: Path,+ org: str,+ name: str,+ *,+ shards: int = 1,+) -> Path:+ model_dir = root / org / name+ model_dir.mkdir(parents = True)+ config = {"model_type": "qwen3", "quantization": {"group_size": 64, "bits": 4}}+ (model_dir / "config.json").write_text(json.dumps(config), encoding = "utf-8")+ (model_dir / "tokenizer_config.json").write_text("{}", encoding = "utf-8")+ if shards == 1:+ (model_dir / "model.safetensors").write_bytes(b"weights")+ else:+ names = [f"model-{i + 1:05d}-of-{shards:05d}.safetensors" for i in range(shards)]+ index = {"weight_map": {f"l{i}": n for i, n in enumerate(names)}}+ (model_dir / "model.safetensors.index.json").write_text(json.dumps(index), encoding = "utf-8")+ for n in names:+ (model_dir / n).write_bytes(b"weights")+ return model_dir+++def _write_hf_cache_repo(cache: Path, org: str, name: str) -> Path:+ repo = cache / f"models--{org}--{name}"+ blobs = repo / "blobs"+ snapshot = repo / "snapshots" / "abc123"+ blobs.mkdir(parents = True)+ snapshot.mkdir(parents = True)+ (repo / "refs").mkdir()+ (repo / "refs" / "main").write_text("abc123", encoding = "utf-8")+ contents = {+ "config.json": json.dumps({"model_type": "qwen3"}),+ "tokenizer_config.json": "{}",+ "model.safetensors": "weights",+ }+ for index, (filename, body) in enumerate(contents.items()):+ blob = blobs / f"blob{index}"+ blob.write_text(body, encoding = "utf-8")+ (snapshot / filename).symlink_to(blob)+ return snapshot+++def home(monkeypatch, tmp_path):+ monkeypatch.setattr(storage_roots.Path, "home", staticmethod(lambda: tmp_path))+ monkeypatch.delenv("OMLX_BASE_PATH", raising = False)+ monkeypatch.delenv("OMLX_MODEL_DIR", raising = False)+ return tmp_path+++def _write_settings(base: Path, model: dict) -> None:+ base.mkdir(parents = True, exist_ok = True)+ (base / "settings.json").write_text(json.dumps({"model": model}), encoding = "utf-8")+++def test_hub_paths_reexports_the_one_resolver():+ assert hub_paths.omlx_model_dirs is storage_roots.omlx_model_dirs+++def test_default_models_dir_without_settings(home):+ models = home / ".omlx" / "models"+ models.mkdir(parents = True)+ assert storage_roots.omlx_model_dirs() == [models]+++def test_no_omlx_install_yields_nothing(home):+ assert storage_roots.omlx_model_dirs() == []+++def test_model_dirs_replace_the_default(home):+ first, second = home / "vol" / "one", home / "vol" / "two"+ first.mkdir(parents = True)+ second.mkdir(parents = True)+ (home / ".omlx" / "models").mkdir(parents = True)+ _write_settings(home / ".omlx", {"model_dirs": [str(first), str(second)]})+ assert storage_roots.omlx_model_dirs() == [first, second]+++def test_legacy_model_dir_used_when_model_dirs_empty(home):+ configured = home / "vol" / "single"+ configured.mkdir(parents = True)+ _write_settings(home / ".omlx", {"model_dirs": [], "model_dir": str(configured)})+ assert storage_roots.omlx_model_dirs() == [configured]+++def test_unreadable_settings_fall_back_to_default(home):+ models = home / ".omlx" / "models"+ models.mkdir(parents = True)+ (home / ".omlx" / "settings.json").write_text("{not json", encoding = "utf-8")+ assert storage_roots.omlx_model_dirs() == [models]+++def test_duplicate_and_missing_roots_are_dropped(home):+ models = home / ".omlx" / "models"+ models.mkdir(parents = True)+ _write_settings(home / ".omlx", {"model_dirs": [str(models), str(home / "gone"), str(models)]})+ assert storage_roots.omlx_model_dirs() == [models]+++def test_lmstudio_root_listed_by_omlx_is_not_returned(home):+ lmstudio = home / ".lmstudio" / "models"+ lmstudio.mkdir(parents = True)+ omlx = home / ".omlx" / "models"+ omlx.mkdir(parents = True)+ _write_settings(home / ".omlx", {"model_dirs": [str(omlx), str(lmstudio)]})+ assert storage_roots.omlx_model_dirs() == [omlx]+++def test_base_path_env_overrides_bootstrap_and_default(home, monkeypatch):+ (home / ".omlx" / "models").mkdir(parents = True)+ moved = home / "moved"+ (moved / "models").mkdir(parents = True)+ monkeypatch.setenv("OMLX_BASE_PATH", str(moved))+ assert storage_roots.omlx_model_dirs() == [moved / "models"]+++def test_model_dir_env_overrides_settings(home, monkeypatch):+ first, second, saved = home / "a", home / "b", home / "saved"+ for d in (first, second, saved):+ d.mkdir()+ _write_settings(home / ".omlx", {"model_dirs": [str(saved)]})+ monkeypatch.setenv("OMLX_MODEL_DIR", f"{first}, {second}")+ assert storage_roots.omlx_model_dirs() == [first, second]+++def test_macos_bootstrap_file_moves_the_base(home):+ moved = home / "Volumes" / "ext" / "omlx"+ configured = home / "Volumes" / "ext" / "weights"+ configured.mkdir(parents = True)+ _write_settings(moved, {"model_dirs": [str(configured)]})+ bootstrap = home / "Library" / "Application Support" / "oMLX" / "base-path"+ bootstrap.parent.mkdir(parents = True)+ bootstrap.write_text(f"{moved}\n", encoding = "utf-8")+ assert storage_roots.omlx_model_dirs() == [configured]+++def _hub_rows(cache: Path, empty: Path, omlx_root: Path):+ sources = local_inventory._LocalInventorySources(+ cache, empty, empty, (), (), (), (), omlx_dirs = (omlx_root,)+ )+ return asyncio.run(local_inventory._scan_local_models_response(str(empty), [], sources)).models+++def _compat_rows(cache: Path, empty: Path, omlx_root: Path):+ sources = models_route._CompatLocalInventorySources(+ cache, empty, empty, (), (), omlx_dirs = (omlx_root,)+ )+ return models_route.collect_local_models(empty, custom_folders = [], sources = sources)++[email protected](params = ["hub", "compat"])+def collector(request, tmp_path):+ empty = tmp_path / "_empty"+ empty.mkdir()+ scan = _hub_rows if request.param == "hub" else _compat_rows+ return lambda cache, root: scan(cache, empty, root)+++def test_hub_sources_include_omlx_roots(monkeypatch, tmp_path):+ monkeypatch.setattr(local_inventory, "omlx_model_dirs", lambda: [tmp_path])+ assert local_inventory._local_inventory_sources().omlx_dirs == (tmp_path,)+++def test_compat_sources_include_omlx_roots(monkeypatch, tmp_path):+ import utils.paths as utils_paths+ monkeypatch.setattr(utils_paths, "omlx_model_dirs", lambda: [tmp_path])+ assert models_route._compat_local_inventory_sources().omlx_dirs == (tmp_path,)+++def test_omlx_rows_report_the_omlx_source(collector, tmp_path):+ cache = tmp_path / "hf"+ cache.mkdir()+ _write_mlx_model(tmp_path / "omlx", "mlx-community", "Qwen3-4bit", shards = 2)++ rows = collector(cache, tmp_path / "omlx")++ assert [(m.source, m.model_id) for m in rows] == [("omlx", "mlx-community/Qwen3-4bit")]+++ "scan", [local_inventory._scan_lmstudio_dir, models_route._scan_lmstudio_dir]+)+def test_source_is_the_only_difference_from_an_lmstudio_root(scan, tmp_path):+ _write_mlx_model(tmp_path, "mlx-community", "Same-4bit", shards = 2)++ (as_omlx,) = [m.model_dump() for m in scan(tmp_path, source = "omlx")]+ (as_lmstudio,) = [m.model_dump() for m in scan(tmp_path)]++ differing = {k for k in as_omlx if as_omlx[k] != as_lmstudio.get(k)}+ assert as_lmstudio["source"] == "lmstudio"+ assert differing <= {"source", "inventory_id"} and "source" in differing+++def test_folder_linking_into_hf_cache_is_listed_with_the_repo(collector, tmp_path):+ cache = tmp_path / "hf" / "hub"+ snapshot = _write_hf_cache_repo(cache, "mlx-community", "Shared-4bit")+ model = tmp_path / "omlx" / "mlx-community" / "Shared-4bit"+ model.mkdir(parents = True)+ for entry in snapshot.iterdir():+ (model / entry.name).symlink_to(entry)++ rows = collector(cache, tmp_path / "omlx")++ assert [Path(m.path).name for m in rows if m.source == "omlx"] == ["Shared-4bit"]+ assert any(m.source == "hf_cache" for m in rows)+++def test_flat_folder_inside_an_hf_cache_root_is_found(collector, tmp_path):+ # oMLX can list the HF cache itself; its flat <publisher>__<model> folders are invisible to+ # the models--* walk.+ cache = tmp_path / "hub"+ snapshot = _write_hf_cache_repo(cache, "mlx-community", "Shared-4bit")+ flat = cache / "mlx-community__Shared-4bit"+ flat.mkdir()+ for entry in snapshot.iterdir():+ (flat / entry.name).symlink_to(entry)++ rows = collector(cache, cache)++ assert [Path(m.path).name for m in rows if m.source == "omlx"] == ["mlx-community__Shared-4bit"]+++def test_omlx_root_registered_as_a_scan_folder_is_listed_once(monkeypatch, tmp_path):+ # Registering ~/.omlx/models as a custom folder was the workaround before this scan.+ root = tmp_path / ".omlx" / "models"+ model = _write_mlx_model(root, "mlx-community", "Qwen3-4bit")+ monkeypatch.setattr(local_inventory, "note_scan_folder_scanned", lambda *_a, **_k: None)+ monkeypatch.setattr(local_inventory, "record_scan_failure", lambda *_a, **_k: None)++ rows = asyncio.run(+ local_inventory._collect_models_from_default_sources(+ tmp_path / "models",+ tmp_path / "hf",+ tmp_path / "legacy",+ tmp_path / "default",+ (),+ (),+ (),+ (),+ [{"path": str(root)}],+ omlx_dirs = (root,),+ )+ )+ rows = local_inventory._filter_and_dedupe_local_models(rows)++ # Trainable, so the custom twin wins: the train picker refuses oMLX rows.+ assert [(row.source, row.path) for row in rows] == [("custom", str(model))]+++def test_compat_omlx_root_registered_as_a_scan_folder_is_listed_once(tmp_path):+ root = tmp_path / ".omlx" / "models"+ model = _write_mlx_model(root, "mlx-community", "Qwen3-4bit")+ empty = tmp_path / "_empty"+ empty.mkdir()+ sources = models_route._CompatLocalInventorySources(+ empty, empty, empty, (), (), omlx_dirs = (root,)+ )++ rows = models_route.collect_local_models(+ empty, custom_folders = [{"path": str(root)}], sources = sources+ )++ assert [(row.source, row.path) for row in rows] == [("custom", str(model))]++[email protected]("link_publisher", [False, True])+def test_compat_custom_symlink_alias_into_an_omlx_root_is_kept(tmp_path, link_publisher):+ root = tmp_path / "omlx"+ model = _write_mlx_model(root, "mlx-community", "Qwen3-4bit")+ custom = tmp_path / "custom"+ custom.mkdir()+ if link_publisher:+ (custom / "mlx-community").symlink_to(model.parent, target_is_directory = True)+ else:+ (custom / "Qwen3-4bit-alias").symlink_to(model, target_is_directory = True)+ empty = tmp_path / "_empty"+ empty.mkdir()+ sources = models_route._CompatLocalInventorySources(+ empty, empty, empty, (), (), omlx_dirs = (root,)+ )++ rows = models_route.collect_local_models(+ empty, custom_folders = [{"path": str(custom)}], sources = sources+ )++ assert sorted(row.source for row in rows) == ["custom", "omlx"]+++def test_resolver_index_scans_omlx_roots(monkeypatch, tmp_path):+ # MLX weights are servable only on Apple Silicon, so assert the scan feeds the index.+ import core.inference.local_model_resolver as resolver+ import utils.paths as utils_paths++ root = tmp_path / "omlx"+ model = _write_mlx_model(root, "mlx-community", "OnlyInOmlx-4bit")+ monkeypatch.setattr(utils_paths, "omlx_model_dirs", lambda: [root])+ seen = []+ monkeypatch.setattr(+ resolver, "_local_servable_entry", lambda _id, info: seen.append(info) and None+ )++ resolver._build_index()++ assert ("omlx", str(model)) in [(i.source, i.path) for i in seen]+++def test_hf_cache_repos_under_an_omlx_root_are_listed(collector, tmp_path):+ active = tmp_path / "active"+ active.mkdir()+ external = tmp_path / "external-hub"+ _write_hf_cache_repo(external, "mlx-community", "External-4bit")++ rows = collector(active, external)++ assert [(m.source, m.model_id) for m in rows] == [("hf_cache", "mlx-community/External-4bit")]diff --git a/studio/backend/utils/paths/__init__.py b/studio/backend/utils/paths/__init__.pyindex 1295d82c5ba..49b9a7a7904 100644--- a/studio/backend/utils/paths/__init__.py+++ b/studio/backend/utils/paths/__init__.py@@ -43,6 +43,7 @@ from .storage_roots import (lmstudio_model_dirs,ollama_model_dirs,hermes_model_dirs,+ omlx_model_dirs,well_known_model_dirs,ensure_account_dir,ensure_dir,@@ -98,6 +99,7 @@ __all__ = ["lmstudio_model_dirs","ollama_model_dirs","hermes_model_dirs",+ "omlx_model_dirs","well_known_model_dirs","ensure_account_dir","ensure_dir",diff --git a/studio/backend/utils/paths/storage_roots.py b/studio/backend/utils/paths/storage_roots.pyindex 9c16255990d..532a86470b7 100644--- a/studio/backend/utils/paths/storage_roots.py+++ b/studio/backend/utils/paths/storage_roots.py@@ -667,6 +667,67 @@ def hermes_model_dirs() -> list[Path]:)+def _omlx_base_path() -> Path:+ """oMLX's data root, resolved as its own ``resolve_default_base_path`` does:+ ``OMLX_BASE_PATH`` > the macOS app's bootstrap file > ``~/.omlx``."""+ env_value = os.environ.get("OMLX_BASE_PATH", "").strip()+ if env_value:+ return Path(env_value).expanduser()+ bootstrap = Path.home() / "Library" / "Application Support" / "oMLX" / "base-path"+ try:+ raw = bootstrap.read_text(encoding = "utf-8").strip()+ except (OSError, UnicodeDecodeError):+ raw = ""+ return Path(raw).expanduser() if raw else Path.home() / ".omlx"+++def _omlx_configured_dirs(base: Path) -> list[str]:+ """``model.model_dirs``, else the legacy ``model.model_dir``, from oMLX's settings.json."""+ settings_path = base / "settings.json"+ if not settings_path.is_file():+ return []+ try:+ settings = json.loads(settings_path.read_text(encoding = "utf-8-sig"))+ model_settings = settings.get("model") or {}+ configured = model_settings.get("model_dirs") or []+ if isinstance(configured, str):+ configured = [configured]+ if not configured and model_settings.get("model_dir"):+ configured = [model_settings["model_dir"]]+ return [d for d in configured if isinstance(d, str) and d]+ except Exception as exc:+ logger.debug("Ignoring unreadable oMLX settings at %s: %s", settings_path, exc)+ return []+++def omlx_model_dirs() -> list[Path]:+ """Return oMLX model directories that exist on disk.++ oMLX keeps the same ``publisher/model`` layout as LM Studio and can list LM Studio's+ folder among its own roots; that one is dropped so it is not scanned twice. An HF cache+ root stays: its ``models--*`` walk cannot see oMLX's flat folders beside those repos.+ """+ base = _omlx_base_path()+ # oMLX applies OMLX_MODEL_DIR (comma-separated) over settings.json.+ env_dirs = [d.strip() for d in os.environ.get("OMLX_MODEL_DIR", "").split(",") if d.strip()]+ candidates: list[str | Path] = env_dirs or _omlx_configured_dirs(base) or [base / "models"]+ lmstudio = set()+ for path in lmstudio_model_dirs():+ try:+ lmstudio.add(str(path.resolve()))+ except (OSError, RuntimeError, ValueError):+ continue+ out = []+ for path in _existing_dirs(candidates, resolve = False):+ try:+ if str(path.resolve()) in lmstudio:+ continue+ except (OSError, RuntimeError, ValueError):+ continue+ out.append(path)+ return out++def well_known_model_dirs() -> list[Path]:"""Return directories commonly used by other local LLM tools.diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex 9d3da38ca6a..6cdbc167a45 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -2697,6 +2697,7 @@ const NON_CHAT_TASKS: ReadonlySet<string> = new Set([const AUTO_LOAD_LOCAL_SOURCES: ReadonlySet<string> = new Set(["models_dir","lmstudio",+ "omlx","hermes","custom",]);diff --git a/studio/frontend/src/features/chat/api/chat-api.ts b/studio/frontend/src/features/chat/api/chat-api.tsindex f2529b054e0..7f12f1de38e 100644--- a/studio/frontend/src/features/chat/api/chat-api.ts+++ b/studio/frontend/src/features/chat/api/chat-api.ts@@ -648,7 +648,7 @@ export interface LocalModelInfo {id: string;display_name: string;path: string;- source: "models_dir" | "hf_cache" | "lmstudio" | "ollama" | "hermes" | "custom";+ source: "models_dir" | "hf_cache" | "lmstudio" | "omlx" | "ollama" | "hermes" | "custom";model_id?: string | null;// Backend-detected weights format ("gguf" when known), for folders whose name lacks -GGUF.model_format?: string | null;diff --git a/studio/frontend/src/features/chat/local-model-options.ts b/studio/frontend/src/features/chat/local-model-options.tsindex c28542bb4f7..d8d128115cd 100644--- a/studio/frontend/src/features/chat/local-model-options.ts+++ b/studio/frontend/src/features/chat/local-model-options.ts@@ -10,6 +10,7 @@ import type { LoraModelOption } from "@/features/model-picker";* `materialize_ollama_model_ref`, which creates the `.gguf` link on demand. */const CHAT_LOCAL_SOURCES: ReadonlySet<LocalModelInfo["source"]> = new Set(["lmstudio",+ "omlx","models_dir","ollama","hermes",@@ -20,6 +21,8 @@ function baseModelLabel(source: LocalModelInfo["source"]): string {switch (source) {case "lmstudio":return "LM Studio";+ case "omlx":+ return "oMLX";case "ollama":return "Ollama";case "hermes":diff --git a/studio/frontend/src/features/hub/inventory/constants.ts b/studio/frontend/src/features/hub/inventory/constants.tsindex 0c0fbcbcc5b..c9b4fac0172 100644--- a/studio/frontend/src/features/hub/inventory/constants.ts+++ b/studio/frontend/src/features/hub/inventory/constants.ts@@ -5,6 +5,7 @@ export const LOCAL_MODEL_SOURCE = {MODELS_DIR: "models_dir",HF_CACHE: "hf_cache",LMSTUDIO: "lmstudio",+ OMLX: "omlx",OLLAMA: "ollama",HERMES: "hermes",CUSTOM: "custom",@@ -14,6 +15,7 @@ export const LOCAL_MODEL_SOURCES = [LOCAL_MODEL_SOURCE.MODELS_DIR,LOCAL_MODEL_SOURCE.HF_CACHE,LOCAL_MODEL_SOURCE.LMSTUDIO,+ LOCAL_MODEL_SOURCE.OMLX,LOCAL_MODEL_SOURCE.OLLAMA,LOCAL_MODEL_SOURCE.HERMES,LOCAL_MODEL_SOURCE.CUSTOM,diff --git a/studio/frontend/src/features/hub/inventory/view-models.ts b/studio/frontend/src/features/hub/inventory/view-models.tsindex a3eef280a0d..76eb93b5f43 100644--- a/studio/frontend/src/features/hub/inventory/view-models.ts+++ b/studio/frontend/src/features/hub/inventory/view-models.ts@@ -20,6 +20,8 @@ export function localSourceLabel(source: LocalModelInfo["source"]): string {switch (source) {case "lmstudio":return "LM Studio";+ case "omlx":+ return "oMLX";case "ollama":return "Ollama";case "hermes":@@ -238,6 +240,7 @@ function sourceSortWeight(source: LocalModelInfo["source"]): number {case "custom":return 1;case "lmstudio":+ case "omlx":return 2;case "ollama":return 3;diff --git a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsxindex 1483ace6c28..1c19789be46 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx+++ b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx@@ -3368,14 +3368,15 @@ export function HubModelPicker({);// Ollama rows list alongside custom folders: both are user-managed stores outside ./models,// and an Ollama root added as a custom folder is where the rows were expected (#9226).- // Hermes' one-click downloads are the same kind of store; a source in no bucket never renders.+ // Hermes and oMLX downloads are the same kind of store; a source in no bucket never renders.const customFolderModels = useMemo(() =>pickerInventory.localModels.filter((m) =>m.source === "custom" ||m.source === "ollama" ||- m.source === "hermes",+ m.source === "hermes" ||+ m.source === "omlx",),[pickerInventory.localModels],);diff --git a/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.ts b/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.tsindex 724dd628946..5ac0a262018 100644--- a/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.ts+++ b/studio/frontend/src/features/model-picker/inventory/use-chat-picker-inventory.ts@@ -24,6 +24,7 @@ import {const PICKER_LOCAL_SOURCES: ReadonlySet<LocalSource> = new Set(["lmstudio",+ "omlx","models_dir","ollama","hermes",diff --git a/studio/frontend/src/features/recipe-studio/dialogs/models/local-recipe-model-selector.tsx b/studio/frontend/src/features/recipe-studio/dialogs/models/local-recipe-model-selector.tsxindex d1b4933bfaa..c830c7ac9b7 100644--- a/studio/frontend/src/features/recipe-studio/dialogs/models/local-recipe-model-selector.tsx+++ b/studio/frontend/src/features/recipe-studio/dialogs/models/local-recipe-model-selector.tsx@@ -76,6 +76,8 @@ function sourceLabel(model: LocalModelInfo): string {return "HF cache";case "lmstudio":return "LM Studio";+ case "omlx":+ return "oMLX";case "ollama":return "Ollama";case "hermes":diff --git a/studio/frontend/src/features/train-model-picker/components/train-model-selector.tsx b/studio/frontend/src/features/train-model-picker/components/train-model-selector.tsxindex a9321f93beb..2ce2bb1d3e1 100644--- a/studio/frontend/src/features/train-model-picker/components/train-model-selector.tsx+++ b/studio/frontend/src/features/train-model-picker/components/train-model-selector.tsx@@ -345,7 +345,12 @@ export function TrainModelSelector({if (row.partial) {return false;}- if (row.source === "lmstudio" || row.source === "ollama") {+ // Host-app stores hold pre-quantized inference weights, not training bases.+ if (+ row.source === "lmstudio" ||+ row.source === "omlx" ||+ row.source === "ollama"+ ) {return false;}if (!row.capabilities.canTrain) {diff --git a/studio/frontend/src/features/training/api/models-api.ts b/studio/frontend/src/features/training/api/models-api.tsindex 0b484ef2acd..a6ba9d52b55 100644--- a/studio/frontend/src/features/training/api/models-api.ts+++ b/studio/frontend/src/features/training/api/models-api.ts@@ -93,7 +93,7 @@ export interface LocalModelInfo {id: string;display_name: string;path: string;- source: "models_dir" | "hf_cache" | "lmstudio" | "ollama" | "hermes" | "custom";+ source: "models_dir" | "hf_cache" | "lmstudio" | "omlx" | "ollama" | "hermes" | "custom";model_id?: string | null;updated_at?: number | null;}diff --git a/studio/frontend/tests/chat-local-model-options.test.ts b/studio/frontend/tests/chat-local-model-options.test.tsindex eb120403fd8..6ab83f467cc 100644--- a/studio/frontend/tests/chat-local-model-options.test.ts+++ b/studio/frontend/tests/chat-local-model-options.test.ts@@ -125,3 +125,17 @@ test("custom and models_dir rows keep the labels the picker groups on", () => {["Custom Folders", "Local models"],);});++test("an oMLX row is offered and labelled oMLX", () => {+ const options = chatLocalModelOptions([+ row({+ id: "/Users/u/.omlx/models/mlx-community/Qwen3.8-27B-4bit",+ path: "/Users/u/.omlx/models/mlx-community/Qwen3.8-27B-4bit",+ display_name: "Qwen3.8-27B-4bit",+ source: "omlx",+ model_format: "safetensors",+ }),+ ]);+ assert.equal(options.length, 1);+ assert.equal(options[0].baseModel, "oMLX");+});diff --git a/studio/frontend/tests/hub-local-source-label.test.ts b/studio/frontend/tests/hub-local-source-label.test.tsnew file mode 100644index 00000000000..55336bf92f3--- /dev/null+++ b/studio/frontend/tests/hub-local-source-label.test.ts@@ -0,0 +1,26 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test from "node:test";++import { registerBundlerResolver } from "./helpers/kit.ts";++registerBundlerResolver();++const { localSourceLabel } = await import(+ "../src/features/hub/inventory/view-models.ts"+);+const { LOCAL_MODEL_SOURCES } = await import(+ "../src/features/hub/inventory/constants.ts"+);++test("every known local source has its own label, not the generic fallback", () => {+ for (const source of LOCAL_MODEL_SOURCES) {+ assert.notEqual(+ localSourceLabel(source),+ "Local model",+ `${source} falls through to the generic label`,+ );+ }+});