DEV Community

Cover image for Gemma 4 as an Agent on an 8 GB GPU: E2B, E4B or 12B?
xbill Subscriber for Google Developer Experts

Posted on

Gemma 4 as an Agent on an 8 GB GPU: E2B, E4B or 12B?

Gemma 4 12B works as an agent on an 8 GB card. As served on an RTX 3050, with its drafter and thinking off, it answered 485 of 500 lookup tasks by calling file tools, ten tasks to a conversation. E4B as served answered 189 and E2B 83.

Thinking on lifts E4B to 435 of 500, still 50 behind the 12B as served, and E4B with thinking on took 118.6 minutes for the 500 tasks against the 12B's 54.1. E2B with thinking on reached 204, and 323 when each task started a new conversation. For the 12B, thinking, Google's sampling settings and the drafter changed nothing beyond chance; the drafter doubled its generation speed.

For an agent on an 8 GB card, serve the 12B with its drafter. One run of each setting, 50 conversations of 10 tasks.

This article provides a step by step test of three Gemma 4 sizes as tool-calling agents on one local GPU: 4-bit QAT builds on an 8 GB RTX 3050 through llama.cpp. Each model searched a workspace of text files with four tools to answer questions about services, in six server settings, 9,000 tasks in all.

https://github.com/xbill9/gemma4-dev/tree/main/docs/gemma4-agent-e2b-e4b-12b-3050


The Findings

The 12B answers almost every task in every setting. 423 to 486 of 500 across the six settings. As served it answered 485, gave 1 wrong number, and ran out of tool calls on 13.

E4B needs thinking on. With thinking off it answered 189 to 241 of 500; with thinking on and Google's sampling settings, 435 in one conversation and 430 with a new conversation per task.

E2B misses most tasks. As served it answered 83 of 500. On 217 tasks it replied that it could not find the answer, and on 163 it gave a wrong number.

Small models do better with a new conversation per task; the 12B does better with one. E2B as served answered 186 with a new conversation per task against 83 in one. The 12B answered 485 in one conversation and 423 with a new one: in one conversation it answered the last task of all 50 sessions.

The drafter and Google's sampling settings change no answers. Level on all three models. The drafter cut the 12B's 500 tasks from 73.1 minutes to 54.1.

What to do with it.

  • 🟒 On an 8 GB card, run agents on the 12B as served: drafter on, thinking off.
  • ⚠️ If E4B is the model, turn thinking on with Google's sampling settings.
  • ❌ E2B answers too few tool-calling tasks to run an agent.

What Was Measured

Models Gemma 4 E2B, E4B and 12B, exact Q4_0 repacks of Google's QAT weights
Card RTX 3050 OEM, 8 GB, driver 615.78.08
Server llama.cpp 7182ef71e, each model's serving flags, one request at a time
Context 131,072 tokens for E2B and E4B, 81,920 for the 12B
Tools list_files, read_file, search, submit_answer
Tasks 50 sessions of 10 questions, the same 500 for every model and setting
Settings 6, listed in Step 2

At This Point You Should Have…

  • An NVIDIA card with 8 GB, here an RTX 3050 OEM
  • llama.cpp built with CUDA, here commit 7182ef71e
  • Python 3
  • A clone of gemma4-dev

Step 1 β€” The Test

Each session builds a workspace of plain-text files from a fixed seed: a deploy manifest naming 12 services with their config file and owner, one config file per service with a listen_port line, an on-call roster with pager numbers, one log per service with a single ERROR line, and six notes files. Lines of filler from the NVIDIA driver README surround every fact, so reading one file adds about a thousand tokens to the conversation.

The model gets four tools through the OpenAI tools field:

  • list_files(dir) lists a directory
  • read_file(path, start_line) returns up to 60 lines
  • search(text) returns up to 15 matching lines with file and line number
  • submit_answer(answer) records the answer

Ten questions per session, four kinds:

Kind Question Path to the answer
port What port does service S listen on? manifest, then config
pager What is the pager number of the owner of service S? manifest, then roster
error What error code is in the log of service S? log
owner What port does the service owned by P listen on? manifest, then config

The system prompt tells the model to use the tools, submit just the answer, and not guess. A task allows 12 tool calls. Scoring is by code: the digits of the submitted answer, or the last number in a reply with no tool call, must equal the stored answer.

