PyTorch Day Japan
27×
faster prefill on a second turn: Qwen3-1.7B on ExecuTorch, reusing 1,192 tokens
Tokyo, 10 December 2026
When the KV Cache Cannot Roll Back: Prefix Reuse on Android.
How a phone skips re-reading a 2,050-token agent prompt, built twice because the app's two runtimes have different cache constraints.
The talk
An agent prompt on a phone can open with about 2,050 tokens of harness, 1,700 of them tool definitions. On a Dimensity 9500s, a 1,036-token prefix takes 9.3 s to prefill on LFM2.5-1.2B and 45 s on SmolLM3-3B; faster decode does nothing to that wait. We solved it with prefix reuse, built twice because our open source app ships two runtimes with different cache constraints.
ExecuTorch's Android API exposes prefill and full reset, but no partial rollback. We prefill the shared head at model load, then feed only the unmatched suffix while the prompt is an exact extension. On our llama.cpp path, LFM2.5's recurrent state cannot rewind without per-token snapshots, so we snapshot the warmed 12 MB state and restore it.
Correctness depends on byte identity. The date is pinned per conversation, history replays the engine's own bytes, changing reasoning mode invalidates the prefix, and truncated replies are never reused. The talk shows the cache rules, the failures and the regression tests; measurements and logs are public.
The evidence
What prefix reuse saves
| Runtime and model | What was compared | Before | After |
|---|---|---|---|
| ExecuTorch, Qwen3-1.7B | Prefill on the first turn against the second, which reused 1,192 tokens | 5,852 ms | 215 ms |
| llama.cpp, LFM2.5-1.2B | Cold prefill of the head against a fresh chat's first token | 9,326 ms | 235 ms |
ExecuTorch ran Qwen3-1.7B q8da4w on 2026-08-31, feeding 903 tokens on the first turn and 20 new ones on the second. llama.cpp ran LFM2.5-1.2B Q4_K_M on 2026-09-03 on a synthetic 1,036-token prefix, restoring a 12 MB snapshot. The two rows measure different things and do not compare with each other. Both ran on the same POCO X8 Pro Max.
Where and when
- Conference
- PyTorch Day Japan, hosted by the PyTorch Foundation, Hugging Face, IBM and Mitsubishi Electric
- Date
- Thursday 10 December 2026, 5:15 PM to 5:35 PM JST
- Room
- 2F Hall, Bellesalle Akihabara, Tokyo
- Track
- Physical AI/Edge AI
- Speakers
- Alpha Romer Coma and Arjhine Ty