Repository navigation
Do not self-heal MLX into a --no-torch install - #10409
Conversation
A --no-torch install is GGUF-only, but the runtime self-heal reinstalled mlx/mlx-lm/mlx-vlm on first launch, flipping hardware to MLX and turning Train/Export on against the user's choice. Treat a recorded no-torch install like the existing kill switch. Unknown stays False so installs predating the manifest keep today's behaviour.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Two gaps found while testing this branch. The unit tests the description promises were not in the branch: the only test change was the one fixture line in test_health_holds_verdict_during_mlx_repair.py. test_mlx_autorepair_no_torch_optout.py adds them. It pins that only a literal True opts out, so None (every install predating the manifest key) and a truthy non-bool keep today's behaviour; that an unreadable manifest, a missing studio package and a raising lookup all fail open rather than costing someone their training stack; that a --no-torch install starts no repair even when the verdict blames MLX, without spending the one-shot latch; that a normal install and an older install with no recorded mode still repair; and that an opted-out venv with a usable stack still overturns a chat-only verdict, which is the reason the opt-out was spelled into the kill switch's condition rather than given an early return. Six of the cases run through the shipped install_manifest.py against a real manifest on disk, so a change to its parsing cannot pass this file while breaking the gate. test_mlx_repair.py now neutralises the install mode in its autouse fixture, the same way the health test does. Left ambient, the answer comes from the manifest of whatever venv the tests run in: with a GGUF-only Studio venv, which is a real place to run them, four of its tests fail on this branch (test_apple_silicon_missing_mlx_starts_repair_and_redetects, test_attempts_only_once_per_process, test_a_stack_that_is_really_unusable_keeps_its_verdict, and test_the_repair_worker_is_scoped_to_the_epoch_read_before_the_measurement). 91 tests pass across the three files with a no-torch manifest present and with none.
|
I went through this branch and pushed one commit to it. The change itself holds up; two things around it did not. The changeCorrect, and the unknown case is the right way round. What I pushedThe unit tests the description promises were not in the branch. The only test change here was the single fixture line in
That is the same ambient-state problem the fixture in Verification
Relationship to #10431Independent, disjoint files, mergeable in either order. #10431 fixes the opposite direction, MLX failing where it was wanted: on a normal torch install on macOS arm64 the installer leaves transformers and tokenizers pinned apart, so |
|
Verified this on an Apple Silicon Mac against a real no-torch venv: main installs mlx and flips Pushed 239673b with two fixes:
225 passed across the related test files with system Python and inside the no-torch venv. ruff clean. |
…ng MLX on a --no-torch install
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Confirmed the self-heal in studio/backend/utils/mlx_repair.py has no install-mode gate today, so a --no-torch install gets MLX put back on first launch, and the follow-up commits added the unit tests and pinned the ambient manifest in the older test files. Will get this reviewed. |
The runtime gate and the new no_torch verdict are both well covered now, but the line that makes the opt-out survive an update was not: install_python_stack.py's MLX step runs on IS_MAC_ARM and not skip_base, the updater clears SKIP_STUDIO_BASE, and without the not NO_TORCH guard a routine 'unsloth studio update' reinstalls mlx/mlx-lm/mlx-vlm into a GGUF-only venv and the next launch enables Train before the no_torch verdict is ever reached. Structural, for the reason test_diffusers_pin.py is: running the installer needs a Mac, and what has to hold is a property of the gate. Four checks: the step is gated on both IS_MAC_ARM and not NO_TORCH; the base_total accounting uses the same expression, so the progress bar cannot count a step that never runs; the updater still clears SKIP_STUDIO_BASE, so the first check cannot pass vacuously; and _infer_no_torch still consults the manifest, which is what makes NO_TORCH true during an update, since the updater injects no environment variable. Verified against a tree with the guard removed: the first two fail, naming the weakened gate and the desynced accounting.
|
Re-checked at 679c416 after the review round. All six items look genuinely addressed, and I verified the one with the widest blast radius myself rather than taking the commit headline for it. The update path. This was the item that mattered: gating the runtime self-heal is only half an opt-out if That line had no test, so I pushed one: The other five. Two things I checked for and did not find: Suites. 253 pass locally across The red check is not this PR. |
|
@codex security review |
_NO_TORCH_SETTLED_EPOCH was assigned before the CHAT_ONLY_REASON check, so a settle that arrives after another same-epoch pass has already enabled training declined, as it should, but still marked the epoch. The next transient MLX import failure in that lifespan then published no_torch immediately, which reads as settled, and start_mlx_autorepair_if_needed() returned early because the verdict no longer blamed the MLX stack, leaving a usable stack unmeasured until a restart. Narrow, but reachable on exactly the host this PR is about: a --no-torch install carrying a manually installed MLX stack. Moving the assignment below the check also matches what the flag is documented to mean, which is that the post-warm probe measured this host's stack unusable. test_a_declined_settle_does_not_mark_the_epoch covers it: with the assignment back above the check it fails on the epoch, and a following detect_hardware() publishes no_torch instead of mlx_unavailable. 222 tests pass across the six affected suites.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Problem
install.sh --no-torchon Apple Silicon is GGUF-only: no training stack. The installer honours that and installs no MLX. The runtime self-heal then puts it back on first launch.Observed on a clean
--no-torchinstall, from the server log:Result: 9
mlx*packages installed,chat_onlyflips tofalse, and Train/Export turn on. The user opted out of the training stack and got it anyway, roughly 20s after first launch.start_mlx_autorepair_if_needed()gated on Apple Silicon, theUNSLOTH_DISABLE_MLX_AUTOREPAIRkill switch, and stack availability, but never on the install mode.mlx_repair.pyhad no reference to no-torch at all.Fix
Treat a recorded no-torch install exactly like the existing kill switch, so it reuses that path unchanged: no reinstall, but a correct verdict still overturns a stale one.
recorded_no_torch()returnsOptional[bool], and its docstring is explicit thatNonemust not be read as False. Only a literalTrueopts out, so an install predating the manifest keeps today's behaviour, and a broken or unreadable manifest never silently disables the repair.Verification
Real installs into clean
UNSLOTH_STUDIO_HOMEroots on macOS arm64, each launched and observed for 45s:mlx*packageschat_only--no-torch, beforefalse--no-torch, aftertruefalseThe third row is the regression check: the self-heal must still work where it is wanted. It fires, succeeds, and logs
MLX self-heal succeeded; Train/Export enabled.Added 14 unit tests covering
True/False/None, manifest exceptions, and truthy non-bool returns.tests/test_health_holds_verdict_during_mlx_repair.pyandtests/test_defaults_refresh_after_redetect.py: 36 passed. One of them was inheriting the ambient manifest and would have failed on a no-torch runner, so theapple_siliconfixture now pins the install mode alongside the other ambient state it already neutralises. Both files now pass under a no-torch venv and a normal venv.Relationship to #10403
Independent and separately mergeable. #10403 stops the installer from putting MLX into a GGUF-only install; this stops the runtime from putting it back. Either can land first.