Repository navigation
AMEVA-Runtime v2.8.1: context shift on the GPU route
Release Notes - AMEVA-Runtime v2.8.1
Release Tag: v2.8.1
Distribution Channels: PyPI (ameva-runtime), NPM (@ameva/runtime), GitHub Releases (uno-km/ameva-runtime-releases)
Target Platform: Android ARM64 / Qualcomm Adreno, ARM Mali, Linux & Edge
License: Apache-2.0
Summary
A patch release for one defect of 2.8.0: on the GPU route, text generation past the end of the context with context
shifting enabled stopped with an abort. ameva-run exec does not enable context shifting, so its own runs were not
affected; a caller that passes --context-shift to the bundle's llama.cpp, or a front end that shifts the context
itself, was.
Everything else is as in 2.8.0, whose notes hold the description of the GPU route and its speed tables:
https://github.com/uno-km/ameva-runtime-releases/releases/tag/v2.8.0.
Changes
1. The defect and the fix
When a context is full, llama.cpp discards the older half of its KV cache and moves the rest down. With RoPE the
stored keys have to be rotated for their new positions, which llama.cpp does in place on the backend that owns the
cache: a ROPE operation on a view of the f16 key cache. ggml-ameva ran ROPE on f32 tensors only. A tensor that lives
in a backend's buffer cannot be handed to another backend, so llama.cpp stopped:
ggml-backend.cpp:809: pre-allocated tensor (cache_k_l0 (view) (view)) in a buffer (AMEVA) that cannot run the operation (ROPE)
Reproduced with the 2.8.0 backend on the Galaxy S21: llama-completion --device AMEVA0 -c 256 -n 700 --context-shift
ends with exit status 134 at the first shift; the CPU run completes. ggml-ameva now runs ROPE on f16 tensors
(ameva-compute f2265d1): the conversions are those of the CPU backend (f16 to f32 exactly, f32 to f16 to nearest
even). The quantized-cache path of the same shift (cast to f32, ROPE, copy back) already worked.
2. llama bundle
llama-cli-vulkan-android-arm64.tar.gz: the 2.7.9 archive with every member unchanged plus the backend files built
from ameva-compute 7e99154 on the Galaxy S25 (clang 21.1.8, 0 compiler warnings, AMEVA_QMM_CHECK=PASS (516/516),
both batch KATs). Pin 1d086faf6227.... The four other bundles are those of 2.7.9.
Besides the fix the backend has one addition since 2.8.0: on devices whose Vulkan driver has no
VK_KHR_shader_integer_dot_product (Galaxy S21, Galaxy A53) token generation can use an integer dot product computed
with 32-bit multiplications. It is measured per weight shape together with the other layouts and used where more than
10 % faster. Those two devices keep the CPU route by default.
Verification
2026-10-05, the backend of this bundle (plugin 4c07da7b...), tools/fleet/lab/verify_kv.sh and
tools/fleet/lab/test_rel.sh; Qwen2.5-0.5B and Llama-3.2-1B, Q4_K_M. The files are in
docs/handover/evidence/20261005-v2.8.1-candidate/.
All five fleet devices were verified. The Galaxy A35 was verified last, on 2026-10-06, once another job that had
held it (a CPU video generation) finished. Its test-backend-ops first looked like a pass but was not: the device's
~/abi-lab/rt098 carries a libggml-base whose ggml_backend_i member count differs from the release bundle's
(b8471), so ameva_abi_check refused the AMEVA backend and 0 AMEVA tests ran under rc=0. Re-run against the
bundle's own ggml it passes in full (section 4). The other four used a matching ggml and were not affected.
1. Context shift and KV cache against the CPU (ameva-compute tests/ameva_llm_parity.cpp --kv-ops 32, context
256: the context is filled, half of it is discarded and the rest moved as --context-shift does, then 32 tokens are
scored against the CPU doing the same; "reuse" decodes 32 tokens, removes them, decodes others in their cells, removes
those and decodes the first ones again, third pass against the first. Gate kld_mean <= 0.01, reuse kld_max <= 1e-4.)
| kld_mean | S25 Adreno 830 | S20 Adreno 650 (Turnip) | A35 Mali-G68 r38 | A53 Mali-G68 r32 | S21 Mali-G78 |
|---|---|---|---|---|---|
| after a shift, Qwen2.5-0.5B (RoPE NEOX) | 5.74e-3 | 7.30e-3 | 8.65e-3 | 6.18e-3 | 7.49e-3 |
| after a shift, Llama-3.2-1B (RoPE NORMAL) | 2.87e-3 | 2.56e-3 | 2.85e-3 | 2.68e-3 | 2.76e-3 |
| reuse of cells, both models (kld_max) | 0 | 0 | 0 | 0 | 0 |
| one token per call, no shift, Qwen / Llama | 4.04e-3 / 2.91e-3 | 5.10e-3 / 3.83e-3 | 3.99e-3 / 3.63e-3 | 3.76e-3 / 2.78e-3 | 4.21e-3 / 3.46e-3 |
The CPU's own distance between its two kernel paths on the same 16 positions is 4.76e-3 (Qwen) and 3.30e-3 (Llama).
2. A 2048-token context (one chunk, 256 tokens per call, every eighth position of the second half scored: 128
positions at 1024 to 2040 cells; Qwen2.5-0.5B; the CPU's own distance is 1.83e-3)
| kld_mean, batch / one token per call | S25 | S20 | A35 | A53 | S21 |
|---|---|---|---|---|---|
| 1.89e-3 / 1.63e-3 | 1.78e-3 / 1.84e-3 | 1.97e-3 / 1.99e-3 | 1.57e-3 / 1.61e-3 | 1.57e-3 / 1.65e-3 |
3. Text past the end of a context (llama-completion -c 256 -n 700 --context-shift, two prompts, greedy): the
GPU route completes on all five devices. With the 2.8.0 backend it aborts at the first shift
(Galaxy S21). This checks that the run completes, not the text: with a 256-token context and greedy sampling
Qwen2.5-0.5B ends in a repeated phrase on the CPU and on the GPU alike ("units in units in ..." on the CPU,
"the line of the line of ..." on the GPU, Galaxy S25). No output contains characters of another script.
4. Conformance. ggml test-backend-ops (llama.cpp b8471) for AMEVA0, default settings / AMEVA_REPACK_ALL=1:
| S25 | S20 | A35 | A53 | S21 | |
|---|---|---|---|---|---|
| passed | 2025/2025, 1768/1768 | 2023/2023, 1766/1766 | 2024/2024, 1767/1767 | 2024/2024, 1767/1767 | 2024/2024, 1767/1767 |
2.8.0 reported 1949 and 1692 (Galaxy S25): the ROPE cases on f16 tensors were declined then and run now (76 of them
on the Galaxy S25; the totals differ by one or two between the devices).
5. Installation and ameva-run exec (scratch trees with their own HOME / PREFIX, this bundle from a file://
release base; Qwen2.5-0.5B, "What are the three primary colors? Answer in one sentence.")
| S25 | S20 | A35 | A53 | S21 | |
|---|---|---|---|---|---|
Fresh install: 5 bundles, $PREFIX/lib empty, 7 linked commands, plugin of 7e99154 in the llama release |
PASS | PASS | PASS | PASS | PASS |
Upgrade of a tree installed by the published 2.8.0: llama bundle [UPGRADE], four reused |
PASS | PASS | PASS | PASS | PASS |
| Default route and its text | GPU, expected | GPU, expected | GPU, expected | CPU, expected | CPU, expected |
-b vulkan (ggml-ameva) and -b cpu: text |
expected | expected | expected | expected | expected |
6. Speed with this backend, tokens per second, CPU / ggml-ameva (tools/fleet/lab/perf_matrix.sh with QUICK=1:
a prompt of about 370 tokens and 64 generated tokens, two rounds alternating with the CPU, -c 2048 -t 4)
| S25 (clock cap 832 MHz, cores 0-7) | S20 (clock cap 441 MHz) | A53 | S21 | |
|---|---|---|---|---|
| Qwen2.5-0.5B prompt | 126-195 / 1081-1087 | 27.5-27.7 / 180 | 50-55 / 67 | 106-111 / 221-226 |
| Qwen2.5-0.5B generation | 79-105 / 65-76 | 9.3-9.9 / 18.7 | 22.6 / 14.6-14.7 | 43-45 / 22.8-24.3 |
| Llama-3.2-1B prompt | 129-208 / 472-473 | 27.5-28.0 / 72 | 47.6-47.8 / 27.0 | 110-112 / 96.4 |
| Llama-3.2-1B generation | 68 / 45-47 | 6.9 / 12.2 | 13.1-13.5 / 7.8 | 21-22 / 16.1 |
-
Galaxy S25, correction to the 2.8.0 notes (2026-10-05). The 2.8.0 notes say that token generation is "faster
than the CPU on the Galaxy S25" (CPU 16-49, 33-49 without other load, against 72-75 with ggml-ameva for
Qwen2.5-0.5B). In this session, with no other job on the phone and all eight cores allowed to the process
(Cpus_allowed_list0-7), the CPU generated 79-105 t/s (Qwen2.5-0.5B) and 68 t/s (Llama-3.2-1B) against 65-76 and
45-47 with ggml-ameva, andameva-run exec -b cpu115.5 t/s against 69-74 on the GPU route. The GPU figures are
at the level of the 2.8.0 notes. The CPU figures of the 2.8.0 notes were measured in sessions limited to four
cores (Cpus_allowed_list0-1,4-5, recorded in that release's evidence files) and partly under other load; this
release's parity runs on the phone had the same limit, its speed runs did not. So on the
Galaxy S25 the GPU route is 5 to 9 times the CPU in prompt processing (0.5B) and 2.3 to 3.7 times (1B), and 0.6 to
1.0 times the CPU in token generation when the CPU has all its cores. The default route of the S25 is unchanged
(GPU). -
Galaxy S20: its CPU figures in this session are less than half of those in the 2.8.0 notes (generation 25-27, prompt
60 there); the phone had been running another job for hours before the measurement. The GPU figures are at the
level of the 2.8.0 notes for a 441 MHz cap. -
Galaxy S21, Llama-3.2-1B generation: 16.1 against 9.4-12.9 in the 2.8.0 notes; the layouts with the emulated integer
dot product are chosen for its q4_K shapes. The CPU remains faster there, and on the Galaxy A53. -
Galaxy A35: correctness and installation verified (sections 1-5); its CPU/GPU speed table was not re-measured this session (see the 2.8.0 notes).
ameva-run execon the GPU route gave a prompt of about 135 t/s.
Unit tests: 225 passed, 17 skipped on the build host; no write to the host's own AMEVA store.
Known issues
- Quantized KV cache (
-ctk/-ctv): the 2.8.0 notes said that q8_0 "gives the CPU's q8_0 text". That
compared the GPU with the CPU using the same cache type. Against an f16-cache reference the q8_0 cache itself costs
a KL divergence of 3.6e-2 on the CPU and 3.0e-2 to 3.3e-2 on the GPU (Qwen2.5-0.5B, 16 positions), above the 0.01
gate, and 0.5 on both after a context shift. With a q8_0 cache on both sides the GPU is, against the CPU, at
9.7e-3 to 1.10e-2 in batches, 8.4e-3 to 9.2e-3 one token per call and 2.8e-2 to 3.8e-2 after a context shift on the
four verified devices (the CPU's own two kernel paths differ by 7.8e-3 with this cache):verify_kv.shprints
FAIL for that section on every device. Reuse of cells is exact with this cache too. The default cache type is
f16; q8_0 saves memory at that cost. - On the Mali devices token generation on the GPU is slower than on the CPU, and so is prompt processing of the
1B model on the Galaxy A53; Galaxy S21 and A53 keep the CPU route by default (2.8.0 notes, Known issues 2). - Only
ameva-run execandameva_runtime.run()use the plugin (2.8.0 notes, Known issues 3). - The first GPU run in a new
HOMEincludes the layout measurement and pipeline compilation (2.8.0 notes, Known
issues 1).