DEV Community

Cover image for Gemma 4 E2B on a Laptop's Integrated Radeon GPU with llama.cpp Vulkan and a Speculative Drafter
xbill Subscriber for Google Developer Experts

Posted on

Gemma 4 E2B on a Laptop's Integrated Radeon GPU with llama.cpp Vulkan and a Speculative Drafter

The GPU in an ordinary laptop can run a current language model. A Lenovo Yoga 6 with a Ryzen 5 7530U has no graphics card, only the integrated Radeon in the processor: a Vega-generation GPU, a 2 GiB slice of the laptop's 8 GiB of RAM, and no official ROCm support. Through llama.cpp's Vulkan backend, which needs only the Mesa driver the desktop already uses, it serves Gemma 4 E2B at about 30 tokens a second.

That is 32.37 tokens a second with the model alone, 1.26x the processor's own CPU cores, with 432 MiB of the 2 GiB left over. Adding a small drafter model that guesses 2 tokens ahead raises it to about 41. The answers hold up either way: GSM8K 0.9014 and BFCL simple 0.9225 without the drafter, 0.9030 and 0.9225 with it.

This article provides a step by step deployment guide for Gemma 4 E2B on the integrated GPU of a Ryzen 5 7530U laptop with llama.cpp and Vulkan, with a speed sweep of the drafter and a full GSM8K and BFCL run with and without it. The aim is to get the most out of hardware you already own, so every choice here is the one that works best on this chip. The rig is a Makefile and a tpu.env, so serving is one command.

https://github.com/xbill9/gemma4-dev/tree/main/local-llamacpp-r57530u-2b-q4_0


The Findings

The iGPU serves Gemma 4 E2B at 32.37 tokens a second. That is llama-bench tg128 with every layer on the GPU. Prompt processing runs at 348 tokens a second, 3.08x the CPU of the same chip.

The model needs 1.20 GiB on the GPU. The GGUF is 2.605 GB, but its 1.321 GB per-layer embedding table stays in the memory-mapped file and is read from system RAM. Serving at an 8,192-token context holds 1,616 of the 2,048 MiB carve-out.

A 2-token drafter takes it to about 41 tokens a second. Over six prompts the drafter takes decoding from 30.8 to 40.6 tokens a second, 1.317x, and code reaches 1.89x. Over the 534,449 tokens of a full GSM8K pass it averages 41.86.

The drafter keeps the answers. GSM8K 1,191 of 1,319 with it and 1,189 without, BFCL simple 369 of 400 both ways. No question that was right without the drafter is wrong with it.

A full GSM8K pass takes 3.55 hours with the drafter and 5.28 without. 79% of drafted tokens are accepted on GSM8K and 93% on BFCL, against 48% on the six chat prompts.

ROCm does not officially support this GPU; it runs with one override, and Vulkan is the better backend here. A gfx900 build with HSA_OVERRIDE_GFX_VERSION=9.0.0 decodes at 0.976x Vulkan, reads prompts at 0.589x and gives the same BFCL answers, 368 against 369 of 400.

What to do with it.

  • 🟢 Serve the exact Q4_0 GGUF on the iGPU with the drafter at 2 tokens: about 41 tokens a second, same answers.
  • 🟢 Keep -ngl 99 and the memory map: the per-layer table never has to fit in the carve-out.
  • ⚠️ The CPU of the same chip decodes at 25.68 tokens a second, so the GPU's lead on decoding is 1.26x; its lead on reading a prompt is 3.08x.
  • ❌ Three drafted tokens fall back to 1.145x: the third is accepted too rarely to pay for itself.
  • ⚠️ ROCm needs the gfx900 override on this chip, which AMD does not list, and reads prompts at 0.589x Vulkan.

What Was Measured

Four runs on one laptop, all on llama.cpp 7182ef71e with the same GGUF. First, llama-bench prompt and decode speed on the iGPU and on a CPU-only build of the same commit. Second, six chat prompts against llama-server with no drafter and with 1, 2 and 3 drafted tokens, three greedy passes each, then no drafter again. Third, all 1,319 GSM8K questions and all 400 BFCL simple questions through llama-server, one request at a time, with the drafter at 2 tokens and without it. Fourth, a ROCm build of the same commit against Vulkan on the same day: llama-bench, and BFCL simple with and without the drafter.


