Gemma-4-E2B-it (GGUF) – Renesas X5H
Text-only release. This version supports text input and text output only. Image, audio and video input are coming soon.
Introduction
This repository hosts Gemma-4-E2B-it, the instruction-tuned "E2B" (~2B effective parameters) model from Google's Gemma 4 family, targeting the Renesas R-Car X5H platform for text generation and chat on the NPX6 NPU.
- Model Architecture: Gemma 4 decoder-only language model (E2B, elastic parameters).
- Source Model: google/gemma-4-E2B-it
- Task: Text generation / chat (text-only)
Provided Artifacts
| Artifact | Status | Notes |
|---|---|---|
| FP16 (GGUF) | ✅ | fp16/gemma-4-E2B-it-F16.gguf — language model, text-only |
| FP16 X5H runner | ✅ | fp16/binaries/rcar-x5hv1/xOS-v4.34/gemma4-e2b-runner-0.1.0-Linux.sh |
| Tokenizer / config | ✅ | fp16/tokenizer.json, tokenizer_config.json, generation_config.json, chat_template.jinja, processor_config.json |
| W4A16 (quantized) | ⏳ | Coming soon — 4-bit weights, 16-bit activations |
| Vision projector (mmproj) | ⏳ | Coming soon with image support |
Performance
Measured on Renesas R-Car X5H (xOS-v4.34, NPX Toolkit), hardware-in-the-loop.
Benchmark configuration: 1× NPU · 12 cores · 1066 MHz · Batch size: 1 · Text input
| Model | Precision | Device | Throughput (tokens/s) | Type |
|---|---|---|---|---|
| decode | FP16 | X5H · 1× NPU · 12 Core · 1066 MHz | 11.3 | Measured |
| decode | W4A16 | X5H · 1× NPU · 12 Core · 1066 MHz | 27.2(cold), 29.5 (warmup) | Measured |
| prefill | W4A16 | X5H · 1× NPU · 12 Core · 1066 MHz | input-token-len:829 0.708s@1170tps(cold), 0.577s@1436tps (warmup) | Measured |
| audio-encode | W8A8 | X5H · 1× NPU · 12 Core · 1066 MHz | 30sec clip, 81.6ms | Measured |
Accuracy
TBD — not yet measured/published for this repo.
Roadmap
- ✅ Text generation / chat, FP16 (this release)
- ✅ W4A16 quantized model
- ⏳ Image input — coming soon
- ✅ Audio input
- ⏳ Video input — coming soon
Prerequisites
To run the model, you need:
- Renesas R-Car X5H board (xOS-v4.34) with NPX6 NPU
- Hugging Face CLI to download the model and installer
Deployment
FP16
- Download the installer gemma4-e2b-runner-0.1.0-Linux.sh from the Files and versions tab under
fp16/binaries/rcar-x5hv1/xOS-v4.34/. - Copy the installer to the X5H board and run it:
bash ./gemma4-e2b-runner-0.1.0-Linux.sh --prefix=./ --exclude-subdir --skip-license - Download GGUF gemma-4-E2B-it-F16.gguf from the
fp16/folder and copy it into the installed directory on the X5H board. - Expected directory structure on the X5H board:
gemma4-e2b-runner/ ├── gemma-4-E2B-it-F16.gguf ├── firmwares ├── kernel_modules ├── gemma4-e2b-runner ├── scripts └── setup_npu.sh
Inference
FP16
cd gemma4-e2b-runner
bash ./setup_npu.sh
./gemma4-e2b-runner <PROMPT>
W4A16
Contents
gemma4-e2b-runner-0.3.0-Linux.sh is a self-extracting installer. It holds the runner, the NPU
graphs, the NPU firmware, the kernel modules and the NPU setup scripts, already built for the board.
Nothing is compiled on the board.
gemma4-e2b-runner/
├── gemma4-e2b-runner # the runner
├── setup_npu.sh # NPU bring-up
├── scripts/ # npuN_power_on.sh, npuN_run.sh
├── firmwares/npu0, npu1/ # NPU firmware (14 ELFs per NPU)
├── kernel_modules/multi_cma/ # snps_accel, snps_arcsync, snps_rproc
└── graphs/gemma4-e2b/ # NPU graphs and their int4/int8 coefficients (~2.5 GB)
What you need
| Board | R-Car X5H (b001, dual NPX48K), root access |
| Free disk space | ~2 GB for the package and ~2.5 GB once it is installed |
| Model (text) | gemma-4-E2B-it-F16.gguf, the FP16 GGUF of Gemma 4 E2B-it (9.3 GB, 601 tensors) |
| Model (audio, optional) | gemma-4-E2B-it-audio.safetensors (~615 MB): the audio encoder weights of google/gemma-4-E2B-it, see below |
| Audio input (optional) | a 16 kHz mono wav, up to 30 s |
The runner reads the text weights from the GGUF and the audio encoder weights from the safetensors file. The int4 and int8 weights the NPU uses are already in the graphs.
Download the model files
On any machine with internet access, then copy the files to the board.
Text model, the FP16 GGUF:
curl -L -o gemma-4-E2B-it-F16.gguf \
https://huggingface.co/SthRen0125/google_gemma-4-E2B-it/resolve/main/gemma-4-E2B-it_text_model_gguf/gemma-4-E2B-it-F16.gguf
sha256sum gemma-4-E2B-it-F16.gguf
# 69de3d48261cfa07ac2e50df5c5d1ebabb7f31f4d9725f24f083a66c357a82ec (the file this release was measured with)
Audio encoder weights (only for audio input). The runner needs only the audio tower and audio
embedder of the HF checkpoint, 752 tensors (model.audio_tower.*, model.embed_audio.*), about
615 MB of the 10 GB model.safetensors. extract_audio_weights.py, next to this README, reads
just those tensors from the Hub with HTTP range requests, so the 10 GB file is never downloaded:
pip install huggingface_hub
python3 extract_audio_weights.py --remote
# -> gemma-4-E2B-it-audio.safetensors, 752 tensors, 614464840 bytes
sha256sum gemma-4-E2B-it-audio.safetensors
# 7c8ce98aa51975a9ecce3ef7b48c22704f4f66b41e56230d5c03bcb71b428608 (the file this release was measured with)
If model.safetensors is already downloaded, cut the file out of it instead
(pip install safetensors torch):
python3 extract_audio_weights.py --src path/to/model.safetensors
The runner also accepts the full model.safetensors as --audio-weights and reads the same
tensors from it.
If Hugging Face asks for it, accept the Gemma license on the model page and log in
(hf auth login, or pass -H "Authorization: Bearer <token>" to curl).
Audio input
Any recording can be converted to a 16 kHz mono wav with ffmpeg:
ffmpeg -i input.mp3 -ac 1 -ar 16000 -t 30 clip.wav
Install
bash ./gemma4-e2b-runner-0.3.0-Linux.sh --prefix=./ --exclude-subdir --skip-license
cd gemma4-e2b-runner
Run
Bring up the NPU once after each boot (NPU0, the default):
./setup_npu.sh
Text prompt:
./gemma4-e2b-runner "What is AI?" path/to/gemma-4-E2B-it-F16.gguf -n 128
Audio prompt (speech transcription):
./gemma4-e2b-runner \
$'Transcribe the following speech segment in English into English text.\n\nFollow these specific instructions for formatting the answer:\n* Only output the transcription, with no newlines.\n* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three.' \
path/to/gemma-4-E2B-it-F16.gguf -n 128 \
--audio clip.wav --audio-weights path/to/gemma-4-E2B-it-audio.safetensors
Add --print-stats to print the timing: prefill and generation rates, time per NPU graph, and
the audio encoder steps.
Options
Usage: ./gemma4-e2b-runner <prompt> [model_path] [max_tokens]
-n, --max-tokens N maximum generated tokens (default: fill the context)
--print-stats print performance metrics
--npu-idx N NPU cluster, 0 or 1 (default: 0); run setup_npu.sh
with the same --npu-idx
--audio FILE 16 kHz mono wav
--audio-weights FILE gemma-4-E2B-it-audio.safetensors, or the HF model.safetensors
--lm-head-fp16 fp16 lm_head, instead of the int4 one
--no-rescore int4 lm_head argmax as it is, without the fp16
rescoring of its top 8
--no-batched-prefill process the prompt one token at a time
--no-padded-prefill prompt tail token by token instead of one
padded chunk
The defaults are the configuration measured in BENCHMARK.md. The int4 LM head rescores its top 8
candidates with the fp16 weights, so the chosen token is the same as with the fp16 LM head.