E5 ELI5.LabVisual explainers
AI & FRONTIER / 45 MINELI5

Inside LLM serving: one model, millions of chats

A frontier AI model is one read-only copy of hundreds of gigabytes of numbers, shared by everyone who uses it. Each chat owns only a small, growing pile of memory. Nearly every odd thing about AI products, from pricing to slow first words, follows from those two facts. This page walks through all 25 chapters of the original study, with its hands-on controls.

Built from the study “Inside LLM Serving” (shared by the reader, Oct 2026; author not named), facts checked against the papers and spec sheets it cites

Three kinds of numbers appear below. public means a published spec sheet, paper or plain arithmetic. example means one made-up but self-consistent system (set out in chapter 10) used to show how things work. not public means Anthropic has not said; nothing here claims to be the real size or setup of any Claude model.

compute, weights, output memory & the KV cache waiting, waste, price wires and networks the wrong intuition

The setup

One copy, millions of chats

A frontier model sits in the memory of a small group of chips. Its weights are the numbers it learned in training: one read-only copy of hundreds of gigabytes, spread over 8 to 72 chips. Thousands of people use that one copy at the same moment, because nobody changes it while chatting.

The only private thing each person has is the conversation so far, held in a form the chips can reuse. That pile is called the KV cache (chapter 11 explains the name). A longer conversation is a bigger pile. Everything below explains why this layout works and what limits it.

ONE MODEL · 3 px = 1 GB weights · 200 GB read-only, shared by everyone 8 to 72 chips each chat’s KV · 1.3 GB private, grows with every token One copy serves thousands of conversations at once.

The trip

A message’s short journey

Your message first reaches a gateway, which does cheap checks: are you signed in, have you hit your usage limit, does a safety filter flag anything, and how much to bill. Then a router picks a replica: one complete copy of the model, spread over 8 to 72 chips that act as one machine. It prefers a replica with free room that may already hold the start of your conversation.

The replica does two jobs. First it reads your whole prompt in one parallel pass, called prefill. Then it writes the answer one token (a chunk of a word) per pass, called decode, and streams each token to your screen as soon as it exists. Almost everything before the replica is light work. The replica is the expensive part, and it is shared.

Common mix-up: one customer does not get one chip. A replica handles many conversations in the same instant, which is why the rest of this page exists.

You Gateway Router Replica Screen checks & limits picks a replica reads, then writes streams tokens WHERE THE TIME GOES · 50 px = 1 s 0.3 s prefill 12 s decode · 600 tokens · 20 ms each first word
Go deeper: where the time goes

Typical time at each stage, as an example for a request with a few thousand prompt tokens:

StageRough timeWhat decides it
Network to the gateway20 to 100 msyour distance and connection
Checks and routing1 to 10 mscheap lookups
Waiting in a queue0 ms to secondshow busy the fleet is
Prefill (reading the prompt)0.1 to 3 sprompt length, cache hits
Each decode step (one token)10 to 40 msmemory speed, how many people share the step

The model has no memory between messages. Every turn, the app sends the instructions, tool descriptions, the whole conversation so far and your new message as one long text. The server rebuilds its working state from that text each time. Caches (chapter 13) make the rebuild cheap when the earlier part has not changed.

Streaming. Tokens are pushed to you the moment they are made, usually over a connection that stays open (server-sent events). So the first words appear right after prefill, not after the whole answer.

When it stops. The model writes a special end-of-turn token, or hits the output limit you set, or produces a stop phrase. The replica then frees that conversation’s seat, and the bill counts input and output tokens separately.

The engine

A model only guesses words

That is the whole job. Given the text so far, the model gives every possible next token a score. A formula called softmax turns those scores into chances that add up to 100%. One token is picked at random using those chances, added to the text, and the whole pass runs again for the next one.

Temperature is a dial on that pick. Low temperature makes the top word win almost every time. High temperature flattens the chances, so unlikely words get picked more often. Try it:

TEMPERATURE

Go deeper: scores, chances and cost

Scores, then chances. The last layer produces one raw score for every entry in the model’s word list, often 100,000 entries or more. Each score is divided by the temperature, then softmax turns the scores into chances. At temperature 0 the sampler simply takes the top word every time (called greedy decoding).

chance(word) = e^(score ÷ T) ÷ (sum of e^(score ÷ T) over every word)

Cutting the tail. Before picking, servers often keep only the k best words (top-k), or the smallest group whose chances add up to some share p (top-p). This stops rare nonsense words from ever being chosen.

Why a longer answer costs more. Each new token needs one full pass through the model. A 1,000-token answer is 1,000 passes, one after another. They cannot run side by side, because token 501 depends on token 500. This single fact drives most of the engineering on the rest of the page.

Why answers vary. The pick uses a random number. Same prompt, different draw, different word, and every later word builds on it.

The six words and their scores here are made up to show the shape; they are not from a real model.

The unit

Words become tokens

The model never sees letters or whole words. It sees tokens: chunks of text taken from a fixed list. In English one token is about four characters, or three quarters of a word. Common words are one token; rare words are split into pieces. Real tokenizers differ, and Claude’s is not public.

Tokens are the unit for everything: the context limit, the answer limit, the bill, and the memory a conversation takes on the chips. In the example system, every token of conversation holds 160 KB of KV cache, so 1,000 tokens hold about 160 MB. Type below to see your own text measured:

characters
words
tokens, roughly (characters ÷ 4)
KV memory it would hold in the example system
Serv ing a model is mostly memory . 8 TOKENS · 33 CHARACTERS 1 token ≈ 4 characters ≈ ¾ of a word KV MEMORY · 0.5 px = 1 MB 1,000 tokens = 160 MB 8k = 1.3 GB
Go deeper: where the token list comes from

Building the list. Before training, a tokenizer is built by finding the chunks that appear most often in a huge sample of text. The common method is called byte-pair encoding: it starts from single bytes and keeps merging the most frequent pairs. Any text can still be written, piece by piece, so no word is ever “unknown”.

