--- library_name: coreai license: apache-2.0 base_model: Qwen/Qwen3-4B tags: - coreai - apple - aimodel - apple-silicon --- Core AI is Apple's on-device ML runtime in iOS 27 / macOS 27 and the successor to Core ML: PyTorch models are exported with Apple's `coreai-torch` (LLMs: `coreai.llm.export`) into `.aimodel` bundles that run on the GPU or the Neural Engine, e.g. Qwen3-8B 4-bit decodes at 94 tok/s on an M4 Max GPU, MLX 90 under the same protocol ([apple-silicon-llm-bench](https://github.com/john-rocky/apple-silicon-llm-bench), macOS 27 beta 26A5353q, 2026-06-11). This model has no row on [DeviceMark](https://devicemark.github.io/), the on-device LLM leaderboard. # Qwen3-4B — official Apple Core AI exports Pre-converted **`.aimodel` bundles from Apple's official [coreai-models](https://github.com/apple/coreai-models) export recipe — unmodified**, with the exact environment, hashes, and measured performance published. ```bash uv run coreai.llm.export qwen3-4b # macOS uv run coreai.llm.export qwen3-4b --platform iOS ``` ## Use it **New to Core AI? [Start with CoreAIKit 0.7.3](https://github.com/john-rocky/coreai-kit#readme).** Follow its requirements and first-run steps for `qwen3-0.6b`, then open the same release's [ChatDemo](https://github.com/john-rocky/coreai-kit/tree/0.7.3/Examples/ChatDemo). The README records the tested OS/SDK and download size; model and device coverage is stated per example. ⚡ **One line** — this model is the default behind the kit's task op (`import CoreAIOps`; no session, no model plumbing, downloads on first use): ```swift let tldr = try await CoreAI.summarize(text) ``` Every op, one shape — [Cookbook](https://github.com/john-rocky/coreai-kit/blob/0.7.3/docs/COOKBOOK.md). ▶️ **Run it (source)** — the [ChatDemo runner](https://github.com/john-rocky/coreai-kit/tree/0.7.3/Examples/ChatDemo) (GUI + CLI, one app for every chat model in the catalog): ```bash git clone --branch 0.7.3 --depth 1 https://github.com/john-rocky/coreai-kit export DEVELOPER_DIR=/Applications/Xcode-27.0.0-RC.app/Contents/Developer open -a /Applications/Xcode-27.0.0-RC.app coreai-kit/Examples/ChatDemo/ChatDemo.xcodeproj # → Run, then pick "Qwen3 4B" in the model picker # agents / headless (macOS): cd coreai-kit/Examples/ChatDemo swift run -c release chat-cli --model qwen3-4b --prompt "What can you do, offline?" ``` Use Xcode build **27A266a** from the release's `.xcode-pin`; adjust the app path if your installation is named differently. 💻 **Build with it** — complete; the glue is kit API, copy-paste runs: ```swift import CoreAIKit let id = "qwen3-4b" let chat: ChatSession if id == "qwen3-0.6b" { // Freeze the release starter; other selections retain the live catalog's // model-specific dispatch (including paired Gemma bundles). guard let model = ModelCatalog.builtin.entry(id: id)?.modelID else { throw CoreAIKitError.modelNotAvailableOnPlatform(id: id) } chat = try await ChatSession(model: model) } else { chat = try await ChatSession(catalog: "qwen3-4b") } let reply = try await chat.respond(to: prompt) // reply: the answer, generated fully on-device ``` The take-home is [`Examples/ChatDemo/Sources/QuickStart.swift`](https://github.com/john-rocky/coreai-kit/blob/0.7.3/Examples/ChatDemo/Sources/QuickStart.swift) — this exact code as one typed function, no UI; the CLI is an argument shell over it, and the GUI drives the same `ChatSession` across turns for its transcript. Multi-turn? Hold the `ChatSession` and call `respond(to:)` per turn — it keeps the conversation history; `streamResponse(to:)` yields tokens as they decode. **Integration checklist** - SPM: `https://github.com/john-rocky/coreai-kit` (exact **0.7.3**) → product **CoreAIKit** - Info.plist: none needed - Entitlements (iOS): `com.apple.developer.kernel.increased-memory-limit` - First run downloads the model — ~2,279 MB (Mac) / ~2,502 MB (iPhone) — then it loads from the local cache (Application Support; progress via the `downloadProgress` callback) - Measure in Release — Debug is ~3× slower on per-token host work ## Why pre-converted bundles? 1. **The conversion needs a big-RAM Mac** (the 20B export was done on 128 GB); running only needs enough RAM to mmap the artifact. 2. **An `.aimodel` is a build artifact, not a pure function of the recipe** — the same export command produced a 2.2× slower artifact across the macOS 26 → 27β boundary ([forensics](https://github.com/john-rocky/apple-silicon-llm-bench/blob/main/methodology/coreai-export-lowering.md)). Hosted artifacts + hashes are the reproducible ground truth; every bundle here is exactly the one measured in [apple-silicon-llm-bench](https://github.com/john-rocky/apple-silicon-llm-bench). ## Bundles & integrity | Bundle | Contents | SHA-256 (`main.mlirb`) | |---|---|---| | `macos/` | macOS dynamic, int4 | `e9d1e9e49e70e7abe0c9a24062603a827483ed6ffb9ac4f244c553156c8ce5e7` | | `ios/` | iOS static ctx4096, mixed 4/8-bit palettized | `a1c45800117f2a0a00df5cd4196485a7ea6bc9d894b3d4cac3f3aa032a1c0a89` | ## Measured (Apple's official `llm-benchmark`, greedy) | Bundle | Protocol | Decode tok/s | Prefill | Load (warm) | |---|---|---:|---:|---:| | macos | M4 Max, 512p/1024g | 145.4 | 1,635 | 0.36 s | | ios (ANE, h18p) | iPhone 17 Pro, 512p/1024g | 13.2 | 546 | 0.46 s (cold spec ≈194 s) | ## Export environment - macOS 27.0 beta (build 26A5353q) · Xcode 27.0 (27A5194q) - `coreai-core 1.0.0b1` · `coreai-torch 0.4.0` · `coreai-opt 0.2.0` · `torch 2.9.0` - apple/coreai-models @ `b1cb71b` (export code identical to upstream `0c1055f`) ## Run it ```bash # CLI (from a coreai-models checkout) swift run -c release llm-runner --model --prompt "Hello" swift run -c release llm-benchmark --model ``` Or chat with it in [CoreAIChatMac](https://github.com/john-rocky/coreai-samples) (point "Choose Models Folder…" at the download directory). iOS static bundles must be AOT-compiled before device use: `xcrun coreai-build compile .aimodel --platform iOS --preferred-compute neural-engine --architecture h18p` (h18p = iPhone 17 Pro), then set `metadata.json` `assets.main` to the `.aimodelc`. --- Maintained alongside [coreai-model-zoo](https://github.com/john-rocky/coreai-model-zoo) (community models) and [coreai-samples](https://github.com/john-rocky/coreai-samples) (apps). --- **More models in this format:** [Core AI Model Zoo](https://huggingface.co/collections/mlboydaisuke/core-ai-model-zoo-6a7ff330f753e8dcae04671a) — 75 models, each with the recipe that produced it. **Want a different model on-device?** [Open a request](https://github.com/john-rocky/on-device-requests) — free, open weights only; the export and its measured numbers get published publicly.