Tune on-device inference performance
Measure and tune backend choice, GPU offload, context and batch sizes, generation settings and speculative decoding for faster on-device inference.
On this page
Treat tuning as a measurement problem:
- Pick a representative prompt or workload.
- Record baseline timings.
- Change one variable at a time.
- Keep the fastest stable configuration.
On Android Vulkan, leaving microBatchSize unset evaluates text prompts eight
tokens per call on GPUs with a subgroup size below 32 other than 8, which was
faster on the Mali-G715 measured; a llama.cpp runtime older than ggml 0.28.0
also limits native Qwen3.5 there to ordinary text. See
Android Vulkan.
Pick a tuning goal#
- First-token latency: tune load-time setup, prompt size and prompt evaluation cost.
- Sustained throughput: tune backend choice, the decode path and batching.
- Stability: lower GPU pressure, reduce context and keep multimodal inputs small.
- Multimodal responsiveness: reduce image and audio size first, then revisit backend and token budget.
If you do not know which goal matters most, start with latency and stability.
Work in this order:
-
Benchmark the exact prompt shape you care about. On native llama.cpp,
GenerationParams(ignoreEos: true)keeps a run going past the model's end of reply, so every run decodes the same number of tokens. - Compare
cpuand GPU backends before changing anything else. -
Reduce
contextSizeandmaxTokensto the smallest values that fit your use case. - Tune load-time knobs (
gpuLayers, threads, batch sizes) one at a time. -
Tune sampling (
temp,topK,topP) last. It changes output style more than runtime cost.
Model load tuning (ModelParams)#
const modelParams = LlamaCppModelParams(
contextSize: 4096,
gpuLayers: ModelParams.maxGpuLayers,
preferredBackend: GpuBackend.vulkan,
numberOfThreads: 0,
numberOfThreadsBatch: 0,
batchSize: 0, // Native decoder default: min(contextSize, 2048).
microBatchSize: 0, // Native decoder default: min(resolved batch, 512).
);
-
preferredBackend: the biggest choice. Small models on mobile can be faster oncputhan onvulkanor WebGPU; larger models and longer responses favor the GPU. Always measure both. A GPU is not automatically faster for small embedding models either; see Android llama.cpp Vulkan. -
gpuLayers: start with the default and lower it if stability or latency is worse than on CPU. -
contextSize: keep it only as large as the use case needs. Oversized context raises first-token latency and memory use (on Windows, see Known platform issues for system commit limits at very large contexts). -
numberOfThreads/numberOfThreadsBatch:0(automatic) is a good baseline. On native llama.cpp it means 4, or the host's core count when lower. Some mobile devices prefer fewer threads; set them only after measuring. Set them explicitly under a container CPU limit (docker --cpus,--cpuset-cpus, Kubernetes CPU limits) or CPU affinity (taskset): Dart still reports the host's cores there, and more threads than usable cores can make inference tens of times slower. Fromllamadart-nativev1.1.0-2each llama.cpp context keeps persistent CPU worker threads sized by these counts for its lifetime, instead of starting a pool for every graph compute. -
batchSize/microBatchSize: native decoder models start at the llama.cpp-aligned caps of2048and512. LowermicroBatchSizefirst (for example to256or128) when memory or GPU stability is tight; bigger is not always faster. On Android Vulkan, a text prompt can be decoded in smaller micro-batches by default; see Android llama.cpp Vulkan. Encoder-only embedding models keep full-context native defaults for correctness; set both values explicitly for a known embedding workload (Embeddings). -
maxParallelSequences: matters for batched embeddings and true multi-sequence workloads, not single-turn chat.
WebGPU keeps full-context automatic batching because the bridge cannot report
model architecture before context creation. Two presets apply when
batchSize is 0:
-
If the model URL contains
gemma-4ormodelBytesHintis at least 2 GiB, the batch is capped atmin(contextSize, 512). An explicitmicroBatchSizeis kept up to that cap. -
If the model URL contains
qwen3.5-0.8b, both batch sizes are unset, the backend is notcpuandgpuLayersis not0, the sizes are32/8.
URL matching ignores case.
For the existing Qwen3.5-0.8B URL preset, CPU loads
(preferredBackend: GpuBackend.cpu or gpuLayers: 0) resolve unset sizes as
native decoders do: a batch of min(contextSize, 2048) and a micro-batch of
at most 512. This reduces temporary memory without reducing contextSize.
Other models keep full-context automatic batching on CPU too: applying a
512-token micro-batch to a non-causal embedding model can abort on longer
inputs, even with memory64. A renamed Qwen model URL does not select the
preset; set batch sizes explicitly in that case.
Decoder-focused web apps can set 2048 / 512 explicitly after validating
their model and browser. For a decoder that is constrained by WebGPU compute
memory, try setting both batchSize and microBatchSize to 256
or 128.
Smaller batches can slow long prompts even when token generation stays as fast.
Benchmark prompt processing on the target model and browser before choosing.
Field reference: Runtime parameters.
Native LiteRT-LM .litertlm loads have their own opt-in fields, listed in
LiteRT-LM runtime controls.
After changing the activation type or prefill chunk size, benchmark load time,
prefill and decode throughput, and output quality on the deployment device.
On macOS Metal, LiteRT-LM v0.19.1-6 disables sampler lookahead for models
that declare linear attention to keep independent requests consistent on a
reused engine. On an Apple M4 Max, median Qwen3.5-0.8B int8 decode throughput
was 109 tokens/s with the guard and 151 tokens/s with only the state reset.
Runtime fix and qualification.
LiteRT-LM v0.19.1-7 fixes the GPU command-buffer race that could duplicate
tokens with sampler lookahead enabled. Qwen3-0.6B keeps lookahead on Metal.
Backport and qualification.
For native LiteRT-LM, getPerformanceContext() exposes the runtime's
initialization timer as loadMs. C API 1.0.x sums recorded initialization
phases. C API 1.1.x reports engine creation alone, or zero when that phase
was not recorded. Compare like runtime versions when measuring load latency.
Upstream timer change
LiteRT-LM on Pixel Tensor devices#
Studio on Pixel 11 Pro XL
Studio 0.23.1 RC with LiteRT-LM v0.20.0 ran the same text prompt with
Gemma 4 E2B LiteRT-LM INT4 on a Pixel 11 Pro XL (Tensor G6, Android 17).
The test ran three fresh chats per backend, GPU first, with an 8K context,
a 128-token cap, temperature 0.30, top-K 64, top-P 0.95, and thinking and tools
off. Runs used a 180-second cooldown. Android thermal status was 0 before and
after each turn.
| Studio compute selection | Median estimated decode (tok/s) | Median time to first streamed output (s) | Median Send to completion (s) |
|---|---|---|---|
| CPU | 20.4 | 3.14 | 10.26 |
| Auto (GPU via OpenCL) | 13.9 | 1.40 | 11.22 |
The decode estimates use visible text retokenized with a Gemma-family GGUF tokenizer and the RC's rounded decode timing. Studio reported the selected CPU and GPU paths. GPU operator placement was unmeasured. For this prompt, GPU streamed the first output sooner and CPU completed the turn sooner.
Studio main (a8712e9b) with native evaluation counters confirmed the same
trade-off on LiteRT-LM v0.20.0. Across three reasoning-enabled turns per
backend at thermal status 0, median decode was 18.5 tok/s on CPU and 14.8 tok/s
on GPU. Median time to first streamed token was 4.43 s on CPU and 2.23 s on
GPU, including tokens on the reasoning channel. In a single control turn per
backend with thinking off and a 128-token cap, CPU decoded at 19.6 tok/s with a
3.90 s first token, and GPU decoded at 14.1 tok/s with a 1.66 s first token.
A separate diagnostic app on the same phone used the G6-compiled Gemma 4 E2B bundle and verified calls to Google's Tensor dispatch. Its median native decode rate was 26.6 tok/s and time to first token was 0.148 s after engine creation. The diagnostic used a different model artifact and timing boundary. Tensor G6 NPU execution in ordinary Studio installs is pending qualification.
Four-Pixel native C API harness
The shell harness ran LiteRT-LM v0.20.0 (C API 1.1.0) with the generic
gemma-4-E2B-it.litertlm bundle (2,588,147,712 bytes,
SHA-256 181938105e0eefd105961417e8da75903eacda102c4fce9ce90f50b97139a63c).
Each condition ran one blocking turn with a 2,048-token context, 28 prefill
tokens, 128 decode tokens, greedy sampling (top_k=1, top_p=0.95,
temp=0, seed=1), and default runtime threads (threads=0). Cold runs
started with an empty program cache, and warm runs reused that cache. Engine
creation was timed separately from native time to first token (TTFT) and
decode. Thermal status was unrecorded.
| Device and Android build | CPU engine creation, cold / warm (s) | CPU warm TTFT (s) / decode (tok/s) | GPU engine creation, cold / warm (s) | GPU warm TTFT (s) / decode (tok/s) |
|---|---|---|---|---|
Pixel 11 (cubs, Tensor G6, Android 17 CD1A.260714.001.A9) |
1.96 / 0.33 | 0.578 / 30.54 | 24.59 / 1.99 | 0.235 / 16.96 |
Pixel 11 Pro (grizzly, Tensor G6, Android 17 CD1A.260714.001.A9) |
2.09 / 0.32 | 0.558 / 30.36 | 24.16 / 2.01 | 0.237 / 16.70 |
Pixel 11 Pro XL (kodiak, Tensor G6, Android 17 CP4A.261105.040.D1) |
4.04 / 0.64 | 0.505 / 27.66 | 27.86 / 3.53 | 0.334 / 15.45 |
Pixel 9 Pro (caiman, Tensor G4 / Mali-G715, Android 15 BP1A.250505.005) |
2.47 / 0.32 | 0.557 / 25.42 | 25.89 / 1.57 | 0.336 / 14.19 |
CPU logs recorded creation of the XNNPACK delegate. GPU logs recorded the
OpenCL library loading via dlopen and buffer requirements warnings for
KV-cache tensors. Operator-level GPU placement was unmeasured.
Choosing CPU vs GPU on Android
LiteRT-LM ComputeDevice.auto tries GPU first with automatic CPU fallback on
Android. The policy is under review in
#2453.
-
Keep
autowhen the first token after model load is the priority. Warm native TTFT was 34–59% lower on GPU, with reductions of 59% on Pixel 11, 58% on Pixel 11 Pro, 34% on Pixel 11 Pro XL, and 40% on Pixel 9 Pro. GPU engine creation took about 24–28 s with an empty program cache and 1.6–3.5 s with a warm cache. -
Pass
LiteRtLmModelParams(device: ComputeDevice.cpu)or choose CPU in Studio when sustained decode throughput or shorter cold initialization matters more. CPU led on both measures in the native runs.
These measurements cover gemma-4-E2B-it.litertlm on the tested Pixel builds.
Benchmark other models and non-Tensor Android GPUs such as Adreno before
overriding auto.
Generation tuning (GenerationParams)#
const generationParams = GenerationParams(
maxTokens: 256,
temp: 0.7,
topK: 40,
topP: 0.9,
minP: 0.0,
penalty: 1.1,
presencePenalty: 0.0,
reusePromptPrefix: true,
streamBatchTokenThreshold: 8,
streamBatchByteThreshold: 512,
);
-
maxTokensis a performance knob as much as a quality knob. Cap it aggressively on latency-sensitive paths. -
temp,topK,topP,penaltyandpresencePenaltyshape output; they rarely fix a slow backend. Change them gradually, one at a time. -
penaltyis a repetition penalty.presencePenaltyis a separate llama.cpp-native control that penalizes any token already present in the recent window; one does not substitute for the other. WebGPU appliespresencePenaltyandminPonly with bridge assets whosegetCompletionCapabilities()reports them, and otherwise rejects a non-zero value. Native LiteRT-LM appliespresencePenaltyand rejectsminP; LiteRT-LM Web rejects both. -
streamBatchTokenThreshold/streamBatchByteThreshold(native): Lower thresholds flush native worker pieces sooner. Chat deltas can still group multiple pieces. Higher thresholds reduce isolate message overhead. -
reusePromptPrefixis on by default for native generation. Keep it on for multi-turn chat and repeated prompts. Reuse targets evolving prompts with a shared prefix; an exact prompt replay is re-ingested to keep output deterministic. Validate output parity for your model with and without reuse.
Strict grammar sampling#
Native llama.cpp can reduce grammar sampling work on models with at least
131,072 vocabulary tokens. When the runtime exports
llama_dart_sampler_init_grammar_top_k_p (llamadart-native v1.1.0-5),
eligible strict grammar requests follow progressive candidate certification:
-
Greedy requests (
temp <= 0with typical sampling, XTC, and dynamic temperature disabled) check the highest-logit candidate first at anytopK, then fall back through progressive stages before scanning the full vocabulary. -
Stochastic requests without
typicalP < 1certify progressively whentopKis1..128and/ortopPis in(0, 1)(including combinedminPwhen applicable). WithtypicalP < 1, onlytopKin1..128is certified. -
Requests with
topK > 128,minP > 0withouttopKortopP < 1, or pure un-truncated stochastic sampling (topK <= 0,topP >= 1,minP <= 0) keep the full-vocabulary grammar path.
Runtimes without v1.1.0-5 fall back to llama_dart_sampler_init_grammar_top_k
(llamadart-native v1.1.0-3, covering greedy requests at any topK
and ordinary
topK 1..64 shortlists), and older runtimes keep the raw grammar sampler. The
same downstream sampler chain selects and accepts the token, preserving
bit-exact greedy output and seeded sampling.
Older runtimes and requests with lazy grammar, a thinking budget, DRY, top-n-sigma, Mirostat, requested token logprobs, or speculative decoding keep their existing paths.
Speculative decoding#
Speculative decoding is off by default and is not a universal speedup. Benchmark it on the target model and device, and compare deterministic output, acceptance and warmed throughput against the same baseline before enabling it in production.
-
Native LiteRT-LM: set
GenerationParams(speculativeDecoding: true). It was slower for Gemma 4 E2B on both measured devices (a Pixel 9 Pro and an Apple M4 Max). -
Native llama.cpp: pass
speculativeDecodingConfig. The legacyspeculativeDecoding: trueflag without a config runsngram-mod. When the native runtime cannot initialize a speculative session for the model and context, generation throwsLlamaSpeculativeDecodingUnsupportedException. Itsstrategiesfield identifies the attempted strategies. Validation failures for unsupported options or a missing native speculative API throwLlamaUnsupportedException. -
WebGPU: the same configs, with bridge assets whose
getCompletionCapabilities()reports the strategy.draftModelis a remoteModelSourcewhose URL the runtime fetches, the n-gram cache paths are URLs, andmtpuses only the model's own MTP layers. See WebGPU bridge. -
LiteRT-LM WebGPU supports a bundled drafter. Load with
loadMtp: true, then opt in per turn. See LiteRT-LM Web MTP. -
On llama.cpp, native or WebGPU, speculative decoding is text-only and cannot
be combined with
thinkingBudgetorgrammar.
For native llama.cpp, Unsloth's Gemma 4 E2B target GGUFs ship with a separate
gemma4-assistant drafter. Pass it as
SpeculativeDecodingConfig.mtp(draftModel: ModelSource.path(...)).
Use loadMtp only for MTP tensors embedded in the target GGUF.
See the Gemma 4 E2B drafter.
Leave MTP off by default for Gemma 4 E2B on Android. In the November 29, 2026 DDP Pixel runs, llama.cpp CPU warm decode with four threads fell from 15.7 to 13.2 tokens/s on Pixel 9 Pro, from 25.1 to 19.1 on Pixel 11, and from 17.2 to 9.6 on Pixel 11 Pro with three draft tokens. LiteRT-LM CPU was also slower with MTP on all three phones. At three or more draft tokens, output can differ from plain greedy decoding. DDP Pixel runs.
(await engine.capabilities).speculativeDecodingStrategies reports the
strategies the loaded runtime runs.
SpeculativeDecodingConfig constructors mirror upstream llama.cpp
--spec-type values:
| Constructor | Upstream type | Draft model |
|---|---|---|
mtp(...) |
draft-mtp |
draftModel
, or a target with embedded MTP layers loaded with
ModelParams(loadMtp: true)
|
draftSimple(...) |
draft-simple |
draftModel; generation throws without one |
draftEagle3(...) |
draft-eagle3 |
draftModel; generation throws without one |
draftDflash(...) |
draft-dflash |
draftModel; generation throws without one |
draftDspark(draftModel: ...) |
draft-dspark |
draftModel; generation throws without one |
ngramSimple(...)
,
ngramMapK(...)
,
ngramMapK4v(...)
,
ngramMod(...)
,
ngramCache(...)
|
ngram-simple
,
ngram-map-k
,
ngram-map-k4v
,
ngram-mod
,
ngram-cache
|
None; uses token history or n-gram caches |
mixed(strategies: [...]) |
comma-separated list | At most one draft-model strategy plus any n-gram strategies |
const generationParams = GenerationParams(
maxTokens: 256,
temp: 0,
speculativeDecodingConfig: SpeculativeDecodingConfig.ngramMapK(
ngramSizeN: 4,
ngramSizeM: 8,
),
);
draftModel is a ModelSource: a local path, an HTTP(S) URL or a Hugging
Face file. The draftModelPath: parameter is deprecated. LlamaEngine
resolves the draft model when the first generation that uses it starts: on
native backends it checks a local file, or downloads a remote one into the
model cache with draftModelDownload (cache policy and directory,
authentication, checksum, retries and cancel token). Later generations on the
same loaded model reuse that file, so the download and any sha256 check run
once per loaded model; unloading or reloading the model resolves it again.
ModelCachePolicy.noCache and refresh throw LlamaUnsupportedException.
Cancelling the generation, or unloading the model, stops the download.
LiteRT-LM, and a backend that does not support the configured strategies,
throw LlamaUnsupportedException before anything downloads. The download
reports no progress; to show progress, download the file first:
final draft = ModelSource.parse('hf://owner/repo/draft-model.gguf');
await engine.modelDownloadManager.ensureModel(
draft,
onProgress: (progress) => print('${progress.receivedBytes} bytes'),
);
final params = GenerationParams(
maxTokens: 256,
temp: 0,
speculativeDecodingConfig: SpeculativeDecodingConfig.draftSimple(
draftModel: draft,
),
);
Pass the same options to ensureModel as draftModelDownload so the
generation finds the cached file.
Knobs:
-
Draft-model strategies and
ngram-cache:draftTokenMaxcaps the draft length per step. -
ngram-simple,ngram-map-k,ngram-map-k4v:ngramSizeMis the effective draft length, matching upstream's draft m-gram window;draftTokenMaxdoes not cap them. -
ngram-mod:ngramTokenMaxwhen set, otherwisedraftTokenMax, otherwise the llama.cpp default. -
draftMicroBatchSize(native llama.cpp only; upstream--spec-draft-n-ubatch): the draft context's micro-batch (n_ubatch). Unset, the draft follows the target'smicroBatchSize. A smaller value shrinks the draft compute buffer. It can change which tokens the draft proposes, and so speed, acceptance and sometimes the output, even with greedy sampling; the target still verifies every accepted token. It must be between 1 and the context's resolvedbatchSize, and at leastdraftTokenMax + 1fordraftDflashanddraftDspark, which decode a whole draft block in one micro-batch. With a LiliCorr draft model (GGUFlilicorr.candidate_topkabove zero) that block is the model'sdflash.block_size(16 when absent), so it must also be at least that. Unset, the target's resolvedmicroBatchSizemust hold the block llama.cpp actually decodes: the LiliCorr block, or elsemin(draftTokenMax, block_size - 1) + 1(DFlash and DSpark withdflash.sample_from_anchorfalse) ormin(draftTokenMax, block_size)(anchor-first DSpark), withblock_sizefrom the draft model'sdflash.block_size. N-gram-only configurations, WebGPU and LiteRT-LM reject it. -
loadMtp(ModelParams): keep itfalseunless bundled MTP tensors will be used, because loading them costs memory. An external MTP draft model loads as MTP automatically. -
speculativeRollbackTokenMax: keep the default0; native llama.cpp rejects nonzero values on recurrent or hybrid models. See Runtime parameters.
Draftless n-gram strategies depend on the workload. On prompts with little repetition they can produce no drafts and run slower than baseline. A repeated-context prompt with small n-gram sizes was the clear speedup in local checks; short natural-language and code prompts were slower.
LiteRT-LM Web MTP#
Use @litert-lm/core 0.20.0 or later and a drafter-bearing bundle, such as the
standard gemma-4-E2B-it.litertlm. The Artisan -gpu.litertlm
and
-web.litertlm variants have no drafter. The SDK checks that the loaded engine
actually executes a speculative round. Web CPU, an older runtime without
SpeculativeDecodingMode, and bundles that fail the probe report
LlamaUnsupportedException.
import 'package:llamadart/llamadart.dart';
Future<LlamaCompletion> runWebMtp(Uri bundleUrl, String prompt) async {
final engine = LlamaEngine(LlamaBackend.withTextHistory());
try {
await engine.setModel(
LlamaModel(ModelSource.url(bundleUrl)),
params: const LiteRtLmModelParams(
device: ComputeDevice.gpu,
loadMtp: true,
),
);
return await ChatSession(engine).send(
prompt,
params: const GenerationParams(
speculativeDecodingConfig: SpeculativeDecodingConfig.mtp(),
),
);
} finally {
await engine.dispose();
}
}
Use speculativeDecoding: true, SpeculativeDecodingConfig.backendDefault()
or SpeculativeDecodingConfig.mtp() without extra tuning or an external draft
model. Other turns use plain decoding even when the drafter is loaded.
Speculative output can differ from plain output, including with greedy sampling.
Set window.__llamadartLiteRtLmModuleUrl to the module URL to let llamadart
import it. If you preload it yourself, expose window.LiteRtLmEngine,
window.LiteRtLmBackendEnum and window.LiteRtLmSpeculativeDecodingMode
from
the same module's Engine, Backend and SpeculativeDecodingMode
exports.
DSpark#
DSpark (SpeculativeDecodingConfig.draftDspark(draftModel: ...)) is an
experimental, opt-in llama.cpp external-draft strategy mapped to upstream
draft-dspark. The default v1.1.0-6 runtime supports it, including
speculators-format checkpoints. Native recurrent/hybrid target pairs such as
LFM2 remain subject to the rollback restriction above. It is never
selected automatically, and support still depends on the target, draft and
backend. If speculative initialization fails, the LlamaUnsupportedException
names the minimum native tag, b10356.
DFlash draft models#
DFlash drafts must use upstream-compatible GGUF metadata:
general.architecture=dflash plus the dflash.* metadata block, including
dflash.target_layers. A known-good public pair is target
unsloth/Qwen3.5-4B-GGUF (Qwen3.5-4B-Q4_K_M.gguf) with draft
EntityDeletr/Qwen3.5-4B-DFlash-GGUF (Qwen3.5-4B-DFlash.gguf).
If the draft fails to load and native logs report
unknown model architecture: 'dflash-draft' or missing DFlash target-layer
metadata, the artifact uses general.architecture=dflash-draft or lacks
dflash.target_layers. Reconvert or replace the draft GGUF; llamadart does
not patch draft metadata at runtime.
Multimodal tuning#
- Reduce image size before anything else.
- Keep
contextSizeandmaxTokenstighter than text-only defaults. - If GPU multimodal is unstable, get a correct CPU baseline first, then revisit GPU and offload settings.
- Treat projector loading and multimodal generation as separate stages; one can be healthy while the other is slow or unstable.
Read the diagnostics#
-
first: first-token latency. If high, look at model load, prompt size, context and prompt evaluation. total: end-to-end wall time.avg: throughput across the whole request.decode: steady-state generation speed once output starts.
Native llama.cpp timing fields:
-
p_eval: prompt evaluation time. High values point to prompt and context overhead, not the sampler. -
eval: decode time for generated tokens. High values point to backend kernel or scheduler cost. -
sample: token selection overhead. Usually small; if large, check for unusual sampling settings. -
reuse: prompt-prefix reuse count. If it stays low in multi-turn chat, prefix reuse is not helping.
Check the active backend and VRAM where available:
final backendName = await engine.getBackendName();
final vram = await engine.getVramInfo();
print('$backendName total=${vram.total} free=${vram.free}');
Heuristics by environment#
- Mobile native: test CPU against GPU early; small models often favor CPU.
- Desktop native: the GPU pays off more as model size or response length grows.
- Browser: start with conservative GPU settings; browser GPU paths have tighter stability limits than native.
- Multimodal: expect stricter limits than text-only, especially on mobile and browser targets.
Compare fairly#
-
Use the same model, prompt,
contextSize,maxTokensand backend-specific limits across runs. - Record latency and throughput; a setting that improves one can hurt the other.
- Validate memory behavior with your real context sizes.
In one historical comparison of Gemma 4 E2B (Pixel 9 Pro, Apple M4 Max and Chromium on the same Mac), LiteRT-LM on the GPU was about 9x faster than llama.cpp on Vulkan on the Pixel, about as fast as llama.cpp on Metal on the Mac, and about 2x faster than the llama.cpp WebGPU bridge on web. On web the GGUF path was also more sensitive to serving behavior: a large model needs a range-capable server or a browser cache. Treat this as a reason to measure both formats on your target device, not as a ranking; on desktop, decide on model format, features and distribution constraints (Choosing llama.cpp or LiteRT-LM).
For when getPerformanceContext() returns null, see
Token usage and timings.