DEV Community

Cover image for EmbeddingGemma 2 on the Free GPU Inside a Ryzen Laptop
xbill Subscriber for Google Developer Experts

Posted on

EmbeddingGemma 2 on the Free GPU Inside a Ryzen Laptop

A Ryzen laptop has a GPU built into its processor, and EmbeddingGemma 2 is a great match for it. The model is small enough to live in the GPU's memory and does its work in one large batch per input, which is what a GPU is for. On the integrated Radeon of a Ryzen 5 7530U, through llama.cpp's Vulkan backend, it embeds 877 tokens per second, 2.3x the same laptop's CPU: a 6,898-token document in 7.9 seconds and a short query in under 0.15, one request at a time.

The GPU comes for free. It ships inside the processor the laptop already has, and the firmware reserves 2 GiB of the 8 GiB of RAM for it whether anything runs there or not. The 1.1 GB of F32 weights sit in that reserve: the server adds 1,355 MiB to it, and 1,218 MiB of shared system memory besides. No extra card, no cloud API and no per-request bill.

The embeddings hold up too. Against sentence-transformers in fp32 on the CPU, they are 99.998% similar or better over nine texts of 16 to 6,898 tokens, and no ranking changes.

On this GPU the F32 GGUF is the one to serve. It is closer to the reference than bf16 and 1.32x faster on a 6,898-token input, because the GPU has no bf16 hardware. The error left on long inputs comes from llama.cpp's Vulkan flash-attention kernel, and below about 2k tokens turning it off brings the GPU level with the CPU.

This article provides a step by step deployment guide for EmbeddingGemma 2 on the integrated GPU of a Ryzen 5 7530U laptop with llama.cpp and Vulkan, with a parity check of every setting against sentence-transformers. 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-embed2


The Findings

The model fits in memory the laptop already gives the GPU. The server takes 1,355 MiB of the 2,048 MiB carve-out, which the operating system never sees: the kernel reports 5,773 MiB of the 8 GiB with or without the server.

The iGPU embeds 877 tokens per second on a 6,898-token document and 1,206 on a 1,818-token one. The CPU manages 381 and 617.

Its embeddings are 99.998% similar to the reference or better. That is the F32 GGUF on the GPU, worst case over nine texts, measured as cosine similarity. The query's similarity to its matching document is 76.27% on both sides, and to the unrelated one 58.21%.

bf16 is about as far off on either backend. The bf16 GGUF reaches 99.9975% on the GPU and 99.9979% on the CPU, so its error comes from llama.cpp's bf16 arithmetic, not from the GPU. Google's warning that float16 is incompatible with this model does not come into it.

F32 is faster than bf16 on this GPU. 877 tokens per second against 663 on the 6,898-token input. The GPU is Vega-class gfx90c, with no bf16 hardware.

Long inputs drift on the GPU because of flash attention. At 1,818 tokens the F32 GPU reaches 99.9998% with flash attention on and 99.999978% with it off, where the CPU reaches 99.999974%. Storing K and V in f32 changes no digit.

Flash attention stays on at the full 8,192-token context. An encoder reads the whole input in one batch, and without flash attention a 6,898-token input ran the GPU out of memory and crashed the server.

What to do with it.

  • 🟢 Serve the F32 GGUF on the iGPU: 877 tokens per second, 2.30x the CPU on a 6,898-token input, and 99.998% similar to the reference or better.
  • 🟢 The server takes 1,355 MiB of the 2,048 MiB carve-out and 1,218 MiB of shared system memory.
  • ⚠️ For reference-grade numbers on inputs up to 2k tokens, turn flash attention off at -c 2048: 99.999948% worst case, 1.23x slower.
  • ❌ Do not turn flash attention off at -c 8192: a 6,898-token input exhausts GPU memory.
  • ⚠️ ROCm runs too, with a gfx900 override, but Vulkan is 1.64x faster and closer to the reference with flash attention on (Step 10).

