Benchmarking Gemma 4 for the Voxel51 Agent: TPU, GPU, or CPU?

•
17 min read
In Part 1 I served Gemma 4 on a single consumer GPU, connected it to the Voxel51 Agent as an OpenAI-compatible endpoint, and built a FiftyOne panel that shows the server's live metrics.
The Gemma vLLM Metrics panel from Part 1 shows live vLLM server metrics inside FiftyOne.
That left an obvious question: where should this model run? Part 2 takes the same model and measures it on a local GPU, a cloud GPU (an NVIDIA L4), a Cloud TPU v6e (through vLLM-TorchTPU), and a CPU, as part of the TorchTPU Content Sprint.

The short answer

If you are choosing where to run Gemma 4 for the Voxel51 Agent, start from these four facts, all measured:
  1. An agent task is tiny. On our test set a Voxel51 Agent task takes about 2.7 model calls, reads about 970 prompt tokens, and writes about 59 output tokens. You are not buying tokens, you are buying hours of a machine being on.
  2. Every environment gave the same answers. With Gemma 4, the agent passed 12 of 18 runs (67%) on the local GPU, the cloud GPU, the TPU, and the CPU, with 100% valid tool calls and the same tool calls and arguments (the CPU's JSON differs only in whitespace). The weights match everywhere except the CPU, which uses a GGUF build, and the TPU also used an fp8 key-value (KV) cache. Pick on speed, cost, and effort, not quality.
  3. All of them feel interactive for one user. A Gemma 4 agent task took 0.6 s on the local GPU, 1.0 s on the cloud L4, 1.8 s on the TPU, 3.2 s on the local CPU, and 7.1 s on the 8-vCPU cloud CPU.
  4. The cost difference is about utilization. A cloud L4 VM costs about $0.94 an hour ($686 a month always on, $165 if on 8 hours a weekday). A TPU v6e-1 costs $2.70 an hour ($1,970 always on, $475 for 8 hours a weekday) and, for Gemma 4 E2B, was about three to five times more expensive per token than the L4 at concurrency 8. The local GPU costs about $31 a month in electricity, plus the card you already own.
If you are...Run it onWhy
One person exploring datasetsYour own GPU, or the CPU if you have noneFastest per stream (100-127 tok/s), and the CPU still answers a task in about 3 s
A small team sharing one endpointA cloud L4 (or any GPU you keep on)325-529 tok/s at 8 concurrent requests, about $0.5-0.8 per million tokens. Finding a zone with stock took effort (22 zones had none)
Long prompts (8K+) and low first-token latencyProbably the TPU, if you can keep it busyFirst token in about 380 ms versus about 580 ms on the local GPU, 750 ms on the L4, and 17 s on the local CPU. The TPU's timing for that cell has an inconsistency (see its results), so treat this as indicative
Offline batch jobsA cloud GPU first, TPU Flex-start only if you can get itL4 is about $0.5-0.8 per million tokens at concurrency 8. TPU Flex-start is about $1.1-1.4 but needs capacity
Planning to move to the larger Gemma 4 modelsTest the TPUThat is the case it is built for, and I did not test it
Where to run Gemma 4 for the Voxel51 Agent, by type of user, with the recommended hardware and the reason.
The rest of the post shows where each number comes from. Monthly figures are hourly price times 730 hours (24/7) or 176 hours (8 h on 22 weekdays).
Four environments, one shared client, and one Gemma 4 model.

The rule: change one thing at a time

A hardware comparison is only worth reading if the hardware is the only thing that changed. So before running anything I wrote down what has to stay fixed: the checkpoint, the precision, the request sizes, the sampling settings, and the client. Anything that can't stay fixed gets labeled in the results, not hidden.
That rule paid off immediately, because the checkpoint I used in Part 1 turned out not to be the right one for a controlled comparison.

Finding 1: the Part 1 checkpoint can't be the controlled one

Part 1 used Google's quantization-aware-trained build, gemma-4-E2B-it-qat-w4a16-ct. It's a good fit for a 12 GB card. But a community write-up of serving Gemma 4 on a single TPU v6e chip reports that this QAT variant fails to load there (missing weights for layers 15-34), while the plain google/gemma-4-E2B-it serves fine. A different checkpoint on TPU would break the comparison, so the plain checkpoint had to become the common baseline.

Finding 2: bf16 doesn't fit on a 12 GB GPU

The plain checkpoint in bf16 is the cleanest choice on paper. On the RTX 4070 Ti it ran out of memory while loading: the weights alone took 9.74 GiB of the 11.57 GiB the card exposes, leaving almost nothing for the KV cache. (Gemma 4's "E2B" name is the effective parameter count. The real parameter count is larger.)
The fix that keeps the comparison controlled is online fp8 quantization of the same checkpoint (--quantization fp8) on every environment. On the local GPU it fits with room to spare:
SettingValue
KV cache1.39 GiB (48,512 tokens)
Max concurrency at 9,216 tokensabout 16.9 requests
Online fp8 Gemma 4 E2B on the local RTX 4070 Ti: KV cache size and maximum concurrency at 9,216 tokens.
A smaller gotcha on the way there: asking vLLM for 90% of GPU memory failed because the desktop was already holding about 1.4 GB of VRAM. 85% works.

The benchmark harness

Everything runs through vllm bench serve, the load generator the vLLM-TorchTPU docs recommend, so every environment is measured by the same client. The matrix is frozen in workloads.json:
WorkloadInput tokensOutput tokens
Short~128128
Medium~2,048256
Long~8,192512
The three benchmark workloads, with input and output token counts.
Each workload runs at concurrency 1, 4, and 8, with warmup requests and three trials, using a fixed seed, temperature 0, and ignored end-of-sequence tokens so output lengths are comparable. That's 27 runs per environment. For every run the harness records the server version, hardware, and settings next to the results, so a number never travels without its context.
One methodology correction, found in review. The three trials reuse the same fixed-seed prompts, and vLLM caches prompt prefixes by default. On the L4 and the TPU the server log shows an 86% prefix cache hit rate, and trials 2 and 3 show much lower first-token times than trial 1 (for the 8K prompt at concurrency 1: 750, 83, and 82 ms on the L4). The local card's KV cache holds only 48,512 tokens, so it can't keep sixteen 8K prompts around, and its trials look the same. Averaging all trials would flatter the machines with bigger caches, so every result in this post uses trial 1, the cold-cache run. The all-trials averages are in benchmarks/results/analysis_all_trials.csv.

Results: local GPU baseline

27 of 27 runs completed with zero failed requests. Each point is the cold-cache first trial. The charts here and in the sections below show all environments.
Median time per output token for Gemma 4 across all environments.
WorkloadConcurrencyOutput tok/sp50 per-token (ms)p95 end-to-end (ms)
short1127.37.81,007
short4489.08.01,062
short8935.98.21,118
medium1117.38.12,212
medium4425.28.82,639
medium8748.69.33,216
long1100.58.95,197
long4288.511.77,433
long8416.417.110,614
Local GPU (RTX 4070 Ti) results for Gemma 4 by workload and concurrency: throughput, per-token latency, and end-to-end latency.
WorkloadConcurrencyp50 TTFT (ms)p95 TTFT (ms)
short12021
short42845
short86884
medium1117119
medium490344
medium8102566
long1583594
long41,1981,726
long81,0932,358
Local GPU (RTX 4070 Ti) time to first token for Gemma 4 by workload and concurrency, median and p95.
What stands out:
  • Short and medium requests scale well. Throughput grows almost linearly with concurrency, and short-request latency barely moves.
  • Long prompts are where this setup struggles. Past concurrency 4 the throughput gains flatten and the first token takes over a second. Eight concurrent 8K-token prompts means a lot of prefill work for a small GPU.
  • Per-token speed holds up (about 8-17 ms), so once a response starts it streams steadily. The pain is mostly waiting to start on long inputs.
Caveat: one machine, with the desktop sharing the GPU. These numbers are a baseline for comparison, not a precise hardware benchmark.

Does the agent still work?

Speed isn't the whole story. The same model can behave differently on different deployments: quantization changes outputs, tool-call parsing is a server feature, and some sampling parameters aren't supported on every engine. So the harness includes a small agent-task check: a plain tool-calling loop with four read-only FiftyOne tools over a 24-image dataset, six questions, and answers computed from the data itself.
On the local GPU (fp8 E2B, thinking off, 6 tasks x 3 repeats):
MetricResult
Task success67% (4 of 6 tasks)
Valid tool calls100%
Average turns2.7
Average time per task0.61 s
Voxel51 Agent check results for Gemma 4 on the local GPU, with thinking off.
Tool calling works. The two failures are instructive, and they are the model's, not the harness's:
  • Asked for the most common predicted class other than "person", the model skipped the tool that answers it directly. It guessed a few vehicle classes one at a time and stopped at "car" (the answer is "kite").
  • Asked for the difference between two counts, it looked up both correctly and then reported one of them instead of subtracting.

A fairness bug I almost published

My first CPU run scored 83% against the GPU's 67%, and the CPU solved the task the GPU failed. It looked like hardware changing the answer. It wasn't. Gemma 4 has a thinking mode, and the two servers disagreed about it: llama.cpp auto-detects it from the chat template and turns it on, while my vLLM server ran with it off. The tell was token counts. On the trivial "how many samples?" task the GPU generated 22 completion tokens and the CPU generated 381. The CPU was reasoning before every answer, which also explains why its agent runs took 30 to 90 seconds and the GPU's took about one.
The fix is to stop trusting server defaults. The agent check now sets chat_template_kwargs.enable_thinking on every request, so all engines run the same way, and it saves each run's tool-call trace. With thinking off on both:
EnvironmentSuccessValid tool callsAvg time per task
Local GPU (vLLM fp8)67%100%0.61 s
CPU (llama.cpp Q8_0)67%100%3.2 s
Agent check results with thinking off on the local GPU (vLLM fp8) and the CPU (llama.cpp Q8_0).
Same score, same failing tasks, and the traces match call for call. The quantization and the engine did not change what the agent does. The thinking setting did. Lesson for any cross-engine comparison: pin every behavioral switch (thinking, sampling, templates) explicitly, then check token counts before you believe a quality difference.
Thinking is a real lever, not just a nuisance. With it explicitly on (CPU, same traces otherwise), the agent scores 83%: it solves top_pred_class (3 of 3) by reasoning its way to the label-discovery tool, and still fails person_gap. The cost is time: 37 s per task on average instead of 3.2 s, and 1,921 tokens on the hardest task instead of about 100. So the choice between thinking on and off is a quality-versus-latency decision the deployment has to make deliberately. The thinking-on variant is only run on CPU so far, because vLLM needs a reasoning parser to return it cleanly.
That is a useful baseline: if TPU shows a different success rate or invalid tool calls with the same settings, the deployment caused it.

Cloud TPU v6e with vLLM-TorchTPU

Getting a TPU was the hard part

I asked for a single v6e chip and it took several attempts. Two Flex-start requests (one in a zone Google doesn't list for v6e Flex-start, one in a zone it does) sat in WAITING_FOR_RESOURCES for their full hour and failed with Max start time passed. An on-demand attempt was rejected outright, because on-demand requests can't carry a hard stop (--max-run-duration is Flex-start only). A one-hour on-demand wait expired the same way. The fifth, on-demand in two zones with a two-hour window, was granted in us-east5-b after about an hour and a half.
Two lessons for anyone planning this:
  • Quota is not capacity. The project had quota for the chip, and a request still waited for hours. Quota is also per zone: several zones had a limit of 0, so only us-east5-a and us-east5-b would even accept a request.
  • The safety net matters. Without a hard stop, I ran a watchdog script that deletes the VM by exact name after a time limit, and tore everything down myself the moment the metrics were saved. A WAITING_FOR_RESOURCES request costs nothing. A forgotten VM does.

Does Gemma 4 E2B run on vLLM-TorchTPU?

Yes, with the same flags as the other environments. The docs only validate the larger Gemma 4 models (31B dense and 26B-A4B mixture of experts) and list v6e as supported but not covered by continuous integration, so this was the biggest unknown. On a plain v6e-1 VM:
  • uv pip install vllm-torchtpu worked as documented (about 4 minutes, vllm-torchtpu 0.33.0, libtpu 0.0.50).
  • vllm serve google/gemma-4-E2B-it --quantization fp8 with the gemma4 tool-call parser and --async-scheduling started and served. The first start compiled TPU graphs for about 15 minutes.
  • Tool calling worked: 100% valid tool calls in the agent check.
  • The Prometheus /metrics endpoint is there, with 403 vllm: series, so the Part 1 panel should work against it unchanged.
One thing I didn't expect: on v6e the backend automatically picks an fp8 KV cache (fp8_e5m2, as the server log shows). The local GPU used the default KV precision. The weights match, the KV cache doesn't, so this leg is not perfectly controlled. With a short context and a small model I'd expect the effect to be small, but I can't prove it.

Results

27 of 27 runs completed with zero failed requests. Same workloads, same client. Each point is the cold-cache first trial.
WorkloadConcurrencyOutput tok/sp50 per-token (ms)p95 end-to-end (ms)
short146.320.83,016
short4158.421.26,532
short8277.121.76,490
medium147.119.25,445
medium4180.721.35,810
medium8343.321.86,273
long146.06.311,150
long4168.48.113,209
long8290.68.719,960
Cloud TPU v6e results for Gemma 4 with vLLM-TorchTPU by workload and concurrency: throughput, per-token latency, and end-to-end latency.
WorkloadConcurrencyp50 TTFT (ms)p95 TTFT (ms)
short137370
short4713,842
short8983,734
medium1123123
medium4119323
medium8135420
long1383384
long43371,266
long83951,796
Cloud TPU v6e time to first token for Gemma 4 with vLLM-TorchTPU by workload and concurrency, median and p95.
Gemma 4 output throughput by concurrency and workload, all environments.
p95 time to first token for Gemma 4 by concurrency and workload.
What stands out:
  • For this small model, one v6e chip is not faster than a desktop GPU. A single stream decodes at about 46-47 tokens/s on the TPU against 100-127 on the RTX 4070 Ti, and at concurrency 8 the GPU is ahead on throughput too (for example 936 vs 277 tokens/s on short requests).
  • Long prompts are where the TPU looks best, with a caveat. At concurrency 1 the 8,192-token prompt starts streaming in 383 ms on the TPU, against 583 ms on the local GPU and 750 ms on the L4, and at concurrency 8 the TPU's p95 is 1,796 ms against 2,358 ms (local) and 1,836 ms (L4). I'd expect a TPU to be good at prefill, but I didn't test that explanation, and the caveat below applies to exactly this cell.
  • Throughput was still scaling at the top of the test. The server was capped at 8 concurrent sequences, and TPU throughput grows almost linearly up to that cap (46, 158, 277 tokens/s on short requests). Concurrency 8 is where my test stops, not where the chip does.
  • The first requests are slow. Short requests have a p95 time to first token of 3.7-3.8 s at concurrency 4 and 8 against a 71-98 ms median, which looks like first-use compilation of new batch shapes that four warm-up requests didn't cover. I'd warm up harder before drawing conclusions about tail latency.
  • A number I don't trust. For the long workload the benchmark reports a per-token time of 6.3 ms, but throughput (46.0 tokens/s) says about 21 ms, like the short workload. The per-request timings for the medium and long cells also don't add up: at concurrency 1 the long run took about 11 s per request by wall clock, but the reported mean end-to-end latency is 6.2 s. I didn't have the VM to chase it, so use throughput for the TPU, and treat its long-prompt first-token time as indicative.
Voxel51 Agent task success per task with Gemma 4, identical across all environments.
The agent check on the TPU matches the others: 67% success (12 of 18 runs), 100% valid tool calls, the same two failing tasks. The deployment did not change what the agent does.

Cloud GPU and CPU

Cloud GPU: NVIDIA L4

The cloud GPU is an NVIDIA L4 (24 GB) on a g2-standard-8 VM, running the same container image, the same fp8 checkpoint, the same server settings, and the same 27-run matrix as the local card. It is a different GPU from the RTX 4070 Ti, with the same Ada architecture but about 60% of the memory bandwidth (300 versus 504 GB/s), so expect it to be slower per stream.
Getting it was easier than the TPU, but not trivial: the L4 was out of stock in 22 zones across the US and Europe before one in Montreal (northamerica-northeast1-b) granted it. Quota was never the problem (32 L4s, none used). One difference from the TPU worked in my favor: a Compute Engine VM accepts a hard maximum run time that Google enforces by deleting the VM, so I did not depend on my own watchdog alone.
WorkloadConcurrencyOutput tok/sp50 per-token (ms)p95 end-to-end (ms)Cost per 1M (on-demand)
short172.713.51,766$3.59
short4279.413.91,846$0.93
short8529.214.42,036$0.49
medium167.814.13,802$3.85
medium4247.515.34,440$1.06
medium8433.016.95,361$0.60
long160.715.18,499$4.30
long4203.518.111,412$1.28
long8324.723.315,450$0.80
Cloud NVIDIA L4 results for Gemma 4 by workload and concurrency: throughput, per-token latency, end-to-end latency, and on-demand cost per million output tokens.
WorkloadConcurrencyp50 TTFT (ms)p95 TTFT (ms)
short14242
short46778
short8106215
medium1183185
medium4159517
medium8188697
long1750757
long45171,673
long86001,836
Cloud NVIDIA L4 time to first token for Gemma 4 by workload and concurrency, median and p95.
All 27 runs succeeded, with zero failures. The numbers line up with the hardware. A single stream decodes at 61-73 tokens/s (about 14 ms per token), roughly 55-65% of the local card, and throughput at concurrency 8 is 325-529 tokens/s. The agent check matches every other environment: 67% success (12 of 18), 100% valid tool calls, about 1.0 s per task.
The first token on the 8K prompt is slower than the local card's at concurrency 1 (750 ms versus 583 ms), which fits the L4's lower compute and memory bandwidth. At concurrency 4 and 8 it is faster (517 and 600 ms versus 1.2 and 1.1 s). The local card holds only 48,512 tokens of KV cache against the L4's 359,520, so eight 8K requests don't fit in it at once. I think that is why, but I didn't isolate it.
The billed window was about 1 hour 49 minutes, roughly $1.70 at $0.94 per hour.
CPU. The CPU runs a different engine (llama.cpp) and a different weight format (GGUF Q8_0), so this is labeled as not controlled. To keep the run short I used a reduced matrix: all three concurrencies for short requests with three trials, medium with one trial, and long at concurrency 1 only. 13 cells, zero failures. I also ran the same llama.cpp setup on the cloud VM's 8 vCPUs, described after the table.
WorkloadConcurrencyOutput tok/sp50 per-token (ms)p95 end-to-end (ms)
short121.646.06,042
short430.3126.717,623
short865.4111.417,574
medium115.049.317,716
medium422.4140.358,095
medium839.0132.485,977
long111.456.446,375
Local CPU results for Gemma 4 with llama.cpp on the reduced matrix: throughput, per-token latency, and end-to-end latency.
WorkloadConcurrencyp50 TTFT (ms)p95 TTFT (ms)
short17478
short47571,532
short81,3862,934
medium14,8085,074
medium45,72819,223
medium86,00336,310
long117,21317,765
Local CPU time to first token for Gemma 4 with llama.cpp on the reduced matrix, median and p95.
The CPU is usable for one person and nobody else: about 22 tokens/s on short requests, and a long 8,192-token prompt takes 17 seconds before the first token appears. Medium prompts at concurrency 8 reach a p95 time to first token of 36 seconds. It is a valid fallback for a single user and a non-starter for a shared endpoint.
Cloud CPU (a g2-standard-8 VM's 8 vCPUs, GPU idle). I ran the same llama.cpp setup and the same reduced matrix, plus the agent check. This leg spans two VMs of the same type: the short cells ran on the L4 VM in Montreal, and the medium cells, the long cell, and the agent check on a second VM in Singapore, because the first one was deleted before the CPU matrix finished (about another 1 hour 33 minutes of billing). The local machine's CPU has 24 threads. The cloud VM has 8. 13 cells, zero failures.
WorkloadConcurrencyOutput tok/sp50 per-token (ms)p95 end-to-end (ms)
short110.589.512,353
short417.1220.231,351
short830.0241.436,935
medium16.7101.339,089
medium411.1256.6128,900
medium815.4311.1208,144
long14.8211.9110,228
Cloud CPU (8 vCPUs on a g2-standard-8 VM) results for Gemma 4 with llama.cpp on the reduced matrix: throughput, per-token latency, and end-to-end latency.
WorkloadConcurrencyp50 TTFT (ms)p95 TTFT (ms)
short1924952
short41,8743,401
short83,4396,472
medium113,01613,080
medium4584119,086
medium8789188,165
long1053
Cloud CPU (8 vCPUs on a g2-standard-8 VM) time to first token for Gemma 4 with llama.cpp on the reduced matrix, median and p95.
The cloud CPU is about half as fast as the local one: 10.5 tokens/s at concurrency 1 on short requests (21.6 locally), and 4.8 tokens/s on the long prompt (11.4 locally). An 8,192-token request takes about 110 seconds end to end at the 95th percentile. The agent check gave the same 67% (12 of 18) with 100% valid tool calls, but each task took 7.1 s, against 3.2 s on the local CPU.
One caution: I don't trust the time-to-first-token column for the medium concurrency 4 and 8 cells and the long cell on this VM. For medium the median (0.6-0.8 s) sits next to a 95th percentile of 119 and 188 seconds, and for long the median is 0 ms with a p95 of 53 ms, while a request took about 110 seconds. Candidates are llama.cpp reusing a cached prompt (the warm-up requests use the same prompts) and the server streaming an empty first chunk before the prompt was processed. I didn't confirm either. Throughput and end-to-end latency don't depend on that, so use those. It confirms the point above: a CPU, local or rented, is a single-user fallback.

Cost per million output tokens

The cost chart answers "what does a million output tokens cost on each environment?" using one formula:
cost per 1M output tokens = price per hour / (output tokens per second x 3600) x 1,000,000
Gemma 4 cost per million output tokens on each environment, at on-demand and electricity prices.
It assumes the accelerator is kept busy at that concurrency level, which is the best case for every environment. The prices:
  • Cloud L4 (g2-standard-8): about $0.94 per hour on-demand in Montreal, from third-party price trackers, because Google's own page snippet was ambiguous (a $0.854 figure may belong to another region). Check your billing report.
  • TPU v6e-1: $2.70 per chip-hour on-demand ($1.35 with Flex-start), per Google's TPU and Dynamic Workload Scheduler (DWS) pricing pages. The page I could reach looked stale, so check your own billing report. Our run used on-demand.
  • Local GPU: $0.043 per hour of electricity, an assumption (285 W at $0.15/kWh), not a measurement, and it does not include buying the GPU.
  • CPU: not priced. There's no honest hourly number for a machine I own, so it isn't on the chart.
At concurrency 8 the L4 comes to about $0.49-0.80 per million output tokens (about $3.6-4.3 at concurrency 1), and the TPU to about $2.2-2.7 on-demand (about $1.1-1.4 with Flex-start, about $16 at concurrency 1). For this model the L4 is roughly three to five times cheaper per token than the TPU, in the best case, and with a third-party L4 price. The local GPU is one to two orders of magnitude cheaper, because the electricity is cheap and the hardware is already paid for. That comparison flatters the GPU, so read it as "marginal cost once you own it".
The best case is also not what I paid. The TPU was billed for about 2 hours 45 minutes (roughly $7.40), and in that time it generated about 334,000 output tokens. That is an effective $22 per million, ten times the chart, because the machine spent most of its billed time waiting: 15 minutes compiling, and about an hour and a half stalled on a bug in my own script (more on that in the process log). Utilization is the real cost driver on a TPU.

What it means for a real deployment

Because an agent task writes only about 59 tokens, token cost is almost irrelevant here. The monthly bill is set by how many hours the machine is on:
SetupMonthly costWhat you get
Local GPU, on 24/7about $31 electricity (assumed) plus the card0.6 s per task, no capacity risk
Cloud L4, on 24/7about $6861.0 s per task, no hardware to own
Cloud L4, 8 h on weekdaysabout $165same, must be turned on and off
TPU v6e-1 on-demand, 8 h on weekdaysabout $4751.8 s per task, fast long prompts, must be turned on and off
TPU v6e-1 on-demand, 24/7about $1,970same, always ready
TPU v6e-1 Flex-start, 8 h on weekdaysabout $240same, but capacity is not guaranteed and I could not get it
Estimated monthly cost of running Gemma 4 for the Voxel51 Agent on each setup, and what each setup gets you.
Two consequences follow:
  • Size for concurrency, not tokens. At concurrency 8 the TPU produced about 330 output tokens/s, which is far more than a team of agent users generates. I did not test agent tasks under concurrent load, but a single E2B replica on any of these machines is unlikely to be the bottleneck.
  • A chip you do not keep busy is expensive. Our effective cost was $22 per million tokens, ten times the best case, because the VM was idle. For a team workload, a cloud L4 is the cheaper rented choice for this model and an owned GPU is cheaper still. The TPU only wins when very low first-token latency on long prompts or a larger model makes it necessary.

So where should Gemma 4 run?

Local GPU (RTX 4070 Ti)Cloud GPU (L4)Cloud TPU v6e-1CPU (llama.cpp)
Single-stream decode100-127 tok/s61-73 tok/s46-47 tok/s11-22 local, 5-11 cloud
Time to first token, 8K prompt, concurrency 1583 ms750 ms383 ms (indicative)17 s local, unreliable on cloud
Throughput at concurrency 8416-936 tok/s325-529 tok/s277-343 tok/s39-65 local, 15-30 cloud
Cost per 1M tokens at concurrency 8about $0.01-0.03 (electricity only)about $0.49-0.80about $2.2-2.7 on-demandnot priced
Agent success (thinking off)67%67%67%67%
Agent time per task0.6 s1.0 s1.8 s3.2 s local, 7.1 s cloud
Operational effortone containerfind a zone with stock, one VMcapacity, quota, 15 min compileone container
Gemma 4 on four environments side by side: decode speed, first-token time, throughput, cost, agent results, and operational effort.
Recommendation by use case (the table at the top has the same advice by who you are), with the caveat that this is one small model on one chip:
  • Interactive, single user: the local GPU. It's the fastest per stream and the cheapest per token, if you already own one (the card itself isn't in that price).
  • A small team on rented hardware: the cloud L4, at about $0.5-0.8 per million tokens and about $165 a month for working hours, with the caveat that the price is from third-party trackers.
  • Long-context prompts on a shared endpoint: the TPU looks best on first token (383 ms versus 583 ms on the local card and 750 ms on the L4 at 8K), but that cell's timings have an inconsistency, and it only pays if you keep the chip busy.
  • Offline batch: the L4 at about $0.5-0.8 per million tokens is the cheaper rented option here. The TPU's Flex-start rate of about $1.1-1.4 is reasonable too, but only if you can get the chip.
  • A single user with no GPU: the CPU works, slowly.
What I did not test is the case the TPU is built for: the larger Gemma 4 models (31B, 26B-A4B) that the docs actually validate and that don't fit on a 12 GB desktop GPU. A single v6e chip is under-used by E2B, and I'd expect the picture to change there.

Reproduce it

Everything is in the repository: benchmarks/ has the workloads, the runner, the analysis, and the agent check, and docker/compose.bench.yml has the local GPU setup. The CPU setup is in docker/compose.cpu.yml and the TPU runbook is in deploy/tpu/. The cloud GPU runbook, with preflight, create, run, a zone sweep, teardown, and a watchdog, is in deploy/gpu/. The same harness works against any OpenAI-compatible endpoint.

Limits of this study

  • One machine per environment, one model, one checkpoint family.
  • Online fp8 on every environment is a compromise for fairness. It is not the best quality or the best speed on any of them.
  • The agent check is a small proxy for the Voxel51 Agent, not the full application.
  • Prices change. The TPU price is from search snippets of Google's pages, and the L4 price is from third-party trackers.
  • Trial 1 is the only trial used for every number, to avoid prefix-cache hits in later trials. That gives one sample per cell.
  • The cloud CPU leg ran on two VMs of the same type, in two regions.
  • The CPU legs used a reduced matrix (single trial for medium and long), and time to first token on the cloud CPU's medium and long cells is unreliable (see above).
  • The L4 is not the same card as the local RTX 4070 Ti, and I did not isolate why its 8K time to first token is better.
  • The monthly figures are arithmetic on hourly prices, not invoices.
  • The TPU ran with an fp8 KV cache chosen by the backend. The GPU did not.
  • The server cap of 8 sequences means no environment was pushed to saturation.

Follow-up tasks

Four things I would do next, in order of value:
  1. Test the larger Gemma 4 models on the TPU (31B and 26B-A4B). This is the case the TPU is built for and the one E2B can't show.
  2. Run the agent check with thinking mode on for the GPU and TPU. It needs a reasoning parser configured in vLLM. On the CPU, thinking lifted success from 67% to 83% at ten times the latency per task.
  3. Run agent tasks under concurrent load, to turn "one replica is probably enough for a team" into a measurement.
  4. Explain the TPU's long-workload per-token number. The benchmark reports 6.3 ms, but throughput implies about 21 ms, and the per-request timings in the medium and long cells don't match wall-clock time. It needs a second run with a longer warm-up, which would also show whether the short-request tail latency is first-use compilation.

Frequently asked questions

Headshot of Adonai Vera
Machine Learning Engineer
I'm exploring how we can make agents see, understand, and transform the world around us. I’m dedicated to building systems that bridge perception and action, shaping a future where technology seamlessly integrates into our lives.
See all articles by Adonai Vera

Try Voxel51 for yourself

Related posts

Boost your visual and physical AI workflows.
View all