fix(mlx): bundle native libs and broaden error handling for Apple Silicon#93
Merged
jamiepine merged 1 commit intojamiepine:mainfrom Feb 23, 2026
Merged
Conversation
…icon The distributed macOS aarch64 binary shipped without MLX acceleration despite the model and backend code supporting it. Two root causes: 1. **OSError not caught in platform_detect.py** PyInstaller bundles isolate the filesystem, so when MLX tries to load its Metal shader libraries (.metallib) it raises OSError, not ImportError. platform_detect.get_backend_type() only caught ImportError, causing a silent fallback to PyTorch even on Apple Silicon hardware. Fix: broaden the except clause to (ImportError, OSError, RuntimeError) and import mlx.core instead of mlx (forces native lib loading eagerly). 2. **collect_data_files used instead of collect_all for MLX** build_binary.py and voicebox-server.spec used --collect-data / collect_data_files for mlx and mlx_audio. This copies Python source and pure-Python data, but NOT native shared libraries (.dylib, .metallib). Fix: switch to --collect-all / collect_all which captures binaries too, then pass them to Analysis(binaries=...) in the spec. Result: macOS Apple Silicon users now get MLX inference (~4-5x faster than PyTorch CPU), matching the performance documented in the README.
|
before and binary count and servers e input in the lag das |
|
woo , the apply is very good , an terminate and addons corresct the process |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The distributed macOS aarch64 binary (
voicebox_aarch64.app.tar.gz) silently falls back to PyTorch CPU instead of using MLX, despite the README advertising 4-5x faster inference on Apple Silicon.Two root causes:
1.
platform_detect.pyonly catchesImportErrorInside a PyInstaller bundle, MLX loads its Metal shader libraries (
.metallib) at import time. When those files are missing from the bundle, Python raisesOSError— notImportError. The original code:This causes a silent fallback to PyTorch on every Apple Silicon machine running the binary.
2.
collect_data_filesmisses native librariesbuild_binary.pyandvoicebox-server.specused--collect-data/collect_data_filesformlxandmlx_audio. This only copies pure-Python files — native.dyliband.metallibfiles are excluded. PyInstaller needs--collect-all/collect_all+Analysis(binaries=...)to bundle shared libraries correctly.Fix
platform_detect.py— catch(ImportError, OSError, RuntimeError)and importmlx.core(forces native lib loading eagerly so any failure is caught here)build_binary.py— replace--collect-data mlx/mlx_audiowith--collect-allvoicebox-server.spec— usecollect_all()and pass collected binaries toAnalysis(binaries=...)Testing
Reproduced on macOS 15 (Apple Silicon M4 Mac mini):
Backend: pytorch, generation takes 30+ min for a 5s clipBackend: MLX | GPU: MPS (Apple Silicon), same clip in ~39s (first run) / ~8s (warm)