Skip to content

Studio: install the supported MLX stack on fresh macOS installs - #10403

Merged
danielhanchen merged 8 commits into
mainfrom
macos-mlx-fresh-install
Sep 8, 2026
Merged

danielhanchen merged 8 commits into
mainfrom
macos-mlx-fresh-install

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Fresh Apple Silicon installs could finish with Train and Export disabled because SKIP_STUDIO_BASE=1 also skipped the MLX dependency pass. The resulting tokenizers version prevented MLX imports, leaving Studio in chat-only mode after installation.

Run the existing MLX step on fresh training installs and keep its progress count aligned. Preserve the NO_TORCH guard so GGUF-only installs skip MLX. Pin mlx and mlx-metal to 0.32.1, mlx-lm to 0.31.3, and mlx-vlm to >=0.4.4,<0.7.0, matching the supported requirements used by Zoo and MLX repair.

Validation on an M3 Max with separate clean Studio directories and Python environments, with MLX auto-repair disabled:

  • Parent: tokenizers 0.23.2, failed MLX imports, chat_only=true, Export disabled.
  • Fixed install: tokenizers 0.22.2, working MLX imports, chat_only=false, Export enabled, and the MLX versions satisfy Zoo's requirements.
  • Fresh --no-torch install: torch and MLX absent, UI available, chat_only=true.
  • Real 30-step LoRA training on unsloth/gemma-3-270m-it: loss fell from 8.4531 to 0.0003. LoRA, merged 16-bit, and Q8_0 GGUF exports passed reload/inference checks and generated Unsloth!.
  • The PR includes 39 MLX regression cases covering platform and mode guards, shared base requirements, supported pins, interruption, and uv/pip fallback. The pin checks failed before the fix and pass afterward.
  • Full installer suite: 3,211 passed, 177 failed, 18 skipped. All failures and skipped test IDs match the parent run exactly. Lint and formatting checks pass.
  • uv pip check no longer reports the tokenizers or MLX pin mismatch. Six unrelated dependency warnings remain, all present in the parent environment.

Additional isolated checks under the workspace:

  • Python 3.9 through 3.14: 612 installer simulations and 540 compatibility tests pass on each interpreter, totaling 6,912 checks. The simulations compare complete installer sequences across 480 platform, GPU backend, install mode, package-source, shared-requirements, and uv/pip combinations. All six deliberately broken variants were detected.
  • Corrected two test fixtures exposed by that matrix: write manifest records without a Python 3.10-only argument, and supply explicit accepted/rejected Python versions when testing Windows wrapper resolution. Windows automatic interpreter selection remains limited to 3.11-3.13 and rejects 3.13.8.
  • A new venv with spaces in its path reproduces the tokenizers import error. The actual MLX step repairs it, remains stable on repetition, and restores the supported pins after an intentional upgrade to MLX 0.32.2. The real pip fallback also installs an importable stack within the required version bounds.
  • Backend MLX repair/capability tests: 63 passed. Frontend capability tests: 64 passed.
  • Chrome, Edge, Firefox, and WebKit: 40 capability and recovery cases passed, including missing MLX, pending or unavailable health responses, and recovery to working training. WebKit navigation cancellation noise also occurs before the PR; stable pages and browser-to-backend requests pass. Actual Safari is unverified because remote automation is disabled.

The local host is macOS arm64. Linux and Windows matrix cases are simulations, not native GPU runs. A native Linux ARM clean-install CI check passed on installer commit 413473b7f; the broader native Windows/Linux results are still pending.

Linux, Windows, and Intel Mac installation paths remain unchanged. This adds dependency work during Apple Silicon training installation; it does not add work to training or inference execution. Cross-hardware performance has not been benchmarked.

install.sh sets SKIP_STUDIO_BASE=1 so the core packages are not reinstalled,
but that flag also gated the by-name MLX install. On the fresh path mlx-lm
then only arrived transitively, nothing held tokenizers inside its
<=0.23.0 window, and Train and Export came up disabled until
`unsloth studio update` was run.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-08T12:03:43.535184Z 7ac8596 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The ungated MLX step also ran under --no-torch on Apple Silicon, where
install.sh sets both SKIP_STUDIO_BASE and UNSLOTH_NO_TORCH. These are direct
package args so NO_TORCH_SKIP_PACKAGES cannot filter them. Gate on NO_TORCH,
matching the MLX health probe below.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