Why the count matters. Code, numbers and languages other than English usually need more tokens per word than plain English, so they cost more and fill the context faster.

Embeddings. The first step inside the model swaps each token’s id for a long list of numbers, looked up in a table with one row per token in the list. With 150,000 entries and 12,288 numbers per row, that table alone holds about 1.8 billion numbers.

The building block

Inside one pass

One pass through the model is a stack of identical layers. First, each token is swapped for a list of thousands of numbers. Then every layer does two things. In attention, tokens look back at each other (chapter 5). In the MLP (a block of big multiplication tables, also called feed-forward), each token is processed on its own.

Each block adds its result to a running list of numbers that travels up the stack, so earlier information is never thrown away. At the top, the model scores every token in its word list and one new token comes out. In a typical model, attention holds about a third of the weights and the MLP about two thirds.

ONE LAYER · SHARE OF WEIGHTS attention · 1/3 MLP · 2/3 THE SAME SHAPE, REPEATED × 80 layers the running list: each layer adds a correction
Go deeper: sizes and the cost rule

Sizes in public models. public Llama 3 70B has 80 layers with 8,192 numbers per token; Llama 3.1 405B has 126 layers with 16,384; GPT-3 has 96 layers with 12,288; DeepSeek-V3 has 61 layers. not public Claude’s layer count and width.

Where the weights sit. Call the width of one token’s list d. Attention has four d-by-d tables (for the query, key, value and output), about 4d² numbers. A standard MLP widens to 4d and back, about 8d². That gives the one-third / two-thirds split. Modern designs shift the ratio a little, not the idea.

The cost rule that drives everything. Each weight is used for one multiply and one add per token. So one pass costs about 2 × (number of parameters) operations per token. A 200-billion-parameter model needs about 400 billion operations per token, and must read all 200 GB of its weights (at 1 byte each) to do it. Chapter 9 shows why that ratio decides the speed.

The running list is called the residual stream. Because each block only adds a correction, very deep stacks can still be trained, and early information is still available at the end.

The mechanism

Attention looks backwards

Attention is how a token gathers context. The newest token asks a question, called the query (“what do I need?”). Every earlier token has already stored a label, its key, and some content, its value. The query is compared with every key; good matches get a bigger share. The result is a blend of the values, weighted by those shares.

A token’s key and value depend only on the tokens before it, and those never change. So instead of recomputing them on every step, the replica saves them. That saved pile of keys and values is the KV cache, and it is the main subject of chapters 11 to 13.

line thickness = attention weight KKKKK VVVVV Thecatsatonthe saved: keys and values next query
Go deeper: heads, cost and order

Many heads. A layer runs dozens of these lookups side by side. Each one is called a head and learns its own view: one may track grammar, another which name a “she” refers to. Their results are joined and mixed by the output table.

Cost grows with context. Each new token compares its query with every earlier key, so the work per token grows in step with the conversation length. Across a whole sequence, the total grows with the square of the length. That is why very long contexts get expensive in both time and memory.

Only looking back. A token may only look at tokens before it (and itself). This rule, called the causal mask, is exactly what makes the saved keys and values reusable.

Word order. Attention by itself has no sense of order, so position is added in. The common method (rotary embeddings, or RoPE) turns each query and key by an angle that depends on its position.

The hardware

The weights are huge

Every number in the model must sit in the chips’ fast memory while it serves. A model’s parameters are those learned numbers. Precision is how many bits each one uses: a 16-bit number takes 2 bytes, an 8-bit number takes 1 byte, and a 4-bit number takes half a byte. Multiply the count by the bytes each one takes, and a single chip is nowhere near enough for a large model.

Pick a model size, a precision and a chip below. Each column in the drawing is one chip: teal is weights, the dark part is room left for conversations. Weights are allowed to fill at most 60% of a chip, and chips come in fixed group sizes.

PARAMETERS IN THE MODEL
BITS PER NUMBER
MEMORY PER CHIP
of weights to store
chips minimum, if weights fill at most 60% of each
chips at the next common group size
left for conversations in that group

The 8-chip example in later chapters uses more chips than capacity alone needs. Each extra chip also adds memory speed, which decides how fast a step runs (chapter 9). not public Anthropic has not published the size of any Claude model. The controls build intuition; they are not a guess.

Go deeper: why 60%, why groups, real chips weight bytes = parameters × bytes per parameter

200 billion parameters at 1 byte each (8-bit) is 200 GB. At 2 bytes (16-bit) it is 400 GB. At half a byte (4-bit) it is 100 GB. Lower precision trades a little accuracy for a lot of memory and speed (chapter 19).

Why only 60%. The rest of the memory is not spare. It holds every active conversation’s KV cache, temporary working numbers, buffers for talking to other chips, and the compiled programs. If the weights filled the chip there would be no room to serve anyone. The more room is left, the more people fit at once (chapter 11).

Why group sizes jump. Chips are sold in boxes of 8, linked at full speed inside the box, and a rack can link 72. Groups follow those physical shapes, so you round up to 8, 16, 32, 64 or 72 instead of using an exact count.

Mixture-of-experts models (chapter 16) store a large total but use only a slice per token. The total is what must fit in memory.

Chip publicMemoryMemory speed8-bit maths, dense
NVIDIA H10080 GB3.35 TB/sabout 2.0 PFLOPS
NVIDIA H200141 GB4.8 TB/sabout 2.0 PFLOPS
NVIDIA B200192 GB8 TB/sabout 4.5 PFLOPS
AMD MI355X288 GB8 TB/snot used here

TB/s is terabytes per second; one PFLOPS is a thousand trillion (10¹⁵) operations per second. “Dense” means without a trick that skips zeros, which the headline spec-sheet numbers often include. NVIDIA’s DGX B200 page lists 180 GB per chip as usable, against 192 GB on the chip. Google TPUs and AWS Trainium chips have their own sizes in the same range. Anthropic has said it uses three chip platforms (Google TPUs, Amazon Trainium and NVIDIA GPUs), which is why this page says “chip” rather than “GPU”.