One task, as served, the same in all three models:

What is the pager number of the owner of service backups?   (answer 4694)

12B:  search "backups"; list_files people; read_file people/roster.txt;
      read_file people/roster.txt from line 61; submit_answer "4694"       right
E4B:  search "service backups owner"; list_files people; read_file people/roster.txt
      "The roster.txt file contains a list of people and their pager numbers,
       but it does not mention "service backups"..."                         no answer
E2B:  search "service backups owner pager number"; search "service backups";
      list_files logs; read_file logs/backups.log
      "I have read the logs/backups.log file. I am looking for information..." no answer
Enter fullscreen mode Exit fullscreen mode

The 12B searched for the bare service name, then read the roster to its second page. E4B read the roster without the owner's name, and E2B read the service's log.


Step 2 β€” Six Settings

Setting Drafter Sampling Thinking Conversation
As served 2 tokens temperature 0 off one per session
No drafter none temperature 0 off one per session
Google's sampling none temperature 1.0, top-k 64, top-p 0.95 off one per session
Thinking on none temperature 1.0, top-k 64, top-p 0.95 on one per session
As served, new conversation 2 tokens temperature 0 off one per task
Thinking on, new conversation none temperature 1.0, top-k 64, top-p 0.95 on one per task

"As served" is how each model's rig on this card runs. In one conversation per session, every tool result stays in context for the next question, as in a coding-assistant session; with one per task, each question starts from the system prompt on the same workspace. Google's sampling settings come from the model's generation_config.json, with a fixed seed per task. Replies are capped at 1,024 tokens, and 8,192 with thinking on.

The 12B serves at 81,920 tokens of context with a q4_0 cache to fit the card; E2B and E4B at 131,072 with f16. No session reached its context limit: the longest conversation held 86,609 tokens, on E2B.


Step 3 β€” Answers by Model

Tasks answered right, of 500:

Setting E2B E4B 12B
As served 83 189 πŸ₯‡ 485
No drafter 107 203 482
Google's sampling 77 190 πŸ₯‡ 486
Thinking on 204 πŸ₯‡ 435 485
As served, new conversation 186 241 423
Thinking on, new conversation πŸ₯‡ 323 430 475

The 12B's worst setting, 423, is ahead of E2B's best and close to E4B's best. Compared session by session, the 12B as served was ahead of E4B with thinking on in 29 sessions and behind in 2 (p = 4.63e-7).


Step 4 β€” How the Misses Look

How each task ended, of 500:

Right Wrong number Gave up in prose Out of tool calls
E2B, as served 83 163 217 37
E2B, thinking on 204 147 148 1
E4B, as served 189 118 166 27
E4B, thinking on 435 28 36 1
12B, as served 485 1 1 13
12B, thinking on 485 12 1 2

E2B and E4B stop early. The most common replies with no answer open with "I have searched the available files for any mention of a service…" (E2B) and "I could not find any information about the port…" (E4B). They give up after a median of 3 tool calls (E2B) and 2 (E4B).

Thinking on turns those replies into answers. E4B with thinking on gave up on 36 tasks against 166, and gave 28 wrong numbers against 118.

The 12B submits through the tool. As served it called submit_answer on 468 of 500 tasks; E2B as served did so on 32 and answered the rest in prose.


Step 5 β€” One Conversation or a New One per Task

The two context styles pull in opposite directions:

Model Setting One conversation New conversation per task Sessions ahead / behind p After correction
E2B As served 83 πŸ₯‡ 186 new +43 / βˆ’2 5.89e-11 holds
E2B Thinking on 204 πŸ₯‡ 323 new +40 / βˆ’7 1.07e-6 holds
E4B As served 189 241 new +29 / βˆ’14 0.0315 level
E4B Thinking on 435 430 new +15 / βˆ’20 0.5 level
12B As served πŸ₯‡ 485 423 one +36 / βˆ’2 5.4e-9 holds
12B Thinking on 485 475 one +19 / βˆ’9 0.0872 level

E2B loses its way as the conversation grows. As served, by the last question of a session the median conversation held 28,818 tokens, and E2B answered 1 of 50 last questions.

