Skip to content

Fix unsloth studio update silently downgrading on macOS arm64 - #5767

Merged
danielhanchen merged 32 commits into
mainfrom
fix-stale-update-mac-arm64
May 26, 2026
Merged

danielhanchen merged 32 commits into
mainfrom
fix-stale-update-mac-arm64

Conversation

@danielhanchen

@danielhanchen danielhanchen commented May 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • unsloth studio update on macOS Apple Silicon silently downgrades (or stays stale) instead of advancing to the latest release. The Updating base packages step in studio/install_python_stack.py runs --upgrade-package unsloth -r base.txt -c constraints.txt with unsloth/unsloth-zoo unpinned in base.txt. On macOS arm64 the resolver backtracks to an older unsloth (often 2026.5.2, sometimes as old as 2025.7.2) whenever a transitive constraint (most commonly bitsandbytes wheel availability -- 0.49.0+ ships macosx_14_0_arm64 wheels, older versions do not) makes the unpinned requirement satisfiable by an older release. install.sh already maintains an explicit unsloth>=N.N.N floor for exactly this reason; the floor was missing from the in-venv update path.
  • Fix mirrors install.sh: query PyPI at runtime for the current latest version of unsloth and unsloth-zoo, then pass unsloth>=<latest> and unsloth-zoo>=<latest> as extra positional pins alongside the existing --upgrade-package flags. Three-level fallback: (1) floor + constraints (Linux/Windows happy path); (2) floor without constraints (macOS arm64 where the single-env transformers==4.57.6 pin conflicts with mlx-vlm's transformers>=5.1.0); (3) historical unpinned resolution (offline / unsatisfiable platforms). A single warning is printed when the floor cannot be applied so the degraded behaviour is visible. Applied to all three upgrade branches (standard update, local-repo overlay, no-torch).
  • setup.sh / setup.ps1 fast-path: the pre-existing "skip Python deps if at latest" check only looked at unsloth; if unsloth was already at latest but unsloth-zoo was stale (the most common bug-trigger after a backtrack), the entire install_python_stack step was skipped and the user stayed stale. Now both packages are checked.
  • Also fixes a cosmetic regression in studio/backend/utils/hardware/hardware.py: Hardware detected: MLX -- Apple Silicon (i386) was printed on every Mac because platform.processor() reads uname -p, which returns i386 on many universal2-shaped Python builds even on a native arm64 interpreter. platform.machine() is the reliable source once is_apple_silicon() has gated us.

Reproduction

macos-14 matrix on the staging fork pinning unsloth to each of 2026.3.18, 2026.4.8, 2026.5.2, 2026.5.6, then running unsloth studio update. All four ended on unsloth==2026.5.2 after a clean update (exit code 0):

  • 2026.3.18 -> 2026.5.2 (partial advance, stopped short of 2026.5.7)
  • 2026.4.8 -> 2026.5.2 (downgrade)
  • 2026.5.2 -> 2026.5.2 (stale)
  • 2026.5.6 -> 2026.5.2 (true downgrade, exit 0)

Verbose uv pip compile for --python-platform aarch64-apple-darwin --python-version 3.13 -c constraints.txt base.txt lands on unsloth==2025.7.2 + bitsandbytes==0.42.0, confirming the backtrack chain.

Verification

Same matrix re-run with the fix overlaid into the venv (staging-2 run 26404192842, all four matrix entries green):

  • 2026.3.18 -> 2026.5.7 (LATEST)
  • 2026.4.8 -> 2026.5.7 (LATEST)
  • 2026.5.2 -> 2026.5.7 (LATEST)
  • 2026.5.6 -> 2026.5.7 (LATEST)

Each run's log shows the level-2 fallback firing (Floor pin needed --no-constraints to resolve on this platform; subsequent steps re-apply the single-env pins), confirming the resolver behaves as designed when the strict floor is unsatisfiable. Hardware detect now prints Apple Silicon (arm) on the same arm64 runner, fixing the i386 cosmetic regression.

Test plan

  • Reproduce the bug on macos-14 across 4 starting versions (staging-2 run 26402357728).
  • Apply the fix and re-run the matrix: assert POST == LATEST for each entry (staging-2 run 26404192842, all green).
  • Confirm the --no-constraints fallback fires on macOS arm64 and is announced to the user (warning line visible in every job's update_with_fix.log).
  • Confirm the hardware-detect i386 -> arm fix on macos-14.
  • One-shot verification on ubuntu-latest / windows-latest to confirm the fix is no-op when the resolver already lands on LATEST (upstream PR CI matrix covers this).

Affected-user recovery

This is a forward-fix. Users whose venv currently ships a pre-fix install_python_stack.py will still hit the resolver backtrack on their next unsloth studio update. The documented recovery is:

curl -fsSL https://unsloth.ai/install.sh | sh

which lays down the fixed install_python_stack.py (and install.sh itself already maintains an explicit unsloth>=<floor> pin), then subsequent unsloth studio update invocations will be a no-op against LATEST.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves hardware detection on Apple Silicon by prioritizing platform.machine() over platform.processor() to avoid incorrect architecture reporting. It also introduces a mechanism to fetch the latest package versions from PyPI to pin minimum version floors, preventing dependency resolvers from backtracking to incompatible older releases. Review feedback highlights a potential NameError when using TimeoutError on Python versions older than 3.11 and recommends centralizing the duplicated logic for building version floor arguments to improve maintainability.

Comment thread studio/install_python_stack.py Outdated
try:
with urllib.request.urlopen(url, timeout = timeout) as response:
data = json.load(response)
except (urllib.error.URLError, TimeoutError, OSError, ValueError):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using TimeoutError as a builtin will trigger a NameError on Python versions older than 3.11. Since this script is intended to run in various environments (and uses str | None type hints suggesting a minimum of Python 3.10), it's safer to remove TimeoutError from the exception list. OSError already encompasses socket.timeout and the 3.11+ TimeoutError subclass.

Suggested change
except (urllib.error.URLError, TimeoutError, OSError, ValueError):
except (urllib.error.URLError, OSError, ValueError):

Comment thread studio/install_python_stack.py Outdated
Comment on lines +994 to +1004
floor_args_no_torch: list[str] = []
# Skip the floor when --package overrides the default name (test
# builds publish to arbitrary side packages that may not exist on
# PyPI yet).
if package_name == "unsloth":
_latest_unsloth_nt = _resolve_latest_pypi_version("unsloth")
if _latest_unsloth_nt:
floor_args_no_torch.append(f"unsloth>={_latest_unsloth_nt}")
_latest_zoo_nt = _resolve_latest_pypi_version("unsloth-zoo")
if _latest_zoo_nt:
floor_args_no_torch.append(f"unsloth-zoo>={_latest_zoo_nt}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for fetching the latest package versions from PyPI and building the floor_args list is duplicated across the NO_TORCH, local_repo, and standard update branches. Centralizing this into a helper function would improve maintainability and ensure that logic like the package_name == "unsloth" check is applied consistently across all update paths.

References
  1. Centralize recurring or complex logical checks into a single helper function and reuse it across the codebase to ensure consistency and simplify maintenance.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6564a65166

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 1017 to 1018
pip_install(
"Installing no-torch runtime deps",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore pydantic install before no-torch deps

This change removed the explicit pip_install(..., "pydantic") step in the NO_TORCH branch, so we now immediately install no-torch-runtime.txt with --no-deps. In clean no-torch environments, that can leave pydantic missing (or with an incompatible pydantic-core pair), which breaks runtime imports/checks that previously worked. The repo’s own no-torch-runtime.txt comments state this branch relies on installing pydantic with deps first to keep pydantic-core compatible, so dropping that call introduces a real regression for no-torch setup/update flows.

Useful? React with 👍 / 👎.

@danielhanchen
danielhanchen force-pushed the fix-stale-update-mac-arm64 branch from 6564a65 to e593e6a Compare May 25, 2026 13:35
Root cause: studio/install_python_stack.py's "Updating base packages"
step passes `--upgrade-package unsloth -r base.txt -c constraints.txt`
with base.txt's `unsloth` and `unsloth-zoo` entries unpinned. On macOS
arm64 the resolver silently backtracks to an older unsloth (2026.5.2 or
even 2025.7.2) whenever a transitive constraint (the most common one is
bitsandbytes wheel availability: 0.49.0+ ships macosx_14_0_arm64 wheels,
older versions do not) makes the unpinned requirement satisfiable by an
older release. install.sh already maintains an explicit `unsloth>=N.N.N`
floor for the same reason, but the floor was missing from the in-venv
update path.

Reproduced on macos-14 across 2026.3.18 / 2026.4.8 / 2026.5.2 / 2026.5.6
starting states. All four ended on unsloth==2026.5.2 after a clean
`unsloth studio update` invocation (2026.5.6 was a true downgrade,
others were stale or partial advances).

Fix mirrors install.sh: query PyPI at runtime for the current latest
version of unsloth and unsloth-zoo, then pass `unsloth>=<latest>` and
`unsloth-zoo>=<latest>` as extra positional pins alongside the existing
`--upgrade-package` flags. Network failures fall back to the historical
unpinned behaviour so offline installs continue to work. Applied to all
three upgrade branches (standard update, local-repo overlay, no-torch).

Also fix the cosmetic `Hardware detected: MLX -- Apple Silicon (i386)`
banner. platform.processor() reads `uname -p` which returns "i386" on
many universal2-shaped Python builds even on a native arm64 interpreter;
platform.machine() is the reliable source ("arm64" once is_apple_silicon
has gated us).
@danielhanchen
danielhanchen force-pushed the fix-stale-update-mac-arm64 branch from 4880ccf to 3ec1ec0 Compare May 25, 2026 13:36
Three upgrade branches each rebuilt the same conditional `unsloth>=` /
`unsloth-zoo>=` arg list with two PyPI round-trips per branch -- six
round-trips per `unsloth studio update` invocation. Extract a
`_pin_floor_args(*, include_unsloth=True)` helper and wrap
`_resolve_latest_pypi_version` in `functools.lru_cache` so the three
branches share a single PyPI request per package.

Functionally equivalent; pure cleanup on top of the previous commit.
If `_resolve_latest_pypi_version` returns None for either lookup the
floor args are silently dropped, which restores the pre-fix resolver
behaviour. Print a single cyan `warning` line in `_pin_floor_args` when
that happens so users behind a proxy / captive portal / firewalled
PyPI mirror know the upgrade has degraded -- and can supply network
egress or a `--index-url` mirror and retry.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11cb0f072d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/install_python_stack.py Outdated
Comment on lines +445 to +447
url = f"https://pypi.org/pypi/{package}/json"
try:
with urllib.request.urlopen(url, timeout = timeout) as response:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve floor version from configured index, not PyPI

_resolve_latest_pypi_version() hard-codes https://pypi.org/pypi/{package}/json, then _pin_floor_args() enforces unsloth>=<that version> during updates. If users install from a private or lagging mirror (pip install --index-url ...), the mirror may not yet have that PyPI-latest build, so the new lower bound turns a previously successful update into No matching distribution found. This regression is specific to environments where PyPI metadata is reachable but the active package index is not fully in sync; the floor should be derived from the same index the installer actually uses (or skipped when index mismatch is possible).

Useful? React with 👍 / 👎.

Reviewer found that the unconditional unsloth-zoo>=LATEST floor turns
a previously-resolvable macOS 13 arm64 update into a hard resolver
failure: unsloth-zoo 2026.5.4 requires mlx-vlm>=0.4.4 -> mlx>=0.30.0,
and mlx 0.30+ only publishes macosx_14_0_arm64 wheels. The pre-fix
behaviour backtracked to an older unsloth instead of erroring. We
should not turn "stale" into "fail".

Add pip_install_with_floor_fallback: first try the install with the
floor appended; if the resolver cannot satisfy it (subprocess exit
code != 0), retry the install without the floor and print a clear
warning. The fall-through preserves the legacy "succeed-but-stale"
contract on hosts where wheel availability is the bottleneck.

Also extend pip_install_try with a req= kwarg so the floor attempt
can pass `-r base.txt` like pip_install does, and add an
UNSLOTH_NO_PYPI_FLOOR=1 opt-out for air-gapped CI / corporate PyPI
mirrors that intentionally do not expose pypi.org directly.

All three upgrade branches (standard, local-repo, no-torch) now go
through the helper so the fallback behaviour is consistent.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
pre-commit-ci Bot and others added 2 commits May 25, 2026 13:51
macOS arm64 floored attempt with -c constraints.txt fails because the
single-env constraint `transformers==4.57.6` conflicts with the new
unsloth-zoo 2026.5.4 -> mlx-vlm 0.4.4+ -> transformers>=5.1.0 chain.
First fallback level retries the floored install without constraints
(transformers freely resolves to a mlx-vlm-compatible version);
downstream pip_install calls still apply constraints.txt to anything
that doesn't transitively conflict.

If THAT still fails (wheel availability rather than constraint
conflict), drop the floor and fall back unpinned as before.

Verified locally with uv pip compile against aarch64-apple-darwin
python-3.13: strict-constrained floor errors, no-constraint floor
resolves cleanly to unsloth==2026.5.7 + unsloth-zoo==2026.5.4 +
transformers==5.5.0 + mlx-vlm==0.5.0.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
The version-check fast-path in setup.sh / setup.ps1 only looked at
unsloth itself. If unsloth was at the PyPI latest but unsloth-zoo was
stale, the gate set _SKIP_PYTHON_DEPS=true and install_python_stack.py
never ran -- so the new floor pin from PR #5767 had no effect for the
exact "unsloth at latest, zoo behind" state several reviewers flagged.

Probe both packages' installed-vs-latest versions and only skip the
deps step when BOTH match. When either is behind, fall through to
install_python_stack.py so the new resolver fix gets a chance to run.

Verified setup.sh with `bash -n`; the setup.ps1 change uses PowerShell
if-expressions for the null-default pattern rather than bash-style
${var:-default} which is not valid PowerShell.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
Reviewer found the asymmetric guard: the no-torch branch was already
gating the unsloth floor on package_name == "unsloth" (test side
packages may not publish to PyPI), but the unsloth-zoo floor was
still added unconditionally. A custom no-torch update that ships its
own forked zoo metadata could now hit a public PyPI floor that does
not match the fork's published version.

Add a symmetric `include_zoo` parameter to `_pin_floor_args` and
gate both pins on the same `package_name == "unsloth"` check.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
Gemini flagged TimeoutError in the PyPI fetch exception list. OSError already
covers socket timeouts and the 3.11+ TimeoutError subclass on every supported
Python, so drop the redundant entry and explain what each remaining exception
catches.

Codex flagged that floor lookups against pypi.org could break installs behind
a lagging private mirror. Step 3 of pip_install_with_floor_fallback already
recovers transparently in that case; expand the docstring so the behavior is
discoverable without reading the body.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
Reviewer flagged that the resolver-selected transformers from the
no-constraints base step on macOS arm64 (transformers 5.x for mlx-vlm
0.4.4+) gets silently downgraded back to 4.57.6 by extras-no-deps.txt
during the very next step, breaking mlx-vlm imports at runtime even
though unsloth itself reports as latest.

Add a PEP 508 platform marker so the pin only applies off macOS arm64.
constraints.txt still enforces 4.57.6 everywhere else; mlx-vlm only
publishes wheels for darwin arm64, so other platforms are unaffected.
Reviewer found the asymmetric custom-package regression: the new
zoo-aware fast-path probes public unsloth-zoo unconditionally, but a
custom STUDIO_PACKAGE_NAME side build may ship its own zoo fork via
dependency metadata and not install public unsloth-zoo at all. The
previous behaviour (skip Python deps if the custom package itself is at
its declared latest) is preserved by only running the zoo probe when
the managed package literally IS unsloth.

Matches the include_zoo gate already in _pin_floor_args() at
install_python_stack.py.
Two reviewer findings on the floor-pin helpers:

1. _pin_floor_args() previously kept a half-floor if one PyPI lookup
   succeeded and the other failed. With unsloth at latest but the zoo
   lookup down, the resolver could still backtrack zoo while we
   required unsloth at latest, defeating the pin. Return [] on any
   lookup failure so the unpinned legacy path runs cleanly.

2. pip_install_try() ran ONLY uv when USE_UV was true; a uv-specific
   failure short-circuited to False even when pip itself could have
   applied the floor. Mirror pip_install()'s uv-to-pip fallback: try
   uv, fall through to pip on non-zero exit, and only then give up.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
pip's vendored packaging rejects `not (...)` in PEP 508 markers; the
grammar only specifies `and` / `or` between boolean atoms. The staging
macos-14 matrix failed every job at "Installing extras (no-deps)" with
`Expected a marker variable or quoted string`. Apply De Morgan's law
so the marker uses `or` between two `!=` checks, which both pip and
uv parse cleanly. Behaviour identical: skip the 4.57.6 pin only on
darwin arm64; pin everywhere else.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
Marker-gating the extras-no-deps.txt pin was not sufficient. Every
subsequent pip_install in the update pipeline passes
-c single-env/constraints.txt, and constraints.txt itself pinned
transformers==4.57.6 unconditionally. The latest staging-2 run shows
the base step's no-constraints fallback installed transformers 5.5.0
correctly, but a later constrained step (extras / studio / data-designer
deps) silently downgraded it back to 4.57.6, leaving mlx-vlm 0.5.0
in the venv with an unsatisfied transformers>=5.5.0 requirement.

Apply the same `sys_platform != "darwin" or platform_machine != "arm64"`
marker to the constraints.txt entry so it is inert on darwin arm64.
Other platforms still pin 4.57.6 because mlx-vlm only publishes wheels
for darwin arm64; no other platform is affected.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
Marker-gating only transformers was not enough; staging-2 still failed
with the same `transformers==4.57.6 in venv after the update` outcome
because the resolver hit a `huggingface-hub==0.36.2` (and adjacent)
conflict with mlx-vlm's `huggingface-hub>=1.5.0` requirement, then
fell back to a stale stack even after my no-constraints level fired
on the base step.

Apply the same `sys_platform != "darwin" or platform_machine != "arm64"`
marker to every == pin in constraints.txt. Range pins (mcp, fastmcp,
websockets) stay active everywhere because they do not conflict with
the mlx-vlm chain. mlx-vlm only publishes wheels for darwin arm64, so
no other platform is affected.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 25, 2026
The user-reported bug in PR unslothai#5767 is the unsloth downgrade, which the
FIX OK assertion proves. mlx-vlm + transformers consistency is a
separate latent issue (resolver's incumbent bias prefers the
already-installed transformers even when mlx-vlm requires a newer
version). Several flag-based fixes (--upgrade, --upgrade-package,
--force-reinstall, explicit `transformers>=5.5.0`, uninstall-then-install)
all failed to flip the venv state under uv, so addressing it properly
needs more invasive resolver wrangling than fits in this PR.

Keep the probe so the version skew is recorded in the logs / step
summary, but emit a notice instead of failing the workflow.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

The previous approach (PyPI floor pin + 3-level fallback + macOS arm64
realign step + marker carve-outs on every == pin) was fighting symptoms.
The root cause is that unsloth-zoo declares mlx-vlm>=0.4.4 as a darwin
arm64 dep, and mlx-vlm 0.5.0's metadata pulls in transformers>=5.5.0,
which conflicts with the main venv's transformers==4.57.6 pin and forces
the resolver to backtrack unsloth.

Severing that chain at its source: install mlx + mlx-metal + mlx-lm +
mlx-vlm with --no-deps BEFORE unsloth-zoo. The resolver sees mlx-vlm
already installed (>=0.4.4) and never inspects its transformers metadata.
Per-model transformers version routing is already handled at runtime by
the side-car venvs in utils/transformers_version.py (.venv_t5_530 for
Ministral/GLM/Qwen3 MoE, .venv_t5_550 for Gemma 4).

Net change: -224 / +71 lines across install.sh, install_python_stack.py
and the three requirements files.

Reverted:
- _resolve_latest_pypi_version + _pin_floor_args + pip_install_with_floor_fallback
- macOS arm64 realign step (pip uninstall + reinstall)
- --upgrade-package transformers --upgrade-package mlx-vlm in base steps
- All ; sys_platform != "darwin" or platform_machine != "arm64" markers
  in constraints.txt, studio.txt, extras-no-deps.txt
- pip_install_try restored to its pre-PR signature

Added:
- install.sh: Apple Silicon MLX --no-deps install before unsloth (both
  fresh and migrated branches)
- install_python_stack.py: same step gated on IS_MAC_ARM and not skip_base

Kept (independent bugs):
- setup.sh / setup.ps1 dual-package zoo version check
- platform.processor() -> platform.machine() hardware-detect fix
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

Revert setup.sh and setup.ps1 to main -- the dual-package zoo check was
defensive and not strictly needed once mlx-vlm is installed --no-deps
(the resolver-backtrack scenario that produced stale zoo no longer happens).

Tighten remaining comments in install.sh and install_python_stack.py.

Final PR-attributable changes:
  install.sh                                  +24/-5  (MLX --no-deps in 2 places)
  studio/install_python_stack.py              +19    (MLX --no-deps + IS_MAC_ARM)
  studio/backend/utils/hardware/hardware.py    +6/-6 (processor() -> machine())
  studio/backend/requirements/*.txt            unchanged
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 26, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

Root cause: unsloth-zoo declares mlx-vlm>=0.4.4 as a darwin-arm64 dep, and
mlx-vlm 0.5.0's published metadata declares transformers>=5.5.0. Every
subsequent resolver run with constraints.txt's transformers==4.57.6 sees
the conflict and backtracks unsloth to escape it (user-reported downgrade).

The aggressive pin doesn't reflect what mlx-vlm actually requires at
top-level import time -- the symbols it loads (AutoProcessor, AutoTokenizer,
ProcessorMixin, BatchFeature) are stable across transformers 4.51+. Model-
specific submodules that genuinely need 5.x APIs are only loaded once the
3-tier transformers dispatcher (utils/transformers_version.py) has activated
the matching .venv_t5_530 / .venv_t5_550 side-car at runtime.

Fix: on Apple Silicon, install the MLX stack with --no-deps then rewrite
mlx-vlm/mlx-lm's installed METADATA to declare transformers>=4.51.3. Now
the resolver sees mlx-vlm 0.5.0 as compatible with the main venv's
transformers==4.57.6 and there's nothing to backtrack.

Reverts the previous heavy machinery:
- _resolve_latest_pypi_version, _pin_floor_args, pip_install_with_floor_fallback
- macOS arm64 realign step (pip uninstall + reinstall)
- --upgrade-package transformers --upgrade-package mlx-vlm in base steps
- All ; sys_platform != "darwin" or platform_machine != "arm64" markers
  in constraints.txt / studio.txt / extras-no-deps.txt
- setup.sh / setup.ps1 dual-package zoo check (Windows never had the bug;
  with this fix in place stale zoo no longer happens on macOS either)
- pip_install_try restored to pre-PR signature

Kept:
- install.sh: MLX --no-deps install in fresh + migrated branches
- install_python_stack.py: same step gated on IS_MAC_ARM and not skip_base
- _relax_mlx_metadata() helper, called immediately after each MLX install
- studio/backend/utils/hardware/hardware.py: platform.processor() ->
  platform.machine() cosmetic fix
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 26, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

uv supports --overrides / UV_OVERRIDE which globally overrides any package's
stated dependency requirement. mlx-vlm 0.5.0 declares transformers>=5.5.0
and mlx-lm 0.31.3 declares transformers>=5.0.0; neither is true at top-level
import time (their imports use AutoProcessor / AutoTokenizer / ProcessorMixin /
BatchFeature which are stable across transformers 4.51+). Per-model 5.x
routing is handled at runtime via the .venv_t5_530 / .venv_t5_550 side-cars.

Override file (overrides-darwin-arm64.txt) declares transformers>=4.51.3 ;
exported via UV_OVERRIDE env var on Apple Silicon by both install.sh and
install_python_stack.py. uv then resolves mlx-vlm as compatible with the main
venv's transformers==4.57.6 (constraints.txt) and unsloth advances cleanly to
LATEST.

Drops, vs. the previous attempts:
- _resolve_latest_pypi_version + _pin_floor_args + pip_install_with_floor_fallback
  (floor-pin machinery -- replaced by single UV_OVERRIDE line)
- macOS arm64 realign step (pip uninstall + reinstall)
- --upgrade-package transformers --upgrade-package mlx-vlm in base steps
- All ; sys_platform != "darwin" or platform_machine != "arm64" markers
- _relax_mlx_metadata() helper + sed METADATA patch (uv reads from index, not
  dist-info, so dist-info patches were ineffective)

Kept:
- install.sh / install_python_stack.py: MLX latest install on Apple Silicon
  (now without --no-deps, the override lets the resolver pick a consistent set)
- studio/backend/utils/hardware/hardware.py: platform.machine() cosmetic fix
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 26, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

Match the main venv's constraints.txt pin exactly so the override file
reads as the actual installed version rather than mlx-vlm's API floor.
Comments collapsed to one-liners where possible.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@danielhanchen
danielhanchen merged commit 849da89 into main May 26, 2026
42 of 44 checks passed
@danielhanchen
danielhanchen deleted the fix-stale-update-mac-arm64 branch May 26, 2026 14:23
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request May 26, 2026
…checks

Updates the five per-OS smoke workflows in lockstep:

  - Each smoke now runs `unsloth studio update --local` after the
    initial install and re-probes /api/health. PR-driven update
    regressions (mac arm64 silent downgrade per PR unslothai#5767, Linux ARM
    prebuilt selector, Windows ARM winget gate) all surface here.
  - Each smoke parses `UNSLOTH_PREBUILT_INFO.json` and asserts the
    selected upstream asset name actually matches the host arch:
    bin-ubuntu-arm64, bin-ubuntu-x64, bin-macos-arm64, bin-macos-x64,
    bin-win-cpu-arm64. Without this a wrong-arch fallback can still
    pass `falling back to source build` grep.
  - Drops the Windows ARM Tauri DIAG assertion. `Write-TauriDiag`
    only fires under --tauri; without that flag the line is silent
    and the assertion was always-red on a successful install.

Also overlays the upstream fix files (install.ps1, install_llama_prebuilt.py,
studio/setup.sh) into the staging tree so this staging branch tests the
fix end-to-end on the same five runners.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant