Start hereLesson 00

Zero to Ready

The mental model behind the whole site — tokens, transformers, inference, harnesses, and the four budgets that decide whether a system works.

Start here18 min readUpdated November 2026

Zero to Ready

You do not need a PhD to understand why a model is slow, why an agent loops, or why the bill doubled. You need a clear picture of what happens between a prompt and a token — and between a token and an action.

This site teaches two disciplines that are usually learned separately:

  • Inference engineering — turning trained weights into a reliable, affordable stream of tokens.
  • Harness engineering — turning a stream of tokens into work that can be trusted.

They meet at the same boundary. Inference decides how fast and how cheaply a model can think. The harness decides what the model is allowed to do with that thought, what it remembers, and when the work is actually finished.

The 60-second version

A language model is a very large function. You give it a sequence of integers and it returns a probability distribution over the next integer. Then you pick one, append it, and repeat.

Those integers are tokens. A tokenizer chops text into pieces — sometimes a whole word, sometimes a fragment, sometimes a single space or punctuation mark. The model never sees characters. It sees token IDs.

Figure 0.1Transformer serving view
The transformer from a serving perspectiveTokens go through embedding layers, repeated attention and MLP blocks, then a language-model head. Attention writes keys and values to the KV cache during prefill and reads them during decode.The only parts serving cares aboutTOKENS → EMBED → N × (ATTENTION + MLP) → LM HEAD → LOGITSINPUTtoken IDsB × TEMBEDvectorsB × T × HN TRANSFORMER LAYERSattention + MLPresidual + norm each blockweights dominate memoryLM HEADvocab logitsH → VSAMPLE / VERIFYnext tokenthen loop backINSIDE ONE ATTENTIONQ · K · VQ = current tokenK, V = cached prefixKV cache lives herePREFILL VS DECODESame weights, different shapeprefill: T prompt tokens in paralleldecode: 1 token, read all weights + KV→ compute-bound vs bandwidth-boundA 70B model has roughly 70 billion weights. Every decode step reads them again.
The same transformer runs in two very different shapes. Prefill processes the prompt in parallel; decode produces one token per step and reuses the KV cache.

The model itself is a stack of transformer blocks. Each block has an attention layer and an MLP. Attention lets each position look at earlier positions. The MLP transforms each position independently. Residual connections and normalization hold the stack together. At the end, a language-model head projects the final hidden state onto the vocabulary.

There are two phases:

  1. Prefill reads the prompt. All prompt tokens are processed in parallel. This phase is usually compute-bound, and it fills the KV cache — the stored keys and values that later tokens will attend to.
  2. Decode produces output one token at a time. Each step reads the weights and the growing KV cache, does relatively little math per byte moved, and appends one token. This phase is usually memory-bandwidth-bound.

That distinction explains most serving behavior. Prefill sets time to first token (TTFT). Decode sets time per output token (TPOT) and therefore how fast text streams. When people say “the model is slow,” one of those two numbers is usually bad — and they have different fixes.

Inference is a resource-allocation problem

A serving system has four budgets, and they push against each other:

BudgetWhat it limitsTypical lever
MemoryWeights + KV cache + workspaceprecision, parallelism, context length
BandwidthTokens per second during decodequantization, batching, KV compression
LatencyTTFT and TPOT under loadscheduling, chunked prefill, cache hits
MoneyCost per completed requestutilization, batch size, model choice

You can almost always improve one by making another worse. A bigger batch raises throughput and lowers cost per token, but it can raise TPOT and hurt tail latency. A longer context improves capability, but the KV cache eats the memory that would have served more users. A cheaper model lowers token cost, but may need more retries.

This is why the inference track keeps returning to the same question: what is the workload, and what does “good” mean for it? A benchmark without an SLO is a science experiment, not a capacity plan.

A harness is the rest of the product

A raw model call takes text and returns text. An agent takes a goal, observes an environment, calls tools, remembers what happened, and decides when to stop. The layer that makes this possible is the harness.

Figure 0.2Harness anatomy
The anatomy of an agent harnessThe model sits at the center. Around it, the harness supplies a loop, tools, context, policy, state and observability. The model is one component; the harness turns it into an agent.The model is the engine. The harness is the vehicle.SIX SURROUNDING SYSTEMS TURN A COMPLETION INTO AN ACTIONMODELweights + sampling01 · LOOPobserve → plan → act → verify → stop02 · TOOLSread, edit, shell, search, MCPtyped schemas + errors03 · CONTEXTsystem, history, retrieved files,compaction, pinned decisions04 · STATEsessions, checkpoints, event log05 · POLICYpermissions, sandbox, approvals,secrets, budgets, allowlists06 · TRACESspans, costs, evals,replay and auditMost agent failures are not “the model was too small.” They are missing context, missing verification, or missing authority boundaries.
The model is one component. The harness supplies the loop, tools, context, policy, state and observability around it.

A harness has six recurring jobs:

  • Loop — observe, plan, act, verify, repeat or stop.
  • Tools — typed functions the model can call: read a file, run a test, search the web.
  • Context — what the model sees on this turn, and what gets summarized or dropped.
  • Policy — what the model may do, where, and with whose approval.
  • State — durable facts, checkpoints, and an event log that survives a crash or a compaction.
  • Observability — traces, costs, evals, and replay.

Most agent failures are not “the model was too small.” They are missing context, missing verification, or missing authority boundaries. A harness that gives a model shell access but no sandbox has not built an agent; it has built an incident generator.

The two tracks, side by side

QuestionInference trackHarness track
What is the core object?A requestA task
What is the scarce resource?GPU memory and bandwidthContext, steps and trust
What does “fast” mean?TTFT, TPOT, goodputTime to a verified result
What does “cheap” mean?Cost per million tokensCost per completed task
What is the classic failure?Averages hide a terrible tailA confident answer without evidence
What is the key discipline?Measure the workloadDefine done, then enforce it

The tracks are not independent. An agent’s tool calls are inference requests. A serving SLO is part of the product experience. A harness that retries five times because the model is cheap can be more expensive than one strong call. And an inference stack that streams beautifully is useless if the harness loops forever.

How to read this site

You can read linearly, or take a path:

  • New to all of this: start here, then the inference track, then the harness track. Do the tokenizer lab early — it makes token counts concrete.
  • You run models: start with The Life of a Token, then GPU anatomy, KV cache and batching. Use the Serving Workbench after each lesson.
  • You build agents: start with What Is a Harness?, then the agent loop, context and permissions. Use the Harness Workbench to break things on purpose.
  • You need a reference: the Stack Map shows how the layers connect. The Glossary has working definitions, not marketing ones.

Two themes are available in the header. Draft is a warm paper notebook: serif display type, ink lines, cobalt and orange. Live is a night signals desk: indigo surfaces, electric cyan, hot magenta and violet traces. They are the same information in two visual languages. Use whichever helps you think.

The one habit that matters

When something is slow, expensive or unreliable, do not start with a technique. Start with a boundary:

  • Where does the request wait?
  • What is in memory at that moment?
  • Which budget is exhausted?
  • What evidence would prove the system is working?

That habit is the whole site. The rest is detail — important, learnable detail, but detail.

In the next lesson, follow a single request from arrival to the last streamed token. That journey is the spine of the entire inference track.

Sources and further reading

One question before you go

retrieval check
Why can two models produce different token counts for the same sentence?
Why: Tokenization is model-specific. A different vocabulary segments the same text differently, which changes prompt length, cost and context usage.
Type at least two characters. Search is indexed after the production build.
Lessons · labs · glossary↑↓ to browse · esc to close