← All posts

Two Engines, One AppWhy We Bet on the Phone's GPU

29th September, 2026

"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 April

Same 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.

Context : three chips, one engine

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:

"Silent CPU Fallback and Misleading UI Layer Count (99L) on Failed OpenCL Init … the phone runs completely cool."

GitHub issue #373 · Adreno 613 · May

Options on the table in May

OptionForAgainstOutcome
Tune llama.rn's GPU pathOne engine, every model fileCrashes, quant limits, silent fallbackKept, and still improving
Add LiteRT-LMThe engine Google's Edge Gallery uses, built for mobile GPUsAndroid only, few models, new native codeChosen, as a second engine
Hexagon NPU via llama.rnFastest per watt on paperPer-chip, unproven on our modelsTried later; see below

Decision : add a second engine, GPU first

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.

What about iOS?

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 · June

Consequences : what didn't work

A second engine means a second set of failure modes. In order:

The clamp: free RAM minus the model, divided by about 0.15 MB per token.
LiteRT keeps the chat in native memory. Faster per turn, harder to manage.

And the biggest cost: its teardown crash became our top Android crash. We wrote that case up separately.

The numbers we have, and the ones we don't

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.

Review : the decision, one month later

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".

OptionWhat we found in July
MLC LLMGPU only
MediaPipe LLMGPU and CPU, now maintenance-only
ExecuTorchCPU on Android; a Qualcomm backend PR was closed unmerged
CactusNo Android NPU in the open source repo
NexaSDKNo React Native binding
LiteRT NPUNeeds 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:

Two engines, three backends, one phone. Only the GPU column is all green.

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.

What we'd revisit

What we took away