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 the Unsloth Studio MLX pins to mlx-vlm 0.7.8 (#13699)

Long Yixing48b4ca249d90
diff --git a/studio/backend/tests/test_mlx_inference_backend.py b/studio/backend/tests/test_mlx_inference_backend.py
index ced42257845..dac313f7f7b 100644
--- a/studio/backend/tests/test_mlx_inference_backend.py
+++ b/studio/backend/tests/test_mlx_inference_backend.py
@@ -8974,7 +8974,7 @@ def test_mlx_vlm_every_release_reads_one_models_rate_the_same_way(
):
"""A model's declared rate must not depend on which mlx-vlm is installed.
- Studio pins ``mlx-vlm>=0.4.4,<=0.7.4``, which spans both shapes: releases with no resolver
+ Studio pins ``mlx-vlm>=0.4.4,<=0.7.8``, which spans both shapes: releases with no resolver
and, from 0.7.0, releases that have one. Reading the rate only through the resolver left
every install on the older shape sampling at the library default instead of the rate the
checkpoint asked for.
diff --git a/studio/backend/tests/test_mlx_repair.py b/studio/backend/tests/test_mlx_repair.py
index a3e1fdf06e6..333bbd29fe8 100644
--- a/studio/backend/tests/test_mlx_repair.py
+++ b/studio/backend/tests/test_mlx_repair.py
@@ -62,7 +62,7 @@ def test_uv_cmd_targets_this_interpreter_with_mlx_packages(monkeypatch):
# mlx-vlm keeps a floor so the resolver cannot backtrack to an old one that
# imports but breaks VLM Train/Export, and a ceiling so this unattended
# install cannot cross a major line on its own.
- assert "mlx-vlm>=0.4.4,<=0.7.4" in cmd
+ assert "mlx-vlm>=0.4.4,<=0.7.8" in cmd
# Pinned, not floored: see _MLX_INSTALL_SPECS.
assert "mlx==0.32.3" in cmd
assert "mlx-lm==0.31.3" in cmd
@@ -134,11 +134,35 @@ def test_no_uv_repair_stays_chat_only_without_pip(monkeypatch):
def test_constraint_pins_installed_transformers(monkeypatch):
transformers = pytest.importorskip("transformers")
+ datasets = pytest.importorskip("datasets")
args, path = mr._transformers_constraint_args()
try:
assert args[:1] == ["--constraint"]
assert args[1] == path
- assert Path(path).read_text().strip() == f"transformers=={transformers.__version__}"
+ assert Path(path).read_text().splitlines() == [
+ f"transformers=={transformers.__version__}",
+ f"datasets=={datasets.__version__}",
+ ]
+ finally:
+ if path:
+ Path(path).unlink(missing_ok = True)
+
+
+def test_constraint_caps_datasets_when_its_metadata_is_missing(monkeypatch):
+ import importlib.metadata as md
+
+ real_version = md.version
+
+ def _version(name):
+ if name == "datasets":
+ raise md.PackageNotFoundError(name)
+ return real_version(name)
+
+ monkeypatch.setattr(md, "version", _version)
+ args, path = mr._transformers_constraint_args()
+ try:
+ assert path is not None
+ assert "datasets<5.0.0" in Path(path).read_text().splitlines()
finally:
if path:
Path(path).unlink(missing_ok = True)
@@ -172,10 +196,11 @@ def test_repair_install_pins_transformers_and_cleans_up(monkeypatch):
# transformers is pinned via a constraint file so the mlx install cannot
# upgrade it underneath Unsloth, and the temp constraint file is cleaned up.
assert "--constraint" in cmd
- assert "--upgrade" in cmd
+ assert "--upgrade" not in cmd
reinstall_pairs = set(zip(cmd, cmd[1:]))
for name in mr._MLX_PACKAGE_NAMES:
assert ("--reinstall-package", name) in reinstall_pairs
+ assert ("--upgrade-package", name) in reinstall_pairs
# Not MLX_PACKAGES verbatim: mlx-vlm carries the installed zoo's range appended to ours.
for pkg in mr._install_packages():
assert pkg in cmd
diff --git a/studio/backend/utils/mlx_repair.py b/studio/backend/utils/mlx_repair.py
index b5cf1a57752..cc2410dbc9a 100644
--- a/studio/backend/utils/mlx_repair.py
+++ b/studio/backend/utils/mlx_repair.py
@@ -30,11 +30,11 @@ _UNRESOLVED_PYTHON_MARKER = "No virtual environment or system Python installatio
_MLX_MIN_VERSIONS = {"mlx": "0.22.0", "mlx-lm": "0.31.2", "mlx-vlm": "0.4.4"}
_MLX_PACKAGE_NAMES = tuple(_MLX_MIN_VERSIONS)
_MLX_RUNTIME_IMPORTS = ("mlx.core", "mlx_lm", "mlx_lm.sample_utils", "mlx_vlm")
-# What the self-heal INSTALLS (the floors above judge a stack already there). Pinned, not floored: this install is unattended and mlx breaks in patch releases (0.32.1, unslothai/unsloth#9466). Keep in sync with unsloth-zoo's darwin deps. mlx 0.32.3 rather than mlx-vlm's 0.32.2 floor: 0.32.2's GQA-8 decode kernel read the first sequence's KV for every batch row (mlx#4431). mlx-vlm stays a range: 0.7.4 under the installer's transformers override, 0.6.4 under the plain cap.
+# What the self-heal INSTALLS (the floors above judge a stack already there). Pinned, not floored: this install is unattended and mlx breaks in patch releases (0.32.1, unslothai/unsloth#9466). Keep in sync with unsloth-zoo's darwin deps. mlx 0.32.3 rather than mlx-vlm's 0.32.2 floor: 0.32.2's GQA-8 decode kernel read the first sequence's KV for every batch row (mlx#4431). mlx-vlm stays a range: 0.7.8 under the installer's transformers override, 0.6.4 under the plain cap.
_MLX_INSTALL_SPECS = {
"mlx": "==0.32.3",
"mlx-lm": "==0.31.3",
- "mlx-vlm": ">=0.4.4,<=0.7.4",
+ "mlx-vlm": ">=0.4.4,<=0.7.8",
}
MLX_PACKAGES = tuple(f"{name}{spec}" for name, spec in _MLX_INSTALL_SPECS.items())
@@ -91,6 +91,8 @@ def _install_packages() -> tuple[str, ...]:
_MLX_REINSTALL_ARGS = tuple(
arg for name in _MLX_PACKAGE_NAMES for arg in ("--reinstall-package", name)
)
+# Per name: a bare --upgrade re-resolves every transitive dependency (pandas, pyarrow) to its newest.
+_MLX_UPGRADE_ARGS = tuple(arg for name in _MLX_PACKAGE_NAMES for arg in ("--upgrade-package", name))
# Require pre-built wheels for the unattended self-heal: a source distribution's PEP 517 build backend runs arbitrary code at install time, and this install is default-on and runs before the post-install stack check can reject anything. mlx/mlx-metal ship wheels only (no sdist on PyPI) and mlx-lm/mlx-vlm publish py3-none-any wheels, so requiring wheels does not break a healthy self-heal; if a wheel is genuinely unavailable the install fails and Unsloth stays chat-only.
_ONLY_BINARY_ARG = "--only-binary=:all:"
# Allowlist of environment variables forwarded to the install subprocess. The self-heal runs without confirmation on the default startup path, so it must not hand resolver/build code the full Unsloth environment. Dropping everything else excludes three classes by construction: secrets (HF_TOKEN, AWS_*, WANDB_API_KEY) a malicious wheel/sdist build hook would read out of os.environ; package-source redirects (UV_INDEX*, UV_DEFAULT_INDEX, UV_FIND_LINKS, PIP_INDEX_URL) that could repoint the install at an attacker-controlled index; and cache-dir redirects (UV_CACHE_DIR, XDG_CACHE_HOME) that could point uv at an attacker-staged cache. uv still honours on-disk config (uv.toml / pip.conf), so a corporate mirror keeps working, and UV_OVERRIDE is set in _mlx_install_env, so a poisoned one here is ignored.
@@ -317,17 +319,21 @@ def _mlx_install_env() -> dict[str, str]:
def _transformers_constraint_args() -> tuple[list[str], str | None]:
"""Pin transformers to the running version for the mlx install. The install must never upgrade transformers underneath a running Unsloth (the single-env install pins a compatible default). With UV_OVERRIDE set this is belt-and-suspenders; on the plain-pip path (no UV_OVERRIDE support) it is the actual guard, since the resolver either finds an mlx build compatible with the pin or fails, leaving us chat-only rather than breaking Unsloth. Returns (pip args, temp file path to clean up). Read the version from installed metadata rather than `import transformers`: transformers can have valid metadata yet fail to import (e.g. an incompatible huggingface_hub), and in that case we still want to pin it so the mlx install cannot quietly upgrade it out from under Unsloth."""
- from importlib.metadata import PackageNotFoundError, version as _dist_version
+ from importlib.metadata import version as _dist_version
- try:
- transformers_version = _dist_version("transformers")
- except PackageNotFoundError:
- return [], None
- except Exception:
+ # datasets: mlx-vlm 0.7.8 requires it unbounded, so a moved or absent one would resolve to 5.x, past unsloth's <5.
+ pins = []
+ for name in ("transformers", "datasets"):
+ try:
+ pins.append(f"{name}=={_dist_version(name)}\n")
+ except Exception:
+ if name == "datasets":
+ pins.append("datasets<5.0.0\n")
+ if not pins:
return [], None
fd, path = tempfile.mkstemp(prefix = "mlx_repair_", suffix = ".txt")
with os.fdopen(fd, "w", encoding = "utf-8") as fh:
- fh.write(f"transformers=={transformers_version}\n")
+ fh.writelines(pins)
return ["--constraint", path], path
@@ -340,7 +346,7 @@ def attempt_mlx_repair(*, timeout: int = _REPAIR_TIMEOUT_S) -> bool:
constraint_args, constraint_path = _transformers_constraint_args()
packages = _install_packages()
cmd = _uv_install_cmd(
- "--upgrade",
+ *_MLX_UPGRADE_ARGS,
_ONLY_BINARY_ARG,
*_MLX_REINSTALL_ARGS,
*constraint_args,
diff --git a/studio/install_python_stack.py b/studio/install_python_stack.py
index b1c80bc8f56..a47c5d8e146 100644
--- a/studio/install_python_stack.py
+++ b/studio/install_python_stack.py
@@ -9557,7 +9557,7 @@ def _build_pip_cmd(args: tuple[str, ...]) -> list[str]:
# By canonical project name: `--upgrade-package mlx` beside `mlx==0.32.3` is one project,
# and pip refuses a double requirement where uv does not.
def _project(requirement: str) -> str:
- # _requirement_name stops at "==" and "@"; a range (mlx-vlm>=0.4.4,<=0.7.4) needs the
+ # _requirement_name stops at "==" and "@"; a range (mlx-vlm>=0.4.4,<=0.7.8) needs the
# rest.
return _canonical_package_name(
re.split(r"[<>=!~;\[ ]", _requirement_name(requirement), maxsplit = 1)[0]
@@ -10644,7 +10644,7 @@ def _has_working_git() -> bool:
# The MLX stack, one place; test_mlx_install.py compares it with utils/mlx_repair.py's
# _MLX_INSTALL_SPECS.
_MLX_PINS: tuple[str, ...] = ("mlx==0.32.3", "mlx-metal==0.32.3", "mlx-lm==0.31.3")
-_MLX_VLM_SPEC = "mlx-vlm>=0.4.4,<=0.7.4"
+_MLX_VLM_SPEC = "mlx-vlm>=0.4.4,<=0.7.8"
# Exact: llguidance.mlx / llguidance.hf are the API grammar_constraint.py binds to.
_LLGUIDANCE_PIN = "llguidance==1.8.0"
_MLX_NAMES: tuple[str, ...] = tuple(spec.partition("==")[0] for spec in _MLX_PINS) + ("mlx-vlm",)
diff --git a/tests/studio/install/test_dependency_pass_skips.py b/tests/studio/install/test_dependency_pass_skips.py
index a8c91425402..3bb96ef9ee3 100644
--- a/tests/studio/install/test_dependency_pass_skips.py
+++ b/tests/studio/install/test_dependency_pass_skips.py
@@ -1058,12 +1058,12 @@ def test_the_pip_fallback_never_names_one_project_twice() -> None:
"--upgrade-package",
"mlx-vlm",
"mlx==0.32.3",
- "mlx-vlm>=0.4.4,<=0.7.4",
+ "mlx-vlm>=0.4.4,<=0.7.8",
)
)
assert "--upgrade" in cmd and "--upgrade-package" not in cmd
assert cmd.count("mlx") == 0 and cmd.count("mlx-vlm") == 0
- assert "mlx==0.32.3" in cmd and "mlx-vlm>=0.4.4,<=0.7.4" in cmd
+ assert "mlx==0.32.3" in cmd and "mlx-vlm>=0.4.4,<=0.7.8" in cmd
def test_a_package_named_only_by_the_flag_is_still_passed() -> None:
diff --git a/tests/studio/install/test_mlx_install.py b/tests/studio/install/test_mlx_install.py
index 50782ea7e77..0bc549be968 100644
--- a/tests/studio/install/test_mlx_install.py
+++ b/tests/studio/install/test_mlx_install.py
@@ -325,7 +325,7 @@ def test_pin_floor_is_revisited_whenever_the_pins_move():
assert _repair_specs() == {
"mlx": "==0.32.3",
"mlx-lm": "==0.31.3",
- "mlx-vlm": ">=0.4.4,<=0.7.4",
+ "mlx-vlm": ">=0.4.4,<=0.7.8",
}
assert (stack._MLX_MIN_PYTHON, stack._MLX_MIN_MACOS_MAJOR) == ((3, 10), 14)