Good catch on the --no-torch case, that was a real regression in the first commit and it is fixed in 21a50ff.

On Apple Silicon install.sh sets UNSLOTH_NO_TORCH="$SKIP_TORCH" on the same two env handoffs that set SKIP_STUDIO_BASE=1 (lines 5692 and 5704), so a --no-torch run had both set. Once the step stopped keying off skip_base it started running there too, and because these are direct package args rather than a requirements file, NO_TORCH_SKIP_PACKAGES never filtered them. A GGUF-only install would have picked up the full MLX training stack.

Now gated on NO_TORCH as well, which also matches the _report_mlx_stack_health() gate further down that already used IS_MAC_ARM and not NO_TORCH.

Verified on macOS arm64 with real installs into clean UNSLOTH_STUDIO_HOME roots:

install MLX step result
./install.sh --no-torch not run no mlx* packages in site-packages, GGUF-only preserved
./install.sh --local runs once mlx training stack ready, chat_only: false on first launch

The --no-torch update path is tightened by this too. It previously satisfied IS_MAC_ARM and not skip_base and installed MLX into a no-torch environment, which was never intended.

@shimmyshimmer shimmyshimmer changed the title Studio: install the MLX stack on fresh macOS installs Studio: install the supported MLX stack on fresh macOS installs Sep 7, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: bfb6893d11

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed main still gates the MLX step on not skip_base in studio/install_python_stack.py, so a fresh Apple Silicon install ends up without a usable MLX stack, and the added NO_TORCH gate matches the health check further down. Will get this reviewed.

Resolve the MLX step conflict: keep the branch's drop of the skip_base gate
so fresh installs still get MLX, keep main's NO_TORCH gate and its rationale,
and keep the supported pins.

Update the progress-budget assertion in test_mlx_install.py: main added one
installer step, so the macOS base is 12/13 rather than 11/12.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 8, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 8, 2026
The pins are not installable everywhere Apple Silicon is, and pip_install
exits on failure, so on those hosts this step ends the whole install.

  mlx 0.32.1 / mlx-metal 0.32.1  macosx_14_0_arm64 wheels only, no sdist
  the whole pinned set            cp310 and up, no cp39 wheel

Read off the index rather than reasoned about:

  uv pip install --python-platform aarch64-apple-darwin mlx==0.32.1
    -> no wheels with a matching platform tag (e.g. macosx_13_0_arm64)
  the same resolve at --python-version 3.9
    -> no wheels with a matching Python implementation tag (e.g. cp39)

Before this branch, macOS 13 arm64 reached neither failure: the fresh path
skipped the step, and the update path was unpinned and resolved mlx 0.29.3.
Running it on fresh installs and pinning it turns both into an abort with no
manifest written, i.e. a venv the CLI then reports as half-built.

Nothing is lost by stepping aside, because those hosts cannot have a usable
stack in the first place. mlx_repair's own floors (mlx>=0.22, mlx-lm>=0.31.2,
mlx-vlm>=0.4.4) are unsatisfiable there:

  uv pip install --python-platform aarch64-apple-darwin 'mlx-lm>=0.31.2'
    -> mlx>=0.30.4 has no wheels with a matching platform tag

The unpinned resolve the update path used was worse than nothing: mlx-lm
0.29.1 and mlx-vlm 0.3.9 are both under those floors, so Studio rejected the
stack anyway, and it dragged transformers to 5.16.1, the version
overrides-darwin-arm64.txt documents as stranding tokenizers and breaking
every `import transformers` on macOS arm64.

Both branches spend a progress slot, so the denominator does not depend on
the host, and the gate the budget is computed from is unchanged.

test_no_torch_skips_mlx_stack.py reads the guard out of the AST and the step
now sits one branch deeper, so it walks the enclosing chain and asserts on the
outermost test, which is still the platform gate it exists to protect.
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 8, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 8, 2026
@danielhanchen

Copy link
Copy Markdown
Member

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 9a7bee0277

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
Comment lines only, AST-verified: 66 removed for 30 added across the three files.
Every load-bearing fact stays, including the wheel provenance the two floor
constants are read from.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 7ac8596cb8

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 8, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Sep 8, 2026
@unslothai unslothai deleted a comment from shimmyshimmer Sep 8, 2026
@danielhanchen
danielhanchen merged commit a42840c into main Sep 8, 2026
10 of 72 checks passed
@danielhanchen
danielhanchen deleted the macos-mlx-fresh-install branch September 8, 2026 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants