Skip to content
Projects

About

Run one LLM across your Mac, iPhone and iPad. llama.cpp RPC on Metal, over Wi-Fi and USB-C.

AI & Machine Learning

How these counts are measured

13 stars4 Forks +1 in 24h

Measured star growth

in 24h
+1
in 7 days
Collecting history
in 15 days
Collecting history
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

Orchard

Run one LLM across your Mac, iPad and iPhone as a single system, and use it from any of them.

The Mac is the master. It holds most of the model and serves an OpenAI-compatible API on your network. iPhones and iPads join as workers and run some of the model's layers on their own GPUs (Metal). Under the hood it is llama.cpp's RPC backend on every device. Orchard adds the native apps, discovery, placement and the speed work around it.

Status: early, working. The Orchard Mac app finds iPhones and iPads, plans the split, runs llama-server --rpc and lets you chat from any device. The worker app runs llama.cpp's RPC server on Metal. Pairing with an allowlist isn't built yet: use it on networks you trust.

Proof-of-concept results

Hardware:

  • Master: MacBook Air M2, 8 GB, about 5.3 GB usable by Metal.
  • Worker: iPad Air 5 (M1, 8 GB). With the increased-memory-limit entitlement, the app may use about 7.9 GB, and Metal reports a 5.7 GB working set.

Test setup:

  • llama.cpp b11157 (RPC protocol 7.0.0), Flash Attention on, 4096-token context.
  • Greedy decoding, median of 2–3 runs, measured by llama-server's own timings.
  • Two links to the iPad:
    • Wi-Fi: 34 ms average ping, with spikes up to 155 ms, measured idle.
    • USB-C: the iPad's built-in USB network interface (169.254.x.x). The ping is 1.1 ms, and no iproxy is needed.

Qwen3-1.7B Q4_K_M (1.1 GB), free-text answer, 256 tokens

Setup Generation ms/token
Mac only 63.2 tok/s 15.8
Mac + RPC server on the same Mac (loopback, no iPad) 59.8 tok/s 16.7
Mac 75% + iPad 25%, USB-C 32.7 tok/s 30.6
Mac 50% + iPad 50%, USB-C 29.5 tok/s 33.9
Mac 25% + iPad 75%, USB-C 30.4 tok/s 32.9
iPad 100% (output layer on the iPad too), USB-C 22.9 tok/s 43.6
Mac 50% + iPad 50%, Wi-Fi 19.9 tok/s 50.4
Mac 25% + iPad 75%, Wi-Fi 20.1 tok/s 49.8

Speculative decoding (n-gram lookup), Mac 75% + iPad 25% over Wi-Fi

Task No speculation ngram-simple ngram-mod
Code edit: rename a function, return the whole file (526 tokens) 20.3 tok/s 63.4 tok/s (403/624 drafts accepted) 64–104 tok/s
Free-text explanation (256 tokens) 20.1 tok/s 20.6 tok/s –

Qwen3-8B Q4_K_M (5.0 GB): doesn't fit on the 8 GB Mac alone

Settings: 128 tokens of free text, median of 2 runs. Every row except the first loads without mmap (-lm none, see below).

Setup Generation vs best Mac-only
Mac only, all layers on the GPU (mmap on, the default) fails (Metal out of memory) –
Mac only, llama.cpp auto-fit 1.5 tok/s 0.2×
Mac only, 32/36 layers on the GPU, rest on CPU 5.8 tok/s 0.9×
Mac only, 28/36 layers on the GPU, rest on CPU 6.4 tok/s (best) 1.0×
Mac 50% + iPad 50%, Wi-Fi 9.4 tok/s 1.5×
Mac 50% + iPad 50%, USB-C 13.4 tok/s 2.1×
Code-edit task, Mac 50% + iPad 50%, Wi-Fi, no speculation 8.4 tok/s –
Code-edit task, same split, Wi-Fi, ngram-simple 31.6 tok/s (428/576 drafts accepted) –

mmap must be off on the master. With mmap on (the default), the 8B model on the 8 GB Mac hit kIOGPUCommandBufferCallbackErrorOutOfMemory, even with only half the layers on the Mac, or 20/36 on the GPU in the Mac-only runs. With -lm none, the same splits load and run. My guess, not yet verified, is that the Metal buffers wrap the whole mapped file rather than only the Mac's layers. scripts/serve.sh now passes -lm none by default.

Gemma 3 27B IT IQ3_XXS (10.7 GB): Mac + iPad + iPhone, started from the Orchard app

Setup:

  • Devices: MacBook Air M2 (8 GB), iPad Air M1 (8 GB), iPhone 16 Pro (8 GB).
  • Both phones were connected automatically over USB-C (7–8 ms).
  • Split by the planner: iPad 24, iPhone 23, Mac 15 of 62 layers.
  • 4K context, q8_0 cache, n-gram speculation on.
  • Loading took about 4.4 min, mostly sending ~7.5 GB of layers over USB.
  • The Mac's free memory while running was 17%.
Task Generation Prompt
Free text (128 tokens) 3.4 tok/s 11 tok/s
Code edit, return the whole file (585 tokens), ngram-simple 10.0 tok/s (504/607 drafts accepted) 19 tok/s

A 27B model doesn't fit on any one of these devices. Across the three it runs at reading speed for edits, and slower than reading speed for free text.

What the numbers say

  • A split costs a fixed amount per token, not per layer. Over USB-C, moving the iPad's share from 25% to 75% of the model changes the time per token by only 2 ms. Simply having the iPad in the pipeline adds about 15 ms per token over USB-C, and about 34 ms over Wi-Fi.
  • The overhead isn't the RPC protocol. Splitting against an RPC server on the Mac itself costs only about 1 ms per token. Per token, the Mac sends 5 fire-and-forget set_tensor calls and a cached graph_recompute, then makes one blocking get_tensor call: a single round trip. A 1 ms link should therefore cost about 1 ms, so most of the 15 ms is spent on the iPad side: network stack, waking the GPU and submitting the command buffer. Raising the worker thread to QOS_CLASS_USER_INTERACTIVE didn't change it. This is the first thing to profile next.
  • The output layer must stay on the Mac. The "iPad 100%" row is 10 ms slower than the 75% row because the logits come back over the link for every token: 151,936 × 4 bytes, about 600 KB per token.
  • USB-C beats Wi-Fi by 1.5× on every split we tried. The iPad's CoreDevice USB interface is a normal IP link, so the worker needs no code changes and the Mac needs no iproxy.
  • Splitting doesn't make a model faster. It makes larger models fit. A model that fits on the Mac runs fastest on the Mac alone. A model that doesn't fit is a different story: the 8B model ran 2.1× faster on Mac + iPad over USB-C than the Mac's best effort with layers spilling onto its CPU.
  • Speculation helps exactly where output repeats input. For code edits, refactors and "return the whole file" tasks, n-gram lookup tripled the speed over Wi-Fi on the 1.7B model, and gave 3.7× on the 8B model: one round trip verifies up to 16 tokens. On free text it does nothing, and a small draft model on the Mac is the plan there.

Design

Engine: llama.cpp RPC + Metal on every device

  • One engine everywhere. macOS and iOS use the same GGUF files and k-quants, and the Mac's llama-server provides the OpenAI API, speculative decoding and multi-slot serving for free.
  • Workers run ggml_backend_rpc_start_server on their Metal GPU.
  • MLX is about 10–20% faster on a single Mac, and mlx-swift runs on iOS. But MLX's distributed backends (ring/JACCL) are Mac-only, so iOS workers would need a custom transport and scheduler. That's deferred until benchmarks show it's worth it.
  • llama.cpp is pinned to tag b11157 in vendor/llama.cpp. That tag speaks RPC protocol 7.0.0. PrivateLM's Android workers currently speak 4.0.0, so they can't join until PrivateLM updates its llama.cpp.

How this differs from exo

exo runs heterogeneous clusters mostly of Macs, with MLX, and uses RDMA over Thunderbolt 5 for tensor parallelism. Its iOS app was dropped. Orchard aims at the devices people already carry:

exo Orchard
Devices Macs (Linux too); no iOS Mac master + iPhone/iPad workers
Engine MLX (Python) llama.cpp (C++), native Swift apps
Model format MLX safetensors GGUF (k-quants)
Fast link Thunderbolt 5 RDMA, Mac to Mac USB-C to iPhone/iPad (CoreDevice IP link)
Placement memory-weighted ring measured bandwidth + free memory; fastest devices first; output layer stays on the master
Per-token latency tensor parallelism over RDMA speculative decoding (n-gram, draft model) so each round trip yields several tokens

Topology

  iPhone (worker) ─┐                     ┌─ any device: chat UI / OpenAI clients
                   ├─ RPC (Wi-Fi/USB) ── Mac master: llama-server :8080
  iPad (worker)  ──┘                     └─ embeddings + output layer + most layers
  • The Mac is the master. It holds the most layers plus token_embd and output, so the logits never cross the network. It serves /v1/chat/completions on the LAN.
  • Each worker app also has a chat tab that talks to the Mac's API, so the cluster is usable from every device in it.

Discovery and pairing

  • Each worker runs two servers: llama.cpp's RPC server on port 50052, and a small status endpoint on port 50053 (GET /status returns JSON: id, Wi-Fi and USB-C addresses, Metal working set, free memory, footprint, bandwidth, connected master).
  • Workers advertise themselves over Bonjour as _orchard._tcp, on the status port, with id, kind and rpc in the TXT record.
  • Adding devices:
    • USB-C connects by itself. A device that the Mac reaches over its USB-C link (169.254.x.x) is added as soon as it's plugged in, because plugging it in is the intent. A device you remove stays removed until it scans the code.
    • Over Wi-Fi, the device scans the Mac's code. Add Device on the Mac shows a QR code (orchard://pair?name=…&hosts=<Mac IPs>&port=50054&token=<one-time>). On the iPhone or iPad, Scan Mac's Code opens the camera. The device then POSTs its status to every address in the code at once, and the first to answer wins. The Mac checks the token, and that it can reach the device itself, before adding it. A new token is made each time the sheet opens.
    • Nearby (Bonjour) and Address remain as fallbacks.
    • The Mac's status polls tell the device which Mac added it, so the device shows "Connected to ".
  • Added devices are remembered by id. If a device's IP changes, Bonjour finds it again.
  • The Mac also advertises its API as _orchard-api._tcp, so the iOS app's chat tab finds it.
  • llama.cpp's RPC server has no authentication. Anyone on the network can send it tensors and graphs. Planned fix:
    1. You confirm the pairing on the device.
    2. The worker then accepts connections only from the paired Mac's IP. This needs a small patch to the accept loop.
  • Until that patch exists, run workers only on networks you trust.
  • Links: the Mac polls each added device every 2 s, trying its USB-C address first and then Wi-Fi, and uses whichever answers. The card shows the link and its round-trip time. Plug a device in and the next Start uses USB-C.
  • A worker serves one master at a time. If the master dies:
    • The worker drops the connection within ~3 s when the Mac closes it (for example kill -9 of llama-server; tested).
    • For silent drops (cable pulled, Mac asleep), the worker turns on TCP keepalive for the master's connection (5 s idle, 3 probes 2 s apart), so a dead master is dropped in about 11 s.
    • The Mac app stops its server on SIGTERM, and on launch it kills a server left behind by a crash.

Speed

  • Placement planner (apps/mac/Sources/Model/Planner.swift):
    • It reads the GGUF header for the exact bytes of each layer, the output layer, the vocabulary size and the attention shape. It sizes the KV cache per layer, accounting for Gemma's sliding window and the q8_0 cache.
    • It picks the fewest devices that hold the model: the Mac alone if it fits, else the Mac plus workers in order (USB-C before Wi-Fi, then faster memory first). Each extra device adds a fixed cost per token.
    • The Mac keeps the output layer, plus its compute buffers.
    • Within that set, every device fills the same fraction of its budget. That leaves headroom on the 8 GB Mac instead of filling it to the brim.
    • Budgets:
      • Mac: 78% of Metal's working set.
      • Workers: 85% of min(Metal working set, available memory) − 250 MB.
    • Measured: for an 8B model split between Mac and iPad over USB-C, the ratio barely matters. iPad 9/Mac 27, 18/18, 22/14 and 27/9 all ran at 10.2–12 tok/s, so the fixed per-token cost dominates and sharing headroom costs nothing.
  • Speculative decoding:
    • n-gram lookup is on by default for edit and code workloads, using ngram-mod / ngram-simple.
    • Next: a small draft model on the Mac, using a model from the same family (for example Qwen3-0.6B for Qwen3-8B).
  • Keep the link hot:
    • The worker sends the master a 1-byte VO-class UDP packet every 20 ms, so iOS keeps the Wi-Fi radio out of power save. This comes from PrivateLM.
    • The idle timer is off, so the screen stays on.
    • The RPC thread runs at user-interactive QoS.
  • Precompiled Metal kernels (default.metallib) ship in the app bundle. Compiling them from source on the device took over 20 s, and iOS's launch watchdog killed the app.

Apps

  • Orchard for Mac (apps/mac, SwiftUI, macOS 14+):
    • Cluster view:
      • Model picker. It reads GGUFs from your folders and shows the quant, size and layer count.
      • Context size, n-gram speculation and compact cache options.
      • Start/Stop, with load stages.
    • The split bar shows each device's layers and GB, and how much is missing if the model doesn't fit.
    • Device cards show live link (USB-C/Wi-Fi + ms), memory budget, the current share and bandwidth.
    • Add Device sheet: the Mac's QR code (scanned by the device), Nearby, or Address. USB-C devices connect without it.
    • Models screen:
      • My Models: use, show in Finder, Move to Trash. Each model has a fit badge ("Runs on this Mac", "Mac + 2 devices", "Needs more devices") estimated from the devices online now.
      • Browse: a curated catalog of 11 GGUFs from 1 to 12 GB, with sizes and SHA-256s from Hugging Face.
      • Hugging Face: search any GGUF repo and pick a file.
      • Downloads use URLSession with progress, speed and time left. They can be paused and resumed, and resume on their own after network changes (up to 20 retries). There's a disk-space check before starting, and a SHA-256 check before the file goes into the models folder.
    • Chat:
      • Streaming, a collapsible thought process, tok/s, Copy and Regenerate.
      • Chat settings (inspector panel):
        • System prompt with presets: Concise, Coder, Writer, Translator, Tutor.
        • A "Think before answering" switch (enable_thinking).
        • Temperature, Top P, Min P, Top K, repeat penalty and max reply length.
    • Menu-bar panel: status, split, devices, Start/Stop.
    • Bundles one static llama-server (17 MB, Metal embedded). Build it with scripts/build-macos-app-server.sh.
  • Orchard for iPhone and iPad (apps/worker-ios):
    • Share tab:
      • A ring showing how much of the model is on this device.
      • Status ("Working for your Mac" + USB-C/Wi-Fi).
      • Scan Mac's Code (camera) to join over Wi-Fi.
      • Stats: bandwidth, free memory, Wi-Fi and USB-C addresses, GPU.
    • Chat tab: talks to the Mac's API. It uses the Mac this device is working for, or finds one over Bonjour. It has the same chat settings as the Mac, saved per device.
    • Keeps the screen awake, precompiled Metal kernels, status server.
  • Shared code (apps/shared): wire formats, the tiny HTTP client, and the chat model and view used by both apps.

