Model and Modality PlaybooksNovember 23, 2026Flatkey Team

TPU vs GPU: choose based on workload, software, and total cost

A roadmap for inventorying dependencies, comparing equivalent workloads, and calculating migration costs without turning assumptions into benchmarks.

TPU vs GPU: choose based on workload, software, and total cost

By Flatkey Team. Sources and calculations checked on November 23, 2026.

The TPU vs GPU comparison starts with the program your team needs to run. Before looking at the chip's advertised capacity, list the model, operators, extensions, data format, and project timeline. An accelerator only enters the economic comparison after it runs the workload at the required quality.

For a team with existing CUDA code, the first baseline should be that environment working. A TPU alternative deserves a test when there is a compatible software path and time to validate the change. Having a model load does not demonstrate that training converges, that inference meets latency requirements, or that the migration is worthwhile.

This guide provides a compatibility checklist, a test protocol, and a reproducible budget calculation. We did not run a GPU or TPU benchmark for this article. The Python example was run on CPU and only recalculates stated assumptions. There are no rental prices, availability promises, or customer results.

The hardware difference that matters for the decision

A TPU is an accelerator designed by Google for machine learning workloads; a GPU serves a broader range of parallel computing tasks. This distinction helps frame questions, but it does not choose the platform for you. The official Cloud TPU introduction distinguishes suitable situations according to operations, formats, and effective batch sizes.

Compare specific configurations. Record the generation, number of devices, available memory, interconnects, and host resources. One card, a machine with multiple GPUs, and a TPU slice are different units. The hourly rate only makes sense after defining what is included in each allocation.

TPU vs GPU: a short decision guide

Your project situation Next useful test Evidence required to proceed
Code depends on specific CUDA extensions Reproduce the GPU environment and inventory every extension Versions, operators used, and a documented alternative for each dependency
The model already has a maintained TPU path in the selected runtime Run a small, representative copy Validated output, memory profile, and behavior with your formats
The prototype frequently changes shape and size Test the actual input distributions Observed preparation, execution, and recompilation times
The work has a short deadline and runs only a few times Measure the adaptation effort before reserving capacity Engineering hours and payback timeline approved by the team
The workload will be repeated over several periods Compare recurring cost and upfront cost separately Useful throughput, quality, availability, and auxiliary costs
You lack your own weights or the need to manage machines Also compare a model API Same task set, acceptance criteria, and total budget

The rows are an investigation guide. They do not claim that every GPU supports every library or that every TPU is efficient at a given batch size. Record the result of the test your team actually ran, including failures.

Create the software inventory before requesting quotes

Use one row per dependency. Avoid the generic answer “uses PyTorch,” which hides versions, custom kernels, and serving tools.

Field What to record When to mark as pending
Model and weights Repository, revision, license, and checkpoint format Only another model or precision has been validated
Operators Standard operations and extensions used by the actual path An operation has no validated implementation
Runtime Backend, version, container image, and installation method The example depends on a different version
Precision Weight format, activations, and numerical criteria Quality has not yet been assessed in this format
Memory Weights, states, cache, buffers, and observed headroom Only the chips' advertised memory has been added up
Distribution Number of processes, parallelism, and topology The test used one device and the proposal uses several
Operations Checkpointing, restart, logs, and monitoring The service only worked in a manual run

The goal is to produce a verifiable list, not a subjective rating. If an essential operation remains pending, keep the cost comparison on hold. You can research an alternative, but do not record the migration as resolved.

Beware of old PyTorch tutorials for TPU

As checked on November 23, 2026, the older PyTorch/XLA documentation displays a deprecation notice and directs new work to TorchTPU. The current Google guide presents TorchTPU as a native PyTorch backend and provides guidance for migrating existing workloads.

This changes the inventory: record which backend the tutorial uses, which one is installed, and which one the target runtime supports. Current documentation describes eager execution and compilation integration; it does not replace testing your application's extensions and model. Do not copy old execution-marking instructions to a different backend without checking the corresponding guide.

For inference, the decision also involves the server. Our guides on TensorRT-LLM vs vLLM and vLLM vs SGLang help distinguish the choice of engine, format, and testing method. Mentioning a framework does not guarantee support for every model on every accelerator.

How to design a comparable test

Write the acceptance criterion before measuring. For inference, it can combine response validity, correct task completion, and a latency limit. For training, it can include validation quality, stability, and the ability to resume from a checkpoint. Use exactly the same rule for both candidates.

  1. Freeze the inputs. Save the model revision, evaluation set, transformations, input sizes, and precision. If you adapt a component, record that difference.
  2. Test the minimum path. Load the model and run representative examples. An operator or memory error is a test result, not a reason to silently change the workload.
  3. Separate setup from recurring execution. Record initialization and compilation, then run the warmed-up workload. For a short task, the initial cost can be material.
  4. Wait for actual completion. Do not time only asynchronous submission. In the JAX documentation on JIT, the measurement example separates warm-up and uses block_until_ready() to wait for the work.
  5. Vary relevant inputs. Include batch sizes, input sizes, and concurrency that exist in your project, rather than only a favorable case. Note out-of-memory events, recompilation, and wait time.
  6. Compare accepted work. Count outputs that passed quality control. Retries, failures, and idle time still count when they are billed.

Do not mix the latency of one request with the throughput of a large batch. Also, do not compare only the GPU on one side with the cost of the entire server on the other. First equalize the test boundary; then explain the differences that cannot be equalized.

Template to copy for your test

model_and_revision:
backend_and_version:
environment_image:
accelerator_and_quantity:
memory_and_topology:
precision_and_format:
inputs_and_size_distribution:
quality_rule:
latency_limit:
setup_and_compilation:
synchronization_method:
total_work_and_accepted_work:
failures_retries_and_idle_time:
allocation_cost_and_auxiliary_costs:
migration_effort:

Fill in “not measured” when an observation is missing. The template is a test plan, not a claim that these measurements were performed for this article.

A transparent TPU vs GPU calculation

Consider two fictional candidates, A/GPU and B/TPU, serving the same accepted work per period. All rates below are in budget units (BU), with no connection to a currency, vendor, or commercial price list. The durations are also assumptions; they were not measured on the accelerators.

Assumption per period A/GPU B/TPU
Allocation rate, BU/h 12 10
Execution, billed hours 100 80
Setup, billed hours 0.5 2
Auxiliary costs, BU 100 160
Accepted jobs 10000 10000
Initial migration, engineering hours 0 16

The engineering hour is another assumption: 50 BU. B's initial migration cost is therefore 800 BU. The calculation is:

recurring_cost = rate × (execution + setup) + auxiliary_costs
initial_cost = recurring_cost + migration
cost_per_accepted_job = total_cost / accepted_jobs

A costs 1306 BU per period. B costs 980 BU to operate, but 1780 BU in the first period when migration is included. The initial costs per accepted job are 0.1306 and 0.178 BU, respectively.

In this invented scenario, B's recurring savings would be 326 BU per period. Dividing 800 by 326 results in approximately 2.454 periods; by the end of the third period, totals would be 3918 for A and 3740 for B. This conclusion applies only if workload, prices, quality, and costs remain as assumed. It is not a recommendation to procure a TPU.

Sensitivity to migration effort

B migration hours Initial migration cost Calculated continuous payback First full period in which B costs no more
8 400 BU 1.227 periods 2
16 800 BU 2.454 periods 3
32 1600 BU 4.908 periods 5

The hourly rate is identical across all three lines, but the timeline changes. If the project will only have two periods and the adaptation requires 32 hours, the hypothetical operational savings will not pay for the change within that timeframe. If there are no positive recurring savings, the formula does not yield a finite return.

The script below was run on Python 3.14.6, on macOS arm64, without a GPU, TPU, or API calls. It uses Decimal for the calculation and refuses the comparison when compatibility or quality have not been confirmed. The assert statements verify the arithmetic in the example; they do not verify hardware.

"""Recalculo CPU de orcamento hipotetico; nao mede GPU ou TPU."""
from decimal import Decimal, ROUND_CEILING
import json, platform, sys
D = Decimal

def period_cost(rate, run_hours, setup_hours, extras):
    values = tuple(map(D, (rate, run_hours, setup_hours, extras)))
    if any(x < 0 for x in values):
        raise ValueError('Valores negativos nao sao permitidos')
    rate, run_hours, setup_hours, extras = values
    return rate * (run_hours + setup_hours) + extras

def compare(gpu, tpu, accepted, engineering_rate, migration_hours,
            compatibility_ok=True, quality_ok=True):
    if not (compatibility_ok and quality_ok):
        return {'decision': 'teste pendente; nao comparar custo'}
    accepted = D(accepted)
    if accepted <= 0:
        raise ValueError('O denominador deve ser positivo')
    migration = D(engineering_rate) * D(migration_hours)
    if migration < 0:
        raise ValueError('Custo de migracao invalido')
    saving = gpu - tpu
    breakeven = migration / saving if saving > 0 else None
    return {
        'gpu_first_period': str(gpu),
        'tpu_first_period': str(tpu + migration),
        'gpu_cost_per_accepted_job': str(gpu / accepted),
        'tpu_first_cost_per_accepted_job': str((tpu + migration) / accepted),
        'tpu_recurring_cost_per_accepted_job': str(tpu / accepted),
        'migration_cost': str(migration),
        'recurring_saving_per_period': str(saving),
        'break_even_periods': str(breakeven) if breakeven is not None else None,
        'first_integer_period_not_more_expensive': (
            int(breakeven.to_integral_value(rounding=ROUND_CEILING))
            if breakeven is not None else None),
    }

def main():
    gpu = period_cost('12', '100', '0.5', '100')
    tpu = period_cost('10', '80', '2', '160')
    base = compare(gpu, tpu, '10000', '50', '16')
    assert gpu == D('1306.0') and tpu == D('980')
    assert base['first_integer_period_not_more_expensive'] == 3
    assert 3 * gpu == D('3918') and 3 * tpu + D('800') == D('3740')
    blocked = compare(gpu, tpu, '10000', '50', '16', compatibility_ok=False)
    assert 'gpu_first_period' not in blocked
    print(json.dumps({
        'kind': 'hipoteses; nenhuma execucao de GPU ou TPU',
        'environment': {'python': sys.version.split()[0], 'platform': platform.platform()},
        'base': base,
        'migration_sensitivity': [
            {'hours': h, **compare(gpu, tpu, '10000', '50', h)}
            for h in ('8', '16', '32')],
        'compatibility_blocked': blocked,
    }, ensure_ascii=False, indent=2))

if __name__ == '__main__':
    main()

Replace the assumptions with a real proposal and observations from your trial. Keep the same denominator of accepted work. If the TPU completes fewer tasks at acceptable quality, do not reuse 10000 just to keep the table favorable.

What to request before reserving capacity

In a TPU vs GPU quote, request the exact accelerator model, quantity, region, host resources, availability timeline, and interruption policy. Confirm storage, transfer, support, and setup billing terms. For committed capacity, include idle time and cancellation rules in the budget.

Do not assume that the region where your data is located already offers the desired resource. Validate data location and the connection between storage and compute. If the team depends on distributed access, confirm the topology in the offered environment rather than inferring it from the chip name.

On the Flatkey compute page, you can provide GPU requirements, quantity, region, and period to confirm configuration and terms through a formal proposal. This page does not constitute a TPU offer. Flatkey publishes this guide and offers commercial GPU and API services; the presence of links to these services is a commercial relationship of its own, not an independent vendor evaluation.

Frequently asked questions

Is a TPU always faster than a GPU?

That conclusion cannot be made without configuration, workload, software, and measurement method. A useful comparison includes quality, setup, memory, throughput, and latency under the same load. This article did not perform a speed test between the two accelerator types.

Is it possible to migrate just by changing the device name?

Some examples may work with few changes, but the inventory must cover operators, extensions, precision, distribution, and operation. Use the current documented backend and record which dependencies were actually validated. “It ran once” and “it meets production requirements” are different criteria.

How should the cost example be used without confusing it with a real price?

Replace each input with the corresponding proposal and measurement. Keep engineering hours, setup, ancillary costs, and accepted work visible. The example's BU do not represent Brazilian reals, dollars, cloud credits, or Flatkey prices.

When should you continue with the existing GPU?

When it already meets the quality and timeline requirements, and an alternative has not yet passed validation or does not recoup the migration effort within the project horizon. This is a decision based on your constraints. Review it when the model, volume, availability, or commercial terms change.

Next step

To decide TPU vs GPU, complete the compatibility checklist, run a comparable trial, and only then calculate the cost per accepted job. Keep revisions and results to repeat the decision when the workload changes. If an essential test is missing, the correct result is “pending,” along with the next required test.

Back to the English blog.