models/llm: Qwen3-0.6B CoreML — LLM-on-ANE prefill/decode test#77
Open
Alex-Wengg wants to merge 1 commit into
Open
models/llm: Qwen3-0.6B CoreML — LLM-on-ANE prefill/decode test#77Alex-Wengg wants to merge 1 commit into
Alex-Wengg wants to merge 1 commit into
Conversation
Empirically tests the prefill/decode ANE-admission split from knowledge/coreml/ane-cpu-scheduled-matmul.md, on M5 Pro: - decode graph (stateful, in-graph KV mutation): ANE-rejected (ANECCompile -14, matching Surgical Inference 6.3); runs on GPU at 27 tok/s, RTFx 1.80x, coherent output. - prefill graph (stateless, fixed seq): ANE-accepted, 1918/1919 device-assigned ops on the Neural Engine, 12.5ms/128tok (~4x over CPU). Conclusion: an LLM can run on the ANE for prefill (compute-bound, cache-free); decode's cache mutation belongs on GPU/CPU. Ships convert (decode + stateless prefill), benchmark (tok/s + RTFx), and placement probe. Build artifacts gitignored; not HF-uploaded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First
llm-class conversion in mobius. Empirically tests the LLM-on-ANE thesis from the research lead in #76 (knowledge/coreml/ane-cpu-scheduled-matmul.md), on M5 Pro with standalone Qwen/Qwen3-0.6B.Result: the prefill/decode ANE split is real
The two graphs divide exactly as Surgical Inference §6.3 predicts — the ANE admission cliff is in-graph state mutation, not the transformer math.
CPU_AND_NEANECCompile -14CPU_AND_GPUCPU_AND_NECPU_ONLYCPU_AND_GPUBottom line: an LLM can run on the ANE — for prefill (compute-bound, cache-free, Dense-Static). Decode's KV-cache mutation is ANE-rejected and belongs on GPU/CPU, where it is comfortably real-time (RTFx 1.80× > 1). This is the split-phase placement the note predicts.
Nuance: on this M5 Pro the (strong) GPU is marginally ahead of the ANE for prefill via standard Core ML (9.3 vs 12.5 ms). The reviewer's "ANE beats GPU on prefill" claim rests on the private CPU-scheduled matmul path, which this standard export does not use — untested here.
Contents
convert-coreml.py— stateful decode decoder (KV cache as MLState), adapted from the in-repostt/qwen3-asr-0.6bgraph.convert-prefill.py— stateless prefill graph (fixed seq len, no state) — the ANE-positive case.benchmark.py— decode tok/s + RTFx (vs 15 tok/s real-time drain).probe-placement.py— ANE-admission +MLComputePlanper-op device breakdown..mlpackage) gitignored; not HF-uploaded.Notes
coreml-clicouldn't profile this package (its Python 3.14 venv fails to loadlibmodelpackage) — placement was obtained viaMLComputePlanin the working 3.11 env instead. Possible follow-up to fix the tool's env.