Model Caching (Edge)
Loading a machine-learning model can take far longer—and use far more energy—than making one prediction. Model caching avoids paying that setup cost every time by keeping a model, or its prepared runtime form, ready for the next inference.
What is kept in the cache
On an edge device, caching usually means retaining a previously loaded model in RAM between requests. The cache can include more than the model file itself:
- Weights: the learned numerical parameters used for prediction.
- Interpreter or inference session: such as a TensorFlow Lite Interpreter or an ONNX Runtime session.
- Compiled or delegated execution plans: work prepared for a phone GPU, NPU, or accelerator.
- Allocated tensors and buffers: reusable memory for inputs, outputs, and intermediate calculations.
This is different from caching results. A result cache reuses an earlier answer for the same input; model caching keeps the machinery ready to process a new input.
Why it matters on devices
Consider a battery-powered smart camera that runs object detection whenever motion is detected. Reloading and initializing a model for every event adds latency, creates short power spikes, and can make the first frame slow enough to miss. Holding the model in memory enables a faster “warm” inference path. For a wake-word detector, the model is deliberately kept resident because it must respond continuously and predictably.
The trade-off: readiness versus memory
A cache consumes precious RAM. Keeping a large vision model loaded can crowd out the camera pipeline, operating system, or other applications; on a Cortex-M microcontroller, it may be impossible altogether. Edge software therefore sets rules for when to retain, evict, or replace models:
- Evict inactive models under memory pressure.
- Clear cached sessions when a model update arrives, so old weights are never used.
- Warm up a newly cached model before serving time-sensitive requests.
- Cache only the small, frequently used models when several models compete for memory.
Done well, model caching turns repeated edge inference from “load, prepare, predict” into simply “predict,” while staying within the device’s fixed memory and power budget.
Model caching (edge) stores a downloaded, loaded, or hardware-optimized model artifact locally so repeated inferences do not require reloading, recompiling, or fetching it from a server. Cached models can include weights, compiled execution plans, and runtime resources, subject to memory and storage limits. It reduces cold-start latency, network dependence, and energy use, enabling responsive offline inference; cache eviction and version validation prevent stale or incompatible models from running.
Think of model caching like keeping your most-used cooking tools on the kitchen counter instead of putting them back in a cupboard after every meal. They take up some space, but they are ready the moment you need them.
For AI on a phone, camera, or smart sensor, model caching means keeping an AI model—or the parts needed to run it—ready in the device’s memory after it has been used. The device can then respond faster, without repeatedly loading the model from storage or downloading anything.
This matters for features such as face unlock, voice commands, and live camera effects, where even a short delay can feel annoying. The trade-off is that cached models use memory and may need to be cleared when the device needs that space for something else.