Request it for the seed queue, or get it now with pf download assassinshadow/gemma-4-E2B-it-text-SM8450-ExecuTorch-QNN (CLI guide).
gemma-4-e2b-it-text-sm8450-npu-ctx4096.pte is
google/gemma-4-E2B-it compiled for the Hexagon
NPU of the Snapdragon 8 Gen 1 (SM8450, Hexagon v69) with ExecuTorch's Qualcomm AI Engine Direct
(QNN) backend. All 35 decoder layers and the lm_head run on the NPU. It was built for and measured
on a Samsung Galaxy S22 Ultra (SM-S908E).
Text only. The vision and audio towers are not included.
Thinking mode works: the model reasons in its <|channel>thought … <channel|> block and then
answers.
This file is compiled for one chip family. It will not run on other SoCs (the QNN context binaries inside target Hexagon v69), and it needs the patched runner in
runner/. Read "Limitations" before you spend 3 GB of download on it.
AutoDroid Studio is the Android app this model was built for and measured in. It
runs this .pte on the NPU of a Snapdragon 8 Gen 1 phone, exactly as published here. "Running it"
below is for people who want to drive it by hand.
Why use it:
adb, no environment variables. The app sets up
the Qualcomm runtime itself and finds and downloads models from Hugging Face in its own browser.Get AutoDroid Studio on Google Play
| Base model | google/gemma-4-E2B-it (text decoder only) |
| File | gemma-4-e2b-it-text-sm8450-npu-ctx4096.pte, 2.92 GB |
| SHA-256 | b7d430b531b821da8f28c32e462269b7ed490f8a10110f0c99d74c12d88e91a9 |
| Target | SM8450 / Snapdragon 8 Gen 1, Hexagon v69 HTP |
| On the NPU | all 35 decoder layers + lm_head, as QNN contexts |
| On the CPU | the two embedding lookups: token table (262144 × 1536) and the per-layer-embedding table (262144 × 8960, 2.3 B of the model's parameters), both 4-bit in groups of 32 |
| Context | 4096 tokens, shared by prompt and answer |
| Mode | KV ("kv"): one graph, one token per call, prompt included |
| Weights | linear layers 4-bit LPBQ (block 64) |
| Activations | 16-bit |
| KV cache | 8-bit (Hexagon v69 rejects a 16-bit second matmul input) |
| Exporter | ExecuTorch v1.5.1 static llama (examples/qualcomm/oss_scripts/llama, --decoder_model gemma4-e2b), with patches |
| QNN SDK | QAIRT 2.39.0 (compile time and run time) |
| Calibration | 4 thinking-mode conversations written by the float model itself, teacher-forced |
| Runner from a shell | Inside an Android app (backgrounded) | |
|---|---|---|
| Load | 2.3–2.6 s | ~8.7 s |
| Prompt processing | 9.1–10.1 tok/s | first token ~3.5 s on a follow-up turn |
| Generation | 9.0–9.8 tok/s | ~7 tok/s streamed |
Prompt processing runs at generation speed because the graph takes one token per call (see "Why KV mode only").
Single-turn evaluation, greedy, 9 prompts (a fact, letter counting, arithmetic, logic, code, a
two-turn memory test, Japanese, a no-thinking prompt): 8 of 9 clean. It answered Canberra,
18 pencils = $2.40, Carol, a correct is_prime function, remembered a cat's name and age across
turns, answered in Japanese (東京です。) and greeted in French with thinking off. Reasoning stays
in English, closes with <channel|> and leaks no template tokens.
Multi-turn evaluation through an Android app, temperature 0.7, thinking on, 6 conversations, 22 turns (facts carried across five turns, follow-ups on a previous answer, thinking toggled mid-chat, regenerate and edit, a stop followed by new questions, a new chat): 19 of 22 turns passed once the client handled the quirks below.
| File | What it is |
|---|---|
gemma-4-e2b-it-text-sm8450-npu-ctx4096.pte |
the model |
tokenizer.json, tokenizer_config.json |
the tokenizer of the base model |
special_tokens_map.json |
BOS <bos> and EOS `<turn |
chat_template.jinja |
the base model's chat template, for reference |
runner/qnn_llama_runner |
ExecuTorch v1.5.1 qnn_llama_runner for Android arm64, patched (see below) |
runner/libqnn_executorch_backend.so |
the QNN backend it links against |
runner/patch_runner.py |
the patch, so you can rebuild the runner yourself |
Not included: the Qualcomm runtime libraries. You need these from QAIRT 2.39.0
(lib/aarch64-android/ and lib/hexagon-v69/unsigned/): libQnnHtp.so, libQnnSystem.so,
libQnnHtpV69Stub.so, libQnnHtpV69Skel.so. They are Qualcomm's to distribute. A newer QAIRT
(2.48 was tried with a sibling model) made the DSP restart mid-generation; stay on 2.39.
Push everything into one folder on the phone (the tokenizer files into a tok/ subfolder), then:
cd /data/local/tmp/gemma4
export LD_LIBRARY_PATH=$PWD ADSP_LIBRARY_PATH=$PWD
./qnn_llama_runner \
--decoder_model_version gemma4 --raw_prompt \
--tokenizer_path tok \
--model_path gemma-4-e2b-it-text-sm8450-npu-ctx4096.pte \
--eval_mode 0 --seq_len 4096 --temperature 0 \
--prompt "$P"
$P is the fully rendered conversation, <bos> included:
<bos><|turn>system
<|think|>
<turn|>
<|turn>user
How many days are in a leap year?<turn|>
<|turn>model
Without thinking, drop the system turn (or leave <|think|> out of it):
<bos><|turn>user
Say hello in French.<turn|>
<|turn>model
The model's reply looks like <|channel>thought\n…reasoning…<channel|>The answer.<turn|>.
What matters here:
--decoder_model_version gemma4 is required. It selects the shared-KV (YOCO) cache layout
this model uses. An ExecuTorch v1.0.x runner cannot load the file at all.--raw_prompt is required for thinking. The runner's built-in Gemma 4 template has no
thinking switch, so the client renders the template and the runner passes it through.
--raw_prompt is added by the patch; the stock runner does not have it.<bos> yourself. In gemma4 mode the runner adds no BOS token (its own template
carries it as text). Measured: 28 prompt tokens without it, 29 with. Results are worse without.--eval_mode 0: this is a KV-only export.tokenizer.json. Given a folder, the runner reads
BOS/EOS from special_tokens_map.json; given a file, it guesses them from token names.The stock runner is one-shot and prints nothing until it finishes. The patched one streams, and
with --serve stays resident so the model loads once and the KV cache carries over between turns:
client -> runner GEN <nbytes>\n + nbytes of UTF-8 generate from this text
FEED <nbytes>\n + nbytes put text in the KV, no reply
REWIND <pos>\n forget the KV from token pos on
STOP\n (during a GEN) end it early
RESET\n new conversation
QUIT\n
runner -> client \x01READY stop rewind feed\n once, after loading
<echo of the prompt, then tokens> streamed
\x1eEND <chars> <secs> <pos>\n end of a GEN; pos = tokens in the KV
\x1eFED <tokens> <pos>\n
\x1eOK <pos>\n / \x1eOK\n
\x1eERR <why>\n
The runner stops on <turn|> without feeding it back, so a follow-up GEN must begin with
<turn|>\n to close the previous answer, unless you re-fed the answer yourself.
Measured on the phone: STOP ends a generation in about 0.1 s; after REWIND to where a reply
began and FEED of a replacement, the next turn answers from the replacement.
REWIND to where the reply
began and FEED the answer plus <turn|>\n. A five-turn chat then holds ~110 tokens instead
of over a thousand, and old reasoning cannot leak into later turns.STOP, REWIND to a little before the loop began, and GEN the text
\n<channel|>. The model then answers from the reasoning it had. If the reasoning ran past
~1000 tokens before looping, rewind to the reply's start and GEN
<|channel>thought\n<channel|> instead, so it answers without it.REWIND + FEED), so no unclosed
thought stays in the cache.With those three, a test run that had 3 empty answers and 4 runner restarts in 22 turns had none.
Exported on a PC with 32 GB of RAM under WSL, 57 minutes, with ExecuTorch v1.5.1's static LLM flow and these changes, all needed for Hexagon v69:
QNN weight sharing between a prefill graph and a decode graph needs Hexagon v73 or newer. On v69 a hybrid file holds two full copies of the weights, and one process on this phone's cDSP can map only about 1.85 GB. So the file has a single one-token-per-call graph, and prompts are processed at generation speed.
The model weights derive from google/gemma-4-E2B-it and are under the same licence (Apache 2.0; see the Gemma 4 licence page linked above). Compiled with ExecuTorch and Qualcomm AI Engine Direct. This is an unofficial community build, not affiliated with Google, Meta or Qualcomm.
Have the files? Publish a torrent.
Publish a torrentHave the complete files and permission to share them? Replace the example folder path. The script checks the files, makes a torrent and submits its magnet and checksums. Keep your torrent client seeding. Get your community key from your settings, and read the script before running it.
curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo assassinshadow/gemma-4-E2B-it-text-SM8450-ExecuTorch-QNN ./model-foldergoogle/gemma-4-E2B-it