The 12B learns the workspace. As served in one conversation, it answered 42 of 50 first questions and 50 of 50 last questions. With a new conversation per task, it ran out of its 12 tool calls on 77 tasks, 47 of them pager questions, where it read notes files before finding the roster.


Step 6 β€” Task Kinds

Right answers by kind, as served and with thinking on (each session asks 3 port, 3 pager, 2 error and 2 owner questions):

Port, of 150 Pager, of 150 Error, of 100 Owner, of 100
E2B, as served 6 4 41 32
E2B, thinking on 40 70 51 43
E4B, as served 51 45 47 46
E4B, thinking on 122 135 87 91
12B, as served πŸ₯‡ 142 πŸ₯‡ 146 πŸ₯‡ 97 πŸ₯‡ 100

E2B as served answers the one-file question (error) and few of the two-file ones. Port and pager need the manifest first, then a second file; E2B as served answered 10 of 300 of those, and 110 with thinking on; the 12B as served answered 288.


Step 7 β€” The Drafter, Sampling and Thinking

Every comparison here is paired: the same 50 sessions in two settings. The ten tasks in a session share a conversation, so the unit is the session: total right per session, with an exact sign test over the sessions where the two settings differ. 20 tests in all, corrected with Holm.

Model Comparison Right Sessions ahead / behind p After correction
E2B No drafter vs drafter 107 vs 83 +18 / βˆ’16 0.864 level
E4B No drafter vs drafter 203 vs 189 +25 / βˆ’18 0.36 level
12B No drafter vs drafter 482 vs 485 +3 / βˆ’5 0.727 level
E2B Google's sampling vs temperature 0 77 vs 107 +16 / βˆ’23 0.337 level
E4B Google's sampling vs temperature 0 190 vs 203 +21 / βˆ’25 0.659 level
12B Google's sampling vs temperature 0 486 vs 482 +4 / βˆ’4 1 level
E2B Thinking on vs off 204 vs 77 +39 / βˆ’4 3.11e-8 holds
E4B Thinking on vs off 435 vs 190 +44 / βˆ’3 2.46e-10 holds
12B Thinking on vs off 485 vs 486 +8 / βˆ’7 1 level

Thinking on and off are compared both with Google's sampling settings. With thinking on, E2B and E4B thought in almost every request (1,517 of 1,638 and 1,850 of 1,871); the 12B thought in 801 of 2,101, and its answers stayed where they were.

The five comparisons between models in the 20 all hold: the 12B ahead of E4B as served in 50 sessions of 50, ahead of E4B with thinking on in 29 against 2, and E4B ahead of E2B in both settings.


Step 8 β€” Time and Memory

Wall clock for the 500 tasks, in one conversation per session:

E2B E4B 12B
As served 33.2 min 33.4 min 54.1 min
No drafter 40.4 min 45.6 min 73.1 min
Thinking on 85.6 min 118.6 min 129.2 min
Seconds per right answer, as served 24.0 10.6 πŸ₯‡ 6.7
Seconds per right answer, thinking on 25.2 16.4 16.0
Generation, as served 154.5 tok/s 110.7 tok/s 50.3 tok/s
Generation, no drafter 95.6 tok/s 52.8 tok/s 24.7 tok/s
Drafted tokens accepted 0.752 0.794 0.924
Card memory, as served 3,802 MiB 6,624 MiB 7,814 MiB

The 12B as served spends the fewest seconds per right answer of any model and setting: 6.7. Its drafter has the highest acceptance of the three, and generates about twice as fast as no drafter. Agent replies are short, a median of 22 tokens for the 12B as served, so most of each request is reading the growing conversation.

The 12B with its drafter at 81,920 tokens of context and a q4_0 cache fills 7,814 MiB of the 8,192 on the card.


πŸ”Ž Tip: Score an Agent by What It Submits

A tool-calling model that replies "I could not find it" looks well behaved in a transcript and still leaves the task undone. Build a few tasks whose answers sit one or two files deep in a workspace like yours, ask the model to submit through a tool, and score the submitted value by code. On this card the share of tasks answered right ran from 77 of 500 to 486 of 500 across models and settings, with the same tools and questions.


Compare and Contrast