Inside the chip

A kitchen beside a warehouse

A chip is a small area that computes, called the compute die, with thousands of multiply-and-add units and tens of megabytes of very fast on-chip memory (SRAM). Around it sit stacks of HBM (high-bandwidth memory): the chip’s main memory, where the weights and KV caches live. Every step away from the maths is bigger and slower: SRAM, then HBM, then other chips, then the computer’s ordinary memory, then disk.

The bar lengths below are read speeds on a log scale, so each gridline is ten times faster than the one before. Keep one number in mind: a B200-class chip can do about 560 operations for every byte it can fetch from HBM. That ratio comes back in chapter 9.

READ SPEED · LOG SCALE on-chip SRAM 30 TB/s HBM · main memory 8 TB/s PCIe · to CPU 64 GB/s network · across racks 50 GB/s SSD · disk 10 GB/s 0.010.11101001k10k GB/s each gridline = 10×
Go deeper: the memory ladder

HBM is ordinary memory chips stacked in layers and mounted right beside the compute die, on the same package. That closeness is what gives it terabytes per second.

On-chip SRAM is far faster but tiny. An H100 has about 33 MB of registers, about 33 MB of shared memory and level-1 cache, and 50 MB of level-2 cache. Fast programs try to do as much work as possible on data already in SRAM, which is the idea behind FlashAttention (chapter 21). example The SRAM speed drawn is a rough total; vendors do not publish one number for it.

The arithmetic is done by tensor cores, units built to multiply small blocks of a table at once. A B200-class chip does about 4.5 thousand trillion 8-bit operations per second, while HBM delivers 8 trillion bytes per second: about 560 operations per byte.

Below HBM. The computer’s main memory, reached over a PCIe link, gives about 64 GB/s. A fast SSD gives around 7 to 14 GB/s. Servers can park rarely used KV caches there (chapter 13), but reading them back is far slower than HBM, so it is a fallback, not a plan.

Two workloads

Reading is parallel, writing is serial

Your prompt is read in one big parallel pass; the answer is written one token per pass. These are two very different workloads. In prefill every prompt token is already known, so the chip handles them all as one large multiplication and reads each weight once for thousands of tokens. The arithmetic units stay busy, so prefill is limited by arithmetic.

In decode, token 501 needs token 500, so each pass makes just one token per conversation and must read all the weights to do it. The arithmetic units mostly wait for memory, so decode is limited by memory speed. You feel two numbers: time to first token (queue plus prefill; a long prompt hurts it) and time between tokens (one decode step; a busy replica hurts it). In the drawing, a 3,000-token prompt takes a few tenths of a second, then each token takes about 20 ms.

SAME REQUEST · TWO WORKLOADS prefill 0.3 s 3,000 tokens · one pass first token decode 20 ms one token per step time to first token = queue + prefill time between tokens = one step
Go deeper: why output costs more than input

Why output is priced higher. Reading a prompt token shares one trip to memory with thousands of other tokens. Writing a token shares its trip only with the other conversations running at that moment. Providers commonly price output several times higher than input for this reason.

Size of prefill. It costs about 2 × parameters operations per prompt token. For the 200B example, 3,000 tokens is 1.2 thousand trillion operations: about 70 ms of the whole 8-chip replica at the example’s 50% arithmetic efficiency. Real systems land at a few hundred milliseconds once attention, scheduling and communication are included.

The analogy

Why writing is slow

Picture a chef who must haul the entire cookbook from a far warehouse to cook one dish. The road is the bottleneck, not the kitchen. In the analogy, the cookbook is the weights, the haul is reading them from HBM, one dish is one token for one person, and cooking is the arithmetic.

For one person, the 200 GB haul feeds one dish and the kitchen is busy only about 0.4% of the time. The trip is the same size no matter how many dishes you cook, so the fix is to cook for many people per trip. In the example system, about 230 people per trip keeps the kitchen fully busy. That is batching. Where the analogy breaks: each dish also needs that person’s own KV cache, which is hauled too (chapter 11).

ONE CHAT weights 200 GB read compute 1 token 230 CHATS weights same 200 GB compute 230 tokens kitchen busy about 0.4% kitchen busy about 100% a batch shares one read of the weights
Go deeper: the ratio that decides it

Operations per byte. A chip can do a fixed number of operations per byte it reads, set by its hardware. For a B200-class chip that is about 4.5 thousand trillion operations per second divided by 8 trillion bytes per second: roughly 560 operations per byte. Writing one token for one person does about 2 operations per weight byte at 8 bits, 280 times below what the chip could handle. The arithmetic units are starved.

Arithmetic intensity is the name for operations done per byte moved. Decode for one person has an intensity near 2; prefill can reach thousands. A chip’s balance point is called its ridge. Below the ridge a job is limited by memory, above it by arithmetic. This picture is called the roofline model.

time per step = the longer of (bytes moved ÷ memory speed) and (operations ÷ arithmetic speed)

The fix is to raise the intensity. Serve B people from one read of the weights and the intensity becomes about 2 × B. With the example’s efficiencies (60% of peak memory speed, 50% of peak arithmetic) the balance point is about 230 people. Past it, the kitchen is the limit and extra people no longer come free.

Why not always run full? Each person then waits for a longer step, and all their KV caches must fit in memory. The next two chapters are about exactly that trade.

The trade-off

Batching: sharing the haul

Put more people on the same replica and the total output rises almost for free, until memory or arithmetic runs out. Here is the example replica used for the rest of the page: 8 chips, running a 200-billion-parameter model at 8-bit. Choose how many people share it and how long their conversations are.

PEOPLE SHARING THE REPLICA
CONVERSATION LENGTH SO FAR
tokens per second each person sees
tokens per second from the whole replica
what limits the step
people fit in memory at this length