Roadmap

  1. Proof of concept (done): build scripts, iOS worker app, Bonjour advert, benchmarks.
  2. Apps (done): Mac app (discover/scan/add, planner, server, chat, menu bar) and the redesigned worker app with chat.
  3. Find the per-token overhead on the iPad:
    • Add timestamps to the worker for receive → graph done → send.
    • Check GPU clock ramp-up and command-buffer latency.
    • Compare with llama-bench running on the iPad itself.
  4. Draft-model speculation on the Mac, for free-text answers.
  5. Pairing and IP allowlist. Also a timeout on the worker for dead masters.

Download

Prebuilt apps are on the Releases page.

  • Mac (Apple Silicon, macOS 14 or later): Orchard-macOS-<version>.zip. The app is ad-hoc signed, not notarized, so macOS blocks the first launch. Right-click the app and choose Open, or run xattr -cr /Applications/Orchard.app.
  • iPhone and iPad (iOS 17 or later): OrchardWorker-iOS-<version>-unsigned.ipa. Install it with a sideloading tool such as AltStore or Sideloadly, or re-sign it with your own Apple ID. The app asks for the increased-memory-limit entitlement; without it (for example with a free Apple ID), iOS gives the app less memory and the device holds fewer layers.

Or build from source, below.

Build from source

Requirements: Xcode, CMake + Ninja (brew install cmake ninja), XcodeGen (brew install xcodegen), and an Apple developer team for signing.

git clone --recurse-submodules https://github.com/orailnoor/orchard && cd orchard
scripts/build-macos.sh        # build/macos/bin/{llama-server,ggml-rpc-server,llama-bench,llama-cli}
scripts/build-ios.sh          # vendor/llama-ios/{lib,include,metal}

Apps:

scripts/build-macos-app-server.sh                       # static llama-server for the Mac app
cd apps/mac && ORCHARD_TEAM=<team id> xcodegen generate && open Orchard.xcodeproj
cd apps/worker-ios && ORCHARD_TEAM=<team id> xcodegen generate && open OrchardWorker.xcodeproj

Run the worker on each iPhone/iPad (allow Local Network access), then in Orchard on the Mac choose Add Device. In the model menu, use "Add Model Folder…" to point it at your GGUFs.

Without the apps (command line):

dns-sd -B _orchard._tcp                         # list workers
dns-sd -G v4 iPad.local                         # their IPs (Wi-Fi and USB-C)
scripts/serve.sh models/model.gguf 192.168.1.42:50052 -ts 1,3   # -ts order: workers first, then the Mac

Benchmark:

bench/run.sh "label" models/model.gguf 169.254.x.x:50052 -ts 1,3
PROMPT_KIND=edit TOKENS=600 bench/run.sh "label" models/model.gguf <worker> -ts 1,3 --spec-type ngram-simple --spec-draft-n-max 16

Results are appended to bench/results/results.jsonl.

Layout

apps/mac/            Orchard for Mac (XcodeGen project.yml)
apps/worker-ios/     Orchard for iPhone/iPad (XcodeGen project.yml)
apps/shared/         code used by both apps (wire format, chat)
scripts/             build-macos.sh, build-ios.sh, build-macos-app-server.sh, serve.sh, make-icon.swift
bench/               measure.py (OpenAI API timings), run.sh, results/
vendor/llama.cpp     llama.cpp at b11157 (git submodule)

Credits

  • Built on llama.cpp (MIT).
  • The worker code is adapted from the iOS cluster worker in PrivateLM, by the same author: Wi-Fi keep-awake, bandwidth probe and iOS build script.

MIT licensed.

Explore related projects

Loading…