At This Point You Should Have…

  • A machine with an AMD integrated GPU and a working Mesa RADV Vulkan driver, here a Lenovo Yoga 6 13ABR8 with a Ryzen 5 7530U
  • glslc, libvulkan-dev and spirv-headers from apt, and cmake
  • Python 3 with numpy, pyyaml and python-dotenv
  • For the ROCm comparison only: hipcc, libamdhip64-dev, librocblas-dev, libhipblas-dev and rocminfo from Debian sid
  • A clone of gemma4-dev

Step 1 — The Machine

The GPU is the one inside the APU, a Barcelo part with gfx90c compute units. Its 2 GiB of "VRAM" is carved out of the laptop's 8 GiB, and the kernel sees the rest:

$ vulkaninfo --summary
    deviceName         = AMD Radeon Graphics (RADV RENOIR)
    driverInfo         = Mesa 26.2.8-1

$ free -m
               total        used        free      shared  buff/cache   available
Mem:            5776        1460        1099           8        3519        4315
Enter fullscreen mode Exit fullscreen mode

The rig names the part r57530u in its directory, because an integrated GPU has no model number of its own. GPU and CPU share one memory bus, one cooler and one power limit.


Step 2 — Build llama.cpp with Vulkan

make build builds llama.cpp 7182ef71e twice: with the Vulkan backend to serve, and with no GPU backend at all, so a CPU number cannot include any GPU work.

$ make build
$ ~/llama.cpp-7182ef7/build-vulkan/bin/llama-server --version
version: 0.7.0-dev (build 11699, commit 7182ef71e)
built with GNU 16.2.0 for Linux x86_64
Enter fullscreen mode Exit fullscreen mode

BUILD_JOBS defaults to 6. A bare -j starts every compile at once, and 5,776 MiB of RAM does not hold that.


Step 3 — The Model and What Has to Fit

make download fetches the exact Q4_0 GGUF of Gemma 4 E2B, where every weight matrix is Q4_0, embeddings included. make verify checks it against the SHA-256 in tpu.env, and make info reads the file to show which part has to live on the GPU:

$ make verify
/home/xbill/models/gemma-4-E2B-it-qat-q4_0-exact-v2/gemma-4-E2B-it-q4_0-exact.gguf: OK

$ make info
  tensors:  541
  total:    2.605 GB
      1321.2 MB  per_layer_token_embd.weight  Q4_0    [8960, 262144]  <- LAZY, host-resident
  lazy (never on GPU):        1.321 GB  (51% of file)
  must be resident:           1.283 GB = 1.20 GiB
Enter fullscreen mode Exit fullscreen mode

The per-layer embedding table is read a row at a time from the memory-mapped file, so it stays in system RAM. Never start the server with --no-mmap.


Step 4 — Serve on the iGPU

make serve runs llama-server with every layer on the GPU (-ngl 99), an 8,192-token context, f16 K/V cache and flash attention. make query sends one chat request:

$ make query > chat.json
$ python3 -c "import json;d=json.load(open('chat.json'));print(d['choices'][0]['message']['content']);print(d['timings']['predicted_per_second'])"
A TPU, or Tensor Processing Unit, is a specialized hardware accelerator designed to speed up machine learning workloads, particularly those involving matrix multiplications common in deep learning.
31.233501658398186
Enter fullscreen mode Exit fullscreen mode

make gpu-mem reads the amdgpu driver's own counters, before the server starts and while it serves:

before: VRAM 220 / 2048 MiB  GTT 46 / 2888 MiB
serving: VRAM 1616 / 2048 MiB  GTT 1563 / 2888 MiB
Enter fullscreen mode Exit fullscreen mode

GTT is system memory the GPU maps. The carve-out and the GTT both come out of the laptop's 8 GiB.


Step 5 — Speed on the GPU and the CPU

llama-bench with 512 prompt tokens and 128 generated, five repetitions per setting, the package cooled to 65 °C before each:

cell             backend     ngl          pp512 t/s        tg128 t/s
vk-fa1-f16       Vulkan       99    348.18 ±   1.21    32.37 ±  0.02
vk-fa0-f16       Vulkan       99    339.64 ±   1.04    31.82 ±  0.02
vk-fa1-q8        Vulkan       99    345.25 ±   1.44    31.68 ±  0.13
cpu-t6           CPU          -1    112.89 ±   1.09    25.68 ±  0.03
cpu-t12          CPU          -1    118.20 ±   2.86    21.37 ±  0.18
vk-fa1-f16-rep   Vulkan       99    348.85 ±   0.69    32.37 ±  0.03
Enter fullscreen mode Exit fullscreen mode