At low batch the step barely changes, so total output climbs almost in a straight line. As more people’s KV caches have to be read, or the arithmetic limit is reached, the step stretches and each person slows down. Longer conversations hit that wall sooner, because every person’s cache is a bigger read. Operators choose a point: a product promising fast streaming runs fewer people per replica; a cheap bulk product runs more. Same chips, different prices.

Go deeper: the example system and its step model
The example system example
Chips in the replica8, each 192 GB, 8 TB/s, 4.5 PFLOPS (8-bit, dense)
Efficiency assumed60% of peak memory speed, 50% of peak arithmetic
Model200B dense, 8-bit, 80 layers, 8 KV heads of 128 numbers, width 12,288
KV cache per token2 × 80 × 8 × 128 × 1 byte = 160 KB
Fixed overhead per step2 ms (syncing chips, launching work)
Memory usable90% of the total
memory time = (weights + people × length × KV per token) ÷ memory speed
arithmetic time = people × (2 × parameters + attention work) ÷ arithmetic speed
step = the longer of the two + overhead

Each person gets one token per step, so their speed is 1 ÷ step, and the replica’s output is people ÷ step. For example, at 128 people and 8k tokens the step takes about 11.6 ms: about 86 tokens per second for each person and about 11,000 for the replica.

What the example leaves out. Real systems add scheduler delays, uneven expert loads, time spent picking tokens, and prompt-reading work that interrupts writing. They also use tricks such as speculative decoding (chapter 20) that change the curve.

The KV cache

The KV cache: what each person owns

Instead of recomputing the key and value of every earlier token on every step, the replica saves them. In the drawing, each row is one step of writing and each cell is one token’s key and value. Without a cache, every step rebuilds all of them (orange). With a cache, each step builds just one new pair and reads the rest back from memory (teal).

That saved pile is private to each conversation, and it grows with every token. Pick a conversation length to see how big one pile gets and how many such conversations fit beside the weights in the example system, which has 1,182 GB spare after the weights.

CONVERSATION LENGTH
of KV cache for this one conversation
conversations like it fit beside the weights

Memory, not arithmetic, is what runs out first for long conversations. That is why per-person speed drops as chats get long, and why long-context requests are priced higher.

Go deeper: the size formula and the real cost KV bytes per token = 2 × layers × KV heads × head size × bytes per number

The example model has 80 layers, 8 KV heads and 128 numbers per head at 1 byte: 2 × 80 × 8 × 128 × 1 = 163,840 bytes, about 160 KB per token. The 2 is for keys and values. Multiply by the conversation length to get the pile’s size.

Where the saving comes from. Without a cache, writing token n means rebuilding keys and values for tokens 1 to n, so the total work over an answer grows with the square of its length. With the cache, each step builds exactly one new pair. The price is memory that grows steadily with length for as long as the conversation stays active.

Reading it back is the real cost. Every writing step reads every person’s whole cache from memory, on top of reading the weights once. At long lengths the cache reads take most of the step.

Memory is the cap. People per replica ≈ (usable memory − weights) ÷ (cache size of one conversation). At 8k tokens the example fits about 900, at 128k about 56, and at 1M tokens about 7. The arithmetic might support more, but the memory does not.

Shrinking the cache

Share the keys and values

Remember that a layer runs many attention heads side by side (chapter 5). The trick: let many heads share a few stored keys and values. The question each head asks stays separate; the stored answers do not. Fewer stored pairs means a smaller cache and fewer bytes read every step.

The original design, multi-head attention (MHA), stores a key and value for every head. Grouped-query attention (GQA) splits the heads into groups with one pair per group. Multi-query attention (MQA) shares one pair among all heads. Multi-head latent attention (MLA) instead stores one small compressed list per token and expands it when needed. The bars count stored numbers per token, per layer, for an example with 64 heads of 128 numbers.

NUMBERS STORED PER TOKEN, PER LAYER MHA · one per head 16,384 GQA · one per group 2,048 MQA · one for all 256 MLA · compressed 576 fewer stored numbers, more chats fit
Go deeper: the four designs and other tricks
  • MHA. Every head stores its own keys and values. Biggest cache: 2 × 64 × 128 = 16,384 numbers.
  • MQA. One key-value pair shared by all heads. Smallest cache (2 × 1 × 128 = 256), with some loss of quality. Proposed by Noam Shazeer in 2019.
  • GQA. Heads are split into groups, one pair per group; with 8 groups that is 2 × 8 × 128 = 2,048. A middle path that keeps most of the quality. public Used in Llama 2 70B and Llama 3, among others.
  • MLA. Used in DeepSeek-V2 and V3. public DeepSeek-V3 keeps 512 compressed numbers plus 64 for position: 576 per token per layer.

Other ways to shrink it. Some layers only look at the last few thousand tokens (a sliding window), so their cache stops growing. Keys and values can be stored in 8-bit or 4-bit instead of 16-bit. Tokens that attention rarely uses can be dropped or compressed. Some layer types keep a fixed-size summary instead of a growing list, and are often mixed with a few ordinary attention layers.

not public Which of these Claude models use. The point is the pressure: every byte shaved from the cache is room for more people per replica.

Paging and sharing

Hand out memory in blocks

A conversation’s final length is unknown when it starts. Early servers reserved one continuous slab of memory sized for the longest possible answer, so most of it sat empty. The fix borrows an idea from how a computer’s operating system hands out memory: give out small fixed blocks (often 16 tokens each) only when a conversation needs one, and keep a small table of where each conversation’s blocks are.

Conversations that begin with the same text, such as the same long instructions, have identical keys and values for that part. So that shared prefix can be stored once and pointed to by everyone. The PagedAttention paper (vLLM, 2023) found that earlier systems used only 20.4% to 38.2% of their KV memory for real data, and reported 2 to 4 times more throughput at the same delay after fixing it.

THREE WAYS TO HOLD KV MEMORY OLD WAY reserve the maximum 19 of 48 cells real the rest sits empty NEW WAY blocks on demand 22 of 32 cells real nothing reserved SHARED shared prefix stored once A B C one copy, three chats
Go deeper: prompt caching, lifetimes and tiers

