"On google's app google edge gallery i could got a 1000tps prefill and 28tps decode speed on gemma4 e2b … [in Off Grid I] got a very slow generation speed about 2 tokens per second."
GitHub issue #229 · Snapdragon 8 Gen 3, 16 GB · 4 AprilSame phone, same model family, 14× slower in our app than in Google's. The user had even set the GPU to its maximum, "opencl 99". A follow-up two weeks later: "The GPU toggle makes zero difference even at 99 Layers." That issue is where this decision started. This post is written as a decision memo: the context, the options, what we chose, what it cost, and what we found when we checked the decision again a month later.
A phone has three places to run a model, and they are good at different things:
In April, Off Grid had one engine: llama.cpp, through llama.rn. It runs almost any model file and it's great on iPhones, where it uses Metal. Our April audit of Android found something else:
Q4_0 and Q8_0 files. Others silently fell back to the CPU, while the UI still said "99L"."Silent CPU Fallback and Misleading UI Layer Count (99L) on Failed OpenCL Init … the phone runs completely cool."
GitHub issue #373 · Adreno 613 · May| Option | For | Against | Outcome |
|---|---|---|---|
| Tune llama.rn's GPU path | One engine, every model file | Crashes, quant limits, silent fallback | Kept, and still improving |
| Add LiteRT-LM | The engine Google's Edge Gallery uses, built for mobile GPUs | Android only, few models, new native code | Chosen, as a second engine |
| Hexagon NPU via llama.rn | Fastest per watt on paper | Per-chip, unproven on our models | Tried later; see below |
We added Google's LiteRT-LM next to llama.rn and left the llama path untouched. It shipped in v0.0.95 on 4 June. The rule for which engine runs is simple: the file format decides. A .gguf runs on llama.rn, a .litertlm runs on LiteRT. The engine is stored on the model once, at download or import.
// src/services/activeModelService/loaders.ts
export async function doLoadTextModel(ctx: TextLoadContext): Promise<void> {
// Route LiteRT models to the LiteRT loader — existing llama path is untouched below
if (ctx.model.engine === 'litert') {
return doLoadLiteRTModel(ctx);
}
Inside the native module, every load builds a fallback chain: NPU, then GPU, then CPU. The settings screen offers only GPU (the default) and CPU. The GPU gets two retries 600 ms apart, because the previous model's video memory isn't always released yet, and a short warm-up after loading primes the GPU's shader cache, about 0.9 s on our test phone.
When we built this, Google's note was: "iOS Swift SDK: not released yet, Coming Soon." Our plan had a stand-in, MediaPipe's LLM Inference API, which we deferred. So on iPhone, Off Grid still runs llama.rn with Metal, which is fast there, and Core ML for image generation. Users noticed the gap:
"Backend parity between Android and iOS … No LiteRT references … Existing support for: llama.cpp / llama.rn, ExecuTorch, Whisper, Core ML Stable Diffusion."
GitHub issue #426 · JuneA second engine means a second set of failure modes. In order:
getBenchmarkInfo() needs internal parameters the public API doesn't expose. We time it ourselves now. Then the time-to-first-token unit flipped twice: multiply by 1,000, then remove the multiply, because it was already in seconds.And the biggest cost: its teardown crash became our top Android crash. We wrote that case up separately.
On a Snapdragon 8s Gen 3 test phone with Gemma 4 E2B, a GPU load took about 17 to 18 s. A CPU load took 9.8 s, then failed to generate (Status 13), so "CPU loads faster" helps no one. An early test on the GPU showed about 7 s to the first token and 38 to 41 characters per second. On the same phone, llama.rn's "GPU" mode capped its layers from 99 to 24 and kept most of the model in CPU memory: 230 MB on OpenCL against about 2 GB on the CPU side.
What we don't have is a clean, same-phone, same-prompt comparison of llama.rn on CPU, llama.rn on GPU and LiteRT on GPU. Our model card says "up to 2x faster than CPU via GPU", and we'd rather prove that than repeat it. That benchmark is the next thing we're figuring out.
In July we wrote an acceleration strategy and checked the decision against everything else out there. One rule framed it: an option must have a React Native binding today, because "only shipping capabilities count, not roadmap".
| Option | What we found in July |
|---|---|
| MLC LLM | GPU only |
| MediaPipe LLM | GPU and CPU, now maintenance-only |
| ExecuTorch | CPU on Android; a Qualcomm backend PR was closed unmerged |
| Cactus | No Android NPU in the open source repo |
| NexaSDK | No React Native binding |
| LiteRT NPU | Needs per-chip vendor binaries; samplers rejected on NPU |
We also tried the NPU for real. We switched llama's Hexagon path back on in July and tested every engine on every backend on one phone:
On the NPU, llama loaded cleanly and produced gibberish with Gemma 4, while OpenCL ran the same model correctly. On a Snapdragon 8+ Gen 1, a user hit Process on cDSP CRASHED!!!. So the NPU ships as "NPU (Beta)", described as best for Llama- and Qwen-style models. The review's verdict on text generation on the NPU: not now. The GPU is the accelerator every Android phone has, and both our engines can use it.