The iGPU decodes 1.26x the CPU and processes prompts 3.08x as fast. Flash attention and an f16 K/V cache are the fastest GPU settings, by about 2%. On the CPU, six threads decode 1.20x as fast as twelve.


Step 6 — The Drafter

The exact Q4_0 drafter is a small model trained to guess Gemma 4 E2B's next tokens. llama-server lets it propose a few tokens, checks them in one pass of the full model, and keeps the ones the full model agrees with. make draft fetches it at a pinned revision and checks its SHA-256, and make serve loads it from tpu.env:

SPEC_DRAFT_MODEL=/home/xbill/models/gemma-4-E2B-it-qat-assistant/gemma-4-E2B-it-qat-assistant-q4_0-exact.gguf
SPEC_DRAFT_HF=xbill9/gemma-4-E2B-it-qat-assistant-q4_0-exact-gguf
SPEC_DRAFT_HF_REVISION=6188294ee6f23cedadd98013fa664b3e1ba7159f
SPEC_DRAFT_N_MAX=2
Enter fullscreen mode Exit fullscreen mode

The server flags are -md <drafter> --spec-type draft-mtp -ngld all --spec-draft-n-max 2. make serve SPEC_DRAFT_MODEL= serves without it.


Step 7 — How Many Tokens to Draft

Six prompts, 256 tokens each, greedy, median of three passes, in tokens a second (speed against no drafter, share of drafted tokens accepted):

                             none                  q4x-n1                  q4x-n2                  q4x-n3              none-again
code         30.2 (1.00x) [0.00]    47.6 (1.58x) [0.90]    56.9 (1.89x) [0.85]    54.8 (1.82x) [0.78]    29.8 (0.99x) [0.00]
chat         30.8 (1.00x) [0.00]    39.7 (1.29x) [0.61]    39.9 (1.29x) [0.47]    34.4 (1.12x) [0.37]    29.6 (0.96x) [0.00]
story        30.9 (1.00x) [0.00]    36.9 (1.20x) [0.50]    36.2 (1.17x) [0.38]    28.6 (0.93x) [0.25]    29.5 (0.95x) [0.00]
explain      30.9 (1.00x) [0.00]    37.4 (1.21x) [0.53]    37.1 (1.20x) [0.40]    31.2 (1.01x) [0.31]    29.4 (0.95x) [0.00]
facts        30.9 (1.00x) [0.00]    40.1 (1.30x) [0.64]    41.1 (1.33x) [0.50]    38.4 (1.24x) [0.47]    29.4 (0.95x) [0.00]
summary      31.1 (1.00x) [0.00]    37.4 (1.20x) [0.51]    35.6 (1.15x) [0.36]    29.7 (0.96x) [0.29]    29.4 (0.95x) [0.00]
GREEDY geomean tok/s: {'none': 30.8, 'q4x-n1': 39.7, 'q4x-n2': 40.6, 'q4x-n3': 35.3, 'none-again': 29.5}
Enter fullscreen mode Exit fullscreen mode
Drafted tokens Tokens / s Against none Accepted
none 30.8 1.000x —
1 39.7 1.289x 61%
2 40.6 1.317x 48%
3 35.3 1.145x 39%

One and two drafted tokens are level: two is ahead on 3 of the 6 prompts, and its 2.3% lead in the mean, inside the 4.5% spread between passes of one setting, comes from the code prompt. The rig drafts 2. The second pass with no drafter reads 0.958x the first, so the laptop ran about 4% slower by the end of the sweep; the drafter settings ran in between, so their gains are if anything understated. At temperature 0.8 the 2-token drafter gives 1.256x.


Step 8 — GSM8K and BFCL, with and without the Drafter

The scorer sends every question to /v1/chat/completions one at a time, up to 2,048 tokens for GSM8K and 512 for BFCL, and checks the final number or the function call. The run log for the pass without the drafter:

2026-12-01T21:53:01-05:00 START bfcl_simple none tctl=79
2026-12-01T21:57:18-05:00 END bfcl_simple none rc=0 tctl=78 {"task": "bfcl_simple", "max_tokens": 512, "n": 400, "right": 369, "accuracy": 0.9225, "errors": 0, "truncated": 0, "wall_s": 257.2}
2026-12-01T21:57:18-05:00 START gsm8k none tctl=78
2026-12-02T03:14:17-05:00 END gsm8k none rc=0 tctl=75 {"task": "gsm8k", "max_tokens": 2048, "n": 1319, "right": 1189, "accuracy": 0.9014, "errors": 0, "truncated": 3, "wall_s": 19018.5}
Enter fullscreen mode Exit fullscreen mode
Task No drafter Drafter, 2 tokens Only one side right
GSM8K, 1,319 1,189 = 0.9014 [0.884, 0.916] 1,191 = 0.9030 [0.886, 0.918] 0 none, 2 drafter
BFCL simple, 400 369 = 0.9225 [0.892, 0.945] 369 = 0.9225 [0.892, 0.945] 0 and 0

Brackets are 95% Wilson intervals.

The drafter changes the wording of 48 GSM8K replies out of 1,319 and of no BFCL reply; it changes two GSM8K answers, both from wrong to right. Two questions apart is no difference: an exact McNemar test on the paired runs gives p = 0.5, and on 1,319 questions at 90% two runs need to differ by about 3.3 points before a gap can be told apart from noise.


Step 9 — Sustained Speed over a Full Benchmark

Task Arm Tokens written Time asking Tokens / s Accepted
GSM8K none 534,583 5.28 h 28.11 —
GSM8K drafter 534,449 3.55 h 41.86 79%
BFCL none 12,772 769 s 16.61 —
BFCL drafter 12,772 585 s 21.82 93%

Over five hours of continuous work the iGPU holds 28.11 tokens a second without the drafter and 41.86 with it, counting each request's prompt processing in the time. The drafter saves 104 minutes on one pass of GSM8K, 1.49x: on worked arithmetic 79% of drafted tokens are kept, against 48% on the chat prompts. BFCL replies are short function calls, 32 tokens on average, and the gain there is 1.31x.


Step 10 — ROCm on the Same GPU

ROCm does not officially support this GPU: gfx90c is missing from AMD's list of GPUs for ROCm 7.2.1. Running it anyway is a workaround. Debian sid packages ROCm 6.4, and its rocBLAS carries kernels for gfx900, the first Vega chip. make build-rocm builds the same llama.cpp commit with HIP for gfx900, and make serve BACKEND=rocm serves it with HSA_OVERRIDE_GFX_VERSION=9.0.0, which tells the runtime the GPU is a gfx900:

$ rocminfo | grep -m1 'Name: *gfx'
  Name:                    gfx90c
$ HSA_OVERRIDE_GFX_VERSION=9.0.0 llama-bench --list-devices
  Device 0: AMD Radeon Graphics, gfx900:xnack+ (0x900), VMM: no, Wave Size: 64, VRAM: 2888 MiB
$ llama-bench -m gemma-4-E2B-it-q4_0-exact.gguf -ngl 99    # without the override
ROCm error: invalid device function
exit status: 134
Enter fullscreen mode Exit fullscreen mode

llama-bench, Vulkan and ROCm on the same day, five repetitions each:

Backend Prompt, tokens / s Decode, tokens / s
Vulkan 347.13 32.47
ROCm, gfx900 override 204.39 31.68
ROCm / Vulkan 0.589x 0.976x

ROCm decodes 2.4% slower than Vulkan, in every one of ten repetitions, and reads prompts at 0.589x. It places the model in GTT, system memory the GPU maps, and leaves the carve-out nearly empty: 376 MiB of 2,048 while serving, with 1,630 MiB of GTT.

All 400 BFCL simple questions through llama-server on ROCm:

Vulkan ROCm
Right, no drafter 369 368
Right, drafter at 2 tokens 369 368
Same reply as Vulkan, no drafter / drafter — 393 / 391
Time, no drafter / drafter 769 s / 585 s 1,089 s / 1,031 s
Median decode, no drafter → drafter 29.13 → 50.45 28.78 → 37.81

The answers match: 3 questions differ without the drafter and 5 with it, split almost evenly, and an exact McNemar test on the paired runs gives p = 1.0 for both. On 400 questions at 92%, two runs need to differ by about 5.3 points before a gap can be told apart from noise. ROCm takes 1.42x as long over BFCL without the drafter and 1.76x with it, because BFCL prompts are short and prompt reading is a large share of each request. Both backends accept 93% of drafted tokens, yet the drafter lifts ROCm's decoding 1.31x against Vulkan's 1.73x; checking a draft is a small batch through the model, the kind of work ROCm runs slower here (inferred, not profiled).