Prompt caching. Blocks are labelled by a fingerprint (a hash) of their contents plus everything before them. A new request that matches reuses the blocks and skips reading that part of the prompt. This is the mechanism behind the prompt caching that API providers sell: cached input tokens are cheaper because they cost memory, not arithmetic.

Why caches expire quickly. A cached prefix takes scarce HBM that could hold live conversations. Servers throw out the blocks used least recently, so entries typically live minutes, not hours, unless moved to a slower tier.

Tiers. Cold blocks can move from HBM to the computer’s main memory, to SSD, or to a shared pool over the network; the public Mooncake system describes this. Reading them back is sometimes slower than recomputing, so schedulers choose.

When memory fills. The scheduler may pause a conversation: move its blocks out, or drop them and recompute later. Good scheduling keeps this rare.

not public Anthropic’s internal design. Prompt caching is a documented product feature; the machinery here is the public research it most resembles.

Try it

How many chats fit?

Now try the three ideas together. The example system has 1,182 GB of room for KV caches after the weights, and every token costs 160 KB. Set how long each conversation is, the maximum an old-style server reserves for each one, and how much of each conversation is a shared prefix. The bars compare how many chats fit under each memory policy; the dashed line is the best case, paging plus sharing.

Perfect packing assumed: every chat reaches its full length, with no fragmentation or activation memory. Real servers are less tidy, so treat these as ceilings.

Many chips

Four ways to cut a model

One chip cannot hold the model, so it is cut up. How it is cut decides what has to travel between chips, and how fast the wires must be. There are four basic cuts, and real systems combine several. Tap one to highlight it:

FOUR WAYS TO CUT

TENSOR chipchipchipchip every table sliced PIPELINE 1-2021-4041-6061-80 layers in stages EXPERTS · pick a few R E1E2E3E4 REPLICA · full copies R fullfullfull real systems mix all four
Go deeper: what travels, and how cuts combine
CutWhat is splitWhat travelsBest where
Tensoreach tablean all-reduce twice per layerinside one fast link domain
Pipelinegroups of layerssmall lists of numbers, once per stageacross slower links
ExpertMoE expertsan all-to-all per MoE layermany chips, large batches
Replicanothing; whole copiesonly the requestsadding capacity

An all-reduce means every chip sends its partial result and every chip gets back the sum. An all-to-all means every chip sends something to every other chip.

How they combine. A common shape is tensor splitting inside one 8-chip server or one 72-chip rack, experts spread across a larger group, and many identical replicas behind a router. DeepSeek’s public description of its serving system spreads experts across dozens of chips, so each chip holds only a few and reads fewer weights per step.

Speed or capacity? Tensor splitting divides the bytes each chip reads, so each step gets faster. Pipeline splitting does not: one token still walks through every stage in turn. It lets a model fit across more chips with cheaper links, at the cost of “bubbles”, moments when a stage has nothing to do.

Splitting the conversation. For very long prompts, the sequence itself can be divided among chips (sequence or context parallelism), so no single chip holds the whole KV cache.

not public The mix Anthropic uses.

The wires

Fast inside the box, slow outside

Bandwidth is how many bytes per second a link can move. Chips in one box talk over NVIDIA’s NVLink almost as fast as they read their own memory: 900 GB/s per chip on an H100, 1.8 TB/s on a B200. Between servers, the data-centre network (InfiniBand or Ethernet) is ten to a hundred times slower. That limit decides which cuts are allowed: tensor splitting stays inside one fast box or rack, while pipeline splitting can cross racks.

BANDWIDTH · LOG SCALE NVLink · same box 900 GB/s PCIe · to CPU 64 GB/s network · across racks 50 GB/s home internet 0.1 GB/s 0.010.11101001k GB/s each gridline = 10×
Go deeper: why tensor splitting stays in the box

The numbers. In the 128-person example, each all-reduce moves about 3 MB (128 people × 12,288 numbers × 2 bytes). There are two per layer and 80 layers, so 160 per step, around 500 MB. Over 900 GB/s NVLink that takes about half a millisecond. Over a 50 GB/s network link it takes about ten milliseconds, nearly a whole step. Each exchange also has a fixed delay of several microseconds, which is why the example charges 2 ms of overhead per step even on fast links.

Link domains. public An 8-GPU server links its chips with NVLink. NVIDIA’s GB200 NVL72 rack links 72 Blackwell GPUs in one NVLink domain, about 130 TB/s combined, which lets a single replica span a whole rack. Google TPU pods link thousands of chips with their own fast links.

Between servers. Servers connect through InfiniBand or Ethernet with remote memory access, so one chip can write straight into another server’s memory without involving its main processor. Switches are arranged so any pair of racks has plenty of paths.

What never travels: the weights. They are loaded once when a replica starts and stay put. What moves while serving is small by comparison: numbers between chips, requests and tokens to and from the router, and sometimes KV cache blocks between prefill and decode pools (chapter 18).

The internet leg. Your connection carries only text. A 1,000-token answer is a few kilobytes, so streaming it adds almost nothing next to the time spent generating it.

Mixture of experts

Many experts, few per token

Instead of one big MLP per layer, a mixture-of-experts (MoE) model keeps many smaller ones, called experts. A small scoring table, the router, picks a few experts for each token and blends their answers. That makes each token cheap in arithmetic. It is not cheap in memory: every expert must still be stored, and any expert chosen by any token in a step has to be read.

Choose the number of experts, how many each token uses, and how many tokens share the step. Each square is one expert in one layer; lit means at least one token chose it, so its weights were read.

EXPERTS IN EACH LAYER
EXPERTS USED PER TOKEN
TOKENS IN THIS STEP (PEOPLE SHARING)
of the experts were read this step
of the expert arithmetic each token does, compared with using all of them
Go deeper: total versus active, and why batching changes it

Total versus active. public DeepSeek-V3 has 671 billion parameters in total and 37 billion active per token, with 256 routed experts per layer and 8 chosen for each token. Mixtral 8x7B has 8 experts per layer and uses 2.

The router. A small table scores every expert for each token. The top few are picked and their outputs are blended using those scores. Tokens in the same sentence can go to different experts.

Why batching changes the picture. With one token, only 8 of 256 experts are read, about 3% of the expert weights. With 64 tokens, the chance that a given expert is untouched is (1 − 8/256)⁶⁴, about 13%, so about 87% are read anyway. With 256 tokens nearly all of them are. At the batch sizes that make serving efficient, the memory reading costs about as much as a dense model of the same total size, while the arithmetic stays at the small active size.

share read ≈ 1 − (1 − experts used ÷ experts)^tokens

Why spread experts over many chips. If 256 experts live on 32 chips, each chip holds 8 and reads only those 8 per step. Each chip serves a large pool of tokens sent from everywhere, so every expert it holds sees a healthy batch. That is expert parallelism (chapter 14); its cost is an all-to-all exchange of tokens at every MoE layer, where every chip sends to every other chip.

Weak spots. Some experts get more traffic than others, and the slowest chip sets the step time. Training adds balancing rules to keep load even; serving adds extra copies of popular experts. not public Whether any Claude model is dense or mixture-of-experts.

The lit squares come from a fixed pseudo-random routing, so the count can differ a little from the formula.

Continuous batching

A finished chat frees its seat

Requests arrive at random and finish at random. Keeping the chips full anyway is a scheduling problem, solved every few milliseconds. If four answers start together as a fixed batch, the batch lasts as long as the longest one; the shorter ones leave empty seats until it ends, and newcomers wait for the next batch. Answer lengths vary wildly, from one word to a long essay, so the waste is large.

Continuous batching decides who runs at every single step: finished conversations leave, waiting ones take the free seat on the very next step, and their KV memory is handed back and reused at once. Nobody waits for the longest answer in the group. The idea was published as iteration-level scheduling in the Orca system (2022) and is now standard.

FIXED BATCH ABCD wasted seats CONTINUOUS ABCD new chats join 12345678910 time →
Go deeper: who gets to join

Two limits on joining. Free KV memory (chapter 11) and a speed promise. If admitting more people would stretch each step past the speed promised to users, the scheduler keeps them in the queue. This is why overload first shows up as waiting rather than errors, until a queue limit is reached.

Mixed steps. One step can include writing work for running conversations and a slice of prompt reading for a newcomer. Chapter 18 shows why that mixing needs care.

What this means for you. Your answer’s speed depends on who happens to share your step. That is one reason the same prompt can stream at different speeds at different times of day.

Reading versus writing

A big prompt stalls the room

A big prompt stalls everyone who is mid-answer. Reading a long prompt keeps the arithmetic units fully busy for tens to hundreds of milliseconds, while writing steps are meant to tick every 10 to 40 ms. A step that includes a whole prompt makes everyone’s next token late, which you see as a stutter in streaming.

There are two fixes. Chunked prefill cuts the prompt into pieces of a fixed size and attaches one piece to each writing step, so steps stay short and the newcomer finishes reading after several steps. Separate pools give reading and writing their own chips: prompt-reading chips are tuned for arithmetic, writing chips for memory. The cost is that each KV cache has to be copied over the network after its prompt is read.

mixed everyone waits prefill chunked one slice per step separate copy the cache KV copy chunked and separate keep tokens flowing time →
Go deeper: the published versions

Chunked prefill was published as Sarathi-Serve (2024) and is available in open serving software.

Separate pools (called disaggregation) appear in public work such as Splitwise (Microsoft), DistServe and Mooncake (Moonshot AI). Each pool can use its own chip count, batch size, even chip type. Mixing and chunking are simplest; separate pools win at large scale.

The balancing act. Too few prompt-reading chips and the first token is late; too few writing chips and answers stream slowly. The fleet adjusts the ratio as traffic changes, for example when coding tools send long prompts and get short replies, or when people ask for long essays from short prompts.

not public Which of these arrangements Anthropic runs.

Smaller numbers

Fewer bits, fewer bytes

Once you know that moving memory is the bill, most speed tricks are the same idea: move fewer bytes, or get more out of each byte. The simplest is to store each weight in fewer bits, called quantization. Half the bytes means half the memory, and when reading memory is the limit, nearly twice the speed. A 200-billion-parameter model is 400 GB at 16-bit, 200 GB at 8-bit and 100 GB at 4-bit.

The cost is rounding error. A 4-bit floating-point number (the E2M1 format) can say only 15 different values, drawn as dots below, packed closer together near zero. A shared scale factor for each small block of weights stretches those 15 values to fit that block’s real range. Training with low precision in mind, and keeping sensitive layers at higher precision, keeps quality.

200B PARAMETERS · MEMORY AND SPEED 16-bit 400 GB 1× 8-bit 200 GB 2× 4-bit 100 GB 4× 4-BIT GRID · E2M1 15 values in 4 bits a block scale stretches them −606
Go deeper: speed, scales and quality

Why speed follows bytes. A memory-limited step takes weights ÷ memory speed: half the bytes, half the time. Newer chips also do low-precision arithmetic faster. public A B200-class chip is rated at about 2.25 thousand trillion operations per second at 16-bit, 4.5 at 8-bit and 9 at 4-bit, without the zero-skipping trick.

Scaling in blocks. Weights are grouped, for example 16 or 32 at a time, and each group shares a scale factor stored in a few extra bits. Formats such as MXFP4 and NVFP4 are built this way.

What gets quantized. Weights always. Often the KV cache too (chapter 12). Sometimes the temporary working numbers as well, which lets the arithmetic itself run at low precision.

Where quality can slip. A few weights and working numbers are unusually large and matter a lot; rounding them hurts. Methods handle them by rescaling, rotating, or keeping them at higher precision. The checks are benchmarks and, more importantly, comparing outputs before and after.

not public The precision Claude models are served at.

Guessing ahead

Guess ahead, then check

Speculative decoding lets a small, fast “draft” model guess the next few tokens. The big model then checks all the guesses in one pass. Checking several tokens costs about the same as writing one, because the step is limited by reading the weights, not by the arithmetic. Every right guess is a free token. At the first wrong guess, the big model’s own token is used instead and the rest are thrown away.

Set how many tokens are drafted per round, how often the big model accepts each one, and how expensive a draft step is compared with a big step.

TOKENS DRAFTED PER ROUND
CHANCE EACH DRAFT TOKEN IS ACCEPTED
DRAFT STEP COST, AS A SHARE OF ONE BIG STEP
tokens kept per big-model pass, on average
faster than normal decoding
Go deeper: the formulas and when it helps tokens per round = (1 − a^(k+1)) ÷ (1 − a)
speed-up = tokens per round ÷ (1 + k × draft cost)

Here k is the draft length, a is the chance each draft token is accepted, and draft cost is a draft step as a share of a big step. The first formula counts the accepted tokens plus the one the big model always supplies where it first disagrees. It treats each guess as accepted independently, which is a simplification.

The output does not change. The standard method (Leviathan and colleagues, 2022; Chen and colleagues, 2023) accepts or rejects guesses with a rule that provably leaves the big model’s output exactly as likely as without the trick. It is a speed trick, not a quality trade.

When it helps less. With many people on the step, the arithmetic units are already busy, so extra checked tokens are no longer free. It shines when few people share a step, as in low-latency products. Easy text (boilerplate code, quotes, repeated phrases) is accepted far more often than hard reasoning.

Variants. Draft with a tiny model; draft with extra prediction heads on the big model itself (Medusa, EAGLE, multi-token prediction); or draft by copying phrases that already appeared in the prompt.

The kernel

Do not write the big grid

Doing several steps in a row on data that stays on the chip beats writing each result back to main memory and reading it again. The simple way to do attention builds a table with one score for every pair of tokens, writes it to HBM, then reads it back to turn the scores into shares and blend the values. For a 32,000-token context that table has about a billion entries per head: far too big for on-chip memory, and many slow trips.

FlashAttention (2022) works through the keys and values in small tiles that fit in on-chip SRAM, keeping running totals as it goes, so the big table never exists. The result is exact, not an approximation. A small program that runs on the chip is called a kernel, and this is a “fused” kernel: several steps in one trip.

STANDARD scores HBM write + read FLASH tiles in SRAM the table never leaves the chip
Go deeper: fusion, launch cost and overlap

Kernel fusion. Many tiny steps around the big multiplications (normalising, adding to the running list, applying the activation, picking the token) each read and write the whole list of numbers. Fusing them into one kernel keeps the data on the chip between steps.

Launch cost. Starting each kernel costs microseconds, and one writing step has thousands of small kernels. Recording them once and replaying them (CUDA graphs on NVIDIA, compiled graphs on TPUs) removes most of that cost.

Overlap. While one group of chips computes, the previous result is already being sent over the wire. Good schedules hide most of the communication from chapter 15 behind arithmetic.

The front door

Queues absorb what chips cannot

Before any replica sees your request, it passes the gateway (sign-in, per-account limits, safety checks), then waits in a line sorted by priority: live chat first, then API traffic, then batch jobs that can wait and fill the gaps. A router then weighs how full each replica is and what it already has cached. A replica that is 80% full but still holds your conversation’s start can beat an empty one, because reusing the cache skips a long prompt read.

When arrivals outrun capacity, the line grows and waiting time shoots up. Capacity cannot be added in seconds, because a new replica must first load hundreds of gigabytes of weights. So when requests wait too long, the gateway turns them away. The Claude API reports this as an overloaded error, status 529.

ARRIVALS · ONE SECOND served now waiting capacity wait grows non-linearly as load approaches capacity past it: longer queues, timeouts, 529 overload errors
Go deeper: limits, priority and shedding

Limits protect the fleet. Per-account limits on requests and tokens per minute stop one customer from soaking up shared capacity. They also help planning: the provider knows the most traffic any tier can send.

Priority. Live chat is sensitive to delay, so it goes first. Bulk jobs that can wait run in the gaps; Anthropic offers its batch API at a discount for exactly this. That is how a fleet keeps chips busy without hurting live users.

Cache-aware routing. Sending a conversation back to the replica that still holds its KV blocks saves reading the earlier part again. Routers trade off load against cache hits, like “sticky sessions” on a website. A real router also weighs geography, model version and failures.

Shedding. Under heavy load, a system can protect core traffic by refusing lower-priority requests first, shortening allowed outputs, or both.

The fleet

Chips fail; traffic must not notice

Replicas sit in racks, racks in data centres, data centres in regions, with a global traffic manager on top. At the scale of thousands of chips, something breaks every day. Meta reported 466 job interruptions in 54 days while training Llama 3 on about 16,000 GPUs; 419 were unexpected, roughly one every three hours. Serving suffers less, because replicas are independent: one failing does not stop the others.

A failed chip takes its replica out of rotation. The router stops sending it work, and spare replicas absorb the load. Fleets keep enough spares to lose a rack, or a whole zone, and carry on.

ONE RACK · SIX CHIPS okokokokok failed spare takes over 466 interruptions in 54 days about one every three hours the request is retried on another replica
Go deeper: updates, many models, many chips

Updates without downtime. A new model version is loaded onto spare replicas, tested on a trickle of traffic (a “canary”), then given a growing share while old replicas finish their conversations and drain. Loading weights takes minutes, so rollouts are planned, not instant.

Many models at once. A fleet serves several model sizes and versions at the same time, each with its own replicas, memory layout and routing rules. Smaller tiers fit in fewer chips and serve more people per chip, which is part of why they cost less.

Many kinds of chips. public Anthropic has said it uses Google TPUs, Amazon Trainium and NVIDIA GPUs. The same model has to be compiled and tuned separately for each, and traffic is spread across them.

