Skip to main content

Layer L3

Systems and Infrastructure

The layer

What this layer is about

L2 covers what a model is; this layer covers actually running it: how many machines it takes, how to make it fast, and where the money goes. The things you notice when you use a chatbot (after you hit send you wait a moment for the first word, the words pop out one at a time, it slows down at peak hours, you're billed by the token) all come from this layer.

For people whose main focus is L4 application engineering, the finish line for this layer is "can explain it + has deployed once": you can explain the tradeoffs of an inference service in a system design question, and you can get an open model running yourself and measure the numbers. You don't need to write CUDA (the language for programming the GPU directly), and you don't need to have run distributed training.

The map of this layer

Inside its boundary there are four topics, plus one for putting things into practice:

  • GPU basics: why it's used, and where the bottleneck is: why the hardware looks the way it does. A GPU uses thousands of simple cores to do matrix multiplication all at once, which matches exactly what neural networks compute. You need to tell apart three quantities, compute, GPU memory capacity and GPU memory bandwidth, and learn two estimates to judge whether the bottleneck is in "computing" or in "moving data". It also explains why one card can't hold a large model.
  • Serving: running models yourself: inference serving, the center of this layer. Turning a model into a service that can take hundreds or thousands of requests at once. Words like TTFT, TPOT, throughput, KV cache, batching and quantization are all explained here for the first time.
  • Parallel training: why one card is not enough: why training takes thousands of cards. Four ways to split a model and its training state across many cards, and where each split adds new communication.
  • The economics of compute: where training money goes, how inference is priced: how the money adds up. Training is one big one-time bill; inference is a running tab. The cost per million tokens comes down to a single formula.
  • Kubernetes: running it at the customer's site: the vocabulary you need to speak with the other side when the model and the application are finally deployed into a customer's environment.

These five nodes can be seen as two lines. The inference side is the center of this layer: start from the GPU test of "compute-bound or bandwidth-bound", move on to continuous batching, a KV cache managed in pages, quantization and parallelism inside the inference service, and end by deploying once yourself, measuring the four quantities, and turning the cost per million tokens into money. The training side only needs to be explainable: one GPU can't hold a large model's parameters, gradients and optimizer state, so there are four ways to split them (data parallelism copies the model, ZeRO shares out the state, tensor parallelism splits a single layer, pipeline parallelism splits into groups of layers), and each one adds some communication. That explains why training is a job for thousands of cards, and also where the training column in the cost ledger comes from.

How the four quantities squeeze each other

An inference service watches only four quantities: throughput (how many tokens the whole machine generates per second for all users), latency (how long a single user waits: the wait before the first word is called TTFT, and the gap between each word after that is called TPOT), GPU memory, and cost. They aren't four independent metrics; they are the ends of one lever.

Every step of decoding has to read all the weights from GPU memory once, so serving a single request barely uses a card at all. Combine many requests into one batch, and one read of the weights feeds many of them, so throughput goes up; but each request's TPOT gets longer, so latency gets worse. How big a batch can grow depends on how much GPU memory is left for the KV cache (the intermediate results the model stores for each conversation so it doesn't recompute everything at every step), and the KV cache grows with both the number of concurrent requests and the context length. Cost is the inverse of throughput: the card's rent is fixed, so how many tokens it produces in an hour decides how much a million tokens costs.

So every optimization comes down to three things: quantization makes the weights smaller (directly faster when bandwidth is the bottleneck, and the same memory holds more concurrent requests); paged management (allocating in small blocks the way an operating system manages memory, instead of reserving one whole block per conversation) and prefix caching (requests that start the same way share one copy) make the KV cache waste less; and parallelism lets a model that won't fit on one card fit. Explain this section well and you've hit the point of this layer's system design questions.

