AI infrastructure

TPU vs GPU: Differences for AI Training and Serving

TPU vs GPU is a question about which accelerator finishes your job for the least money, and the answer depends on the model, the framework and the cloud you already run on. A GPU is a general-purpose parallel processor, sold by NVIDIA and AMD and offered by most clouds. A TPU is a chip Google designed for the matrix math in neural networks, and you rent it from Google Cloud. This guide covers both, then what changes on AWS, where AWS has no TPU at all.

By Jasdeep Bains, SeaGit

·

Key takeaways

  • A GPU is a general-purpose parallel processor. A TPU is an application-specific chip built around matrix multiplication.
  • TPU code must be compiled by the XLA compiler. GPU code usually runs on CUDA and NVIDIA hardware. Your framework and custom operations decide how hard the switch is.
  • TPUs are available only from Google Cloud. AWS does not offer TPUs; it offers NVIDIA GPU instances plus its own Trainium and Inferentia chips.
  • Compare cost to finish your job on your model, not peak specs or hourly price. Measure both before you commit.

What a GPU is

A GPU is a processor built for parallel work. A modern GPU contains thousands of arithmetic logic units that run multiplications and additions at the same time. Neural networks are mostly matrix arithmetic, so this parallelism is why GPUs became the default accelerator for deep learning. Google's own TPU documentation says that on a typical deep learning training workload a GPU can deliver an order of magnitude higher throughput than a CPU.

A GPU is still a general-purpose processor. It has to run many kinds of software, so each calculation reads operands from registers or shared memory and writes results back. The software layer most GPU programs use is NVIDIA CUDA, which NVIDIA describes as the platform for accelerated computing and the foundation for GPU computing.

What a TPU is

A Tensor Processing Unit is an application-specific integrated circuit (ASIC) that Google designs to accelerate machine learning. Google describes it as a matrix processor for neural network workloads. It cannot run a word processor, but it handles large matrix operations quickly.

The core of a TPU is a systolic array. Multiply-accumulate units are wired directly to each other, so each partial result passes to the next unit instead of going back to memory. Google's architecture page says a matrix-multiply unit (MXU) is a 128 x 128 array of multiply-accumulators on TPU versions before v6e, and 256 x 256 on v6e and TPU7x. Inputs are bfloat16 and accumulation is in FP32. Chips carry on-chip high-bandwidth memory (HBM) and can be connected into slices.

Google lists its generations as TPU7x (Ironwood), v6e, v5p, v5e, v4, v3 and v2. Each version has its own chip and slice configurations, so check the page for the one you plan to rent.

Architecture differences

The biggest difference is what each chip is for. A GPU is built to run many kinds of parallel code. A TPU spends its silicon on matrix multiplication and relies on the compiler to map the whole model onto it.

AspectGPU (NVIDIA or AMD)TPU (Google)
Design goalGeneral-purpose parallel processorASIC for matrix operations in neural networks
Core computeThousands of parallel ALUsSystolic array in each matrix-multiply unit
Compiler stepKernels written or selected for the GPUXLA compiles the graph into TPU machine code
Custom operationsWell supported in the training loopPoorly suited when they sit inside the main training loop
Scaling unitMulti-node over the cloud network; on AWS P5, EFA networkingChips connected into slices
Where you rent itMost major clouds, and your own data centerGoogle Cloud only (Compute Engine, GKE, Google's managed AI platform)

Software: CUDA and PyTorch vs XLA, JAX and PyTorch/XLA

The software gap decides most switching projects. GPU code usually runs through CUDA on NVIDIA hardware, and most ML libraries were built on that path first. TPU code must go through XLA, a just-in-time compiler that takes the graph emitted by the framework and compiles the linear algebra, loss and gradient parts into TPU machine code. The rest of the program runs on the TPU host.

  • Google names PyTorch and JAX as frameworks that run on TPUs. Plan for the XLA compile step in both.
  • TensorFlow ops that are not on the Cloud TPU list keep some models on GPU.
  • Custom PyTorch or JAX operations that must run inside the training loop are a common reason teams keep a model on GPU.
  • Moving from CUDA-specific code to XLA is a code change, not a configuration change. Budget engineering time for it.

A practical way to measure the switch: take a checkpoint of your model, run the same training step and the same serving request on each target, and compare step time, memory use and the bill at the same batch size and precision. Keep the input pipeline identical, because a slow data loader can hide the accelerator difference entirely.

Training vs inference

Google's guidance says TPUs suit models dominated by matrix computation, with no custom operations in the main training loop, large effective batch sizes, and training runs that last weeks or months. It also lists ultra-large embeddings in ranking and recommendation workloads as a fit. It says TPUs are a poor fit for linear algebra with frequent branching, many element-wise operations, or workloads that need high-precision arithmetic. Its GPU guidance covers models with many custom PyTorch or JAX operations, models that use TensorFlow ops not on TPU, and medium-to-large models.

Serving is judged differently. The limits are latency per request, whether the model and its cache fit in accelerator memory, and the cost per request at your real traffic. AWS positions Inferentia2 (Inf2) for deep learning inference and the NVIDIA L4 based G6 for inference and graphics. Those are vendor positions, not measurements of your model, so test on your own traffic before you choose.

Availability and lock-in

TPUs are available only from Google Cloud, through Compute Engine, Google Kubernetes Engine and Google's managed AI platform. A TPU workload that moves to another cloud has to move its hardware target as well as its compute. NVIDIA GPUs run on most major clouds and in your own data center, so the hardware is portable even though the CUDA stack still ties you to NVIDIA. Trainium and Inferentia are AWS chips and run only on AWS.

In practice the lock-in sits in the compiler and runtime more than the chip: XLA on TPU, CUDA on NVIDIA, and the AWS Neuron SDK on Trainium and Inferentia. Each one is a toolchain you build on.

If you expect to move between clouds, or to burst to another environment at peak, a GPU-based design keeps the hardware target fixed. A TPU workload stays tied to Google Cloud for as long as it runs there, so decide that before the first long training run.

Cost model: compare cost to finish, not hourly price

A cheaper hourly rate can cost more if the job takes longer or needs weeks of porting. Compare the total cost to finish your training run or to serve your traffic for a month. This article quotes no prices, because prices change by region, commitment and spot or on-demand choice. Check the provider pricing pages for the exact configuration you would use.

  • Hourly price of the instance or slice in the region and purchase option you would really use.
  • Utilization. An accelerator waiting on data bills the same as one doing work.
  • Time to finish, measured on your model, with the same batch size and precision on each side.
  • Engineering cost of porting to XLA or Neuron, and of debugging the port.
  • Storage, data transfer and the cluster network around the accelerator.
  • Capacity. Accelerator instances can be scarce in some regions, and reservations or capacity blocks change the price model.

Side by side: which one fits which job

Use this table as a starting point. The decision rests on your model, your framework and the cloud you already pay for.

JobLean GPULean TPU or AWS chip
Custom CUDA kernels or many custom opsYesNo
Matrix-heavy training, JAX or PyTorch, long runsPossibleTest on TPU (Google Cloud)
Portable across clouds or on-premisesYesNo
Stay on AWS, lower-cost training or inferenceNVIDIA GPU instancesTest Trainium or Inferentia through Neuron
Need Google TPU hardwareNot an optionGoogle Cloud only

Decision checklist

  • Is your code PyTorch or JAX on NVIDIA today, with custom CUDA kernels? Stay on GPU.
  • Do you already run on Google Cloud, with a matrix-heavy model and no custom ops in the training loop? Benchmark a TPU run against your GPU run.
  • Do you run on AWS and want a lower-cost option? Check that your operations are supported by Neuron, then test Trainium for training or Inferentia for inference.
  • Do you need portability across clouds or on-premises? Choose GPU.
  • Do you need to serve an LLM without managing accelerators at all? Consider a managed model API before you buy any accelerator.
  • Did you measure time to finish and total cost on your own model? If not, you have an opinion, not a decision.

On AWS: GPUs, Trainium and Inferentia

AWS does not offer Google TPUs. Its AI accelerators on EC2 are NVIDIA GPUs and its own chips. The EC2 pages name these families:

  • P5 instances, powered by NVIDIA H100 GPUs, and P5e and P5en, powered by NVIDIA H200 GPUs, for deep learning and HPC applications.
  • G6 instances, powered by NVIDIA L4 GPUs, for deep learning inference and graphics.
  • Trn2 instances, powered by 16 AWS Trainium2 chips, for training and deploying generative AI models, with native PyTorch and JAX support.
  • Inf2 instances, powered by AWS Inferentia2 chips, for deep learning inference, including large language models.
  • AWS Neuron SDK, which compiles and runs models on Trainium and Inferentia. It supports PyTorch and JAX, and vLLM Neuron for serving LLMs.

Neuron changes the toolchain, so check that your model and its custom operations are supported before you plan a move. The price and performance case for Trainium or Inferentia has to be measured on your workload, not taken from the marketing pages.

If your team already runs PyTorch on NVIDIA GPU instances, the lowest-change first step on AWS is to keep the GPU instances and measure cost per run. Port to Trainium or Inferentia only when the measured saving covers the engineering time.

Where SeaGit fits

SeaGit deploys apps to Amazon EKS in your own AWS account. It runs on AWS only and does not offer TPUs or Google Cloud and Azure targets.

What the product code shows about accelerators: the node group form offers instance types from the P3, P4d, P5, G5, G4dn, Trn1, Inf1 and Inf2 families, with labels for GPU or Trainium or Inferentia hardware. Some of these are marked as having limited spot capacity. The RAG stack and the LLM gateway call Amazon Bedrock models, so their model inference does not run on a node you manage.

What to check before you schedule GPU pods

The node group picker chooses the instance. I found no NVIDIA driver, GPU AMI, Neuron device plugin or GPU scheduling setup in the SeaGit platform code. Confirm the driver, device plugin and container image for your accelerator in your own cluster before you rely on a GPU node.

Frequently asked questions

TPU vs GPU: Differences for AI Training and Serving: FAQ

Is a TPU faster than a GPU?

It depends on the model and the job. Google describes where TPUs fit well and where GPUs fit better, and neither wins every case. Measure time to finish and total cost on your own model and batch size.

Can I run TPUs on AWS?

No. AWS does not offer Google TPUs. On AWS you choose NVIDIA GPU instances, or AWS Trainium and Inferentia chips through the Neuron SDK.

Does code have to change to run on a TPU?

Yes, at least the compile step. TPU code must be compiled by XLA, and models with custom operations or unsupported TensorFlow ops need more work. Simple PyTorch or JAX training loops are the easiest to port.

Are GPUs only from NVIDIA?

No. AMD also makes data center GPUs. Much of the ML tooling, however, is built on CUDA first, so NVIDIA is the default for most teams.

Which one is cheaper?

There is no general answer. The cheaper option is the one with the lowest total cost to finish your job, including utilization and porting time. Compare on your workload using each provider pricing page.

Does SeaGit run TPU workloads?

No. SeaGit deploys to Amazon EKS in your own AWS account. The node group form can select GPU, Trainium and Inferentia instance types, and you must confirm the accelerator software setup for your workload.

Sources

Checked 12 October 2026.

  1. Google Cloud: Introduction to Cloud TPU — What a TPU is, when to use CPUs, GPUs and TPUs, and the XLA compile requirement.
  2. Google Cloud: TPU architecture — Systolic arrays, MXU sizes, TPU versions and the Compute Engine, GKE and Vertex AI access paths.
  3. NVIDIA: CUDA platform — CUDA as NVIDIA platform for accelerated computing and GPU computing.
  4. AWS: Trainium — Trainium as an AWS chip for training and inference.
  5. AWS: Amazon EC2 Trn2 instances — Trn2 instances with 16 Trainium2 chips and native PyTorch and JAX support.
  6. AWS: Amazon EC2 Inf2 instances — Inf2 instances with Inferentia2 chips for deep learning inference.
  7. AWS: Amazon EC2 P5 instances — P5, P5e and P5en NVIDIA GPU instances and EFA networking.
  8. AWS: Amazon EC2 G6 instances — G6 instances with NVIDIA L4 GPUs for inference and graphics.
  9. AWS Neuron documentation — The Neuron SDK for Trainium and Inferentia, including PyTorch, JAX and vLLM Neuron.

Read next