README: CoreAIKit's LFM3 support is on the kit's main branch (coreai-kit#83); the Mac bundle's later turns resume from a checkpoint since coreai-models 0.2.9-zoo
Browse files
README.md
CHANGED
|
@@ -25,7 +25,7 @@ context. The Mac bundle is one int8 `.aimodel` on the `coreai-pipelined` GPU eng
|
|
| 25 |
tokens at a time; the iPhone 18 Pro bundle is a Neural Engine build with fixed input shapes, compiled in advance for
|
| 26 |
that phone's chip (`h19p`).
|
| 27 |
[CoreAIKit](https://github.com/john-rocky/coreai-kit)'s `ChatSession` and Apple's `LanguageModelSession` drove
|
| 28 |
-
both in the checks below; CoreAIKit's LFM3 support is
|
| 29 |
([Use it](#use-it)).
|
| 30 |
|
| 31 |
Source: [`LiquidAI/LFM3-1.7B`](https://huggingface.co/LiquidAI/LFM3-1.7B) at revision
|
|
@@ -57,7 +57,7 @@ transformer functions in a Neural Engine region. It is compiled for `h19p` only:
|
|
| 57 |
|
| 58 |
**Mac** (M4 Max, macOS 27.0), from a 1,024-token prompt: prefill 1,234 tok/s, 0.83 s to the first token, decode
|
| 59 |
169.5 tok/s (median of 8 runs, 2026-10-31; the published `.aimodel`, compiled on first load, run by the
|
| 60 |
-
coreai-models version CoreAIKit
|
| 61 |
tokens, one process per run). Compiled ahead of time for the Mac GPU it is slower: decode 105.5 tok/s and 1.00 s to
|
| 62 |
the first token in the same window.
|
| 63 |
|
|
@@ -105,7 +105,7 @@ The Mac bundle, on a Mac (M4 Max, macOS 27.0):
|
|
| 105 |
round trip and a 3-turn chat pass.
|
| 106 |
|
| 107 |
The iPhone bundle, on an iPhone 18 Pro (iPhone19,2, iOS 27.2), through the fixed-shape (`static-shape`) engine of the
|
| 108 |
-
coreai-models version CoreAIKit
|
| 109 |
|
| 110 |
- **Teacher-forced** over the replies of the same 17 sequences (721 steps, up to 64 a sequence after its prompt)
|
| 111 |
against transformers fp32: top-1 **692 / 721 = 95.98 %** (bar 93 %; every step's fp32 top-2 gap is at least
|
|
@@ -132,8 +132,9 @@ The full table, the transcripts and how the fp16 activations set a floor on this
|
|
| 132 |
|
| 133 |
What runs today without CoreAIKit is at the end of this section. CoreAIKit's support for LFM3 — the XML tool
|
| 134 |
calls, reading a reply that starts inside the thinking block, the thinking switch (`enableThinking`) and the `lfm3-1.7b` catalog
|
| 135 |
-
entry — is
|
| 136 |
-
LFM3). The CoreAIKit checks above ran a kit build that has it; with
|
|
|
|
| 137 |
|
| 138 |
```swift
|
| 139 |
import CoreAIKit
|
|
@@ -168,15 +169,18 @@ Without the kit: the Mac gates ran `llm-runner` built from the zoo's fork of
|
|
| 168 |
[apple/coreai-models](https://github.com/apple/coreai-models), whose pipelined engine carries the conv state as an
|
| 169 |
extra state and finds the `prefill` function by name, with `COREAI_CHUNK_THRESHOLD=1` and
|
| 170 |
`--inference-engine-variant coreai-pipelined --warmup off`; the iPhone checks ran the `StaticShapeEngine` of that
|
| 171 |
-
fork's tag `0.2.8-zoo`, the one CoreAIKit
|
| 172 |
`ZooLanguageModel` (`swift/Sources/ZooFMProvider` in the zoo; it depends on the coreai-models package, not on
|
| 173 |
CoreAIKit).
|
| 174 |
|
| 175 |
## Limits
|
| 176 |
|
| 177 |
-
- The
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
| 180 |
the KV cache, and in the 3-turn chat its engine reused the earlier turns' prompt tokens (32, then 70).
|
| 181 |
- On the Mac the engine always runs the last prompt token through the one-token `main` function, so a prompt's
|
| 182 |
final 1–64 tokens run one at a time at about the decode speed: a 1,024-token prompt runs 15 chunks and then 64
|
|
|
|
| 25 |
tokens at a time; the iPhone 18 Pro bundle is a Neural Engine build with fixed input shapes, compiled in advance for
|
| 26 |
that phone's chip (`h19p`).
|
| 27 |
[CoreAIKit](https://github.com/john-rocky/coreai-kit)'s `ChatSession` and Apple's `LanguageModelSession` drove
|
| 28 |
+
both in the checks below; CoreAIKit's LFM3 support is on the kit's main branch since `9e9143bc`, not yet in a release
|
| 29 |
([Use it](#use-it)).
|
| 30 |
|
| 31 |
Source: [`LiquidAI/LFM3-1.7B`](https://huggingface.co/LiquidAI/LFM3-1.7B) at revision
|
|
|
|
| 57 |
|
| 58 |
**Mac** (M4 Max, macOS 27.0), from a 1,024-token prompt: prefill 1,234 tok/s, 0.83 s to the first token, decode
|
| 59 |
169.5 tok/s (median of 8 runs, 2026-10-31; the published `.aimodel`, compiled on first load, run by the
|
| 60 |
+
coreai-models version CoreAIKit pinned then: the path an app that uses CoreAIKit takes; `llm-benchmark` with 256 generated
|
| 61 |
tokens, one process per run). Compiled ahead of time for the Mac GPU it is slower: decode 105.5 tok/s and 1.00 s to
|
| 62 |
the first token in the same window.
|
| 63 |
|
|
|
|
| 105 |
round trip and a 3-turn chat pass.
|
| 106 |
|
| 107 |
The iPhone bundle, on an iPhone 18 Pro (iPhone19,2, iOS 27.2), through the fixed-shape (`static-shape`) engine of the
|
| 108 |
+
coreai-models version CoreAIKit pinned then:
|
| 109 |
|
| 110 |
- **Teacher-forced** over the replies of the same 17 sequences (721 steps, up to 64 a sequence after its prompt)
|
| 111 |
against transformers fp32: top-1 **692 / 721 = 95.98 %** (bar 93 %; every step's fp32 top-2 gap is at least
|
|
|
|
| 132 |
|
| 133 |
What runs today without CoreAIKit is at the end of this section. CoreAIKit's support for LFM3 — the XML tool
|
| 134 |
calls, reading a reply that starts inside the thinking block, the thinking switch (`enableThinking`) and the `lfm3-1.7b` catalog
|
| 135 |
+
entry — is on the kit's main branch since `9e9143bc` ([coreai-kit#83](https://github.com/john-rocky/coreai-kit/pull/83)), not yet in a CoreAIKit release (0.7.3 does
|
| 136 |
+
not support LFM3). The CoreAIKit checks above ran a kit build that has it; with the kit's main branch, on a Mac or an
|
| 137 |
+
iPhone 18 Pro:
|
| 138 |
|
| 139 |
```swift
|
| 140 |
import CoreAIKit
|
|
|
|
| 169 |
[apple/coreai-models](https://github.com/apple/coreai-models), whose pipelined engine carries the conv state as an
|
| 170 |
extra state and finds the `prefill` function by name, with `COREAI_CHUNK_THRESHOLD=1` and
|
| 171 |
`--inference-engine-variant coreai-pipelined --warmup off`; the iPhone checks ran the `StaticShapeEngine` of that
|
| 172 |
+
fork's tag `0.2.8-zoo`, the one CoreAIKit pinned then. The Mac tool-call checks also ran through the zoo's
|
| 173 |
`ZooLanguageModel` (`swift/Sources/ZooFMProvider` in the zoo; it depends on the coreai-models package, not on
|
| 174 |
CoreAIKit).
|
| 175 |
|
| 176 |
## Limits
|
| 177 |
|
| 178 |
+
- The engine cannot rewind the Mac bundle's conv state by position. Since coreai-models `0.2.9-zoo` (CoreAIKit's pin
|
| 179 |
+
since [coreai-kit#82](https://github.com/john-rocky/coreai-kit/pull/82)), it checkpoints that state at the end of the prompt's last
|
| 180 |
+
message, on the 64-token chunk grid, and CoreAIKit's `ChatSession` resumes each later turn from the checkpoint
|
| 181 |
+
instead of prefilling the whole history; a history shorter than one chunk is prefilled again (in a three-turn chat
|
| 182 |
+
on the kit's main branch, turn 2, after a 32-token first prompt, prefilled all of its 71 tokens, and turn 3 reused 64
|
| 183 |
+
of its 103). The iPhone bundle keeps the conv history in
|
| 184 |
the KV cache, and in the 3-turn chat its engine reused the earlier turns' prompt tokens (32, then 70).
|
| 185 |
- On the Mac the engine always runs the last prompt token through the one-token `main` function, so a prompt's
|
| 186 |
final 1–64 tokens run one at a time at about the decode speed: a 1,024-token prompt runs 15 chunks and then 64
|