Issue #207Core ML & PerformanceUpdated Reference Archive

Issue #207 — On-Device Core ML Inference & Battery-Safe Mobile ML

Running machine learning models locally on iOS eliminates server costs and protects user privacy — two huge advantages for indie apps. Issue #207 examined practical Core ML optimization techniques so models stay responsive without spiking thermal state.

Compute Unit Selection & Quantization Trade-offs

Precision / TargetModel SizeTypical Latency (A15+)Best Use Case
FP32 (.all)100% baseline18–35 msScientific / high-precision regression
FP16 (.cpuAndNeuralEngine)~50% smaller4–9 msVision classification, OCR, image tagging
INT8 Weight Palettization~25% smaller3–7 msApp-bundle-sensitive indie utilities

Always Guard Compute Units & Load Asynchronously

Never compile or instantiate an MLModel synchronously on the main thread during app launch. Use the async loader and configure compute units explicitly (see MLModelConfiguration):

let config = MLModelConfiguration()
config.computeUnits = .cpuAndNeuralEngine

let model = try await ImageClassifier.load(configuration: config)

Related Reading