On-device AI: running neural networks on phones
Efficient architectures and small models let phones and laptops run AI without sending data to a server
What is on-device AI?
On-device AI means running a neural network's inference directly on a phone, laptop or embedded chip. The data never leaves for a remote server. The MobileNets paper (Howard et al., 2017) frames this as a problem of resource constraints. Robotics, self-driving cars and augmented reality all need recognition tasks carried out in a timely fashion on a computationally limited platform.
The same logic applies to language models. The TinyLlama paper (Zhang et al., 2024) describes its compact model as able to enable end-user applications on mobile devices, where memory and compute are both scarce.
Why do phones and laptops struggle with big models?
Standard convolutional layers and large transformer models were designed for datacentre GPUs, not battery-powered hardware. Howard et al. note that the general trend in computer vision had been towards deeper, more complicated networks to chase accuracy, without regard for size or speed. Those gains do not automatically make networks efficient. A model with more parameters needs more memory to store its weights and more compute per prediction, both limited on mobile silicon.
For language models, the same tension shows up in training choices rather than just architecture. Touvron et al. (2023), cited in the TinyLlama paper, argue that what matters for deployment is the inference budget. A smaller model trained on far more data than a compute-optimal scaling law would recommend can match larger models while staying cheap to run.
What architectural tricks make models efficient?
MobileNets replace a standard convolution with a depthwise separable convolution, splitting filtering and combining into two smaller steps. Howard et al. report this factorisation cuts computation by roughly the reciprocal of the output channel count plus the reciprocal of the kernel size squared. MobileNet's 3x3 depthwise separable convolutions use eight to nine times less computation than standard convolutions, at only a small cost in accuracy. The paper adds two tuning knobs: a width multiplier that thins the number of channels at every layer, and a resolution multiplier that shrinks the input image size. Together they let a developer trade accuracy for latency and size to fit a specific device.
TinyLlama, a 1.1-billion-parameter language model, borrows efficiency tricks built for serving rather than training alone. It uses grouped-query attention, which shares key and value projections across groups of attention heads to cut memory bandwidth and speed up inference, following Ainslie et al. (2023). It also uses rotary positional embeddings and SwiGLU activations, the same choices made in Llama 2. It reports a training throughput of 24,000 tokens per second per A100 GPU, thanks to FlashAttention-2, fully sharded data parallelism and fused kernels from xFormers.
MobileNets vs TinyLlama: two routes to the same goal
MobileNets and TinyLlama tackle on-device constraints from opposite ends. MobileNets shrinks the architecture itself, trading a fixed, small amount of accuracy for a large cut in multiply-add operations and parameter count. The paper reports its full model at 70.6% ImageNet accuracy with 569 million multiply-adds and 4.2 million parameters, against VGG16's 71.5% accuracy at 15.3 billion multiply-adds and 138 million parameters.
TinyLlama instead keeps a conventional decoder-only transformer architecture, borrowed from Llama 2, and leans on data. It trains a 1.1-billion-parameter model on up to 3 trillion tokens, far more than scaling laws from Hoffmann et al. (2022) would prescribe for that size. The paper reports TinyLlama beating OPT-1.3B and Pythia-1.4B on commonsense reasoning and problem-solving benchmarks, despite being smaller than both.
What are the trade-offs and limits?
Shrinking a model is not free. Howard et al. show accuracy drops off smoothly as the width multiplier shrinks a MobileNet, but falls off a cliff once the multiplier reaches 0.25, where ImageNet accuracy drops to 50.6%. Their shallow-versus-narrow comparison also shows that removing layers hurts more than thinning them. A narrower 0.75 MobileNet reached 68.4% accuracy against 65.3% for a shallower model at similar computation and parameter count.
TinyLlama's own history shows that getting a small, long-trained model right takes iteration. The team retrained a second version, TinyLlama v1.1, after finding implementation issues in the learning-rate scheduler and data loading of the original. They restructured training into three stages: basic pretraining, domain-specific continual pretraining, and a cooldown phase with an enlarged batch size. That produced separate variants tuned for general use, for math and code, and for Chinese, each trading breadth for depth in a different domain.
Where is on-device AI used today?
MobileNets have been applied, per Howard et al., to several tasks: fine-grained dog breed classification, face attribute prediction via distillation from a 75-million-parameter in-house classifier, object detection on COCO using SSD and Faster-RCNN frameworks, large-scale geolocation by retraining Google's PlaNet model, and face embeddings distilled from FaceNet. In each case the MobileNet version came close to the accuracy of a much larger network at a fraction of the computation.
TinyLlama targets end-user language applications rather than vision tasks. Zhang et al. release the model's checkpoints and training code openly on GitHub. They pitch it as a lightweight platform both for mobile deployment and for researchers who want to test ideas on language models without the cost of training at full scale.
Key terms
- Depthwise separable convolution
- A convolution factorised into a per-channel filtering step and a 1x1 pointwise step that combines channels, cutting computation sharply versus a standard convolution.
- Width multiplier
- A MobileNets hyper-parameter that uniformly thins the number of input and output channels at every layer to trade accuracy for size and speed.
- Resolution multiplier
- A MobileNets hyper-parameter that shrinks the input image resolution, and with it every internal feature map, to reduce computation.
- Grouped-query attention
- An attention variant, used in TinyLlama, that shares key and value representations across groups of attention heads to reduce memory bandwidth and speed up inference.
- Inference-optimal model
- A model trained with more data than a compute-optimal scaling law recommends, so it performs well within a fixed inference budget rather than a fixed training budget.
- Knowledge distillation
- A training technique where a smaller model learns to emulate the outputs of a larger model instead of training on ground-truth labels alone.
- Multiply-adds
- A count of the multiply-and-add arithmetic operations a model performs, used in the MobileNets paper as a proxy for computational cost and latency.
Written from
On-device AI in the news
llama.cpp ships faster Q8 dequantisation for Intel SYCL backend
A narrow patch, but one of thousands quietly shaping local inference speed
llama.cpp adds dp4a GEMM kernels to OpenCL backend
A narrow kernel patch, but one more sign mobile GPU inference keeps getting cheaper
PyTorch 2.15 brings FP8 and much faster LLM decoding to Apple's MPS
Hugging Face's Metal kernels cut video VAE memory from 270 GiB to 8 GiB
Study finds mobile NPUs waste most of their edge on LLMs
Framework choice, not chip design, decides who wins the phone AI race
llama.cpp fuses qwen4exp activation chain on CUDA
A four-kernel gating step becomes one, matching an earlier Vulkan fix
llama.cpp adds Q1_0, Q2_0 quant support for Hexagon NPUs
Snapdragon devices get another notch of compression for on-device inference
llama.cpp patches Hexagon NPU attention bug in b11696
A single fix for Qualcomm's HMX flash-attention sinks ships in the latest build
llama.cpp b11690 trims memory copies in speculative decoding cache
A single-line fix, but it is the kind that adds up at scale
llama.cpp adds BF16 flash attention kernel for Metal backend
A small patch note for a release that still runs on every Apple GPU
Study finds LLaMA-2 safety hinges on 0.19% of its weights
Researchers say a tiny, localised edit to one MLP layer strips safety guardrails while leaving accuracy almost untouched.
Google releases EmbeddingGemma 2, a 740M multimodal embedding model
Apache 2.0 model unifies text, image, audio and video for on-device search and RAG
New method quantizes Llama 3.2 11B Vision to 2.7 bits for phones
Researchers compress an 11B-parameter vision-language model to 3.7GB for Arm CPUs without needing the original training setup.
Written from the documents above by The Neural Net’s automated desk (claude-sonnet-5, theneuralnet/guides@1) without human review, and updated as news on this topic publishes. How this works.