Demand moves. Traffic follows working hours around the world, peaks on weekdays, and can surge when a new feature launches. Capacity is planned months ahead, because racks cannot be rented by the minute at this scale.

The answer

So how many people per chip?

Pick a world. This calculator uses the example system from chapter 10 and sizes a whole fleet for it. People spend most of their time reading and typing, so one chat “seat” on a replica is shared by many people over a minute or two. That is how tens to hundreds of people can be using one chip at once.

PEOPLE USING IT AT THE SAME MOMENT (PEAK)
SECONDS BETWEEN ONE PERSON’S MESSAGES
TOKENS SENT PER REQUEST (WHOLE CONVERSATION)
SHARE OF THAT ALREADY CACHED
TOKENS WRITTEN PER REPLY
PRICE OF ONE CHIP PER HOUR
requests per second across the fleet
people one 8-chip replica keeps busy
replicas, with 30% spare
chips in total
people per chip
chip cost per million tokens written

Go deeper: the formulas and what they leave out requests per second = people ÷ seconds between messages
replica time per request = prompt-reading time + reply tokens × step time ÷ people in the batch
replicas = requests per second × replica time per request × 1.3

Prompt-reading time comes from the tokens that are not cached, at about 2 operations per parameter each, plus attention work. Step time is the chapter 10 model at 128 people per replica, lowered when long conversations do not fit in memory. 128 is an assumed operating point, not a measured one.

What moves the answer most. The cached share (cached tokens skip prompt reading entirely), the conversation length (it sets both KV memory and the cost of each step), and the length of replies. AI agents and long reasoning make replies longer and keep conversations open longer.

Why list prices are far above the chip cost. The calculator counts only chip rental. Real prices also pay for idle capacity kept for peaks and failures, networking and buildings, much larger models, lower real efficiency than an ideal model, engineering, and training the model in the first place. Do not read the last tile as a price.

not public None of the defaults are Anthropic’s numbers.

Field guide

What you notice from the outside

Most of what looks odd about AI products follows from the mechanics above.

Output costs more than inputReading a prompt token shares one trip to memory with thousands of other tokens. Writing a token shares it only with whoever is on the same step.chapters 8, 9
Long chats get slower and pricierEvery writing step re-reads the whole KV cache, and a longer chat has a bigger one.chapter 11
Cached prompts are cheaperThe replica already holds those keys and values, so it skips reading that part of the prompt.chapter 13
Speed varies by time of dayYour step is shared with whoever else is on the replica at that moment.chapters 10, 17
Huge prompts delay the first wordPrompt reading is limited by arithmetic and grows with prompt length.chapters 8, 18
Smaller tiers are faster and cheaperFewer weights to read each step, so more people fit per replica.chapters 6, 10
Rate limits and overload errorsChips and memory are fixed and cannot be added in seconds. The Claude API reports overload as error 529.chapter 22
Batch jobs are discountedThey can wait, so they fill gaps that would otherwise sit idle.chapter 22

Field guide

The words, in plain language

TokenA chunk of text, about 4 characters in English. The unit of cost, speed and memory.
Weights, parametersThe learned numbers that make up the model. Fixed while serving.
ActivationsThe temporary numbers flowing through the model for the current tokens.
AttentionThe step where each token looks back at earlier tokens.
KV cacheSaved keys and values of earlier tokens. Private to each conversation.
PrefillReading the prompt in one parallel pass.
DecodeWriting the answer, one token per pass.
Time to first tokenWaiting plus prefill, before the first word appears.
BatchThe group of conversations moved forward together in one step.
Continuous batchingLetting conversations join and leave the batch at every step.
ReplicaOne complete copy of the model, spread over a group of chips.
HBMHigh-bandwidth memory beside the chip. Holds the weights and KV cache.
SRAMTiny, very fast memory on the computing part of the chip itself.
NVLinkNVIDIA’s fast link between chips in one server or rack.
All-reduceEvery chip sends its partial result, and every chip gets back the sum.
Tensor, pipeline, expert parallelismCutting a model by table slices, by groups of layers, or by experts.
Mixture of expertsMany small MLPs per layer, with only a few used per token.
QuantizationStoring numbers with fewer bits.
Speculative decodingDraft several tokens cheaply, check them in one big pass.
Arithmetic intensityOperations done per byte moved. Low means limited by memory.
RooflineThe rule that speed is set by memory or by arithmetic, whichever is slower.
Prefix cacheReusing stored KV blocks when a new request starts with the same text.

Field guide

What is known and what is not

PublicClaude runs on a mix of AWS Trainium, Google TPUs and NVIDIA GPUs. Prompt caching and a discounted batch API exist. Rate limits and overload errors exist. The techniques in chapters 6 to 21 are published research or open-source practice.Anthropic posts and docs, papers
Reasonable inferenceA model this size is cut across many chips. KV cache memory limits how many people fit. Continuous batching and prefix caching are in use. Fleets keep spare capacity in several regions.follows from the mechanics
Not publicThe size and shape of any Claude model, dense or mixture-of-experts. The precision it is served at, chips per replica, batch sizes, real people per chip, efficiency, cost per token and real speed on real hardware.Anthropic has not said

The short answer to the question. One replica of several chips holds one shared copy of the weights and moves many conversations forward by one token every step. In the example, 16 conversations are being written on each chip at any instant. Since most of a person’s time is spent reading and typing, on the order of a hundred people can be actively chatting per chip. The real numbers are not published.

Sources the study names: PagedAttention (vLLM), FlashAttention, speculative decoding (two papers), grouped-query and multi-query attention, DeepSeek-V2 and V3, Splitwise, DistServe, Mooncake, Llama 3, and NVIDIA’s published specifications for H100, H200 and B200.

AN IDEA TO TAKE WITH YOU
Every trick in LLM serving does one of two things: share a read of the weights, or stop reserving memory you are not using.