E2B E4B 12B
Right, as served 83 of 500 189 πŸ₯‡ 485
Right, best setting 323, thinking on, new conversation 435, thinking on πŸ₯‡ 486, Google's sampling
Gave up in prose, as served 217 166 πŸ₯‡ 1
Time for 500 tasks, best setting 152.1 min 118.6 min πŸ₯‡ 74.5 min
Seconds per right answer, as served 24.0 10.6 πŸ₯‡ 6.7
Card memory, as served πŸ₯‡ 3,802 MiB 6,624 MiB 7,814 MiB

Pros and cons

  • E2B. 🟒 The least card memory, 3,802 MiB, and the fastest generation. ❌ Answers at most 323 of 500, needs thinking on and a new conversation per task to get there, and misses 417 of 500 as served.
  • E4B. 🟒 435 of 500 with thinking on, in one conversation. ❌ 189 with thinking off; thinking on takes 118.6 minutes for the 500 tasks.
  • 12B. 🟒 485 of 500 as served, level in every setting, fewest seconds per right answer, and better as the conversation grows. ❌ Fills the 8 GB card, and its context stops at 81,920 tokens.

So, Which One?

An agent on an 8 GB card: the 12B as served. Drafter on, thinking off, temperature 0, one conversation per session. It answered 485 of 500, in 54.1 minutes.

On a card that cannot hold the 12B: E4B with thinking on and Google's sampling settings. It answered 435 of 500, in 118.6 minutes against the 12B's 54.1.

E2B for agents: no. Its best setting answered 323 of 500 and needed a new conversation for every task.


Summary

The goal of this article was to find which Gemma 4 size can run a tool-calling agent on an 8 GB card. The key to the solution was the same 500 tasks for every model and setting, scored by code from what the model submitted, session by session. The results were:

  • 🟒 The 12B as served answered 485 of 500 and was level across the drafter, Google's sampling and thinking.
  • ⚠️ E4B answered 189 as served and 435 with thinking on (p = 2.46e-10).
  • ❌ E2B answered 83 as served; the largest share of its misses, 217, were replies that it could not find the answer.
  • 🟒 The 12B gets better through a conversation: 50 of 50 last questions as served.
  • ⚠️ E2B does better with a new conversation per task: 186 against 83 as served.
  • 🟒 The drafter changed no answers and cut the 12B's time from 73.1 to 54.1 minutes.

Scope: one RTX 3050 OEM with 8 GB in one desktop, llama.cpp 7182ef71e, Gemma 4 E2B, E4B and 12B as exact Q4_0 repacks of Google's QAT weights, one request at a time, 2026-11-26 to 28. One kind of workspace, generated text files with one fact per line, four tools and four question kinds; real repositories, longer tool outputs and other tool sets are untested. 50 sessions per setting, one run each, one seed per task for the sampled settings. The 12B ran at 81,920 tokens of context with a q4_0 cache and E2B and E4B at 131,072 with f16, each model's serving setting on this card; no session reached either limit. Thinking on at temperature 0 was not run. The article reports 20 paired tests; corrected for that number (Holm), the gains from thinking on for E2B and E4B, the context-style differences for E2B and the 12B as served, and the gaps between models hold. "Level" means no gap beyond chance.

The strategy for testing small models as agents on a small GPU was validated with an incremental step by step approach.


References

Hope you enjoyed it!

Top comments (3)

Collapse
 
milochen0418 profile image
Milo Chen •

E2B calling submit_answer on only 32 of 500 tasks, and answering the rest in prose, stood out to me. Scoring by what the model submits, checked by code, is a fair way to catch that.

I saw a similar split with Ollama on my Mac. qwen2.5-coder:7b wrote its tool calls as plain JSON text in the reply, so my assistant did nothing. qwen2.5:7b made real tool calls. Did any Gemma size do that, write a tool call as text instead of in the tools field? And would your scorer count it as prose, or pick up the number inside?

Collapse
 
xwickz profile image
Santiago Griman •

I just bought a Macbook Pro M4 Pro I want to test this AI locally... thanks for the insights

Collapse
 
nigel_douglas_edera profile image
Nigel Douglas •

That's amazing and all, but can you get it running on 8GB CPU?
My homelab still doesn't have any fancy graphics cards.