Views
No views yet
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, macOS 27 beta, 2026-06)..aimodel)coreai-pipelined GPU engine — zero
custom kernels, greedy oracle 8/8 exact vs the fp32 Hugging Face reference on the Mac GPU and
the iPhone GPU (iPhone is 24/24 token-identical to the Mac on the determinism probe).Requires the iOS 27 / macOS 27 beta. Conversion code, knowledge base, engine patch stack: coreai-model-zoo — model card:zoo/gemma4-e4b.md.
import CoreAIOps; no session, no model plumbing, downloads on first use):let tldr = try await CoreAI.summarize(text, options: .model("gemma-4-e4b"))1git clone https://github.com/john-rocky/coreai-kit
2open coreai-kit/Examples/ChatDemo/ChatDemo.xcodeproj
3# → Run, then pick "Gemma 4 E4B" in the model picker
4
5# agents / headless (macOS):
6cd coreai-kit/Examples/ChatDemo
7swift run chat-cli --model gemma-4-e4b --prompt "What can you do, offline?"1import CoreAIKit
2
3let chat = try await ChatSession(catalog: "gemma-4-e4b")
4let reply = try await chat.respond(to: prompt)
5// reply: the answer, generated fully on-deviceKitGemmaModel plugs this bundle into the system LanguageModelSession; capabilities (tool calling, guided generation) auto-detect per model.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.https://github.com/john-rocky/coreai-kit → product CoreAIKitdownloadProgress callback)| config | files | size | M4 Max decode / prefill | iPhone decode / prefill |
|---|---|---|---|---|
| ★ provider (runs BOTH platforms) | gpu-pipelined/gemma4_e4b_qat_decode_int4lin/ + ios-frontend/gemma4_e4b_qat_gather_raw/ | 3.7 + 3.4 GB | 53.2 / 62.6 | 15.1 / 21.3 |
| ★ provider, iPhone-ready AOT | gpu-pipelined/gemma4_e4b_qat_decode_int4lin_aotc_h18p/ (precompiled .aimodelc, h18p = iPhone 17 Pro class only) + the same tables | 3.7 + 3.4 GB | — | same as above — skip the AOT step |
| tbl (Mac-fastest) | gpu-pipelined/gemma4_e4b_qat_decode_int4lin_tbl/ + the two embed_per_layer.* table files | 3.7 + 2.7 GB | 55.8 / 61.0 | not viable (3.7 GB graph + 2.7 GB owned tables > the ~6.4 GB entitled limit) |
ios-frontend/gemma4_e4b_qat_gather_raw/), final-logit softcap 30. The QAT checkpoint prunes
the never-used KV projections on the shared layers — the zoo's loader handles both layouts.apple/coreai-models + the zoo's patch stack
(apps/*.patch, in
order). The ★ provider bundle needs EngineOptions.perTokenInputProvider
(coreai-pipelined-per-token-inputs.patch); the tbl bundle needs
EngineOptions.staticInputBuffers (coreai-pipelined-static-inputs.patch).ple_tokens [1,1,42,256] fp16 from the table dump —
row = i8[id] * scale[id] * sqrt(256), mmap-gathered (~0.1 ms). tbl mode: bind
ple_table ← embed_per_layer.i8 and ple_scale ← embed_per_layer.scale.f32 as
OWNED storageModeShared MTLBuffers (buffer-backing traps in the knowledge page).COREAI_CHUNK_THRESHOLD=1 before engine creation; never call engine.warmup()
(S=1 graph; a 1-token generate after load is the warmup)._aotc_h18p/ bundle, or
xcrun coreai-build compile <bundle>.aimodel --platform iOS --preferred-compute gpu --architecture h18p --expect-frequent-reshapes and point metadata.json's
assets.main at the .aimodelc. Ship the
com.apple.developer.kernel.increased-memory-limit entitlement as headroom insurance,
and bench a settled device (a just-unlocked iPhone under-reads ~35%).conversion/export_gemma4_decode_pipelined.py
with --hf-id google/gemma-4-E4B-it-qat-q4_0-unquantized..aimodel bundles redistribute the weights in a different serialization; the conversion adds no additional restrictions.