This tests Debian's ROCm 6.4 packages on a GPU AMD does not support, through an override. It says nothing about ROCm on the GPUs AMD lists, and AMD's own current release was not tested.


Compare and Contrast

The three ways to serve on this laptop:

Decode, tokens / s Prompt, tokens / s GSM8K
🥇 iGPU with the 2-token drafter 40.6 — 0.9030
🥈 iGPU alone 32.37 348.18 0.9014
iGPU through ROCm 31.68 204.39 —
CPU alone, 6 threads 25.68 112.89 —
  • iGPU with the drafter. 🟢 Fastest, same answers, 1.49x faster through GSM8K. ⚠️ A second model to download and keep in the carve-out.
  • iGPU alone. 🟢 One file, 432 MiB of the carve-out to spare. ❌ Decodes at 0.76x the drafter's speed.
  • iGPU through ROCm. 🟢 Same BFCL answers as Vulkan, decoding 2.4% slower. ❌ Needs the gfx900 override, reads prompts at 0.589x Vulkan, and gains less from the drafter.
  • CPU alone. 🟢 Leaves the GPU to the desktop. ❌ Reads prompts at a third of the GPU's speed.

The drafter's decode figure is the six-prompt mean from Step 7 and the others are llama-bench; the ROCm row is from Step 10, a day after the others. GSM8K was run through Vulkan only.


So, Which One?

Serve the exact Q4_0 GGUF on the iGPU with the drafter at 2 tokens. It decodes at about 41 tokens a second on chat and over a full GSM8K pass, and scores GSM8K 0.9030 and BFCL simple 0.9225.

Serve through Vulkan. ROCm is not officially supported on this chip; it works with the gfx900 override and gives the same answers, but it decodes 2.4% slower and reads prompts at 0.589x Vulkan's speed, and Vulkan needs nothing beyond Mesa.

Use the CPU build when the GPU is needed for something else: it decodes at 25.68 tokens a second, 0.79x the iGPU alone, and reads prompts at a third of the GPU's speed.


Summary

The goal of this article was to find out whether a laptop's integrated Radeon GPU can serve Gemma 4 E2B. The key to the solution was llama.cpp's Vulkan backend with the exact Q4_0 GGUF, its per-layer table left in the memory map, and the exact Q4_0 drafter at 2 tokens. The results were:

  • 🟢 32.37 tokens a second on the iGPU, 1.26x the CPU of the same chip, in 1,616 of the 2,048 MiB carve-out.
  • 🟢 40.6 tokens a second with the 2-token drafter over six prompts, 1.317x, and 1.89x on code.
  • 🟢 41.86 tokens a second sustained over a full GSM8K pass with the drafter, 3.55 hours against 5.28 without.
  • 🟢 GSM8K 0.9030 and BFCL simple 0.9225 with the drafter, 0.9014 and 0.9225 without it.
  • ⚠️ ROCm runs with the gfx900 override at 0.976x Vulkan's decode and 0.589x its prompt speed, BFCL 368 against 369.
  • ⚠️ Prompts are read at 348 tokens a second, so a 2,000-token prompt waits about 5.7 seconds before the first word.

Scope: one Lenovo Yoga 6 13ABR8 with a Ryzen 5 7530U and its Radeon iGPU (Barcelo, gfx90c, Mesa 26.2.8 RADV, 2 GiB carve-out), Debian sid, kernel 7.4.0-rc5, llama.cpp 7182ef71e, xbill9/gemma-4-E2B-it-qat-q4_0-exact-gguf and its drafter at revision 6188294. One request at a time, thinking off, an 8,192-token context. One GSM8K and BFCL pass per setting on 2026-12-01 and 2026-12-02. ROCm is Debian sid's 6.4 packages, built for gfx900 and run with HSA_OVERRIDE_GFX_VERSION=9.0.0, measured on 2026-12-02 with llama-bench and one BFCL simple pass per setting; GSM8K was not run through it. This tests Debian's ROCm 6.4 packages on a GPU AMD does not support, through an override. It says nothing about ROCm on the GPUs AMD lists, and AMD's own current release was not tested. The speed sweep is six prompts with three greedy passes each, and the laptop slowed about 4% across it. The 2,000-token wait is arithmetic from the llama-bench prompt speed. No batched serving was measured.

The strategy for serving Gemma 4 E2B on an integrated laptop GPU was validated with an incremental step by step approach.


References

Hope you enjoyed it!

Top comments (0)