What Was Measured

Nine texts, each embedded one at a time through llama-server's /v1/embeddings, against google/embeddinggemma-2 loaded in sentence-transformers 6.1.0 at fp32 on the CPU. Five texts come from the T4 rig's parity check, so the numbers line up with it. Four more add a 6,898-token document, a Unicode and emoji line, a code snippet and a second query.

Seven server settings: F32 and bf16 weights, each on the GPU build and the CPU-only build, then three F32 settings on the GPU that isolate flash attention and the K/V cache. Accuracy is the cosine similarity between each embedding and the reference's embedding of the same text, as a percentage: 100% means the two point the same way. Speed is tokens per second, one request at a time. The query-to-document similarities are checked too.


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 sentence-transformers, transformers, CPU torch and torchvision, and Pillow
  • A clone of gemma4-dev

Step 1 — The Machine

The GPU is the one inside the APU. Its 2 GiB of "VRAM" is a carve-out of the laptop's 8 GiB, and llama.cpp also counts the system memory the GPU can map:

$ llama-server --list-devices
Available devices:
  Vulkan0: AMD Radeon Graphics (RADV RENOIR) (4934 MiB, 4486 MiB free)

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

The kernel sees 5,773 MiB of the 8 GiB after the carve-out. The rig's tpu.env names the part, r57530u, because an integrated GPU has no model number of its own.


Step 2 — Build llama.cpp with Vulkan

The rig builds llama.cpp 7182ef71e, the same commit as the other llama.cpp rigs, twice: once with the Vulkan backend to serve, and once with no GPU backend at all, so a CPU number cannot include any GPU work.

$ make build
$ ls ~/llama.cpp-7182ef7/build-*/bin/llama-server
/home/xbill/llama.cpp-7182ef7/build-cpu/bin/llama-server
/home/xbill/llama.cpp-7182ef7/build-vulkan/bin/llama-server
Enter fullscreen mode Exit fullscreen mode

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


Step 3 — Two GGUFs from One Snapshot

make download fetches the safetensors at a pinned revision, and make gguf converts it twice with the converter of the commit that serves it: F32 to serve, and bf16 to compare against.

$ make download gguf
$ make verify
/home/xbill/models/embed2/embeddinggemma-2-F32.gguf: OK
/home/xbill/models/embed2/embeddinggemma-2-bf16.gguf: OK
Enter fullscreen mode Exit fullscreen mode

The F32 file is 1,099,801,888 bytes and the bf16 file 557,950,240. The conversion is exact, because every bf16 value has an F32 twin, so the F32 file holds the released weights unchanged.

The bf16 tensors match the BF16 file ggml-org publishes byte for byte, although the two files hash differently (see the tip below):

f1545b1bc03a548af83498a1582e27c2bfc0578d5b7924f3917bdc3c7cbe8129 413 embeddinggemma-2-bf16.gguf
f1545b1bc03a548af83498a1582e27c2bfc0578d5b7924f3917bdc3c7cbe8129 413 embeddinggemma-2-BF16.gguf
Enter fullscreen mode Exit fullscreen mode

Step 4 — The Reference

ref.py loads the same snapshot in sentence-transformers at fp32 on the CPU, text tower only, and embeds each text on its own. The processor imports torchvision and Pillow even for text, so both have to be installed.

llama.cpp's tokenizer gives the same token count as the reference on every text:

tokens llama.cpp: [19, 30, 22, 16, 1818, 6898, 27, 34, 20]
tokens ST       : [19, 30, 22, 16, 1818, 6898, 27, 34, 20] MATCH
Enter fullscreen mode Exit fullscreen mode

Step 5 — Serve on the iGPU

make serve runs llama-server --embeddings --pooling mean with every layer on the GPU, a context of 8,192 tokens and a batch of the same size. The encoder reads the whole input in one batch, so the batch has to be as large as the longest input.

