Downloads · 30 days
207
92% of all-time downloads
okayuji/Qwen3.8-27B-coreml-agent
Qwen3.8-27B-coreml-agent is a text generation model from okayuji. Use it when you need the model to write or continue text. It is set up for coreml. The card lists the license as apache-2.0.
Run Qwen3.8 27B locally on an Apple silicon Mac with Core ML. With the companion Swift app it searches the web, reads pages, writes notes and answers with sources. Model inference stays on the Mac; search and page ret…
Downloads · 30 days
207
92% of all-time downloads
All-time downloads
226
Public
Repo size
30.3 GB
Likes
0
Public
Click a slice to open those files.
.bin30.2 GB · 100%
From the Hugging Face model README
Run Qwen3.8 27B locally on an Apple silicon Mac with Core ML. With the companion Swift app it searches the web, reads pages, writes notes and answers with sources. Model inference stays on the Mac; search and page retrieval require network access.
Swift runtime & app · Model guide · Agent walkthrough · Published benchmark
Requires: Apple silicon Mac · macOS 26+ · Xcode 26 / Swift 6.2 · 96 GB+ RAM · ~30 GB disk. Measurements used a 128 GB Mac; 96 GB is untested. See Requirements.
hf download okayuji/Qwen3.8-27B-coreml-agent --local-dir ./qwen38-27b-agent
git clone https://github.com/oka-yuji/coreml-llm-samples
cd coreml-llm-samples
swift run -c release --package-path CoreLLMKit corellm-chat --model ../qwen38-27b-agent --stats \
--prompt "List three fruits, one per line."
This repository contains weights and configuration: int8 weights, a 16,384-token context and the model's own multi-token-prediction head. The companion runtime supplies the stateful chain and speculation loop; the demo app supplies search, page reading, notes and tool calls.
To run the agent: open CoreMLSamples.xcodeproj at the repository root, build the CoreMLSamples scheme for My Mac (arm64), choose the bundle under Models, press Load in Chat, then switch to Agent. If you already downloaded the bundle, the README's Agent section explains how to register the folder without downloading it again.
The first CLI load compiles the graph for the GPU (94 s when measured); later CLI loads take 8–9 s, while the demo app takes about 47 s per process. Conditions are in Load time. Speculation is on by default; --no-mtp disables it and produces byte-identical output.
Demo app headless driver (DemoApp --agent-e2e), Apple M4 Max 128 GB, macOS 26.6.2, GPU, greedy,
reasoning effort low, page budget 10,000 characters, 2026-09-13; this is task S3, round 1, of the
published benchmark.
Task:
Search for what Apple's MLX framework is and summarise it in three lines.
The agent called web_search once, then answered (shown verbatim):
**MLX** is an open-source array framework for machine learning on Apple silicon, developed by Apple's machine learning research team. It offers a NumPy-like Python API (plus C++, C, and Swift bindings) and is optimized for the unified memory architecture of Apple chips, supporting both CPU and GPU. It features lazy computation, composable function transformations, and is used for everything from numerical computing to running large language models.
Sources:
- https://github.com/ml-explore/mlx
- https://mlx-framework.org/
- https://developer.apple.com/videos/play/wwdc2025/315/
| Step | Prompt tokens | Reused from KV | Generated | TTFT | Decode |
|---|---|---|---|---|---|
| 2 (answer) | 1,355 | 945 | 153 (eos) | 3.45 s | 16.0 tok/s |
Whole task: 25.6 s after a 47.0 s bundle load. The runtime checks every URL in a Sources: section
against the pages and search results the agent saw during the task; here all three were seen.
All numbers below were measured on an Apple M4 Max (Mac16,6) with 128 GB unified memory, macOS 26.6.2 unless stated, GPU compute units, greedy decoding, one process at a time. The agent benchmark, its task list, grading script and per-run summaries are published in the runtime repository at the 2026-09-13 benchmark record. The conversion-time measurements (CLI speed, load time, reference agreement) are in the author's lab notes, which are not published; they are reproduced here with their conditions.
qwen38-27b-agent-v1)12 frozen tasks (4 search-and-summarise in Japanese and English, 3 read-this-URL, 3 look-up-and-save-a-note,
2 date-dependent), each graded on answer content, a Sources: section with retrieved URLs, the note
file when one was requested, and completion without a step limit or token cap.
| Condition | Runs | Passed |
|---|---|---|
reasoning effort low, 3 rounds | 36 | 36 |
reasoning effort off, 1 round | 12 | 12 |
| All | 48 | 48 (100%) |
low with file operations enabled (4 tools), 1 round | 12 | 12 |
Across the 148 generations of the 48 runs: decode median 16.65 tok/s (12.4–19.7), time to first token median 6.9 s (0.7–46.4; the maximum is the first prefill of a session), sampled process footprint median 55,662 MiB (58.37 GB) and maximum 55,716 MiB (58.42 GB), speculation acceptance median 0.86, every generation ended at EOS, zero token-cap cuts, zero full re-prefills after the first step.
Memory-unit clarification (2026-10-23): the earlier card labeled these values MB and summarized
them as 55.7 GB. At the benchmark's runtime tag, the log field peakFootprintMB divides bytes by
1,048,576, so its unit is MiB. The published aggregation
reports a median of 55,661.78 and a maximum of 55,715.68 in that field; the decimal-GB conversions
above correct the labels without changing the underlying measurement.
The logger
shows the unit conversion. The engine
takes the larger phys_footprint reading after prefill and at generation end. This is a sampled
footprint measurement, not RSS or a continuously observed process peak.
corellm-chat, 2026-09-03, macOS 26.5.2)| Prompt | Speculation off | Speculation on (S=4, k=3) |
|---|---|---|
| Japanese | 169.5 ms/tok (5.9 tok/s) | 91.7 ms/tok (10.9 tok/s) |
| English | 172.6 ms/tok (5.8 tok/s) | 72.8 ms/tok (13.7 tok/s) |
| Code | 166.8 ms/tok (6.0 tok/s) | 59.4 ms/tok (16.8 tok/s) |
Output is byte-identical between the two columns: on 2026-08-18 the three probe prompts (Japanese 383 B, English 565 B, code 232 B) matched byte for byte with speculation off and on, and a 2026-08-26 smoke prompt matched by SHA-256 (author's lab records). The separate 2026-09-03 CLI session reported peak footprint as 53.6–54.6 GB; those figures retain their original lab-record units. The demo app also holds the UI and web view; its separately measured benchmark footprint, with corrected units, is given above.
| Path | First load on a machine | Later loads |
|---|---|---|
| Demo app, per process (bundle + tokenizer; the MTP head loads at the first generation) | not timed separately (the OS compiles the graph once and caches it) | 47.4 s median, 46.6–49.9 s (48 runs, 2026-09-13) |
CLI corellm-chat (2026-09-03, macOS 26.5.2) | 94 s | 8–9 s |
conv_state / rec_state per layer) and 16 full attention (KV MLState of shape
[4, 16384, 256]), hidden size 5,120, 24 query heads, 4 KV heads..mlmodelc with three functions per chunk:
main (prefill, variable width), decode (one token) and verify (a static 4-row function used
for speculation and, in the same shape, for lossless one-token decoding).mtp.mlmodelc, int8, 451 MB): the model's own multi-token-prediction head drafts up
to three tokens per round; the verify function accepts the greedy-correct prefix and writes the
accepted linear-attention state back, so speculation is lossless by construction.cpuAndGPU: the multi-MLState design needs the GPU; the Neural Engine is not
used.From manifest.json (ChatML with Qwen's thinking block):
promptPrefix: "<|im_start|>user\n"
promptSuffix: "<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\n" (thinking off)
promptSuffixThinking: "<|im_end|>\n<|im_start|>assistant\n<think>\n" (thinking on)
assistantSuffix: "<|im_end|>\n"
bos: none eos: 248044, 248046
The demo app's agent renders a system turn with the tool definitions and reads tool calls in Qwen's
<tool_call><function=name><parameter=key>value</parameter></function></tool_call> form; the exact
prompt and the byte-for-byte re-rendering rules are in
the agent guide in the runtime repository. Multi-turn KV reuse works by text prefix: the runtime
tokenises only the new suffix of a conversation, so a generated turn is never re-tokenised.
| File | Role | Size |
|---|---|---|
chunk_0_16.mlmodelc … chunk_48_64.mlmodelc | four 16-layer chunks, main / decode / verify (each weights/weight.bin is 6,475,094,400 bytes; the last chunk 6,475,104,704) | 6.48 GB each |
lmhead.mlmodelc | LM head, int8 | 1.35 GB |
mtp.mlmodelc | multi-token-prediction head, int8 | 451 MB |
embed_fp16.bin | embedding table | 2.54 GB |
convert_config_v2int4.json | chain configuration read by the runtime (ChainConfigV2); despite the file name the chunks are int8 — the quant block inside is authoritative and the name cannot change because the loader probes a fixed file list | 22 KB |
manifest.json | bundle manifest: format coreml-stateful-chain-v2, prompt template, EOS ids, compute units | 1 KB |
tokenizer.json, tokenizer_config.json, vocab.json, merges.txt | tokenizer | 23 MB |
config.json, generation_config.json, chat_template.jinja | upstream configuration, kept for reference | 14 KB |
LICENSE | Apache License 2.0 (from the base model repository) | 12 KB |
35 files, 30,285,202,520 bytes in total (30.3 GB, 28.2 GiB).
arm64.metrics.jsonl therefore read far lower on
macOS 27 although the bundle occupies the same memory. Do not compare peak figures across OS
versions.web_search uses DuckDuckGo's HTML endpoint by default (a Brave Search API
key is optional); fetch_page reads pages in a web view with a 20 s deadline and refuses local and
private addresses; write_note saves Markdown under the app's notes folder and never overwrites;
move_note is off unless enabled in Settings and only moves notes into Desktop, Documents or
Downloads.cannot rewind from N to M in the log means the runtime had to re-prefill: hybrid recurrent
state cannot be rolled back. With the current runtime this no longer happens across normal agent
turns (0 of 148 generations in the benchmark); it still happens after a stop or a settings change.docs/results/2026-09-03-qwen38-ctx-tax.md); it halves the context and is not
published.conv_state and
rec_state at position 0 are bit-equal (100.0000%, max abs diff 0) over 200 positions regardless of
the filler in rows 1–3; the accepted-prefix write-back after speculation is bit-equal for every
accepted length 1–4.DemoApp --gui-e2e <dir>, part of the runtime
repository) walks the Agent screen through 14 checks (load, tool calls, note save and move, stop
and resume, screen switching, unload) and captures screenshots; 14 of 14 passed on 2026-09-16 on
macOS 27.0 at runtime tag qwen38-27b-agent-v1.This bundle runs with the Core ML runtime in coreml-llm-samples. For separate Core AI / Foundation Models conversions and examples, see coreai-samples. That project is a related collection for comparing the frameworks; its runtime uses different model assets and does not load this Core ML bundle.
The weights in this repository are a quantized Core ML conversion of
Qwen/Qwen3.8-27B (revision 1d4bf0f), released by the
Qwen team under the Apache License 2.0. The same license applies to this conversion; the license
text is included as LICENSE. Changes from the original: weights quantized to int8 (per-block,
block size 32) and split into four Core ML chunks with static verify functions, an MTP head compiled
to Core ML, and a 16,384-token context configuration. The companion Swift runtime is licensed
separately in its own repository. Qwen is a model family of Alibaba Cloud; this conversion is an
independent work and is not affiliated with or endorsed by Alibaba Cloud.