What you can skip for now

  • Writing CUDA and GPU compute kernels: this layer stops at "can estimate, can judge the bottleneck".
  • Running distributed training yourself: being able to explain what the four kinds of parallelism split and where the communication happens is enough.
  • Operating a Kubernetes cluster itself: being able to deploy a service onto it, configure it, and understand what went wrong is enough; installing clusters and managing networks is the platform team's job.
  • Engines that chase peak performance on the NVIDIA stack only (such as TensorRT-LLM): for one deployment, picking one mainstream engine is enough.

Top picks

In reading order; each pick links to its node below.

  1. 1

    What Every Developer Should Know About GPU Computing free

    First learn what the inside of a GPU looks like; only then can you explain why it swallows matrix multiplication so well → GPU basics: why it's used, and where the bottleneck is

  2. 2

    Making Deep Learning Go Brrrr From First Principles free

    Teaches you to tell whether time goes to compute, moving data, or miscellaneous overhead. Every tradeoff later rests on that call → GPU basics: why it's used, and where the bottleneck is

  3. 3

    How is LLaMa.cpp possible? free

    Applies the bottleneck test to an LLM generating text and works it through with real numbers. You'll see why quantization buys speed directly → GPU basics: why it's used, and where the bottleneck is

  4. 4

    LLM Inference Handbook — Modular free

    A full handbook on inference serving, with a section on each of the four quantities and each optimization lever. Good as this layer's main textbook → Serving: running models yourself

  5. 5

    Inside vLLM: Anatomy of a High-Throughput LLM Inference System free

    Follow one request all the way through a real inference engine. That is the diagram you'll be drawing in a system design question → Serving: running models yourself

  6. 6

    vLLM documentation free

    The engine and load-testing tools for the deployment project. The numbers in your comparison table come from here → Serving: running models yourself

  7. 7

    The Ultra-Scale Playbook: Training LLMs on GPU Clusters free

    Introduces the four kinds of parallelism one at a time, showing what GPU memory each saves and what communication each adds → Parallel training: why one card is not enough

  8. 8

    How to Scale Your Model: A Systems View of LLMs on TPUs free

    Uses the same "compute or bandwidth" ruler to work out how many chips training and inference each need → Parallel training: why one card is not enough

  9. 9

    DeepSeek-V3/R1 Inference System Overview free

    A company's real, published inference ledger. Watch how the cost of each token is worked out step by step → The economics of compute: where training money goes, how inference is priced

  10. 10

    Learn Kubernetes Basics — Kubernetes documentation free

    The official intro tutorial. Learn the vocabulary you'll need when deploying a service into a customer's environment → Kubernetes: running it at the customer's site

The nodes

GPU basics: why it's used, and where the bottleneck is

ml-mathgpu-basicscompute-economicsparallel-trainingserving

The GPU (graphics processing unit) was originally a chip for drawing game graphics; today nearly every neural network is trained and run on one. An analogy: a CPU is like a few very capable senior professors who can solve any hard problem but handle only a few things at once; a GPU is like thousands of schoolchildren who can only multiply and add. Each one can do little, but on command they all start computing at the same time.

Why it fits so well

The bulk of a neural network's computation is matrix multiplication: numbers in one big table multiplied in pairs with numbers in another table, then added up (Linear algebra). This kind of work has two traits: there is an enormous amount of it, and it can be split into countless small pieces that each compute on their own without waiting for each other. That is exactly what thousands of schoolchildren working at once are best at. Modern GPUs also add dedicated tensor cores, which can finish a small block of matrix multiplication in a single instruction.

Three quantities to keep apart

  • Compute: how many floating-point operations per second it can do (FLOP/s; a floating-point operation is a multiply or add on numbers with decimals). Set by the number of cores and the tensor cores.
  • Memory capacity: the GPU's own memory (called HBM, high-bandwidth memory). The data to be computed has to be put here first. It decides how big a model fits: each parameter is one number, stored in 16-bit precision it takes 2 bytes, so a 7-billion-parameter model (often written 7B) needs about 14 GB for the weights alone. When generating text you also have to hold the KV cache (Decoding and inference).
  • Memory bandwidth: how many bytes per second can be moved from memory to the compute units. However fast it computes, if the data cannot get there, it just waits.