$ make status
{"status":"ok"}  <- healthy
$ make embed
dim 768 norm 1.00000
$ make gpu-mem
VRAM 1735 / 2048 MiB  GTT 1294 / 2887 MiB
Enter fullscreen mode Exit fullscreen mode

Before the server started the carve-out held 383 MiB; with it loaded, 1,738. A 6,898-token input added 7 MiB of carve-out and 87 MiB of mapped system memory.

The model expects a task prefix on every input, task: search result | query: for queries and title: none | text: for documents. The server adds none, so the client writes them, as make embed does.


Step 6 — Parity on the GPU and the CPU

make parity starts each setting on a spare port and runs the nine texts through it:

== f32-vk
1-cos vs ST     : ['7.8e-08', '8.5e-08', '1.6e-07', '3.3e-08', '2.0e-06', '2.0e-05', '5.2e-08', '5.0e-07', '4.5e-08']
max 1-cos       : 1.97e-05   max|elem diff|: 1.17e-03
q0.T4doc 0.7627 (ref 0.7627)  q0.bread 0.5821 (ref 0.5821)
== f32-cpu
1-cos vs ST     : ['5.5e-08', '7.0e-08', '1.4e-07', '1.9e-08', '2.6e-07', '1.7e-07', '5.6e-08', '4.4e-07', '4.4e-08']
max 1-cos       : 4.41e-07   max|elem diff|: 1.12e-04
Enter fullscreen mode Exit fullscreen mode

1-cos in the output is how far the similarity falls short of 1, so 2.0e-05 there means 99.998%. Per setting:

Weights and backend 1,818 tokens 6,898 tokens Worst of nine
F32, iGPU 99.9998% 99.998% 99.998%
F32, CPU 99.999974% 99.999983% 99.999956%
bf16, iGPU 99.99927% 99.9975% 99.9975%
bf16, CPU 99.99959% 99.9979% 99.9979%

Every embedding had unit length in every setting. The T4 rig's vLLM at fp32 reached 99.9999993% on its five texts, and the RTX 3050 llama.cpp rig with bf16 reached 99.99968% on five texts of 19 to 1,368 tokens.


Step 7 — Where the Long-Input Error Comes From

On the GPU the F32 similarity falls with input length, from 99.9999967% on a short text to 99.998% at 6,898 tokens, while the CPU stays at 99.999956% or above. Two settings separate the causes:

F32 on the iGPU 1,818 tokens Worst of the texts
Flash attention on (default) 99.9998% 99.998%
K and V stored in f32 99.9998% 99.998%
-c 2048, flash attention on 99.9998% 99.9998%
-c 2048, flash attention off 99.999978% 99.999948%

The f32 K/V cache matches the default digit for digit, so the cache is clean. Turning flash attention off brings the 1,818-token text to 99.999978%, level with the CPU's 99.999974%, so the drift is in the Vulkan flash-attention kernel. The source of that kernel was not read; a reduced-precision accumulation would produce this pattern.

The -c 2048 settings leave out the 6,898-token text, which needs the next step.


Step 8 — Flash Attention Off at 8,192 Tokens

With flash attention off, attention for the whole input is computed at once, and at 6,898 tokens that is more than this GPU can hold:

terminate called after throwing an instance of 'vk::DeviceLostError'
  what():  vk::Queue::submit: ErrorDeviceLost

$ sudo dmesg | grep -c 'Not enough memory'
479
[101470.976585] amdgpu 0000:04:00.0: [drm] *ERROR* Not enough memory for command submission!
Enter fullscreen mode Exit fullscreen mode

The server died and the GPU did not reset; the desktop on the same GPU carried on. This was seen at llama.cpp 94be107 on the same day and not repeated at 7182ef71e. The rig keeps FLASH_ATTENTION=on in tpu.env, and its parity run only turns it off at -c 2048.


Step 9 — Time per Request

One request at a time:

