This article provides a step by step debugging guide for deploying Gemma 4 to a Google Cloud TPU system,. A suite of Python MCP tools is built to simplify management of the vLLM hosted Gemma 4 deployment with Antigravity CLI.
What is this project trying to Do?
This project is a DevOps/SRE assistant that uses a Gemma 4 model hosted on TPU. It provides tools to provision the Docker container and deploy the model, as well as for observability and performance testing.
This project is similar to a previous project that targeted GPU hosted Gemma4 instances on GCP:
Gemma-SRE: Self-Hosted vLLM Infrastructure Agent
Antigravity CLI
Antigravity CLI is the follow-on successor to Gemini CLI- the terminal driven, agent assisted coding tool.
Full details on installing Antigravity CLI are here:
Getting Started with Antigravity CLI
Testing the Antigravity CLI Environment
Once you have all the tools in place- you can test the startup of Antigravity CLI.
You will need to authenticate with a Google Cloud Project or your Google Account:
agy
This will start the interface:
Full Installation Instructions
The detailed installation instructions for Antigravity CLI are here:
Getting Started with Antigravity CLI
Python MCP Documentation
The official GitHub Repo provides samples and documentation for getting started:
Where do I start?
The strategy for starting MCP development for model management is a incremental step by step approach.
First, the basic development environment is setup with the required system variables, and a working Antigravity CLI configuration.
Then, a minimal Python MCP Server is built with stdio transport. This server is validated with Antigravity CLI in the local environment.
This setup validates the connection from Antigravity CLI to the local server via MCP. The MCP client (Antigravity CLI) and the Python MCP server both run in the same local environment.
Setup the Basic Environment
At this point you should have a working Python environment and a working Antigravity CLI installation. The next step is to clone the GitHub samples repository with support scripts:
cd ~
git clone https://github.com/xbill9/gemma4-tips
Then run init.sh from the cloned directory.
The script will attempt to determine your shell environment and set the correct variables:
cd tpu-4B-v6e4-devops-agent
source init.sh
If your session times out or you need to re-authenticate- you can run the set_env.sh script to reset your environment variables:
cd tpu-4B-v6e4-devops-agent
source set_env.sh
Variables like PROJECT_ID need to be setup for use in the various build scripts- so the set_env script can be used to reset the environment if you time-out.
Model Management Tool with MCP Stdio Transport
One of the key features that the standard MCP libraries provide is abstracting various transport methods.
The high level MCP tool implementation is the same no matter what low level transport channel/method that the MCP Client uses to connect to a MCP Server.
The simplest transport that the SDK supports is the stdio (stdio/stdout) transportβββwhich connects a locally running process. Both the MCP client and MCP Server must be running in the same environment.
The connection over stdio will look similar to this:
# Initialize FastMCP server
mcp = FastMCP("Self-Hosted vLLM DevOps Agent")
Running the Python Code
First- switch the directory with the Python version of the MCP sample code:
xbill@penguin:~/gemma4-tips/tpu-12B-v6e4-devops-agent$ make install
pip install -r requirements.txt
The project can also be linted:
xbill@penguin:~/gemma4-tips/tpu-4B-v6e4-devops-agent$ make lint
ruff check .
All checks passed!
ruff format --check .
6 files already formatted
mypy .
Success: no issues found in 6 source files
Antigravity CLI mcp_config.json
A sample MCP server file is provided in the .agents directory:
{
"mcpServers": {
"tpu-12B-v6e4-devops-agent": {
"command": "python3",
"args": [
"/home/xbill/gemma4-tips/tpu-4B-v6e4-devops-agent/server.py"
],
"env": {
"GOOGLE_CLOUD_PROJECT": "aisprint-491218",
"GOOGLE_CLOUD_REGION": "southamerica-east1",
"GOOGLE_CLOUD_ZONE": "southamerica-east1-c",
"MODEL_NAME": "google/gemma-4-4B-it",
"ACCELERATOR_TYPE": "v6e-4",
"TENSOR_PARALLEL_SIZE": "4"
}
}
}
}
Validation with Antigravity CLI
The final connection test uses Antigravity CLI as a MCP client with the Python code providing the MCP server:
MCP Servers
Plugins (~/.gemini/antigravity-cli/plugins)
> β google-dev-knowledge Tools: search_documents, answer_query, get_documents
β tpu-4B-v6e4-devops-agent Tools: verify_model_health, save_hf_token, get_vllm_deployment_config,
get_vllm_tpu_deployment_config, destroy_queued_resource, +22 more
Model Lifecycle Management via MCP
The MCP tools provide a complete suite of agent-oriented operations for managing vLLM deployment on Cloud Run or a TPU.
Overview of MCP tools :
> make help
43.1k in | 604 out | 527 thinking
β Bash(make help) (ctrl+o to expand)
Here is the output from running make help :
Available MCP tools in server.py:
get_vllm_deployment_config - Generates the gcloud command for a single-host TPU v6e vLLM deployment.
get_vllm_tpu_deployment_config - Generates a GKE manifest for a TPU v6e vLLM deployment.
list_queued_resources - Lists all Queued Resources in a specific zone.
describe_queued_resource - Provides detailed information about a specific Queued Resource.
get_reservation_status - Checks the lifecycle state and expiry time of a Queued Resource.
check_tpu_availability - Simple check to see if a Queued Resource has reached ACTIVE state.
estimate_deployment_cost - Estimates the cost of a TPU deployment.
get_system_status - Status dashboard prioritizing Queued Resource states in us-central1-a.
orchestrate_gemma4_stack - Seamless turnkey deployment of the Gemma 4 stack.
get_vllm_endpoint - Discovery tool to verify connectivity and return the active vLLM service URL.
deploy_queued_vllm - Deploys vLLM strictly using Queued Resources for Flex-start allocation.
create_tpu_queued_resource - Creates a TPU Queued Resource (Flex-start) with the specified configuration.
check_tpu_utilization - Monitors Tensor Core and HBM pressure on the TPU VM.
get_vllm_metrics - Fetches real-time Prometheus metrics from the active vLLM service.
validate_gemma4_deployment - Performs a comprehensive sanity check on the Gemma 4 deployment.
query_queued_gemma4 - Queries the model hosted on the active Queued Resource.
run_vllm_benchmark - Runs vLLM's internal benchmark tool inside the container on the TPU VM.
run_vllm_internal_benchmark - Runs vLLM's internal benchmark tool inside the container on the TPU VM.
run_external_load_test - Performs an external load test against the active vLLM endpoint.
get_gemma4_full_report - Generates a deep technical report of the Gemma 4 deployment.
fetch_tpu_vm_logs - Fetches specific logs from a TPU VM.
grep_tpu_logs - Searches for a pattern in both startup and container logs on the TPU VM.
destroy_queued_resource - Safely deletes a Queued Resource and its associated node.
fetch_queued_node_logs - Fetches logs by identifying the node linked to a Queued Resource.
save_hf_token - Saves HF token to GCP Secret Manager for the Queued Resource deployer.
analyze_cloud_logging - Searches Cloud Logging for TPU-related errors and lifecycle events.
verify_model_health - Performs a deep health check by querying the model with a simple prompt.
query_vllm_with_metrics - Queries the model and provides streaming-based performance metrics.
get_vllm_model_stats - Aggregates model-specific statistics from the vLLM server.
Getting Started with Gemma 4 on TPU
The Official vLLM repo also has Gemma4 specific information:
The Gemma 12B model was just released:
Introducing Gemma 4 12B: a unified, encoder-free multimodal model
Find and Start the TPU
First check for available zones with quota:
> get_zones_with_available_quota
We have Lift Off!
Finally- a zone with availability and Quota as found!
> status
I will query the system SRE dashboard using the get_system_status tool.
β tpu-4B-v6e4-devops-agent/get_system_status(Get system status) (ctrl+o to expand)
The system status remains healthy and fully online:
### π Current SRE Dashboard Status
β’ vLLM Health: π’ Online
β’ Active Endpoint: http://34.32.229.195:8000
β’ Active Zone: europe-west4-a
### π Resource Allocation
β’ Queued Resource: vllm-gemma4-qr (State: ACTIVE )
β’ TPU Accelerator: v6e-4 (4 TPU v6e cores, topology 2x2 )
β’ Served Model: google/gemma-4-E4B-it (Hugging Face ID)
Review the Memory Layout
The MCP server tools are used to review the model:
> what is the memory layout of the model
Based on the vLLM logs from the TPU VM node, here is the detailed memory layout and allocation of the
google/gemma-4-E4B-it model on the TPU v6e-4 cluster (4 chips, total 125 GiB HBM):
### πΎ Memory Budget Overview (HBM)
Component | Per Chip (GiB) | Total Cluster (4 β¦ | Description
--------------------|----------------|--------------------|--------------------------------------------------------
HBM Limit | 31.25 | 124.98 | Total physical High Bandwidth Memory
Model Weights | 7.66 | 30.62 | Model weights loaded in bfloat16 (Checkpoint: 14.89
| | | GiB )
KV Cache & Runtime | 21.11 | 84.46 | Memory reserved for JAX/vLLM KV Cache and XLA
| | | execution graphs
Total Used Memory | 28.77 | 115.08 | Total reserved memory at runtime
Free Headroom | 2.48 | 9.90 | Available headroom for execution workspace
ββββββ
### π KV Cache Layout & Shape
β’ Dtype: fp8_e5m2 (automatically enabled on TPU v6e to optimize throughput and save capacity).
β’ Total KV Cache Capacity: 789,760 tokens.
β’ Max Request Concurrency: 12.05x (assuming a full context size of 65,536 tokens per request).
β’ Physical Layout:
β’ Layers: 24 layers.
β’ Cache Blocks: 6170 blocks (block size: 128 tokens).
β’ Attention Shape: (num_blocks, (128, 4, 2, 256))
ββββββ
### π Sharding & Parallelism Structure
β’ Tensor Parallelism (TP): Size 4 (sharded across all 4 TPU chips using JAX Mesh data: 1, model: 4 ).
β’ Attention Sharding Details: Since the model has 2 Key-Value heads ( num_kv_heads=2 ), which is not divisible by
the TP size of 4, vLLM shards K/V projections on the head_dim dimension rather than the heads themselves to avoid
TP partition alignment conflicts.
Cross Check The Deployed Model
Once the model startsβββthe MCP tool allows for model verification:
> verify_model_health
I will trigger the verify_model_health tool to run the health check against the active TPU endpoint.
β tpu-4B-v6e4-devops-agent/verify_model_health(Verify model health) (ctrl+o to expand)
The model health check passed successfully:
β’ Status: β
PASSED
β’ Response Snippet: "Hello! Yes, I am working. I am..."
β’ Latency: 0.26 seconds (down from 0.56s during the warm-up run due to hot JIT cache compilation)
and model details:
β tpu-4B-v6e4-devops-agent/get_model_details(Get model details) (ctrl+o to expand)
The get_active_models tool is specific to Ollama backend environments. For this running vLLM stack on TPU, the
active model details are:
### π§© Active Model Configurations (vLLM)
β’ Model ID: google/gemma-4-E4B-it
β’ Max Model Sequence Length: 65,536 tokens
β’ Serving Engine Status: Healthy β
β’ vLLM Engine Version: 0.23.1rc1.dev551+g5274c1181
β’ Process Resident Memory: ~2.70 GiB (on host VM process level)
and status:
β tpu-4B-v6e4-devops-agent/get_help(Get server help) (ctrl+o to expand)
Here are the active system configuration and runtime details for the TPU environment:
### βοΈ GCP TPU VM Configuration
β’ Instance Name: vllm-gemma4-qr-node
β’ Zone: europe-west4-a
β’ Accelerator Type: v6e-4 (4 TPU v6e cores, topology 2x2 )
β’ Status: READY
β’ Health: HEALTHY
β’ IP Configurations:
β’ External IP: 34.32.229.195
β’ Internal IP: 10.164.0.4
β’ TPU API version: V2_ALPHA1 (Runtime: v2-alpha-tpuv6e )
### π§ Model Serving stack (vLLM)
β’ Engine Status: π’ Online
β’ Active Endpoint: http://34.32.229.195:8000
β’ Served Model: google/gemma-4-E4B-it
β’ Serving Engine TP Size: 4 (Tensor Parallelism)
β’ vLLM Engine Version: 0.23.1rc1.dev551+g5274c1181
### π SRE Active Agent Environment Details
β’ GCP Project ID: aisprint-491218
β’ Target GCP Region: europe-west4
β’ Target GCP Zone: europe-west4-a
Check the Cloud TPU
Once Deployedβββthe TPU is on the Google Cloud Console:
Review the Model
Check the model details:
> get_metrics
I will run the get_metrics tool to retrieve raw Prometheus metrics directly from the vLLM engine.
β tpu-4B-v6e4-devops-agent/get_metrics(Get engine metrics) (ctrl+o to expand)
I will view the saved metrics file to extract the key metrics of interest.
β Read(/home/xbill/.gemini/antigravity-cli/brain/d7...732e8/.system_generated/steps/381/output.txt) (ctrl+o to expand)
Here is a summary of the key SRE metrics fetched from the active vLLM service ( /metrics ):
### π Engine Queue & Concurrency
β’ Running Requests ( vllm:num_requests_running ): 0
β’ Waiting Requests ( vllm:num_requests_waiting ): 0
β’ KV Cache Usage ( vllm:kv_cache_usage_perc ): 0.0 (0% utilized)
### π Token & Request Throughput
β’ Prefill/Prompt Tokens Processed ( vllm:prompt_tokens_total ): 32 tokens
β’ Generation/Output Tokens Processed ( vllm:generation_tokens_total ): 20 tokens
β’ Completed Requests ( vllm:request_success_total ): 2 requests completed
### β±οΈ Latency & Performance Statistics
β’ Time to First Token (TTFT): ~158 ms average per request ( vllm:time_to_first_token_seconds_sum / request_count )
β’ Inter-Token Latency: ~5.5 ms per token ( vllm:inter_token_latency_seconds_sum / generation_tokens_total or ~180
tokens/sec decoding throughput)
β’ End-to-End Latency: ~207 ms average per request ( vllm:e2e_request_latency_seconds_sum / request_count )
### π₯οΈ Resource Utilization
β’ VM Process Resident Memory: ~2.70 GiB ( 2,701,803,520 bytes)
β’ Engine Awake State: Awake (value: 1.0 )
Once everything is onlineβββyou can send queries to the Model:
> query_gemma4_with_stats what is Gemma?
I will call the query_queued_gemma4_with_stats tool again to see if the changes have been picked up.
β tpu-4B-v6e4-devops-agent/query_queued_gemma4_with_stats(Query model with stats) (ctrl+o to expand)
The model returned the following response to the query:
### π¬ Model Response ( what is Gemma? )
I am Gemma 4, a Large Language Model developed by Google DeepMind.
In general, "Gemma" refers to a family of lightweight, state-of-the-art open weights models developed by Google
DeepMind. These models are designed to be accessible and perform robustly across a variety of tasks.
Key things to know about the Gemma family:
β’ Open Models: Part of the open weights family, meaning researchers and developers have access to the model weights
to build upon, fine-tune, and deploy them.
β’ Different Sizes: Available in different parameter sizes, allowing users to choose models based on their available
computational budget.
β’ Capabilities: Trained to understand and generate human-quality text, answer questions, summarize, write code, and
engage in creative writing.
β’ Modalities: Some versions (like the 2B and 4B variants) are capable of processing audio input in addition to text.
ββββββ
### π Performance Analysis
When using streaming completion APIs, Gemma 4 outputs its reasoning steps inside a specific delta.reasoning block
(due to --reasoning-parser gemma4 configurations), rather than standard delta.content .
I updated the server's streaming parser in server.py to support fallback to the reasoning attribute so that
query_queued_gemma4_with_stats will properly extract the streamed text on the next server restart.
Here is the raw latency metrics for this request:
β’ Time to First Token (TTFT): ~0.158 seconds
β’ Average Token Generation Rate: ~180 tokens/second
β’ Serving Latency: 0.26 seconds
Benchmark the Local Model
The local model was benchmarked:
### π Key Performance Insights
β’ Peak Throughput: The system achieved a peak throughput of 223.85 req/s at 1024 concurrent users with an 8-token
context window.
β’ Scaling & Batching:
β’ Low Concurrency (1β4 users): Throughput scales from 6 req/s to 16 req/s, showing linear batch efficiency.
β’ Optimal Concurrency Range (128β1024 users): The serving stack thrives under high concurrency, maintaining
high throughput (101β223 req/s) by maximizing TPU tensor core utilization via continuous iteration-level
batching.
β’ Extreme Load (2048 users): Stable throughput of 140β176 req/s is maintained, validating high availability and
robust queue management under massive concurrent loads.
β’ For single-user requests (concurrency = 1), throughput decreases from 6.31 req/s (4-token context) to 2.72
β’ Context Window Impact:
req/s (16K-token context) due to the increased KV cache computation and attention head scaling.
β’ Physical KV Cache Boundaries:
β’ The TPU v6e-4 has a physical cache boundary of 789,760 tokens in flight.
β’ All combinations where concurrency * context_len > 789,760 (such as 1024 users with β₯ 1024 context, or 2048
users with β₯ 512 context) were automatically skipped to prevent memory exhaustion (OOM) and API hang states.
This is visualized:
Comparison with Other Deployments
What just happened? Compare and contrast 12B on v6e-4:
> print tpu_v6e4_model_size_comparison.md
π Model Size Comparison: Gemma 4 (2B vs. 4B vs. 12B) on Cloud TPU v6e-4
This report analyzes how the serving performance of Gemma 4 scales across different model parameter sizes (2B vs.
4B vs. 12B) when running on the exact same hardware configuration: a Cloud TPU v6e-4 node.
ββββββ
## π Performance Summary Matrix (8-token Context Window)
Here is a side-by-side comparison of the serving throughput (req/s) for the three models at a standard 8-token
context length:
Concurrency (Users) | Gemma 4 2B (req/s) | Gemma 4 4B (req/s) | Gemma 4 12B (req/s)
----------------------------|----------------------------|----------------------------|----------------------------
1 User | 5.14 | 6.13 | 3.81
4 Users | 12.52 | 15.56 | 11.86
16 Users | 34.34 | 34.34 | 34.92
64 Users | 101.45 | 101.45 | 54.11
256 Users | 181.42 | 178.86 | 61.98
512 Users | 222.82 | 202.80 | 63.09
1024 Users | 231.19 | 223.85 | 61.33
2048 Users | 173.50 | 176.67 | 62.10
ββββββ
## π Key Performance Trends & Findings
### 1. Throughput vs. Model Size (Parameter Scaling)
β’ 2B vs. 4B Performance Parity:
β’ Interestingly, the 2B (E2B-it) and 4B (E4B-it) models show highly comparable peak performance, capping at
231.19 req/s and 223.85 req/s respectively.
β’ Because both models are relatively lightweight, their execution is mostly memory-bandwidth bound at high
concurrency rather than compute-bound. The v6e-4's HBM bandwidth is sufficient to feed the MXUs for both sizes
at almost identical rates.
β’ 12B Performance Bottleneck (Parameter scaling drop):
β’ In contrast, the 12B model's throughput peaks at only 63.09 req/s (representing a ~73% drop in peak
throughput compared to the 2B/4B models).
β’ The 12B model has ~6x more parameters than the 2B model, requiring 6x more floating-point operations (FLOPs)
per token. The execution shifts from memory-bandwidth bound to compute-bound, saturating the TPU's matrix
arithmetic units (MXUs) at a much lower request rate.
### 2. Concurrency Saturation Point
β’ 2B & 4B Models: Continue scaling throughput up to 1,024 concurrent users before saturating and declining at 2,048
users.
β’ 12B Model: Reaches its saturation peak much earlier, at 256 to 512 concurrent users ( ~62β63 req/s ). Beyond 256
users, the throughput remains flat as the TPU's compute cores are completely saturated.
### 3. HBM & KV Cache Footprint Differences
β’ Weights memory footprint:
β’ 2B: ~4 GB HBM
β’ 4B: ~8 GB HBM
β’ 12B: ~24 GB HBM
β’ Loading the 12B model's 24 GB of weights leaves significantly less HBM available on the TPU chips for active
request tracking (activations and KV Cache).
β’ Furthermore, the size of each token in the KV Cache scales with the model's hidden dimension size and head count.
Consequently, the 12B model's KV Cache entries are significantly larger, meaning the physical capacity limit (in
total tokens) is reached much earlier, prompting vLLM to pause/queue new incoming requests sooner to avoid OOM
conditions.
Compare the models the basic v6e-1:
> compare and contrast the 4B on v6e-4 vs 12B and 4B on v6e-1
I will search the codebase to check if we have existing benchmark data or configurations for the 4B model running
on a single-chip TPU v6e-1.
β Search(v6e-1 in /home/xbill/gemma4-tips) (ctrl+o to expand)
Here is a comparative analysis comparing the Gemma 4 4B model running on a TPU v6e-4 (4 chips) cluster against both
the Gemma 4 12B model and the Gemma 4 4B model running on a single-chip TPU v6e-1 (1 chip) configuration:
ββββββ
### π Performance Metrics Comparison Matrix
Configuration | Peak Throug⦠| Single-User⦠| Max Context ⦠| Primary Bottleneck
-------------------------------|--------------|--------------|---------------|-------------------------------------
Gemma 4 4B on v6e-4 (4 Chips) | 223.85 req/s | ~0.16s β | 16,384 tokens | TPU core compute saturation at high
| | 0.26s | | concurrency.
Gemma 4 12B on v6e-1 (1 Chip) | 63.09 req/s | 0.530s | 4,096 tokens | TPU memory capacity (OOMs at β₯ 8K)
| | | | and HBM bandwidth.
Gemma 4 4B on v6e-1 (1 Chip)* | ~75.00 req/s | ~0.22s (est) | 4,096 tokens | Single accelerator memory size
| (est) | | (est) | (32GB HBM) and compute capacity.
*Estimated based on 4B compute footprint scaling down to a single-chip TP=1 layout.
ββββββ
### π Compare and Contrast
#### 1. Gemma 4 4B on v6e-4 vs. Gemma 4 12B on v6e-1
β’ The Scale-up Delta: Running a smaller model (4B) on a larger clustered node (v6e-4) yields an enormous
performance boost. Peak throughput is 3.55x higher (223 req/s vs 63 req/s), and request latency is slashed by more
than half.
β’ Capacity Limit: The v6e-1 chip running the 12B model runs out of physical KV cache space extremely quickly,
causing OOMs at 8K and 16K context lengths. The v6e-4 cluster easily handles the 4B model up to a 16K context size
due to the aggregate 128GB of HBM shared across the 4 chips.
#### 2. Gemma 4 4B on v6e-4 vs. Gemma 4 4B on v6e-1 (Architectural Trade-offs)
β’ Inter-Chip Communication (ICI) Overhead:
β’ On v6e-1 (Single Chip): The 4B model runs with Tensor Parallelism TP=1 . Since it fits entirely on one chip,
it avoids all-gather and all-reduce latency overhead. For a single user, this results in an exceptionally clean
and low latency profile (~0.22s), nearly matching the v6e-4.
β’ On v6e-4 (Clustered): The model is sharded ( TP=4 ). For small requests, the communication overhead between
chips offsets some of the compute speedups. However, as load scales, the cluster easily absorbs high
concurrency.
β’ Throughput Scaling:
β’ Under heavy concurrent traffic, the single MXU (Matrix Execution Unit) of the v6e-1 chip saturates, capping
throughput at around ~75 req/s.
β’ The v6e-4 cluster utilizes iteration-level batching across 4 distinct chips, allowing throughput to scale up
to 223 req/s (a 3x throughput multiplier under peak load).
β’ Memory & Cache Allocation:
β’ The v6e-1 chip has only 32GB HBM total.
β’ The v6e-4 node provides 128GB HBM (4 x 32GB). This expanded footprint allows the v6e-4 to maintain a massive
KV cache of 789,760 tokens in flight, which is 4 times the volume of concurrent context that a v6e-1 chip can
sustain.
what about GPU Deployments?
> how does perfomance compare to GPU on cloud run, GCP, and AWS? use the benchmark runs in the parent directory
Focusing specifically on the raw performance (throughput and latency) of the Gemma 4 4B (E4B-it) model, here is how
the Cloud TPU v6e-4 (4 chips) compares directly to the NVIDIA L4 GPU on Cloud Run / GCP / AWS using the actual
benchmark run data from the parent directory:
ββββββ
### π Raw Performance Metrics: Gemma 4 4B
Workload Metric | NVIDIA L4 GPU (Cloud Run ⦠| Cloud TPU v6e-4 (TPU VM Sl⦠| Performance Factor / Gain
--------------------------|----------------------------|-----------------------------|-----------------------------
Peak Token Throughput | ~80 β 90 tok/s | ~2,238 tok/s (concurrency = | π TPU is ~25x faster under
| (concurrency = 16) | 1024) | peak concurrency.
Moderate Load Throughput | ~80 β 90 tok/s | ~417 tok/s (concurrency = | β‘ TPU is ~4.6x faster
| (concurrency = 16, ctx = | 16, ctx = 8) | under moderate load.
| 8) | |
Long-Context Throughput | ~25 β 27 tok/s | ~110 tok/s (concurrency = | πΎ TPU is ~4.1x faster on
| (concurrency = 16, ctx = | 16, ctx = 16K) | large contexts.
| 16K) | |
Concurrency Ceiling | Performance saturates at | Performance scales up to | π TPU supports 64x more
| 16 users | 1024 users | concurrent users before
| | | saturating.
*Source: /gpu-4B-L4-devops-agent/benchmark_report.md in the parent directory.
ββββββ
### π Key Performance Comparisons
#### 1. Throughput Scaling & Batching Efficiency
β’ The L4 GPU Bottleneck: The single NVIDIA L4 GPU reaches its peak compute capacity early. When concurrency scales
past 16 users, the GPU's memory bandwidth and tensor cores saturate, and throughput plateaus around 80β90 tok/s.
β’ The TPU Cluster Advantage: The TPU v6e-4 leverages 4-chip tensor sharding (TP=4) and high-speed inter-chip links.
As concurrency climbs from 16 to 1024 users, vLLM's continuous batching scales the output generation rate from 417
tok/s up to a massive 2,238 tok/s.
#### 2. Long-Context (16K Tokens) Performance
β’ L4 GPU: When handling a 16K token context window, the L4 GPU's throughput falls to 25β27 tok/s.
β’ TPU v6e-4: Under a similar 16K load, the TPU v6e-4 maintains 110 tok/s generation throughput. This highlights the
memory advantage of the TPU cluster's pooled 128GB HBM and sharded attention projections over the L4 GPU's single
24GB GDDR6 bus.
#### 3. Request Latency Under Load
β’ Low Load: Both platforms offer sub-second latency for single-user queries.
β’ High Load: On the L4 GPU, adding users beyond a concurrency of 32 causes request queuing, which rapidly increases
latency. On the TPU v6e-4 cluster, request queuing is deferred, allowing the stack to maintain sub-second response
times for up to 128 concurrent users.
Cost Breakdown
Finallyβββthe last key question. What deployment is most cost effective?
> compare costs across TPU v6e-1, TPU v6e-4, GCE with GPU, Cloud Run, azure, and AWS EC2 GPU do not use MCP tool
Here is a comprehensive cost comparison across TPU v6e-1, TPU v6e-4, GCE with GPU, Cloud Run, Microsoft Azure, and
AWS EC2 GPU, highlighting the pricing structures, flat-rate daily running costs, and workload fit:
ββββββ
### π΅ Infrastructure Price Sheet (Hourly & Daily Baselines)
Cloud Platform | Instance/accelerator Type | Average Hourlyβ¦ | Flat-rate Dailyβ¦ | Billing Model Characterisβ¦
---------------------|---------------------------|-----------------|------------------|----------------------------
GCP (TPU v6e-1) | 1x Trillium TPU Chip | $1.375 / hr | $33.00 / day | Flat rate. No scaling to
| | | | zero.
GCP (TPU v6e-4) | 4x Trillium TPU Slice | $5.50 / hr | $132.00 / day | Flat rate. High throughput
| | | | efficiency.
GCP (GCE VM GPU) | 1x NVIDIA L4 ( g2- | ~$1.01 / hr | $24.24 / day | Provisioned VM. Regular
| standard-4 ) | | | compute VM + GPU charge.
GCP (GCE VM GPU) | 1x NVIDIA A100 (80GB) | ~$3.67 / hr | $88.08 / day | Provisioned VM. Optimized
| | | | for heavy
| | | | training/inference.
GCP Cloud Run (GPU) | 1x NVIDIA L4 (Active) | ~$1.80 / hr | $0.00 / day (If | Scale-to-zero. Pay-per-
| | | idle) | second only when active.
AWS EC2 (GPU) | 1x NVIDIA A10G ( | ~$1.006 / hr | $24.14 / day | Provisioned EC2 instance.
| g5.xlarge ) | | |
AWS EC2 (GPU) | 1x NVIDIA L4 ( g6.xlarge | ~$0.97 / hr | $23.28 / day | AWS newest mid-tier
| ) | | | standard GPU instance.
Azure (GPU VM) | 1x NVIDIA A10 ( | ~$1.21 / hr | $29.04 / day | Provisioned VM.
| NC24ads_A10_v4 ) | | |
Azure (GPU VM) | 1x NVIDIA A100 ( | ~$3.40 / hr | $81.60 / day | Enterprise grade, sharded
| ND96asr_v4 slice) | | | high-compute.
ββββββ
### π Compare and Contrast
#### 1. Google Cloud TPUs vs. GCP Compute Engine (GCE) GPUs
β’ TPU v6e-1 ($1.375/hr) vs. GCE L4 VM (~$1.01/hr): Running a single L4 GPU on GCE is slightly cheaper than a TPU
v6e-1. However, if your model supports JAX/XLA compile paths, the TPU v6e-1 yields higher token throughput,
offsetting the 30% hourly price premium.
β’ TPU v6e-4 ($5.50/hr) vs. GCE A100 VM (~$3.67/hr): An A100 GPU is cheaper hourly than the TPU v6e-4 cluster.
However, under high batch concurrency and long contexts, the TPU v6e-4's pooled memory bandwidth processes requests
up to 8x faster, yielding a much lower cost-per-million-tokens ($0.53/million tokens on TPU vs. $4.24/million
tokens on A100).
#### 2. Cloud Run (Serverless GPU) vs. Always-On VMs (GCP, AWS, Azure)
β’ The Low-Utilization Workload: For developer sandboxes, SRE diagnostics, or internal testing APIs that only run
for a cumulative 1 hour per day, Cloud Run is the absolute winner. You pay only for active request-processing time
(e.g., $1.80/day), while provisioned VMs or TPUs cost a flat $24β$132/day regardless of idle time.
β’ The High-Utilization Workload: If your production API runs 24/7, the serverless overhead of Cloud Run makes it
more expensive than dedicated VMs or TPUs.
#### 3. GCP vs. AWS vs. Azure (GPU VMs)
β’ GCP G2 (NVIDIA L4) vs. AWS G6 (NVIDIA L4): Pricing is neck-and-neck (~$1.01/hr on GCP vs ~$0.97/hr on AWS),
making cloud migration decisions dependent on your existing VPC architectures rather than hardware cost
differentials.
β’ Azure NC/ND instances: Azure's GPU VMs typically carry a minor premium (~$1.21/hr for A10/L4 equivalents) but
provide excellent integration with Azure Container Apps (ACA) for serverless GPU scaling.
Summary
The strategy for using MCP for Gemma 4 GPU deployment with Antigravity CLI was validated with a incremental step by step approach.
A minimal stdio transport MCP Server was started from Python source code and validated with Antigravity CLI running as a MCP client in the same local environment. This Python server provided all of the management tools to deploy and troubleshoot TPU deployments.





Top comments (0)