Repository navigation
Studio/CLI: report Rosetta, skip audio.cpp CUDA on pre-Turing GPUs, pass doctor on MPS/XPU, hide XPU from token preview - #14374
Conversation
…U, hide XPU from token preview
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. |
[skip ci]
|
@codex review |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afe65a0d87
ℹ️ 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".
| : chatOnlyReason === "rosetta" | ||
| ? "Studio is running under Rosetta (x86_64 Python). Re-run the installer from a native arm64 terminal to enable training." |
There was a problem hiding this comment.
Gate video navigation for Rosetta hosts
When this new reason is returned, videoNavHint() has no rosetta case, so both the sidebar and route guard leave Video enabled. On the same Darwin/x86_64 process, _video_capability_verdict() falls through to the unsupported macOS branch, meaning every click reaches a page that cannot run video and incorrectly describes the machine as an Intel Mac. Handle rosetta in the video navigation/capability path as well, with the native-arm64 remediation.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in fee4169: under Rosetta is_apple_silicon() is False, so the backend verdict did fall into the Intel Mac branch. It now returns reason rosetta with the native arm64 reinstall message, and videoNavHint has the matching rosetta case, so the sidebar row and route guard disable Video with that remedy. Tests: test_rosetta_is_told_to_reinstall_native_not_that_it_is_an_intel_mac and the rosetta case in provisional-hardware-verdict.test.ts.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fee4169b86
ℹ️ 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".
| elif platform.system() == "Darwin" and _running_under_rosetta(): | ||
| # MLX needs a native arm64 Python; "Intel Mac" would be wrong. | ||
| CHAT_ONLY_REASON = "rosetta" |
There was a problem hiding this comment.
Handle Rosetta in the export capability
When Studio runs under Rosetta and PyTorch imports successfully, this new branch records rosetta, but export_capability() has no matching case: because is_apple_silicon() is false in the x86_64 process, it falls through to no_accelerator (or pytorch_not_installed). Consequently, the Export page and its API guard tell these users that hardware or PyTorch is missing instead of giving the actionable native-arm64 reinstall remedy now used for Train and Video.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in b773750: export_capability now has the same Darwin + Rosetta arm as video, returning reason rosetta with the native arm64 reinstall message, so the Export page and its API guard give that remedy instead of no_accelerator. Test: test_rosetta_export_gives_the_native_arm64_remedy.
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
…the arch probe in the fake host
…in the Intel Mac test
|
@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". |
[skip ci]
…14374) (#14407) ## Problem main is over the startup bundle budget, so `Frontend build + bundle sanity` fails on every PR that touches the frontend: ``` eager startup JS: 6698.7 KB raw, 2017.0 KB transfer, 96 chunks over the startup budget: raw 6698.7 KB > 6698.6 KB ``` #14374 added the Rosetta chat-only messages to the eager sidebar (`app-sidebar.tsx`) and the hardware verdict (`hardware-verdict.ts`). Measured on one machine and build (Node 24, 96 chunks), that is 298 B raw / 127 B transfer: | | raw | transfer | |---|---|---| | `34c5203ebb` (before #14374) | 6,859,194 | 2,065,328 | | `e172530d14` (main, after #14374) | 6,859,492 | 2,065,455 | | old limit | 6,859,354 | 2,065,517 | The raw total is 138 B over. #14374's own run most likely measured against an older base that still had headroom. ## Fix Raise `BUDGET` to the measured main build plus the same 160 B raw / 189 B transfer margin as the earlier raises (`6_859_652` raw, `2_065_644` transfer), with a comment entry saying what it is for. ## Verification On main `e172530d14`, after `npm ci` and `npm run build`: - With this change: `within budget (0.2 KB transfer, 0.2 KB raw to spare)`. - With main's limits: `over the startup budget: raw 6698.7 KB > 6698.6 KB`.
## Problem `studio/backend/tests/test_text_io_encoding.py::test_text_io_names_its_encoding` fails on main, so the `(Python 3.13, rest)` backend shard is red on every PR built on top of #14374 (for example #14391): ``` AssertionError: Text I/O without an explicit encoding falls back to locale.getencoding(), ... hardware.py:165: subprocess(text = True) without encoding ``` #14374 added `_running_under_rosetta()`, which runs `sysctl -n hw.optional.arm64` with `text = True` and no encoding. The guard is right. Every other `subprocess` call in `hardware.py` names its encoding, and a bare `text = True` decodes with the locale codec (ASCII under a C or POSIX locale). ## Fix Pass `encoding = "utf-8", errors = "replace"`, as the other probes in this file do. The probe only reads `0` or `1`, so behaviour is unchanged. ## Verification - `studio/backend/tests/test_text_io_encoding.py`: fails on main (the line above); with this change, 857 passed. - `test_chat_only_reason.py`, `test_export_capability.py` and `test_video_capability.py`, which exercise the Rosetta check: 64 passed.
…PU record, JetPack 7 off the CPU note (unslothai#14494) ## Summary Follow-up to unslothai#14363 and unslothai#14374 from a post-merge regression review. ## What changes - **An explicit GPU index beats the Jetson CPU record.** On a Jetson before CUDA 13 with an automatic `cpu` record, an explicit `UNSLOTH_TORCH_INDEX_FAMILY=cu126` (or a cu126 index URL) was overridden and Studio hid the CPU-only PyTorch report. The stated index is now checked before the Jetson exception. - **Thor without a GPU attached** got the generic-wheels note instead of "No GPU detected". With no driver CUDA version, `install.sh` now decides JetPack 7 the way `utils/tegra.py` does (L4T R38+, or `tegra264` with no release file). - Host-dependent tests now force "not a Jetson" / "not Rosetta", so they pass on a real Jetson or Apple Silicon Mac. ## Tests - Changed tests: 342 passed; 5 fail against main's source (the new ones). Installer shell checks 109/109 on both. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
## What `unsloth doctor` only knew how to probe CUDA / ROCm GPUs. Before #14374, a healthy Apple Silicon Mac, where Unsloth trains through the MLX backend (`unsloth_zoo.mlx`), got a **false failure**: ``` $ unsloth doctor === Versions === torch 2.14.1 CUDA (torch build) None driver unknown NCCL unavailable === GPUs (0) === === Verdict: PROBLEMS FOUND === - No GPU is visible to torch. Check `nvidia-smi`, CUDA_VISIBLE_DEVICES, and that torch was installed with CUDA or ROCm support. $ echo $? 1 ``` Since #14374, main passes a Mac as soon as it sees Metal, but it still never checks whether MLX can train. With `mlx_lm` or `mlx_vlm` broken, main's `unsloth doctor` says OK and exits 0 while Unsloth Studio is chat-only. This PR runs the same MLX check Unsloth Studio uses, so doctor's answer matches whether training will actually work. ## Why this is a real gap, not a cosmetic one The MLX backend is a first-class path in this repo — `unsloth train`, `unsloth chat`, `unsloth inference` and `unsloth export` all detect it and run on Apple Silicon. `doctor` is the one command that was never taught about it, and it is the command users reach for first when something goes wrong. This is the same machine, same install, same process — only the doctor was blind: ``` $ unsloth train --model <mlx-4bit-model> ... Step 1/2 Loss 1.4718 (7 tok/s, peak 5.39 GB) Step 2/2 Loss 2.7413 (120 tok/s, peak 5.85 GB) ... compile_support_state='supported_verified' ``` ## The fix `doctor` now asks the repository's own gate which backend is live (`studio.backend.core.training.training.should_use_mlx_training_backend`) and, when MLX is active, runs an MLX preflight instead of the CUDA/NCCL one: ``` $ unsloth doctor === Versions === platform Darwin arm64 backend mlx mlx 0.32.4 unsloth_zoo 2026.10.7 Metal available === Device === Apple M5 applegpu_g17g memory 32.0 GiB recommended working set 24.96 GiB === Verdict: OK === - Apple Silicon GPU through the MLX backend. Multi-GPU, NCCL and peer-copy checks do not apply to this backend, so they were skipped. $ echo $? 0 ``` Details: - **`mlx_backend_active()`**: honours `UNSLOTH_FORCE_GPU_PATH=1`, then defers to the repo's `should_use_mlx_training_backend()` gate. If the Unsloth Studio backend can't be imported, it falls back to the same check that gate makes (macOS on Apple Silicon). It doesn't require `mlx` to be importable, so a Mac without `mlx` gets the MLX verdict's "install mlx" hint instead of the CUDA path's `nvidia-smi` one. - **`collect_mlx_info()`**: collects the platform, the `mlx` and `unsloth_zoo` versions, Metal availability, and the device name, architecture and memory from `mx.device_info()`. `unsloth_zoo.mlx` only counts as present when both `unsloth_zoo.mlx.trainer` and `unsloth_zoo.mlx.loader` import. It also runs `mlx_stack_blockers()` from `studio/backend/utils/mlx_repair.py`, the same check that decides whether Unsloth Studio can train on a Mac (`mlx-lm` / `mlx-vlm` imports and minimum versions). It never raises. - **`verdict_mlx(info)`**: a **pure** function, in the same style as the existing `verdict()`. It reports healthy only when `mlx`, `unsloth_zoo.mlx`, the MLX stack check, Metal and a device all pass. A stack check that couldn't run counts as a failure, since training needs the same modules. Every repair hint says `unsloth studio update`, never a plain `pip install`, which can move Transformers to a version Unsloth Studio can't use. - **The CUDA path is byte-identical.** `_gpu_checks()` is untouched; the only change is the branch that chooses between `_mlx_checks()` and `_gpu_checks(timeout)`. ## Tests `unsloth_cli/tests/test_doctor_mlx.py` has 25 tests, all runnable without a GPU. They cover: - the healthy Apple Silicon case - each failure mode: no `mlx`, an `unsloth_zoo` without MLX, only one of the two zoo MLX modules importing, the MLX stack check reporting a problem or not running at all, no Metal, no device - routing to the MLX checks when `mlx` is missing - the platform fallback when the Unsloth Studio backend can't be imported (Apple Silicon Mac, Intel Mac, Linux) - no hint suggesting a bare `pip install` - `UNSLOTH_FORCE_GPU_PATH` - `doctor` exiting 0 on the MLX path and keeping the CUDA path when MLX is off The two CUDA tests in `test_doctor_gpus.py` are pinned to the CUDA path so they don't pick up the MLX path on an Apple Silicon host. Measured at `4be4c982ea`: | check | result | |---|---| | `pytest unsloth_cli/tests/test_doctor_mlx.py unsloth_cli/tests/test_doctor_gpus.py` | 65 passed | | `pytest tests/security/test_lint_risky_loaders.py` | 46 passed | | `unsloth doctor` on an Apple M5 (32 GB, macOS 26.6, mlx 0.32.3) | exit 0, Verdict OK, about 4 s | | same M5 with `mlx_lm` broken or structlog missing | names the problem, exit 1 | | fresh `uv pip install` of this branch (no mlx, no zoo) | points at `unsloth studio update`, exit 1 | | Codex ([mirror](LeoBorcherding#537 (comment))) | no major issues | | CI ([mirror](LeoBorcherding#537)) | 13 passed, 8 skipped, 2 failed. Neither failure involves `unsloth doctor` (block-compile tests, a Windows WMI-timeout test) | Not run: Linux CUDA or ROCm hosts (the CUDA path is unchanged by this PR). ## Notes - The MLX path is not new — `unsloth_zoo.mlx` has shipped `MLXTrainer` / `FastMLXModel` for a while, and this repo already routes `train`, `chat`, `inference` and `export` to it. This PR only teaches the preflight about it. - `mx.metal.device_info()` is deprecated in favour of `mx.device_info()`; the code prefers the new API and keeps the old one only as a fallback. --- 📎 **Porting index:** https://github.com/shadyuwugurl/mlx-lab — `docs/PR_INDEX.md` lists every upstream PR in this effort, `docs/FINDINGS.md` records the Apple Silicon platform findings, and `docs/MODEL_MATRIX.md` shows the verified model matrix on an M5. --------- Co-authored-by: charlie <charlie@local> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: LeoBorcherding <[email protected]>
Summary
Four small detection fixes for hosts that were misreported, without changing behaviour anywhere else.
What changes
rosettainstead ofintel_mac.sysctl -n hw.optional.arm64: bounded, cached, and it never raises. It runs only on Darwin x86_64 and fails open tointel_mac.CUDA12_ARCHS/CUDA13_ARCHSin the audio.cpp prebuilt workflow).compute_capand installs the CPU build when every NVIDIA card is older than 7.5.UNSLOTH_AUDIO_CPP_REPOrelease keeps CUDA, since its build list is unknown.unsloth doctor:ONEAPI_DEVICE_SELECTOR=opencl:cpu, so torch-xpu does not open a Level Zero GPU context. Only the child env changes.Hosts affected
unsloth doctor.Native arm64 Macs, real Intel Macs, sm_75+ NVIDIA hosts, and CUDA/ROCm hosts keep today's answers.
Tests
studio/backend/tests/test_chat_only_reason.py: Rosetta, Intel Mac, a failing probe, native arm64.tests/studio/install/test_install_audio_cpp_prebuilt_logic.py: pre-Turing, mixed, sm_75+, and unreadable or failing compute_cap queries.unsloth_cli/tests/test_doctor_gpus.py: MPS, XPU, CUDA/ROCm without a device, a CPU build, and a raising probe.studio/backend/tests/test_token_preview.py: the child env hides CUDA, HIP and SYCL, and the parent env is untouched.studio/frontend/tests/mlx-context-helpers.test.ts:rosettarules out MLX.The new tests fail on the merge base and pass here. The related suites show no new failures.
Screenshots
Studio sidebar with
/api/healthreportingchat_only_reason: "rosetta"(injected into the real backend's response on both builds, since this cannot be produced on a Linux host).Train tooltip: before it only said "Train"; now it explains the Rosetta install and the fix.
Video row: before it stayed enabled with no hint; now it is disabled with the same reason and fix.
Export and Video pages show the backend's own message (
export_capability()/video_capability()in/api/system/hardware). On a spoofed Rosetta host (Darwin, x86_64 process,hw.optional.arm64= 1, CPU torch):no_accelerator: "Export requires an NVIDIA, AMD, or Intel GPU, or Apple Silicon (MLX). No supported accelerator was found on this host. (PyTorch is installed, but Unsloth cannot export on CPU only.)"rosetta: "Studio is running under Rosetta (x86_64 Python), so export is disabled. Re-run the installer from a native arm64 terminal to enable export."macos_unsupported: "Video generation requires Apple Silicon. This Intel Mac has no Metal (MPS) device for the video pipelines to run on."rosetta: "Studio is running under Rosetta (x86_64 Python), which has no Metal (MPS) device for the video pipelines. Re-run the installer from a native arm64 terminal to enable video generation."