1,818 tokens 6,898 tokens
F32, iGPU 1,206 tok/s (1.508 s) 877 tok/s (7.866 s)
F32, CPU, 6 threads 617 tok/s (2.945 s) 381 tok/s (18.084 s)
bf16, iGPU 870 tok/s (2.089 s) 663 tok/s (10.407 s)
bf16, CPU, 6 threads 541 tok/s (3.358 s) 348 tok/s (19.828 s)
F32, iGPU, -c 2048, flash attention off 1,079 tok/s (1.685 s) —

Tokens per second falls on the longer input, most likely because attention's work grows with the square of the input's length; that was not profiled. The short texts took 0.023 to 0.14 seconds in every setting, most of it request overhead, so a tokens-per-second figure means little there. On long inputs the iGPU is 1.95x the CPU at 1,818 tokens and 2.30x at 6,898, and F32 is 1.39x and 1.32x bf16 on the iGPU.


Step 10 — The Same Model on ROCm

llama.cpp also has a ROCm/HIP backend, so the rig gained a third build, make build-hip, and make serve-hip to run it. ROCm does not support this GPU: Debian sid's rocBLAS 6.4.4 ships kernels for gfx900 but not gfx90c. So llama.cpp is built for gfx900, the same Vega family, and every run sets HSA_OVERRIDE_GFX_VERSION=9.0.0. Without the override rocBLAS cannot find a kernel library; with it a 256×256 hipBLAS sgemm matched the CPU. The packages are hipcc libamdhip64-dev libhipblas-dev librocblas-dev rocminfo rocm-cmake, and the build took 13 minutes at -j2.

The same nine texts on 2026-12-02, with the Vulkan build re-run in the same session for timing:

Same session Worst similarity 1,818 tokens 6,898 tokens
F32, Vulkan, flash attention on 99.998% 1,471 tok/s (1.236 s) 990 tok/s (6.971 s)
F32, ROCm, flash attention on 99.95% 1,134 tok/s (1.603 s) 604 tok/s (11.421 s)
bf16, ROCm, flash attention on 99.95% 1,024 tok/s (1.776 s) 597 tok/s (11.549 s)
F32, ROCm, flash attention off, -c 8192 99.9999999961% 1,118 tok/s (1.626 s) 74 tok/s (93.113 s)
F32, ROCm, flash attention off, -c 2048 99.99999999908% 1,223 tok/s (1.486 s) —

With flash attention on, Vulkan is 1.64x faster on the 6,898-token input and 1.30x on the 1,818-token one, and ROCm's worst-case gap to the reference is 25x Vulkan's, though every ranking is still kept. F32 and bf16 weights land on the same 99.95%, so the error is in ROCm's flash-attention kernel.

With flash attention off, ROCm is the closest setting in this article, nearer the reference than the CPU. It also fits the full 8,192-token context that ran Vulkan out of memory in Step 8, because ROCm puts its buffers in shared system memory and leaves the 2 GiB carve-out alone. But it is 8.2x slower than with flash attention on, and it peaked at 2,883 of the 2,887 MiB of shared memory the GPU can map, so treat it as fitting this input, not as headroom.

One setting hung the GPU. GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 made the server abort while loading the model, and the kernel had to reset the whole GPU:

HW Exception by GPU node-1 (Agent handle: 0x5607f40b05d0) reason :GPU Hang

amdgpu 0000:04:00.0: Ring comp_1.0.1 reset failed
amdgpu 0000:04:00.0: MODE2 reset
amdgpu 0000:04:00.0: GPU reset(1) succeeded!
Enter fullscreen mode Exit fullscreen mode

The GPU recovered, but the desktop runs on it too. Do not set that variable on this machine.

Vulkan stays the backend to serve. The same-session Vulkan run took 11% less time on the long text than the day before, inside normal run-to-run variation, so Step 9's figures stand.


🔎 Tip: Hash the Tensors When You Compare GGUFs