Two estimates

Remember two rules of thumb and you will have a feel for how fast a large model runs:

  1. How much compute one token takes: about two floating-point operations per parameter (one multiply, one add). So a 7B model takes about 14 billion operations per token, or about 14 GFLOP (G is a billion).
  2. The ceiling on generation speed: during decoding, every token generated means reading all the weights from memory once. So when serving one person at a time, the most tokens per second ≈ memory bandwidth ÷ bytes of weights. With 1 TB per second of bandwidth and 14 GB of weights, for example, the ceiling is around seventy tokens per second.

Compare these two numbers with the chip's specs and you can tell where the bottleneck is: if moving the data takes longer than computing on it, it is a bandwidth bottleneck; the other way around, it is a compute bottleneck. Decoding for a single user is almost always a bandwidth bottleneck: most of the compute sits idle. This judgment decides where optimization should push: quantization (squeezing each parameter from 16 bits down to 8 or 4) means fewer bytes to move, which makes it faster directly; batching (computing many users' requests together) lets one read of the weights serve many people and puts the idle compute to work. The details of both are in Serving: running models yourself.

Why one card cannot hold a large model

A single card has tens of GB of memory, up to two or three hundred. A 70-billion-parameter model needs about 140 GB for its 16-bit weights alone; training also has to hold the gradients and optimizer state, several times the size of the weights. So training large models, and even running inference on them, means splitting the model across many cards (Parallel training: why one card is not enough).

This layer's boundary

Being able to estimate and to identify the bottleneck is enough. You do not need to write CUDA (the language for programming the GPU directly) or your own compute kernels.

Builds on
Math: learn it when you need it
Leads to
The economics of compute: where training money goes, how inference is priced · Parallel training: why one card is not enough · Serving: running models yourself
  • What Every Developer Should Know About GPU Computing free

    article · 40 minutes — GPU hardware intro (SM, warp, register and memory hierarchy) at application-engineer depth. Explains why GPUs handle matrix multiplies and why data movement is the bottleneck.

  • Making Deep Learning Go Brrrr From First Principles free

    article · 45 minutes — How to tell the three bottlenecks apart (compute, bandwidth, overhead), with arithmetic intensity and FLOPs estimates. If asked in an interview 'where is this model slow', this is the framework.

  • How is LLaMa.cpp possible? free

    article · 30 minutes — Applies the first two to LLM decode: weight bytes ÷ bandwidth = per-token floor. You can work out why quantization buys speed and why a laptop runs 7B.

Not picked (4)
  • GPU MODE(原 CUDA MODE)讲座系列 — For people writing their own GPU compute kernels, deeper than this layer's "explain it, no need to write it" boundary; 6,819 GitHub stars, kept as the way in if you want to dig further.
  • Transformer Inference Arithmetic(kipply,2022) — Overlaps with the finbarr piece, and neither of its two HN appearances reached the endorsement bar.
  • How to Scale Your Model 第 1 章(rooflines)与第 12 章(GPUs) — The same book is already a pick in Parallel training: why one card is not enough, so it does not take a second slot.
  • AI Engineering 第 9 章(Chip Huyen) — Good on inference optimization, but the same book is already the paid pick in the LLM: how the model works node, and its content is covered by the handbook in Serving: running models yourself.

Serving: running models yourself

Who asks for it

requestsbatchGPUtokens outBigger batches: more tokens per second in all,and a longer wait for each first token

serving turns a trained model into a service that can take requests at any time: a user sends some text, the service hands it to the model and sends the generated text back as it is being generated, all while handling hundreds or thousands of other people's requests. When you use a hosted API (Calling a model API: token, streaming, tools, cost), the model company does this for you; when you run an open model yourself, it becomes your job, and in the end it comes down to a bill for GPU time.

Most of the work is done for you by an inference engine, such as vLLM or SGLang: it queues requests, batches them, and manages memory. The skill in serving is not rewriting these engines but knowing which of their settings to change, and measuring the numbers under real load. The goal is not to write CUDA but to be able to explain, in a system design question, how four quantities squeeze each other: throughput, latency, memory, and cost.

