leonickson1/Swiftlet
Swiftlet is a Swift and Metal runtime that runs large Qwen Mixture-of-Experts models locally on Apple devices by streaming expert weights from storage, enabling 35B and 80B models to run with low RAM, including on iPhone.
What it solves
Swiftlet allows large Mixture-of-Experts (MoE) models, such as the Qwen3-Next and Qwen3.5/3.6 families (up to 80B or even 397B parameters), to run on consumer Apple hardware, including iPhones. It solves the memory bottleneck by streaming model weights from the SSD to the GPU on demand rather than requiring the entire model to be resident in RAM.
How it works
Swiftlet uses a hybrid approach to memory management:
- Dense Core Residency: It keeps only the essential dense weights (attention, embeddings, routers) resident in memory.
- Expert Streaming: Routed experts are packed into a
.qpackcontainer with fixed strides. When a token is processed, the runtime usespreadto fetch only the required experts from storage into a bounded cache pool. - Metal Integration: The entire forward pass is executed on the GPU using runtime-compiled Metal shaders.
- Linear Attention: It leverages Gated DeltaNet linear attention in 75% of the layers, which prevents the KV cache from growing as context length increases.
Who it’s for
- Apple Silicon Users: Developers and enthusiasts with Macs (M1 through M5) or iPhones (iOS 17+) who want to run high-parameter models locally.
- iOS App Developers: Those looking to integrate a high-performance local LLM engine into Swift-based applications via the
SwiftletCorepackage.
Highlights
- Extreme RAM Efficiency: Runs an 80B model in ~4.3 GB of RAM and a 35B model in ~2.6 GB of RAM (4-bit).
- Cross-Platform: Works across macOS 14+ and iOS 17+.
- Multiple Interfaces: Provides a Swift package for app integration, a CLI for benchmarking, and an OpenAI-compatible server for third-party UIs.
- Validated Correctness: Every layer is validated against
mlx-lmreference implementations to ensure output parity. - iPhone Support: Enables the execution of 35B parameter models on a base iPhone.
Related
- Dispatch
- Project
- Project
- Dispatch
- Project