Sub topic 12
Battery Drain and Thermal Throttling
A model that runs fast for ten seconds in a benchmark can still fail in the field. After a few minutes of continuous inference, the phone gets warm, the operating system lowers clock speeds, and latency climbs. The battery meanwhile drains faster than users accept. This chapter explains why that happens and how to measure and reduce it.
It assumes you have read the earlier chapters on quantization, runtimes, hardware delegates, and on-device benchmarking. You should know what a delegate is and how to time repeated inferences.
Why power and heat matter for vision models
A phone has no fan. It sheds heat only through its chassis, and the chassis has a surface temperature limit set by what a hand can tolerate. The system on a chip (SoC) therefore has a sustained power budget that is much lower than its peak power. Typical phones can sustain a few watts. They can burst well above that for a short time.
Vision workloads are hard on this budget for three reasons:
- They run continuously. A camera preview with per-frame inference never idles.
- They move a lot of data. Each frame is a large tensor, and memory traffic costs more energy than arithmetic.
- They often keep several parts of the chip busy at once: camera, image signal processor, CPU for preprocessing, and the accelerator for the model.
Energy per inference is power multiplied by time. A faster model that draws more power may use the same energy as a slower one. What matters to the user is the energy per frame and the sustained rate, not the peak speed.
How thermal throttling works
Thermal throttling is the operating system or firmware reducing clock frequencies, or shutting off cores, when temperature sensors cross a threshold. The goal is to protect hardware and keep the case comfortable to hold.
The sequence is usually:
- The device starts cool and runs at maximum clocks. Latency is lowest.
- Heat accumulates in the chip and chassis. This takes tens of seconds to minutes.
- Temperature crosses a threshold. The governor lowers CPU, GPU, or NPU frequency.
- Latency rises and settles at a slower sustained level. If it still gets too hot, the system steps down again.
The consequence for benchmarking is direct. A short benchmark measures the cool, fast state. Your app lives in the throttled state. You need to measure both.
What throttling looks like in data
Plot latency against time during a long run. A throttled device shows a flat line, then a rise, then a new plateau. The median over the whole run hides this, so report latency per time window.
Measuring sustained latency
The benchmark from the earlier chapter timed 100 runs. To see throttling, run for minutes and bucket the results by time. The script below does this with the TensorFlow Lite model from earlier in this tutorial.
import time
import numpy as np
import tensorflow as tf
interpreter = tf.lite.Interpreter(model_path="mobilenet_v2_int8.tflite", num_threads=4)
interpreter.allocate_tensors()
inp = interpreter.get_input_details()[0]
image = np.zeros(inp["shape"], dtype=inp["dtype"])
DURATION_S = 300 # run for five minutes
WINDOW_S = 30 # report one line per 30-second window
for _ in range(10): # warm-up
interpreter.set_tensor(inp["index"], image)
interpreter.invoke()
start = time.perf_counter()
window_start = start
window_times = []
while time.perf_counter() - start < DURATION_S:
t0 = time.perf_counter()
interpreter.set_tensor(inp["index"], image)
interpreter.invoke()
window_times.append((time.perf_counter() - t0) * 1000)
if time.perf_counter() - window_start >= WINDOW_S:
elapsed = int(time.perf_counter() - start)
print(
f"t={elapsed:4d}s n={len(window_times):5d} "
f"median {np.median(window_times):.1f} ms "
f"p95 {np.percentile(window_times, 95):.1f} ms"
)
window_times = []
window_start = time.perf_counter()Run this on the target device, not a laptop. On a phone you can run it in a terminal environment, or port the same loop to a native benchmark app. A rising median across windows is the signature of throttling.
Two details improve the measurement:
- Start from a known thermal state. Let the device cool to room temperature between runs, or record the starting battery temperature. Otherwise runs are not comparable.
- Fix the environment. Same screen brightness, airplane mode or the same network state, no charging (charging adds heat), and the same case or no case.
Idle gaps matter
The loop above runs back to back. A real app may run inference at 10 or 15 frames per second and idle in between. Idle time lets heat dissipate. Test with the same duty cycle your app will use, not only with the worst case.
Measuring battery drain
Battery drain is harder to measure than latency because many components contribute. Use a few complementary methods.
| Method | What it tells you | Limitation |
|---|---|---|
| Battery percentage over a fixed time | Real end-to-end drain for a full app session | Coarse, needs 20 to 30 minutes per run |
| OS battery statistics (Android Battery Historian, iOS Xcode Energy gauge and Instruments) | Which component or process uses energy | Estimates, not direct measurement |
| External power monitor on the battery rails | Accurate power in watts | Needs hardware and a modified setup |
| Thermal readings (battery temperature, thermal zones) | Whether the device is heating toward throttling | Sensor locations differ across devices |
Pick one method and use it consistently. Compare variants of your app against each other, not against absolute numbers from another source. A useful summary metric is millijoules per inference, or percent battery per 10 minutes at a fixed frame rate.
Reducing power and heat
Most gains come from doing less work, then from doing the remaining work on efficient hardware.
Run the model less often
The cheapest inference is the one you skip. Options include:
- Lower the frame rate. Many tasks do not need 30 inferences per second. Classification of a slowly changing scene may need 2 to 5.
- Skip frames on low motion. Compare the current frame with the previous one using a cheap difference metric. Run the model only when the scene changed.
- Track between detections. For object detection, run the detector every few frames and use a lightweight tracker in between.
- Trigger with a small model. A tiny model runs always and wakes the larger model only when something is detected.
Use a smaller or cheaper model
A smaller model cuts both energy per inference and heat. This builds on the earlier chapters: an efficient architecture, int8 quantization, and lower input resolution all reduce operations and memory traffic. Reducing input from 224 by 224 to 160 by 160 cuts the pixel count roughly in half. Check the accuracy cost with your validation set before shipping.
Use the right accelerator
Dedicated NPUs and DSPs generally deliver more operations per joule than a CPU, and often more than a GPU, for supported int8 operators. Moving a model from the CPU to an NPU delegate frequently reduces both latency and energy. But the benefit disappears if operators fall back to the CPU, because data then moves back and forth between processors, and that transfer costs both time and energy. See the troubleshooting chapter for how to detect fallbacks.
A faster accelerator can also run in short bursts and then idle. This race-to-idle pattern uses less total energy than a slow, long computation, provided the idle state is deep. Measure it. The result depends on the chip.
Cut the cost around the model
Preprocessing and postprocessing are easy to overlook. Resizing, color conversion, and non-maximum suppression done on the CPU in unoptimized code can consume as much energy as the model. Use hardware-friendly paths: let the camera deliver the target resolution directly, or use GPU or vendor image libraries for resize and conversion. Avoid copying frames between buffers more than necessary.
Adapt at runtime
Both major platforms report thermal state, and you can respond to it:
- Android exposes thermal status through the PowerManager API, with levels from none to light, moderate, severe, critical, emergency, and shutdown.
- iOS exposes
ProcessInfo.thermalStatewith the values nominal, fair, serious, and critical.
A simple policy lowers the inference rate or switches to a smaller model when the state worsens, and restores it after the device cools. Add hysteresis so the app does not flip back and forth: require the state to stay good for some seconds before stepping up.
# Policy sketch, language-independent. Shown in Python for clarity.
from dataclasses import dataclass
@dataclass
class Policy:
fps: int
model: str
LEVELS = [
Policy(fps=15, model="large"), # level 0: nominal
Policy(fps=10, model="large"), # level 1: fair / light
Policy(fps=5, model="small"), # level 2: serious / severe
Policy(fps=1, model="small"), # level 3: critical
]
def choose_level(thermal_state: int, current: int, calm_seconds: float) -> int:
if thermal_state > current:
return min(thermal_state, len(LEVELS) - 1) # degrade at once
if thermal_state < current and calm_seconds >= 30:
return current - 1 # recover one step at a time
return current
level = choose_level(thermal_state=2, current=0, calm_seconds=0)
print(LEVELS[level])Degrade immediately, recover slowly. That asymmetry prevents oscillation.
Common mistakes
- Benchmarking only cold. The device looks fast in testing and slow in the hands of users.
- Testing on a desk with the phone plugged in. Charging adds heat and changes power behavior.
- Ignoring the camera and display. In a camera app, the display, sensor, and image pipeline can draw more than the model. Measure a baseline app with the camera on and no model, then subtract.
- Using more threads is always better. Extra CPU threads raise power and heat, and can reduce sustained throughput once throttling begins. Compare thread counts under sustained load.
- Assuming one device represents all. Throttling policies differ across manufacturers, chips, and cases. Test at least one low-end and one high-end device.
Choosing a strategy
| Situation | Preferred approach |
|---|---|
| Short interactions such as taking a photo | Optimize for peak latency, throttling is rarely reached |
| Continuous camera inference | Optimize for sustained rate and energy per frame |
| Background or always-on sensing | Use a tiny trigger model, minimize wake-ups |
| Device reports serious thermal state | Reduce rate or switch to the smaller model |
Exercise
You benchmark a model on a phone with 100 runs and get a median of 12 ms. In your app, which runs the model continuously on the camera feed, users report the frame rate dropping after about two minutes. Name the likely cause, one measurement you would take to confirm it, and two changes you could make.
Show answer
The likely cause is thermal throttling. The 100-run benchmark finished before the device heated up. To confirm, run inference continuously for 5 minutes or more on the device and report median latency per 30-second window; a rising median across windows confirms throttling, and a battery temperature or thermal status reading rising alongside it supports the diagnosis. Changes that help: lower the inference frame rate or skip frames when the scene is static, move the model to an NPU or GPU delegate with all operators supported, reduce input resolution or use a smaller model, or adapt the rate to the OS thermal state with hysteresis.
Exercise
Why can moving a model to an NPU delegate increase energy use even though the NPU is more efficient for supported operators?
Show answer
If some operators are unsupported, the runtime splits the graph and runs those parts on the CPU. Tensors are then copied between the CPU and the NPU several times per inference. The extra transfers cost time and energy, and can outweigh the NPU's efficiency. Checking that the whole graph is delegated, or changing the model to use only supported operators, removes the penalty.