# Swiftlet

> A Swift and Metal runtime that streams Mixture-of-Experts weights from storage so 35B and 80B models run on a Mac or an iPhone

- Category: Models & Inference / Local Runtimes
- Language: Swift
- Licence: Apache-2.0
- Repository: https://github.com/leonickson1/Swiftlet
- Canonical page: https://ai-tldr.dev/tools/swiftlet/
- Updated: 2026-08-03

## In short

Swiftlet is an inference runtime written in Swift with Metal GPU kernels, built for one specific trick: it keeps only the small dense core of a Mixture-of-Experts model resident in memory and streams the routed expert weights from storage on demand. It sits in the Local Runtimes category of the Models & Inference tools and is open-source, written in Swift and licensed Apache-2.0.

## Overview

Swiftlet is an inference runtime written in Swift with Metal GPU kernels, built for one specific trick: it keeps only the small dense core of a Mixture-of-Experts model resident in memory and streams the routed expert weights from storage on demand. Because a MoE model activates a fraction of its parameters per token, that turns a model far larger than the device's RAM into something an iPhone can hold open.

The runtime targets Qwen MoE models — Qwen3.6-35B and Qwen3-Next-80B in 4-bit and 8-bit variants — on Apple Silicon Macs running macOS 14 or later and iPhones running iOS 17 or later. Reported throughput spans roughly 1 token per second on an iPhone 17 up to about 19.5 tokens per second on an M4 Max, so the trade is explicit: the device stops being the limit on model size and starts being the limit on speed.

Under the hood it caches experts with an LFU eviction policy, compiles its Metal shaders at runtime, and validates its outputs against MLX reference implementations. Swiftlet is distributed as a Swift library, a set of command-line tools, an OpenAI-compatible server and an iOS app (Priv AI), all under the Apache-2.0 licence.

## What it does

- Streams routed MoE expert weights from storage while the dense core stays in memory
- Runs Qwen3.6-35B and Qwen3-Next-80B in 4-bit and 8-bit variants on Apple Silicon and on iPhone
- LFU expert cache keeps the hot experts resident and evicts the rest
- Metal shaders compiled at runtime, with outputs validated against MLX reference implementations
- Ships as a Swift library, CLI tools, an OpenAI-compatible server and the Priv AI iOS app
- Runs on macOS 14+ and iOS 17+, with no cloud call in the loop

## Getting started

Swiftlet builds with the Swift package manager and runs against a .qpack model file. Everything happens on-device.

1. Clone and build

   A release build produces the swiftlet CLI under .build/release.

```bash
git clone https://github.com/leonickson1/Swiftlet.git && cd Swiftlet
swift build -c release
```

2. Chat with a model

   Point the CLI at a downloaded model pack. The core stays in RAM and experts stream from disk as generation proceeds.

```bash
.build/release/swiftlet chat ~/models/qwen3.6-35b.qpack "your prompt"
```

3. Pick the variant that fits the device

   The 4-bit and 8-bit packs trade quality against how much of the model has to be paged in. On an iPhone 17 expect around 1 token per second; on an M4 Max the README reports about 19.5.

```text
# 35B for phones and small Macs, 80B where storage bandwidth allows
```

## When to use it

- Run a large open-weight MoE model on a Mac that does not have enough RAM to hold it
- Put a 35B-class assistant on an iPhone with no network round-trip
- Build an iOS or macOS app on a Swift-native inference library instead of bridging to a C runtime
- Serve a local OpenAI-compatible endpoint from an Apple machine for development

## Version history

- 2026-08-03: Swiftlet was released publicly, running an 80B Qwen model in about 4.3 GB of peak RAM on a Mac and a 35B model in roughly 2.5 GB on an iPhone 17 by streaming experts from disk.
