What Causes This Issue
Users in the Apple Support Community have reported widespread failures when attempting to run local AI model training workflows on Mac using Unsloth, Qwen, and Inkling. The problem typically manifests as out-of-memory errors, Metal Performance Shaders (MPS) backend crashes, or dependency conflicts during environment setup. These issues are most prevalent on Apple Silicon Macs (M1/M2/M3 series) running macOS Sonoma or later, where the unified memory architecture interacts unpredictably with PyTorch’s MPS implementation and Unsloth’s optimized kernels.
The root causes cluster around three areas: insufficient unified memory allocation for model weights and gradients, version mismatches between PyTorch, Unsloth, and the transformers library, and missing system-level dependencies like llama.cpp or bitsandbytes compiled for ARM64. Many users encounter silent failures where training appears to start but stalls at the first backward pass, while others see explicit CUDA-only errors despite running on Mac hardware.
Step-by-Step Fixes
- Verify Python environment and architecture
Open Terminal and runpython -c "import platform; print(platform.machine())". Confirm output showsarm64. If it returnsx86_64, you are running under Rosetta 2 — reinstall Python natively via Homebrew (brew install python) or usearch -arm64 /usr/bin/python3for scripts. - Install PyTorch with MPS support
Runpip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu. The nightly CPU build includes MPS backend for Apple Silicon. Avoid the stable CUDA wheels; they lack MPS operators required by Unsloth. - Install Unsloth from source with MPS patches
Clone the repository:git clone https://github.com/unslothai/unsloth.git && cd unsloth. Checkout the latest tag supporting MPS (git checkout v2024.12or newer). Install in development mode:pip install -e . --no-build-isolation. This compiles custom kernels for ARM64. - Configure memory management for unified memory
Set environment variables before launching training:export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0export PYTORCH_MPS_LOW_WATERMARK_RATIO=0.0
These disable PyTorch’s conservative memory caching, allowing full use of unified memory. Add to your shell profile for persistence. - Install quantized Qwen weights via transformers
Runpip install transformers accelerate bitsandbytes. Note: bitsandbytes requires a patched build for macOS. Install viapip install bitsandbytes-mps(community fork) or compile from source withmake cuda=0 mps=1. Load models withdevice_map="mps"andload_in_4bit=True. - Apply Inkling configuration for Mac
Create aconfig.yamlwith:backend: mpsprecision: fp16offload_to_cpu: true
This forces Inkling to use MPS, enables mixed precision, and offloads optimizer states to CPU RAM when VRAM pressure spikes. - Test with a minimal training loop
Run a 3-step sanity check using a 0.5B parameter Qwen model. Monitor Activity Monitor → Memory tab. If memory pressure exceeds 90%, reduce batch size to 1 and enable gradient accumulation (steps=4).
Additional Solutions
Use llama.cpp for inference-only workloads
If fine-tuning is not required, skip Unsloth entirely. Install llama.cpp via Homebrew (brew install llama.cpp) and run quantized Qwen GGUF models directly. This bypasses PyTorch/MPS instability and runs efficiently on the Neural Engine via Core ML delegation.
Upgrade macOS to 14.5 or later
Apple resolved critical MPS graph capture bugs in macOS 14.5. Users on 14.4 or earlier experience random kernel panics during backward passes. Check System Settings → General → Software Update.
Increase swap file size
macOS dynamically manages swap, but training workloads benefit from a larger reserve. Run:sudo launchctl limit maxfiles 65536 65536sudo sysctl -w vm.swapusage=8G
Requires SIP disabled on Apple Silicon (recovery mode → csrutil disable). Proceed only if comfortable with reduced system protection.
Switch to Docker with Apple Silicon images
Pull dustynv/pytorch:2.4-mps or build a custom container with FROM python:3.11-slim and ARM64 wheels. Containers isolate dependency conflicts and guarantee reproducible MPS behavior across Macs.
Disable Apple Intelligence background processes
On macOS 15+, Apple Intelligence reserves unified memory for on-device models. Temporarily disable via System Settings → Apple Intelligence & Siri → Apple Intelligence (toggle off) during training sessions. Re-enable after.
When to Contact Apple Support
Escalate to Apple Support if:
- Kernel panics occur consistently at the same training step across multiple models — indicates a driver-level MPS bug.
- Memory pressure triggers system-wide freezes despite swap configuration — may signal a memory leak in the MPS allocator.
- External GPU (eGPU) via Thunderbolt fails to appear in
torch.mps.device_count()— requires Apple’s Thunderbolt/MPS integration support. - Neural Engine delegation via Core ML produces incorrect logits compared to MPS CPU fallback — suggests compiler regression.
Before contacting, capture a sysdiagnose (press Control+Option+Command+Shift+.) during failure and note the exact PyTorch, Unsloth, and macOS versions.
FAQ
Can I train Qwen 7B on an 8GB M1 MacBook Air?
Only with aggressive 4-bit quantization, batch size 1, gradient accumulation 16, and CPU offloading. Expect 4-6 hours per epoch. 16GB unified memory is the practical minimum.
Why does Unsloth install but fail at import with “symbol not found” errors?
This indicates a version mismatch between the compiled kernels and your PyTorch build. Reinstall both from source in the same environment. Avoid mixing pip and conda packages.
Does Inkling support multi-GPU on Mac Pro with multiple AMD cards?
No. Inkling and Unsloth currently target single-device MPS or CUDA. For multi-GPU, use PyTorch DDP with device_map="balanced" across CUDA devices on Linux.
How do I verify MPS is actually being used?
Run python -c "import torch; print(torch.backends.mps.is_available()); x=torch.randn(3,3).to('mps'); print(x.device)". Output should show True then mps:0.
Will these fixes work for Llama 3, Phi-3, or Gemma models?
Yes. The MPS memory configuration, Unsloth installation method, and bitsandbytes quantization steps apply universally to any transformer model loaded via Hugging Face transformers on Apple Silicon.







































