Skip to content

Make TrainerBoi work fully on macOS (Apple Silicon / MPS) - #5

Merged
CloudCorpRecords merged 1 commit into
mainfrom
mac-compat
Oct 17, 2026
Merged

CloudCorpRecords merged 1 commit into
mainfrom
mac-compat

Conversation

@CloudCorpRecords

Copy link
Copy Markdown
Owner

TrainerBoi was Windows + NVIDIA-only. This makes it run completely on Apple Silicon Macs (with Metal/MPS acceleration) while keeping Windows behavior unchanged.

How it works

  • New device_utils module: picks CUDA → MPS → CPU and centralizes dtype, 4-bit availability, optimizer, mixed-precision, memory stats, and cross-platform process helpers (kill_pid/kill_tree, file-manager reveal).
  • Graceful fallbacks: Unsloth → HF backend, QLoRA/4-bit → full-precision LoRA, 8-bit/fused optimizers → adamw_torch, bf16 → fp16 (MPS) / fp32 (CPU). Each prints a one-line note instead of crashing.
  • Mac setup: setup.sh/scripts/setup.sh (uv + Python 3.11 + MPS PyTorch + libs + UI), START.sh, launch_*.sh, activate.sh, Desktop .command creator. XGBoost's missing libomp is wired from PyTorch's bundled copy — no Homebrew needed.
  • Audio: transcribe_audio uses the existing PyAV decoder (torchaudio needs torchcodec + system FFmpeg); Transcriber device fixed (device=0 → accelerator-aware).
  • Desktop app: macOS setup flow (MPS torch, libomp copy), portable backend shutdown, dist:mac DMG target, generated icon.icns.
  • Planner: MPS-aware model caps (no 7B without 4-bit unless 20GB+ usable), throughput-scaled time estimates, LoRA/QLoRA wording per machine.
  • Errors, telemetry, hardware: MPS OOM patterns + macOS advice, MPS memory stats, Apple chip + unified-memory reporting.
  • Tests + CI: new tests/test_device_utils.py (19 stdlib tests, no deps); CI matrix now covers macOS and runs them.

Verified on M1 Pro / 16 GB

setup.sh end to end; MPS detected (~4.7 TFLOPS fp16); SFT/DPO/ORPO/KTO/GRPO/pretrain/vision/embeddings smokes; chat, merge, health check, Studio boot + API + classic mount, full guided run (data → plan → train → before/after); arm64 + x64 DMGs build.

- New device_utils module: CUDA -> MPS -> CPU selection, dtype,
  4-bit/optimizer/mixed-precision policy, cross-platform process helpers
- All training scripts (SFT/DPO/ORPO/KTO/GRPO/pretrain/vision/
  embeddings/audio/tabular) and inference paths fall back gracefully
  where NVIDIA-only features (QLoRA, Unsloth, 8-bit optims) are missing
- Mac setup/launch scripts (setup.sh, START.sh, launch_*.sh), libomp
  wiring for XGBoost without Homebrew, requirements markers + rich
- Desktop app: macOS setup flow, portable backend kill, dist:mac DMG
  target, generated icon.icns; CI now tests macOS + runs unit tests
- Device-aware errors, planner estimates/model caps, hardware reporting
- tests/test_device_utils.py: 19 stdlib regression tests

Verified on M1 Pro: setup.sh, SFT/DPO/ORPO/KTO/GRPO/pretrain/vision/
embeddings smokes, chat, merge, health check, Studio boot, guided
end-to-end run, and arm64+x64 DMG builds.
@CloudCorpRecords
CloudCorpRecords merged commit 1396777 into main Oct 17, 2026
2 checks passed
@CloudCorpRecords
CloudCorpRecords deleted the mac-compat branch October 17, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant