The post helps with estimating the number of GPUs for ML modeling, it covers both LLMs and recommendation systems.
Assumptions and everyday numbers
Every estimate in this post uses the values below. They are rounded so the arithmetic stays easy to do in your head.
| Quantity | Value used | Note |
|---|---|---|
| Seconds in a day | 100,000 | exact value is 86,400 |
| Price of one accelerator | 2 USD per chip-hour | a committed or internal rate |
| Peak compute of one accelerator | 1,000 TFLOP/s in bf16 | TPU v6e 918 H100 989 |
| Sustained compute | 400 TFLOP/s | about 40% of peak (Section 2.3) |
| Accelerator memory | 32–80 GB HBM | TPU v6e 32 GB H100 80 GB A100 (both 40GB/80GB option) |
| Accelerator memory bandwidth | 1.6–3.35 TB/s | TPU v6e, H100 |
| A few CPU cores | 100 GFLOP/s and 50 GB/s | a rough working assumption |
| Price of one CPU core | 0.05 USD per vCPU-hour | on-demand cloud |
Rules
R1 Bytes per number
4B params in bf16 takes 8 GB
| Format | Bytes per number | Typical use |
|---|---|---|
| fp32 | 4 | optimizer state master copy of weights in training |
| bf16 / fp16 | 2 | weights and activations in training and serving |
| int8 / fp8 | 1 | quantized serving |
| int4 | 0.5 | aggressively quantized serving |
R2 FLOPs
- N = params that sits inside matmul
- Embedding tables in recsys are excluded
- A lookup is a gather; pooling is a few adds
- An LLM’s output layer (projection to the vocabulary) counts, even when it shares weights with the input embedding.
- MoE: active params for FLOPs, total params for memory
- Embedding tables in recsys are excluded
- Tokens
- examples for non-sequence models
- Candidates for a ranker
- Inference FLOPs = 2 x N x tokens
- Training FLOPs = 6 x N x tokens
- 2 forward pass
- 1 multiply and 1 add
- 4 backward pass
- 2 additional matmuls
- 1 intermediate gradient and 1 for weight
- 2 forward pass
forward Y = X · W 2 · T · d_in · d_outinput gradient dX = dY · Wᵀ 2 · T · d_in · d_out (passed to the layer below)weight gradient dW = Xᵀ · dY 2 · T · d_in · d_out (used to update W)
R3 Training memory
- Training memory is 16 bytes per param in mixed precision training ( 1 bytes = 1B = 8b = 8 bits )
- 1 weight ( stored in bf 16 ) ( 2 bytes )
- 1 gradient ( stored in bf 16 ) ( 2 bytes )
- 2 Adam param
- running mean of gradient ( stored in fp32 ) ( 4 bytes )
- running mean of square of gradient ( stored in fp32 ) ( 4 bytes )
- Total
- 4 number
- 12 bytes
- Master copy of weights in fp32 ( 4 bytes )
- Total
- 16 bytes
R4 Time / Latency calculation
t_compute = FLOPs ÷ sustained FLOP/st_memory = bytes read ÷ bandwidtht ≈ max(t_compute, t_memory) + fixed overhead-----------
Arithmatric Intencity I = FLOPs / (bytes read)We can calculate from params and architecture For bf 16, I = (2 * T * P) FLOPs / (2 * P ) bytes = T Remains same for training and inference as just param P changes for both----------Ridge R = peak FLOPs / bandwidth We get it from the spec sheet
| H100 | R = 989T / 3.35T = 300 |
| TPU v6 | R = 918T ÷ 1.64T = 560 |
| CPU | R = 100G ÷ 50G = 2 |
- How it is used
- If I > P
- Arch is compute bound
- Else
- its memory bound
- If I > P
R5 Cost
cost = chip-hours × 2 USD1 chip-year = 8,760 h × 2 USD ≈ 17,500 USD
Questions
Q1 ML Server and data movement
- ML Server / host
- CPU + main memory (DRAM)
- 8 accelerators ( each has its own memory called HBM )
- An 80 GB H100 means it has 80GB on the chip
- Examples
- DGX H100
- 8 GPUs x 80 GB = 640 GB HBM in one host
- TPU v6e host
- 8 chips x 32 GB HBM
- 1536 FB of DRAM
- DGX H100
| Link | Connects | Bandwidth |
|---|---|---|
| HBM | a chip and its own memory | 3.35 TB/s |
| NVLink | GPU to GPU, same server | 900 GB/s |
| PCIe Gen5 | GPU to the host’s CPU and DRAM | 128 GB/s |
| Network card | server to server | 50 GB/s for a 400 Gb/s card |
- NVLink – NVIDIA’s direct GPU-to-GPU link inside a server. GPUs read each other’s memory without going through the CPU.
- TPU version is ICI (inter-chip interconnect): 800 GB/s per chip, across a whole 256-chip pod
- NVIDIA also has pod structure with DGX SuperPOD
- TPU version is ICI (inter-chip interconnect): 800 GB/s per chip, across a whole 256-chip pod
- Network cards are rated in bits. Divide by 8: 400 Gb/s = 50 GB/s
- Take away:
- HBM is ~4× NVLink
- ~25× PCIe
- ~70× the network.
- Keep data that is read often in HBM, and move data between chips as rarely as possible
- HBM is ~4× NVLink
Q2 GPU Utilization
- Typical utilization
- Large-scale training: 40–55%. NVIDIA reported 54.2% training a 530B model on 2,240 A100 GPUs
- LLM prefill (reading the prompt): 40–60%. Big matrices over many tokens.
- LLM decode (writing the answer): 1–20%. Memory bound (Q7).
- Why training has better utilization than inference
- With masking, you can run prediction for token at pos 10 and pos 11 in parallel
- What causes utilization to be low
- Waiting on memory – the matrix units sit idle until weights and activations arrive from HBM.
- Waiting on other chips – gradients, parameters or embeddings travel between chips, and not all of it hides behind compute.
- Non-matmul work – softmax, layer norm, activation functions and the optimizer step run on slower vector units.
- Small matrices – a TPU v6e matrix unit is a 256 × 256 grid. A matmul with 16 rows leaves most of it idle.
- Fixed overheads – kernel launches, Python, data loading, idle time at the start and end of a pipeline.
- Note on sparsity
- Sometimes number are reported with 2:4 sparsity
- The H100’s 1,979 TFLOP/s bf16 is that sparse number; dense is 989. Use dense unless you prune
Q3 Num of req to QPS
- 1 day = 100k seconds
- 1B request / day = 10k QPS
- Traffic is not flat. Peak hour is ~2–3× the daily average, and capacity is planned for the peak.
- What the model sees depends on how many items it scores per request:
- Ranker scores every candidate: 10,000 QPS × 1,000 candidates = 10M scores/s.
- Retriever or LLM is called once per request: it sees 10,000 QPS.
Q4 Calculate memory footprint of 4B param model
- Short answer: 8 GB to serve in bf16, 64 GB to train with Adam, before the KV cache and activations.
- It depends on three things: serving or training, precision, and model type.
Serving:
- Weights = params × bytes. Same for every model type.
bf16 4B × 2 B = 8 GBint8 4B × 1 B = 4 GBint4 4B × 0.5 B = 2 GB
- An LLM also keeps a KV cache, which grows with batch × context (Q8). Qwen3-4B needs 147 KB per token, so one 4K-token request adds ~0.6 GB.
Training:
- Dense LLM: 16 B × 4Bytes = 64 GB (Rule 3), before activations (Q10).
- MoE with 4B total params: also 64 GB. Every expert sits in memory; only FLOPs use the active params.
- RecSys: depends on the embedding share. Embedding tables are trained with row-wise Adagrad, one number per row, instead of Adam (Q11)
RecSys, 4B params, 64-dim embeddings, row-wise Adagrad 99% embeddings 70% embeddingsembeddings (fp32) 3.96B × 4 Bytes = 15.8 GB 2.8B × 4 Bytes = 11.2 GBoptimizer state 1 number/row = 0.2 GB 0.2 GBdense (Adam, 16 B) 40M × 16 Bytes = 0.6 GB 1.2B × 16 Bytes = 19.2 GBtotal ≈ 17 GB ≈ 31 GB
What embedding share is typical?
- RecSys: usually 95–99%+. The dense part is tens of millions of params; tables hold billions.
- LLM: 3–20%, falling as models grow. Qwen3-4B ~10%, Llama 3 8B ~13%, Llama 3 70B ~3%.
- For an LLM the share barely changes memory, because every weight, embeddings included, is trained with Adam.
- Take away: the same 4B params need anywhere from 17 GB to 64 GB to train, depending on what kind of params they are.
Q5 Calculate FLOPs per request
- Short answer: 2 × N × tokens (Rule 2). The work is in deciding what N and tokens are for each model type.
- Request is referring to inference time here
LLM – worked on Qwen3-4B:
- Config values used below :
| Field | Symbol | Value |
|---|---|---|
| Layers | L | 36 |
| Hidden size | h | 2,560 |
| Query heads | a | 32 |
| KV heads | a_kv | 8 |
| Head dimension | d_head | 128 |
| Attention width (a × d_head) GQA-group query attention | d_attn | 4,096 |
| MLP inner size | d_ff | 9,728 |
| Vocabulary | V | 151,936 |
| Input embedding shared with output layer | yes |
- Param count. Attention has 4 matrices (Q, K, V, O); K and V are narrow because there are only 8 KV heads. The MLP (SwiGLU) has 3 matrices.
Q h × d_attn = 2,560 × 4,096 = 10.5MK h × (a_kv × d_head) = 2,560 × 1,024 = 2.6MV = 2,560 × 1,024 = 2.6MO d_attn × h = 4,096 × 2,560 = 10.5MMLP 3 × h × d_ff = 3 × 2,560 × 9,728 = 74.7Mper layer ≈ 101M ( sum of all above ) 36 layers ≈ 3.63Bembedding V × h = 151,936 × 2,560 ≈ 0.39Btotal ≈ 4.0B
- All 4.0B count. The input lookup is free, but the same 0.39B matrix is reused as the output layer, which is a real matmul.
FLOPs per token ≈ 2 × 4.0B = 8 GFLOPs1,000-token prompt ≈ 8 TFLOPs
- Attention adds work that is not in the weights
- Context c = number of tokens the current token can see: every earlier token, plus itself.
- Per layer, the token scores its query against c keys, then takes a weighted sum of c values.
scores 2 · c · d_attnweighted sum 2 · c · d_attnper token 4 · L · c · d_attnprompt of S tokens: average c = S/2, so 2 · L · S · d_attn per tokenS = 1,000: 2 × 36 × 1,000 × 4,096 ≈ 0.3 GFLOPs (~4% of 8 GFLOPs)equal to weight FLOPs when S = N ÷ (L × d_attn) = 4.0B ÷ (36 × 4,096) ≈ 27,000
- So ignore attention below a few thousand tokens. Past ~20K it dominates.
Ranker:
- YouTube ranker – 25M params | 50M FLOPs (per candidate).
- 25M is a working number for the dense part, not a published figure.
- Embedding tables add params but no FLOPs (Rule 2).
FLOPs per request = candidates × 2 × dense params = 1,000 × 50M = 50 GFLOPs
- Many features depend only on the user or the request. Request-only optimization (ROO) computes that part once per request instead of once per candidate.
- It inference time also we can split model into RO arch and merged arch. (disagg setup)
MoE – generative retriever:
- Generative retriever – 1B activated params MoE, 1,000-token context prefill.
FLOPs per request = 2 × 1B active × 1,000 tokens = 2 TFLOPs
Sequence RecSys (HSTU-style):
- Past actions become tokens and the same dense weights run at every position, like an LLM.
FLOPs per request ≈ 2 × N × (history length + candidates)
Q6 Calculate time taken per request
- Make two estimates and take the larger one (Rule 4).
- Compute: FLOPs ≈ 2 × non-embedding params × tokens.
- Time = FLOPs ÷ the FLOP/s your hardware actually sustains.
- Memory: at batch size 1, each forward pass reads every weight once.
- Time ≥ weight bytes ÷ memory bandwidth.
- Compute: FLOPs ≈ 2 × non-embedding params × tokens.
Example – BERT-base on a 16-token query:
- Non-embedding params: 12 layers × 12 × 768² ≈ 85M. The other ~25M are embeddings.
- 12 × h² per layer = 4h² attention + 8h² MLP (two h × 4h matrices).
- BERT as an encoder has no vocabulary output layer, so only the 85M count.
- Compute: 2 × 85M × 16 ≈ 2.7 GFLOPs.
- CPU sustaining ~100 GFLOP/s: ~27 ms.
- GPU at ~10 TFLOP/s: ~0.3 ms.
- Utilization we took – only ~1% of peak, because 16 rows leave most of the matrix units idle (Q2).
- Memory: 85M × 4 bytes (fp32) = 340 MB.
- CPU at ~50 GB/s: ~7 ms. In int8 it’s 85 MB, ~2 ms.
- GPU at 3.35 TB/s: ~0.1 ms
- Which one wins?
- Intensity = 2 × 16 FLOPs per 4-byte weight = 8 FLOP/byte.
- CPU: 8 > ridge of 2, so compute bound. ~27 ms.
- GPU: both under 0.5 ms. At batch 1, a couple of hundred kernel launches at a few µs each dominate, so expect ~1–2 ms. Batching queries fixes it.
Why does int8 speed up this CPU case?
- Not because of memory. The CPU is compute bound, so cutting 7 ms of memory time to 2 ms leaves the 27 ms unchanged.
- The int8 math itself is faster. A vector register holds 4× as many int8 numbers as fp32, and VNNI instructions do an int8 multiply-and-accumulate in one step. Expect ~2–4× on the compute side.
- The memory saving matters when each call processes only 1–2 tokens.
Cost on CPU (assume the 100 GFLOP/s comes from 4 vCPUs):
per query 0.027 s × 4 vCPUs = 0.108 vCPU-secondsper million queries 10⁶ × 0.108 ÷ 3,600 = 30 vCPU-hours × 0.05 USD = 1.5 USD
Q7 Why is LLM decoding slow
- Short answer: decode reads all the weights to produce one token per sequence, so it is memory bound.
- Serving a request has two phases with opposite bottlenecks.
Prefill – reading the prompt:
- All prompt tokens go through in one pass. 1,000 tokens per weight read is above the ridge, so it is compute bound (Rule 4).
Qwen3-4B on H100, 1,000-token promptt_compute = 1,000 × 8 GFLOPs ÷ 400 TFLOP/s = 20 mst_memory = 8 GB ÷ 3.35 TB/s ≈ 2.4 mstime to first token ≈ 20 ms
Decode – writing the answer:
- One new token per sequence per step. With B sequences batched, intensity I = B.
- Memory bound, so the chip delivers I × bandwidth FLOP/s:
MFU ≈ B ÷ RB = 1: 1 ÷ 300 ≈ 0.3%B = 64: 64 ÷ 300 ≈ 21% (upper bound)300 is Ridge of H100
- Real decode is lower, because each sequence also reads its own KV cache, and that read is not shared across the batch.
H100, 64 requests × 4K-token context, Qwen3-4Bbytes per step = 8 GB weights + 39 GB KV cache = 47 GBstep time = 47 GB ÷ 3.35 TB/s ≈ 14 msthroughput = 64 tokens ÷ 14 ms ≈ 4,600 tokens/sMFU = (64 × 8 GFLOPs ÷ 14 ms) ÷ 989 TFLOP/s ≈ 4%
- Take away: batching is the main lever for decode, and the KV cache decides how big the batch can get (Q8).
Q8 How much context fits on GPU
- Short answer: for Qwen3-4B, ~400K tokens on an H100 and ~135K on a TPU v6e. The KV cache, not the weights, fills the chip.
What is the KV cache?
- Every new token attends to the keys and values of all earlier tokens. Recomputing them each step would waste work, so they are stored. ( Read vLLM post)
- Per token and per layer, it stores one key and one value vector for each KV head:
KV bytes per token = 2 × L × a_kv × d_head × bytes per number (2 = one K + one V)
MHA vs GQA:
- option 1 – Multi-head attention (MHA), the original design. Every query head has its own K and V head, so a_kv = a = 32.
- option 2 – Grouped-query attention (GQA), which Qwen3-4B uses. 32 query heads share 8 KV heads, 4 per group, so a_kv = 8.
MHA 2 × 36 × 32 × 128 × 2 B = 589,824 B ≈ 590 KB per tokenGQA 2 × 36 × 8 × 128 × 2 B = 147,456 B ≈ 147 KB per token (4× smaller)
| Load | Tokens cached | MHA | GQA |
|---|---|---|---|
| 1 request, 1K context | 1,000 | 0.6 GB | 0.15 GB |
| 1 request, 32K context | 32,768 | 19 GB | 4.8 GB |
| 64 requests, 4K context each | 262,144 | 155 GB | 39 GB |
- With 64 requests, the GQA cache (39 GB) is ~5× the weights (8 GB). The MHA version would not fit on one H100 at all.
How many tokens fit?
tokens that fit = (HBM − weights − headroom) ÷ KV bytes per token
- H100, 80 GB: ~60 GB left for the cache. 60 GB ÷ 147 KB ≈ 400K tokens.
- TPU v6e, 32 GB: ~20 GB left. 20 GB ÷ 147 KB ≈ 135K tokens.
- Batch size × context length has to stay under this. Since throughput grows with batch size, the cache sets throughput.
Q9 How many chips do I need for serving ?
- Short answer: divide the FLOPs needed at peak by what one chip sustains, then check that the model fits and that one request finishes in time.
chips = peak QPS × FLOPs per request ÷ sustained FLOP/s per chip
Example – ranker vs generative retriever, same traffic:
- Say 1B requests/day: ~12K QPS on average, ~25K at peak (Q3).
- Chip: 400 TFLOP/s sustained, 32 GB, 1.6 TB/s (TPU v6e class).
Ranker (25M dense params, 1,000 candidates)FLOPs per request = 1,000 × 2 × 25M = 50 GFLOPsFLOP/s needed = 25,000 × 50 GFLOPs = 1.25 PFLOP/schips = 1.25e15 ÷ 4e14 ≈ 3Generative retriever (1B active, 1,000-token prompt)FLOPs per request = 2 × 1B × 1,000 = 2 TFLOPsper chip = 4e14 ÷ 2e12 = 200 requests/schips = 25,000 ÷ 200 = 125cost = 125 × 17,500 USD ≈ 2.2M USD per year
- Ranker: compute is not the problem. Server count will come from embedding memory and lookup speed (Q11).
- Retriever: check memory. An MoE holds all experts, so memory uses total params. Assume ~8B total.
weights = 8B × 2 B = 16 GB fits in 32 GB, 16 GB left for the KV cachet_memory = 16 GB ÷ 1.6 TB/s = 10 ms per read of the weightst_compute = 2 TFLOPs ÷ 400 TFLOP/s = 5 ms per request
- One request at a time is memory bound (10 ms > 5 ms). Batching ~5 requests per weight read makes it compute bound, which the 200 requests/s already assumes.
- Our formula for coming up with request per chip assumed that memory bandwidth is not the problem
- Take away: same traffic, ~3 chips vs ~125 chips. Count FLOPs per request before choosing the model.
Q10 Training cost and number of chips
- Short answer: compute is 6 × N × tokens (Rule 2). For a fine-tune that is cheap; memory decides the chip count.
Compute, Qwen3-4B:
fine-tune on 1B tokens 6 × 4e9 × 1e9 = 2.4e19 FLOPs ÷ 4e14 FLOP/s = 6e4 s ≈ 17 chip-hours ≈ 33 USDpretrain on 10T tokens 6 × 4e9 × 1e13 = 2.4e23 FLOPs ÷ 4e14 FLOP/s = 6e8 s ≈ 167K chip-hours ≈ 330K USD
Memory:
- Model states: 16 B × 4 Bytes = 64 GB (Rule 3).
- Activations – outputs of the forward pass kept for the backward pass. For example dW = Xᵀ · dY needs X.
- Bytes per transformer layer, 16-bit :
activations per layer = s · b · h · (34 + 5 · a · s / h)s = sequence length, b = micro-batch size, h = hidden size, a = attention heads
- The 5 · a · s / h term is the s × s attention score grid per head. FlashAttention never stores it, so drop it: ~34 · s · b · h per layer.
one 4K-token sequence, 36 layers 34 × 4,096 × 1 × 2,560 × 36 ≈ 12.8 GB
- The 34 was derived for a GPT-style layer with dropout. Qwen3’s wider MLP pushes it up, no dropout pulls it down. Treat as ±50%.
- 64 GB + 12.8 GB = 77 GB of an 80 GB H100, with one sequence. No room.
What is a micro-batch?
- Mini-batch (global batch) – examples used for one optimizer step.
- Micro-batch – the slice that goes through one forward and backward pass. Gradients add up across slices (gradient accumulation), then the optimizer steps once.
- Same math as one big mini-batch, but only one micro-batch’s activations are in memory at a time.
- Activation memory depends on the micro-batch, not the mini-batch.
mini-batch 512 sequences, 8 GPUs, micro-batch 4accumulation steps per GPU = 512 ÷ (8 × 4) = 16
What is recomputation?
- In the forward pass, keep only each layer’s input. In the backward pass, rerun that layer’s forward to get its activations back.
- Costs one extra forward pass: 2NT on top of 6NT, ~33% more compute. Activations drop to ~2 · s · b · h per layer:
2 × 4,096 × 2,560 × 36 ≈ 0.75 GB (vs 12.8 GB)
Ways to fit, simplest first:
- Recompute activations – 12.8 GB becomes 0.75 GB.
- LoRA – freeze the base in bf16 (8 GB), train small added matrices. Fits on one card.
- QLoRA – LoRA with the frozen base in int4 (2 GB).
- Shard the states across GPUs (FSDP or ZeRO) – over 8 GPUs, each holds 64 ÷ 8 = 8 GB. Needed for full fine-tunes of bigger models.
Q11 Scaling recommendation models is hard
- For RecSys, the larger chunk of params is embeddings, and they don’t add FLOPs. They cost memory, bandwidth and network instead.
Where do the weights live?
- Both dense weights and embedding tables sit in HBM, placed differently:
- Dense weights are copied. 25M params × 4 B = 100 MB, so every GPU keeps a full copy and works on its own examples.
- Embedding tables are split (sharded). Each GPU holds some whole tables, or a range of rows of a big one.
1B IDs × 128 dims × 4 B = 512 GB > 80 GB on one H100, fits across 8 (640 GB)
- Tables bigger than all the HBM: hot rows stay in HBM, the rest go to host DRAM or SSD. Works because ID traffic is skewed – a few IDs get most lookups.
Why is a lookup slow if it is cheap?
- Dense weights are read once per batch and reused by every example. Embedding rows are different for every example, so each example pays for its own scattered reads.
bytes per example = 200 features × 20 IDs × 64 dims × 2 Bytes ≈ 0.5 MBintensity = 50 MFLOPs ÷ 0.5 MB ≈ 100 FLOP/byte < H100 ridge of ~300
- So embedding reads, not FLOPs, set the speed.
Training – the all-to-all:
- A lookup is local only if the row is on the same GPU. Most rows an example needs live on other GPUs, so each step:
- Each GPU sends its examples’ IDs to the GPUs that own those rows.
- Owners look up, pool, and send the vectors back. Every GPU sends to every other GPU – an all-to-all.
- Each GPU runs the dense forward and backward on its own examples.
- Gradients for the vectors go back to the owners (a second all-to-all), which update their rows.
- Say 64 GPUs in 8 servers, 1,024 examples per GPU, 500 pooled features of 128 dims, bf16:
vectors received per GPU = 1,024 × 500 × 128 × 2 B ≈ 131 MBfrom other servers ≈ 7/8 × 131 MB ≈ 115 MBnetwork time = 115 MB ÷ 50 GB/s ≈ 2.3 ms, each waydense compute per GPU = 6 × 25M × 1,024 = 154 GFLOPs ÷ 400 TFLOP/s ≈ 0.4 ms
- ~4.6 ms moving vectors vs ~0.4 ms computing. The lookup is cheap; moving its result is not.
Optimizer for embeddings:
- Adam adds 2 numbers per weight: another 1,024 GB for the 512 GB table. So tables use row-wise Adagrad, one number per row:
s_r = s_r + mean over j of g_r,j² one running sum per row rθ_r = θ_r − α · g_r ÷ (√s_r + ε) same step size for the whole rowextra memory = 1B rows × 4 B = 4 GB (vs 1,024 GB for Adam)
- Rarely seen IDs keep a small s_r, so they take bigger steps when they show up. Suits ID traffic, where most IDs are rare.
SparseCore – hardware for lookups:
- TPU’s main TensorCore is built around big matrix units (256 × 256 on v6e) for dense math. Embeddings run poorly there because of small scattered reads and variable-length exchange between chips
- SparseCore is a separate unit: 16 small tiles, each with its own memory, processing unit and HBM channel, built to keep many reads in flight
- TPU v6e has 2 SparseCores per chip.
- On TPU v4 it sped up embedding-heavy models 5–7×, using ~5% of chip area and power
- GPUs have no such unit; libraries like TorchRec do it in software
Q12 Shall I ship this model ?
- Up to 100 chips per model at inference time is okay.
- More than 1,000 chips needs a design change (per session call, not per request) or becomes a one-way door (embedding backfill).
- In dollars, at 2 USD per chip-hour:
100 chips ≈ 1.75M USD per year1,000 chips ≈ 17.5M USD per year
- These lines are rules of thumb and vary by company. A better check is the lift the model needs just to pay for itself:
break-even lift = annual cost ÷ annual revenue of the product = 17.5M USD ÷ 1B USD = 1.75%
Example:
- The retriever in Q9 needs ~125 chips at 1,000-token prompts. At 10,000-token prompts FLOPs grow 10×, plus attention (Q5): ~1,250 chips.
Design changes, simplest first:
- Call once per session, not per request. With 5 requests per session, 1,250 chips become ~250.
- Cut tokens – shorter prompts, compressed history.
- Distill into a smaller model, or fewer active params.
- Move the work offline – precompute embeddings in batch, serve a lookup.
Is an embedding backfill a one-way door?
- Compute is cheap:
1B items × 1,000 tokens through a 1B-param modelFLOPs = 2 × 1e9 × 1e3 × 1e9 = 2e21time = 2e21 ÷ 4e14 FLOP/s = 5e6 chip-seconds ≈ 1,400 chip-hours ≈ 2,800 USD
- The door is what depends on the embeddings:
- the nearest-neighbor index built from them,
- downstream models trained on that embedding space,
- the pipeline that embeds new items as they arrive.
- Changing the model means rebuilding all three together. That coordination, not the compute, makes it hard to reverse.