A few words first

Each thing you can feel when using a chatbot corresponds to one quantity:

  • TTFT (time to first token): the wait from pressing send until the first word appears. During this time the model is doing prefill: reading and processing your whole prompt in one go. The longer the prompt and the more requests queued ahead of you, the longer you wait.
  • TPOT (time per output token): the rhythm at which words pop out one by one after the first. This stage is called decode, and each step generates one token (Decoding and inference). TTFT and TPOT together make up a request's latency, how fast it feels to a single user.
  • Throughput: how many tokens per second the whole machine generates across all users. A single user cannot feel it; the bill can.
  • KV cache: the intermediate results the model stores for each conversation (the key and value of every token in attention), so the next step does not have to recompute from scratch (Decoding and inference). It takes up memory, and the longer the conversations and the more people chatting at once, the more it takes.

What sets the four quantities

  • Throughput comes mainly from batching. Every decode step reads all the weights from memory once (GPU basics: why it's used, and where the bottleneck is); serving one request at a time, the weights read in are used only once, and the compute sits almost entirely idle. Combine a few dozen requests into one batch, and one read of the weights feeds many of them: throughput rises roughly linearly until either compute or KV cache memory tops out first. Continuous batching goes a step further: new requests can join a running batch at any time, and a request that finishes gives up its place immediately, without waiting for the whole batch to end. It is like a bus that picks up and drops off passengers at every stop, not a charter that leaves only when full and lets everyone off only at the end.
  • Latency has two parts: TTFT is set by prefill and grows with prompt length and queue depth; TPOT is set by how long one decode step takes. The bigger the batch, the higher the throughput, but each step has more to compute, so each request's TPOT stretches out. Throughput and latency are two ends of the same lever. When words seem to come out more slowly at peak hours, a common reason is that more people are using it at once and the batches have grown.
  • Memory holds two things: the weights and the KV cache. The weights are fixed; the KV cache grows with "concurrency × context length," and when it does not fit, the batch has to shrink and throughput drops with it. Paged management (PagedAttention, vLLM's core technique) manages the KV cache the way an operating system manages memory, cutting it into small pages allocated on demand to cut waste; prefix caching lets the same opening shared by many requests (like the same system prompt) be stored once and computed once, which also shortens TTFT.
  • Cost is the inverse of throughput: a card's hourly rent is fixed, so the price per million tokens depends only on how many tokens that hour produced. The levers for cutting cost are therefore the first three: bigger batches; saving KV memory; quantization, squeezing each parameter from 16 bits down to 8 or 4, which makes the weights smaller, directly faster under a bandwidth bottleneck, and leaves room for more concurrency in the same memory, at the price of a possible slight drop in quality that you have to confirm with evals; and parallelism, which lets a model that does not fit on one card fit, or stacks several cards' compute together (Parallel training: why one card is not enough). Tensor parallelism splits each layer across cards inside one machine to cut latency; pipeline parallelism splits by layer across machines to gain throughput; both add communication.

Going from "how much per million tokens" up to "how much a feature burns in a month" is in The economics of compute: where training money goes, how inference is priced; the vocabulary you need when the service is finally deployed into a customer's environment is in Kubernetes: running it at the customer's site.

A hands-on deployment spec

This is only the spec, not the run; when you run it, fill the numbers into the table described below.

What to deploy. One candidate at each of two sizes, from the same family so they compare cleanly: at the 7B class, Qwen3-8B (Hugging Face has the official GGUF and AWQ versions plus a community MLX 4-bit version; these are three formats for already-quantized model files, for llama.cpp, vLLM, and Apple's MLX respectively, so none of the three paths needs you to convert anything yourself), and for the small model, Qwen3-1.7B. If, when you run it, the same family has a newer 7–9B dense model (an ordinary model, not MoE), swap in the newer one; the spec stays the same.

Where to run it, two paths:

Path Tools Good for
Local Apple Silicon llama.cpp (llama-bench measures throughput, llama-server provides the interface) or MLX (mlx_lm.generate prints prompt / generation tokens/s and peak memory directly) Zero cost, can be repeated as often as you like; this is where the effect of quantization on speed and memory is easiest to see. Test concurrency only up to 8: on unified memory there is no "out of memory," only "slower"
Rent a cloud GPU for an hour One 24–80 GB card, vllm serve to start the service, vllm bench serve to apply load To see the real batching curve, the memory use of paged KV, and the rental cost per million tokens; run 1 / 8 / 32 concurrency all within the hour

What to measure, recorded for every configuration:

  1. Throughput: output tokens per second for the whole machine, and tokens per second each single request gets.
  2. TTFT and TPOT at p50 / p90 (p50 means half the requests are faster than it, p90 means nine in ten are; you look at p90 so that a few especially slow requests do not get hidden by the average). vLLM's bench reports the median and P99 by default, so compute p90 from the raw results or set it with the percentile parameter; on the local path, time it yourself with the same load script.
  3. Memory use: the weights part + the KV cache part (vLLM's startup log gives the KV reservation, nvidia-smi gives the total; locally, look at peak memory).
  4. Cost per million tokens: cloud GPU = hourly rent ÷ (output tokens/s × 3600) × 10⁶; for local, record 0 and note that electricity is not counted.

Variable matrix: model (8B / 1.7B) × precision (bf16 or fp16 / 4-bit quantized) × concurrency (1 / 8 / 32) × path (local / cloud), with a fixed prompt length (say 512 input, 128 output). On the local path you can skip 32 concurrency.

Output. A one-page comparison table: one row per configuration, with the four groups of numbers above as columns; under the table, three sentences of conclusions: how much speed quantization bought, how many times throughput grew from 1 to 32 concurrency and how much slower TPOT got, and what the cloud costs per million tokens, set side by side with one hosted API's list price.

Builds on
LLM: how the model works · GPU basics: why it's used, and where the bottleneck is · Decoding and inference
Leads to
The economics of compute: where training money goes, how inference is priced · Kubernetes: running it at the customer's site
On the routes
AI Engineer (Serve it)
  • LLM Inference Handbook — Modular free

    docs · 3–4 hours — Latency, throughput and cost of serving a model — batching, KV cache, quantization, which engine when — as one practical handbook rather than twenty blog posts.

  • Inside vLLM: Anatomy of a High-Throughput LLM Inference System free

    article · 1.5 hours — One request followed through the scheduler, paged KV cache, continuous batching, prefix caching and speculative decoding, ending on the latency-against-throughput curve a design answer needs.

  • vLLM documentation free

    docs · half a day — The engine the cloud-GPU route runs on: the docs explain the trade-off behind each setting, and the bundled vllm bench serve prints TTFT, TPOT and throughput — the deployment project's numbers.

Hands-on project: Serve a small open model and measure it — Serve a small open model with vLLM, then measure time to first token and tokens per second at 1, 8 and 32 concurrent requests, with and without quantization.

Not picked (6)
  • SGLang 文档 — The second mainstream engine, conceptually the same shape as vLLM (its RadixAttention is prefix caching); one deployment needs only one of them. 36,861 GitHub stars.
  • TensorRT-LLM 文档 — Worth it only when chasing peak performance on NVIDIA's software stack; harder to get started with than this layer calls for.
  • llama.cpp、MLX — Tools used directly on the local path; they already appear in the deployment spec, so they do not take pick slots. Both are actively maintained.
  • Life of an inference request (vLLM V1)(Ubicloud,2025-06,HN 175 分) — Covers the same path as the Gordić piece but shorter; of the two, the fuller one is kept.
  • Nano-vLLM(2025–2026) — A good way to learn engines by reading their source, but beyond the "can explain it + deployed it once" boundary.
  • AI Engineering 第 9 章(Chip Huyen) — The same book is already the paid pick in the LLM: how the model works node, and its inference-optimization content overlaps with the handbook.

Parallel training: why one card is not enough

gpu-basicstransformerparallel-training

When you train a large model, memory has to hold more than just the model's parameters. It also holds the gradients (computed by backpropagation: which way, and how far, each parameter should change; see Loss and backpropagation) and the optimizer state (Adam, the most common optimizer, keeps two extra numbers per parameter to track its recent trend of changes). With mixed-precision training, all of this adds up to roughly 16 bytes per parameter. A 70-billion-parameter model therefore needs over a thousand GB, while a single card has two or three hundred GB at most (GPU basics: why it's used, and where the bottleneck is). And that is before the activations: each layer's intermediate results from the forward pass, needed again on the backward pass. So training is first of all a puzzle: how to cut all this up, and which cards to put it on.

Four ways to cut

  • Data parallelism: each card holds a full copy of the model and works on different training data; at the end of each step everyone averages their gradients (this is called synchronization), so all copies stay identical. The simplest, but it requires one card to hold a whole copy.
  • ZeRO: builds on data parallelism, but instead of every card copying all the state, it slices up the optimizer state, the gradients, and even the parameters themselves in turn, so each card keeps one slice and fetches the rest from other cards when needed. Memory is no longer wasted many times over as the card count grows; the cost is more communication.
  • Tensor parallelism: cut a layer's big matrices apart, have several cards each compute one part, then put the pieces together. This happens at every layer, so communication is very frequent, and it is used only inside one machine, where the links between cards are extremely fast.
  • Pipeline parallelism: cut by layer, with the first few layers on one group of cards and the later layers on a second group, passing intermediate results down stage by stage like a factory assembly line. The cost is bubbles: when the pipeline is starting up and winding down, some cards are always waiting for data from upstream, sitting idle.

Training on thousands of cards stacks several of these cuts together: for example, tensor parallelism inside each machine, pipeline parallelism between machines, and another layer of data parallelism wrapped around that. MoE models add one more way to cut: putting different experts on different cards (Long context and MoE).

The hard part is communication

Every way of cutting buys you new communication: syncing gradients, joining matrices, passing intermediate results. The more cards there are, the more easily the time spent waiting for data exceeds the time spent computing. The core engineering skill is "hiding" communication behind computation: compute this layer while sending the previous layer's data, so the cards sit idle as little as possible.

This layer's boundary

Being able to explain what each kind of parallelism cuts, and where the communication happens, is enough; you do not need to have actually run distributed training. The prerequisites are the memory concepts in GPU basics: why it's used, and where the bottleneck is and the structure of the Transformer (knowing which matrices are in "one layer"). It explains why training takes thousands of cards, and also why the training bill is so big (The economics of compute: where training money goes, how inference is priced).

Builds on
GPU basics: why it's used, and where the bottleneck is · Transformer
  • The Ultra-Scale Playbook: Training LLMs on GPU Clusters free

    book · one weekend — From single-card memory to data, ZeRO, tensor, pipeline, context and expert parallelism: what each saves, what communication it adds. You can explain why training needs thousands of cards.

  • How to Scale Your Model: A Systems View of LLMs on TPUs free

    book · one weekend — One roofline yardstick for training and inference. Communication and compute per strategy are formulas, so you can derive chip count and best split on a whiteboard. Ch. 12 moves it to GPU.

  • CS336: Language Modeling from Scratch free

    course · 4 lectures, about 6 hours — For listening, not reading: lectures 5 (GPU), 7–8 (parallelism), 10 (inference), by researchers on design trade-offs; covers this layer's four nodes. Videos are in the YouTube playlist.

Not picked (3)
  • picotron / nanotron(Hugging Face) — A runnable implementation to go with the playbook, but this layer stops at "can explain it" and does not require hands-on training.
  • Megatron-LM、DeepSpeed 官方文档 — The user docs for these two training frameworks, which assume you are already going to use them; they explain the concepts less clearly than the playbook.
  • GPU MODE 的 NCCL / 集合通信讲座 — On the low-level details of moving data efficiently between cards, too deep for this layer; it is the same series as the Not picked item in GPU basics: why it's used, and where the bottleneck is.

The economics of compute: where training money goes, how inference is priced

gpu-basicsservingcompute-economics

This section turns the technical quantities from earlier into money. The money in an AI product goes mostly to two places: training and inference. The first is like building a factory, paid once; the second is like the factory's daily power and raw materials, paid for as long as anyone uses it.

Training: one big bill

Training cost is roughly: number of cards × hours of training × price per card per hour. The real bill is always bigger: when machines fail mid-run you roll back and rerun, there are many small-scale experiments before the real run starts, and then there is the cost of data and researchers. Why so many cards and so many hours was covered earlier: scaling laws say that spending more compute buys predictable progress (Pretraining and scaling), and one card cannot hold it all (Parallel training: why one card is not enough). The bill is one-time, but the next generation of models has to pay it again.

Inference: the running tab

Inference cost is paid every time someone uses the model, and it decides the product's gross margin (what is left of revenue after direct costs). The cost per million tokens has only one formula:

GPU rent per hour ÷ tokens actually produced in that hour × one million

So throughput is the inverse of cost: on the same card, produce twice as many tokens an hour and each token costs half as much. A made-up example: a card rents for 2 dollars an hour, the machine steadily produces 1,000 tokens per second, that is 3.6 million in an hour, so the cost per million tokens is about 0.56 dollars. Throughput is set by the batch size, how frugally the KV cache is used, quantization, and parallelism, which is the last of the four quantities in Serving: running models yourself. That gives you four levers for cutting cost: bigger batches, saving KV memory (paging, prefix caching), quantization, and choosing the right kind of parallelism.

The supply side: chips, power, data centers

The money finally flows to three places. Take three questions with you when you read industry news:

  • Chips: in the price of a GPU, how much is the compute and how much is the HBM memory? Who controls the production capacity for advanced chips?
  • Power and data centers: big clusters need power and cooling; how fast can new power and data centers be built?
  • The rental market: most companies rent cards rather than buy them. The hourly GPU rental price rises and falls with supply and demand, and it is the numerator in the formula above.

What this section is for

In a system design question, you can work out "how much this feature will burn in a month": tokens per day × 30 ÷ one million × cost per million tokens; and you can name the four levers for cutting cost. The prerequisites are GPU basics: why it's used, and where the bottleneck is and Serving: running models yourself.

Builds on
GPU basics: why it's used, and where the bottleneck is · Serving: running models yourself
  • DeepSeek-V3/R1 Inference System Overview free

    article · 30 minutes — A model lab's own inference ledger: nodes, daily tokens, daily GPU cost, revenue at list price. The only first-hand per-token cost with real numbers; why big batching and expert parallelism cut cost.

  • Memory has grown to nearly two-thirds of AI chip component costs free

    article · 15 minutes — Key supply-side fact: HBM, not logic, is now the biggest cost in an AI chip. Explains why memory bandwidth is pricey and why compute growth is stuck on memory supply, not just wafers.

Not picked (4)
  • How AI Labs Are Solving the Power Crisis(SemiAnalysis,2025-12) — The most detailed take on the power supply line, but the cost analysis is behind a paywall (HN 167 points); use it as a paid supplement when needed.
  • Inference Economics of Language Models(Epoch AI,2025-06) — A good piece that models inference cost, but with no independent endorsement (HN 4 points); kept as further reading.
  • LLM Inference Economics from First Principles(Tensor Economics,2025-05) — Same as above: careful derivation, but no endorsement.
  • AI's $600B Question(Sequoia,2024) — It is about whether the whole industry's investment will pay back, not the cost of each token; far from this layer's finish line.

Kubernetes: running it at the customer's site

Who asks for it

Kubernetes (often shortened to k8s) is a system for managing containers. You tell it "run three copies of this service, each using at most 2 GB of memory, and restart any that crash," and it keeps that state in place across a group of machines. A container packages a program together with everything it needs (libraries, runtime environment) into a standard unit that runs the same way on any machine.

Why people building AI applications need to know it: an FDE's job (a forward deployed engineer, who goes on-site with the customer to make the product land, see FDE / AI Engineer) is often to deploy a model service or an agent into the customer's own cloud, into a Kubernetes cluster you do not own. The customer's ops team speaks this vocabulary, and you need to understand it and use it correctly.

A few words you need

  • Deployment: declares which image (a packaged container) a service uses and how many copies run. Change the image version and it does a rolling update, replacing copies one at a time so the service never goes down.
  • Config and secrets (ConfigMap, Secret): pull configuration and secrets like API keys out of the image and manage them separately; to move the same image to another environment, you only swap the config.
  • Resource limits: the most CPU, memory, and GPUs each container may use. Without limits, one runaway process can drag down every other service on the same machine.
  • Health checks (probes): Kubernetes regularly asks your service "are you alive, can you take requests?" If it cannot answer, Kubernetes restarts it, or holds off sending it traffic.
  • Logs and metrics: where to look and what to look at when something goes wrong (Observability: know what is happening in production, and feed it back into evals).

The boundary

If you have shipped a web service before, you already know most of this. You need to be able to deploy a service, configure it, and understand what happened when things break; you do not need to operate the cluster itself. Installing clusters, managing networking, and upgrading machines are the customer's platform team's job. Everything you have done on k3s (a lightweight Kubernetes that runs on a single laptop) counts. It comes after Serving: running models yourself: once a model service runs in your hands, this is the form it finally takes when it goes into the customer's environment.

Builds on
Serving: running models yourself
On the routes
Forward Deployed Engineer (Deploy into their environment)
  • Learn Kubernetes Basics — Kubernetes documentation free

    docs · 2–3 hours — The project's own six-module tutorial: create a cluster, deploy, expose, scale and roll out an app — the vocabulary every customer's environment is written in, in an afternoon.

  • Troubleshooting Applications — Kubernetes documentation free

    docs · 1 hour — Pods, services and running containers debugged with what you get on a cluster you do not own — describe, logs, events, a shell — the job when a customer's deployment misbehaves.

Hands-on project: Deploy your agent where a customer would run it — Package the agent as a container, deploy it to a local cluster with its secrets, a health probe and resource limits, then kill a node and watch what happens.

Self-check

  • Given a card's compute and bandwidth, and a model's parameter count and precision, I can work out in my head the most tokens per second it can generate, and say whether it is currently compute-bound or bandwidth-bound. (Hint: every token generated means reading all the weights from GPU memory once.)
  • I can explain how throughput, TTFT, TPOT and the GPU memory taken by the KV cache each change as concurrency rises from 1 to 32, and which of them quantization moves. (Hint: the bigger the batch, the more people one read of the weights serves, but each step also gets slower.)
  • Given a product's daily token volume and a card's rental price, I can work out the cost per million tokens and the monthly bill, and name four levers for lowering cost. (Hint: cost is the inverse of throughput.)
  • I can explain what data parallelism, ZeRO, tensor parallelism and pipeline parallelism each split, where the communication happens, and why training takes thousands of cards. (Hint: first work out how many bytes each parameter takes up while a large model trains.)
  • I have deployed an open-source model myself and produced a one-page comparison table with numbers.

Hands-on projectOn your own Mac (with llama.cpp or MLX), or on a cloud GPU rented for an hour (with vLLM), get two open models running, Qwen3-8B and Qwen3-1.7B. Across combinations of 1 / 8 / 32 concurrent requests, quantized and not, measure throughput, the p50 / p90 of TTFT and TPOT (the time that half, or nine in ten, of the requests come in under), GPU memory used, and the cost per million tokens, and put it all into a one-page comparison table. When you're done you'll have seen for yourself: add concurrency and throughput multiplies while the gap between words grows longer; quantize and the model gets smaller and runs faster. The full spec is in the "hands-on deployment spec" of Serving: running models yourself.

Spot a mistake on this page?