The converter writes general.name from the name of the snapshot's directory, and the license and tags from its README. Two conversions of the same weights from two directories therefore hash differently. The rig records both hashes in tpu.env: MODEL_SHA256 for the file make gguf writes, and MODEL_TENSOR_SHA256 for the weights, from a short script that hashes each tensor's name and bytes:

$ python3 tensor_sha.py embeddinggemma-2-F32.gguf
49445b8171695c40ed7686a199300a68da548b2d9e970d9b6f2b10c1e1f99b27 413 embeddinggemma-2-F32.gguf
Enter fullscreen mode Exit fullscreen mode

Compare and Contrast

Speed, 6,898 tokens Worst similarity Context
🥇 F32, iGPU, flash attention on 877 tok/s 99.998% 8,192
🥈 F32, CPU 381 tok/s 99.999956% 8,192
🥉 F32, iGPU, flash attention off 1,079 tok/s at 1,818 tokens 99.999948% 2,048
bf16, iGPU 663 tok/s 99.9975% 8,192
  • F32, iGPU. 🟢 Fastest, full context, every ranking kept. ⚠️ Long inputs drift to 99.998%.
  • F32, CPU. 🟢 Closest to the reference at every length. ❌ 2.30x slower on long inputs.
  • F32, iGPU, flash attention off. 🟢 Level with the CPU. ❌ Inputs of 2k tokens at most.
  • bf16, iGPU. ❌ Less accurate and slower than F32 on this GPU, for half the file.

So, Which One?

For search and retrieval, serve the F32 GGUF on the iGPU with flash attention on. The GPU is already in the laptop, and the model fits in the memory reserved for it. At 877 tokens per second it reads a long document in less than half the CPU's time, and over all 36 pairs of texts it moves a similarity by 0.12 percentage points at most.

For numbers that need to match the reference, use the CPU-only build at the full context, or the GPU with flash attention off when every input is under 2k tokens. Keep bf16 for a GPU with bf16 hardware.


Summary

The goal of this article was to serve EmbeddingGemma 2 on the GPU that comes inside a Ryzen laptop's processor and measure how close it comes to the reference. The key to the solution was llama.cpp's Vulkan backend with an F32 GGUF, checked text by text against sentence-transformers in fp32. The results were:

  • 🟢 The iGPU is a great match at no extra cost: the weights sit in the 2 GiB carve-out the firmware already reserves, and it embeds 877 tokens per second at 6,898 tokens, 2.30x the CPU.
  • 🟢 99.998% similar to the reference or better over 16 to 6,898 tokens, with every ranking kept and no similarity moved more than 0.12 percentage points.
  • 🟢 F32 beats bf16 on this GPU: 99.998% against 99.9975% worst case, and 877 against 663 tokens per second.
  • ⚠️ The long-input error comes from Vulkan flash attention: 99.9998% on and 99.999978% off at 1,818 tokens.
  • ❌ Flash attention off at 8,192 tokens exhausts the GPU's memory.
  • ⚠️ ROCm runs with a gfx900 override: 604 tokens per second and 99.95% with flash attention on, near-exact with it off at 74 tokens per second. Vulkan stays the backend to serve.

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, google/embeddinggemma-2 at revision f9972ac, text tower only. The reference is sentence-transformers 6.1.0 with transformers 5.19.0 and torch 2.15.0 on the CPU. Nine texts, one request at a time, one run per setting on 2026-12-01 with no thermal control; the flash-attention-off crash was seen at llama.cpp 94be107 the same day. The ROCm settings ran on 2026-12-02 with HIP 6.4.3 and rocBLAS 6.4.4 from Debian sid. No batched throughput, no image or audio inputs, and no Matryoshka truncation were measured. The T4 and RTX 3050 figures come from those rigs' own runs on other texts and stacks.

The strategy for serving EmbeddingGemma 2 on an integrated laptop GPU was validated with an incremental step by step approach.


References

Hope you enjoyed it!

Top comments (0)