[Feature] Add MLX inference backend
Summary
Add an MLX-based inference backend as an alternative to the existing llama.cpp path, targeting Apple Silicon Macs.
Problem
The current local inference path uses llama.cpp, which runs on the CPU (and partially on Metal via GGML). MLX is Apple's own machine learning framework optimized for Apple Silicon's unified memory architecture. On M-series chips, MLX can deliver significantly better throughput and lower latency than llama.cpp for the same model because it is designed ground-up for the hardware.
Users with Apple Silicon Macs would get faster completions and lower energy draw from local inference without switching to the Apple Intelligence engine.
Proposed direction
- Add a new
SuggestionEngineKindcase (e.g..llamaMLXor.mlx) alongside the existing.llamaOpenSourceand.appleIntelligencecases. - Implement an
MLXSuggestionEngineconforming to the existingSuggestionEngineProtocolcontract inSuggestionSubsystemContracts.swift. - Route through
SuggestionEngineRouterthe same way the llama path does today. - Support GGUF or MLX-native quantized weights (e.g. via
mlx-communityHuggingFace models). Reuse the existingModelDownloadManager/BundledRuntimeLocatorwhere possible. - Gate the engine option on Apple Silicon availability so it never appears on Intel Macs.
- Surface the new engine in the Engine picker in both the menu bar popup and Settings > Engine & Model.
Additional context
- MLX Swift bindings: https://github.com/ml-explore/mlx-swift
- MLX Examples (LLM inference): https://github.com/ml-explore/mlx-swift-examples
- The existing llama.cpp integration lives in
LlamaRuntimeCore,LlamaRuntimeManager, andLlamaSuggestionEngineand is a good structural reference. - The
CotabbyInferenceSwift package currently wraps llama.cpp; MLX could live in a new target in that package or in a dedicatedCotabbyMLXpackage.
I would be happy to support if there is MLX support.
Currently still in works by my partner, hope to have by next release 🤞