viz Β· gaema

viz

Interactive visualizations of CNN/LLM internal math. Each page shows the linear algebra of one mechanism, step by step, following an A1–A12 shape taxonomy.

πŸŽ“ New here? Take the guided tour β†’  β€” a narrated walkthrough of all the demos in curriculum order, with a progress track.

Card descriptions are in plain English (why each one matters in the real world) or technical (what the page shows mathematically) β€” switch at the top right. The same switch is on every demo page, and it remembers.

A β€” Foundational primitives

matmul
Every output cell is one rowΒ·column dot product, and every layer of every model reduces to this. Watch the tiles light up, then resize the problem and watch the cost grow.
A neural network layer is, underneath, a grid of numbers multiplied by another grid of numbers. Each cell of the answer is built by walking one row of the first grid against one column of the second, multiplying the pairs and adding them up, and a model thinking is trillions of those little sums. That is why running AI wants a graphics chip rather than an ordinary processor: the work is enormous but wonderfully repetitive, which is exactly what those chips are built for. Understand this one operation and compute cost stops being a mystery.
dot-product
Two vectors multiplied term by term, plus the geometry behind it: the projection of one onto the other, the angle between them, and the cosine similarity attention is built on.
Take two lists of numbers, multiply them position by position, and add the results up. That single number says how much the two lists point the same way: large and positive when they agree, near zero when they are unrelated, negative when they pull in opposite directions. It is the smallest piece of almost everything a model does, computed once for every pair of things it compares, millions of times per layer. Divide it by how big each list is β€” the square root of the sum of its own squares β€” and you have cosine similarity, the score behind search results and "people also liked".
dtype-bits
Twenty-three number formats bit by bit: sign, exponent and mantissa, what each can represent, and the rounding error you accept for the bits you save. Plus which hardware runs which.
Every number inside a model is stored in a fixed number of bits, and using fewer of them makes the model smaller and faster, which is how one squeezes onto a phone. The catch is what the bits buy. Cutting them coarsens the values, and the popular "four-bit" formats are not four bits per number at all: they are four bits each plus one shared multiplier for a whole block of them, which averages out at 4.25 a number when a block holds thirty-two and 4.5 when it holds sixteen β€” smaller blocks follow the values more closely and cost more to store. There is a second catch that is easy to miss: a format is only fast where the chip can multiply it directly, and where it cannot the numbers are expanded back into a format with more bits first, saving memory and buying no arithmetic speed at all.
softmax
Scores become probabilities: exponentiate, then normalise. Temperature sharpens or flattens the result, and subtracting the largest value first is what stops it overflowing.
A model's raw output is a list of scores with no natural meaning: one word scored 8.3, another 2.1. Softmax turns that list into percentages adding up to 100, by growing each score exponentially and then dividing by the total, so a modest lead in score becomes a large lead in probability. Every classifier and every next-word prediction ends in one of these. A single dial called temperature stretches or squeezes the scores beforehand: turned low it makes the leader nearly certain, turned high it flattens everything toward an even chance.

B β€” Attention

qkv-projection
One token embedding becomes three different views of itself β€” a query, a key and a value β€” through three separate weight matrices. Everything attention does begins here.
Before words can pay attention to each other, each one is turned into three different versions of itself, by running its numbers through three separate tables the model learned during training. One version is the query, what this word is looking for. One is the key, what it advertises to anything looking. One is the value, what it hands over if someone does look. Same word in, three roles out, and that is what lets the next step match one word's question against another word's offer and then pull across only what that second word actually carries.
scaled-dot-attention
The full single-head pipeline: compare every query to every key, scale by the square root of the dimension, mask, softmax, then mix the values. Every other page varies this.
This is the step where words read each other. In "the cat sat on it", something has to work out that it means the cat: every word compares its question against every other word's offer, those comparisons are turned into percentages, and each word pulls in a blend of what the others carry, weighted by how well they matched. Two details do real work. Every score is divided by the same fixed number first so the percentages do not collapse onto a single winner, and a word may only look backwards, never forwards. Every other form of attention is a variation on this one formula.
qk-norm
Queries and keys are divided by their own RMS before the dot product. A long key then stops winning the softmax just by being long, and the aligned key can take the mass.
A word can look important just because the numbers that describe it are large, even when it points somewhere else. Dividing each question and each offer by its own size first takes that advantage away. What is left is the direction. The word that actually matches can then win, and the long one collects only the share its direction earned. Turn the off-axis key down until its raw score prints below the aligned key, and both ways pick the aligned key. When the two raw scores print equal, the raw result is a tie and the norm still picks the aligned key.
multi-head
Split the embedding into heads, run attention independently in each, then concatenate and project. Each head is free to learn a different relationship between tokens.
Comparing every word against every other word once gives the model exactly one notion of what "related" means. Real models run several of these comparisons side by side, called heads, each working on its own slice of each word's numbers, so one head can follow grammatical agreement while another follows the subject of the sentence and another simply looks one word back. Their answers are stitched back together into a single result per word. The cost is that no head sees the whole picture: cutting each word's numbers into eight or thirty-two slices leaves every head reasoning on a fraction of what is there.
gqa-mqa
Several query heads share one set of keys and values. The cache shrinks by the sharing factor, which is why generation gets cheaper β€” and head-specific detail is what you give up.
While a model writes, it keeps notes on every word so far, and each of its attention heads normally keeps a private set. Those notes are the largest memory cost of a long conversation. The saving here is to let several heads read one shared set instead: eight shared sets for sixty-four heads cuts that memory to an eighth, and a single shared set for all of them cuts it further still. What is given up is per-head detail, since heads sharing a set can no longer look at slightly different things, which is why most models share in groups rather than collapsing all the way down to one.
cross-layer-kv
Every share-th layer writes keys and values, and the tail still gets a writer. The layers until the next writer reuse that cache. A share of 1 means every layer writes its own cache.
A model stores notes for every layer, and those notes are most of the memory a long conversation costs. Sharing across layers lets several of them read one set of notes instead of each writing its own. A layer that reuses a set still computes a new query, so it can look at different places in the same notes. The saving is every layer that no longer writes. A share of one puts that saving at zero, because every layer writes its own notes. What is given up, once the share is larger, is a private memory at every depth.
causal-mask
Blank out everything above the diagonal so a token can only read what came before it. Remove the mask and watch information leak backwards from tokens not yet written.
A language model writes one word at a time, and it is never allowed to look at what comes after the position it is working on. A mask enforces that by blocking everything later in the text for every position, which leaves the familiar triangle of allowed comparisons. The rule matters most during training, where seeing even one word ahead would let the model copy the answer it is meant to guess and learn nothing. It sounds like a restriction and it is really an efficiency: because each position is blinded to its own future, an entire book can be shown to the model in one pass and still produce a fair next-word test at every one of its thousands of positions.
fill-in-the-middle
The tokens run prefix, then suffix, then the missing middle, so a causal mask lets the middle read the ending. Two examples under that mask let the second read the first. Isolate them and those cross pairs drop to 0.
Training a model to fill a gap is different from training it to continue a sentence. The example is laid out as the opening, then the ending, then the missing middle, so a mask that only looks backward still lets the middle read the ending. The cost shows up when two examples share that mask: the second can read every token of the first. Isolating the examples removes those pairs, and each middle token still sees its own ending.
attention-patterns
Full, sliding-window, hybrid and sink patterns side by side: which past tokens each query may read, and how much of the sequence each choice quietly throws away.
Letting every word compare itself against every earlier word gets expensive quickly: the work per word grows with how much text came before it, and the notes held in memory never stop growing. So real models restrict what each word is allowed to read. A sliding window lets a word see only the last few thousand; a mixed design keeps most layers local and lets a few see everything; and a sink scheme keeps the first handful of words permanently visible alongside the window. Each of these is cheaper, and each gives up the same thing, because a word outside the allowed set is not read at all.
kv-cache
The cache gains one column per generated token, per layer, and never shrinks. This is why generation is fast, and why a long chat runs out of memory before it runs out of words.
When a chatbot writes a reply one word at a time, it would otherwise have to re-read the whole conversation from scratch before every single word. Instead it keeps the work it already did on each earlier word, two rows of numbers per word in every layer, and reuses it. Those kept rows are the KV cache, and they are why a reply streams steadily instead of slowing to a crawl. The price is memory: the cache grows with every word of the conversation, in every layer at once, which is what a model's advertised limit on how much it will hold at once is really protecting, and why a long chat fills up a graphics card.
rope
Position is encoded by rotating each pair of dimensions by an angle proportional to position. Relative position falls out of the arithmetic; stretching the angles extends context.
Attention on its own is blind to word order. Shuffle the words of a sentence and it computes exactly the same thing, which would make "dog bites man" and "man bites dog" identical to the model. Something has to tell it where each word sits. RoPE does that by rotating each word's numbers through an angle that depends on its position, like turning a dial one notch per word β€” and not one dial but many, some spinning fast enough to tell neighbours apart and some so slowly that they only register whole paragraphs. Two words five apart always end up at the same relative angle, so the model learns "five apart" rather than "word 12 and word 17" β€” and that is why you can stretch a model to longer documents than it was trained on by turning the slow dials slower still.
flash-attention
Attention computed tile by tile with a running maximum and sum, so the full score matrix is never stored. Same answer, memory that grows with the tile instead of the sequence.
Comparing every word against every other word produces a table with one entry per pair, and for a long document that table is far too large to hold in the fast memory next to the chip. FlashAttention never builds it. It walks the earlier words in small tiles, keeping only a running total and a running largest-score per word, and rescaling what it has accumulated whenever a bigger score turns up, so only one tile exists at any moment. The answer comes out identical to building the whole table, which is the unusual part: this is not an approximation, and it is why long-context models are practical at all.
sparse-attention-select
A cheap scorer ranks every past token and only the top few get real attention. Drag the cut and watch the selected set move β€” and a needle just outside it contribute nothing.
Once a model's memory stretches to hundreds of thousands of words, reading all of them again for every new word stops being affordable. So a cheap scoring network ranks the past and only the top slice is read properly. Two costs come with that. The scorer still has to look at every past word, so it carries the same growth problem it is meant to solve and only starts paying once the text is long enough, below which the cheap path is the expensive one. And the cut is absolute: something ranked just outside the slice contributes nothing whatsoever, not a little.
attention-sinks
Softmax has to put its weight somewhere, so a head with nothing to look at dumps it on the first token. Huge attention, almost no contribution β€” and deleting it breaks the model.
Attention weights are forced to add up to 100%, so a head with nothing it actually wants to read still has to put that share somewhere. It parks it on a position every word can see, which in practice is the first token, or the first few. Enormous attention lands there and almost nothing flows out of it, which is why deleting those opening tokens to save memory wrecks the output: the mass they were absorbing gets pushed onto words that do carry meaning. Two fixes exist and they pull opposite ways, giving the head somewhere harmless to put spare attention or letting it turn its own volume down, and both need a trained setting the original model does not have.
sage-attention
The attention scores are rounded to eight-bit integers before the softmax. The output moves, and a row of zeros stays exact because it was already on the grid.
Exact attention keeps every score at full precision. Rounding each score row to eight-bit integers, against that row's own largest entry, moves the mixed output. A row that is already zero stays exact, because every code lands on the grid. The saving is the bytes moved for the scores. The cost is that the attention is no longer the same numbers.

C β€” Transformer block

tokenization
Byte-pair encoding builds a vocabulary by repeatedly merging the commonest adjacent pair. Watch text become token ids, and see why an unusual word costs several of them.
A model does not read letters. Before anything else your text is cut into tokens, a fixed list of somewhere between fifty thousand and a quarter of a million whole words and word fragments, each with a number of its own. That list is built by starting from single characters and repeatedly gluing together whichever pair of neighbours turns up most often across a large pile of text, so common words end up as one token while rare ones get chopped into several. It is why you are billed per token rather than per word, and why an unusual name, or a language the list was not built around, costs several times more to send than ordinary English.
embedding
A token id is a row number, so the embedding table is looked up rather than multiplied. Tied and untied output weights are the same table read in two directions.
A computer can only do arithmetic, so the numbered token your text has been cut into has to become numbers the model can work with. It does that by plain lookup: a large table holds one row of numbers per entry in the token list, and the token's number is simply which row to fetch. Nothing is calculated here, which makes it the cheapest step in the model and also one of the bulkiest to store, since a list of a quarter of a million tokens needs a quarter of a million rows. Many models save that space by reusing the very same table at the end, to turn the finished numbers back into a word.
mlp-gated
Two projections up, one gate, one projection back down. The gate multiplies element by element, letting the layer suppress its own features β€” and this is where most parameters live.
Once attention has let the words look at each other, each word is passed on its own through a small two-stage network, and this is where most of what a model knows is stored β€” usually around two-thirds of all its numbers. The modern version does the first stage twice, side by side: one copy is bent through a curve and then used to scale the other, number by number, so the network can turn parts of itself down to nothing for one word and leave them at full strength for another. That second copy is a third grid of numbers to pay for, so models make each stage narrower to keep the total size roughly where it was.
activations
GeLU, SiLU, Mish and their cheap approximations on one axis. They differ mostly near zero, and that small difference is what decides how gradients flow through a deep stack.
Between the multiplying steps of a layer sits a small bend: a function that takes each number on its own and passes it through a curve. Without it the whole stack collapses, because multiplying by one grid of numbers and then by another is the same as multiplying by a single combined grid, so a hundred layers would be worth exactly one. The curves actually in use are all much the same shape β€” near zero for negative inputs, near unchanged for large positive ones, with a shallow dip in between β€” and that is the honest finding here: which of them you pick makes very little difference.
normalization
RMSNorm against LayerNorm: per-row statistics with and without subtracting the mean, and why placing the step before or after the block changes how stably it trains.
Numbers passing through a deep network drift: run them through enough layers and they either grow without bound or fade away, and training stops working. The fix is to rescale each word's numbers back to a standard size before every layer, working the scale out from that word's own numbers and nothing else. Two recipes are common β€” one shifts the numbers to sit around zero and then divides by how spread out they are, the other skips the shift and only divides, which is cheaper and what most recent models use. Where the rescaling sits matters too: doing it before each layer rather than after the addition is what lets very deep models train at all.
residual-stream
Every block reads the stream, adds its contribution and writes it back. Nothing is ever replaced, which is why information from the first layer can still reach the last.
Running the length of a language model is one set of numbers per word that every layer shares. A layer never replaces it: it reads a copy, works out a small correction, and adds that correction back on, so the model is one long running sum rather than a chain in which each step overwrites the last. That is what makes hundreds of layers trainable, because a layer with nothing useful to add can add almost nothing and do no harm. The cost is that the running total keeps growing with depth, so each later layer's contribution is a smaller share of it and the deepest layers can end up barely heard.
lm-head
The final projection turns one hidden vector into a score for every vocabulary entry. It is frequently the same matrix as the embedding table, read the other way round.
When the model has finished thinking about your prompt it holds one long list of numbers, and it still has to turn that into an actual word. This is the step that does it: the model compares its final state against every word it knows β€” a fixed list of perhaps 50,000 to 250,000 entries β€” and gives each one a score, and the highest scorer is usually what you see appear. It is also one of the largest single parts of a model, because it needs a row of numbers for every word in the language. That is why many models reuse the very same table they used to read your prompt. A few also squash the scores into a fixed range before choosing, so that no single one can run away from the rest.
transformer-block
The whole block assembled: normalise, attend, add, normalise, feed forward, add. Step it and watch one residual stream get transformed, then handed to an identical block.
A language model is built by stacking one repeating unit, and this is that unit. A word's numbers are rescaled to a standard size, sent through attention so that words can pull information from each other, and the result is added back onto the running total; then rescaled again, sent through the small per-word network where the model's knowledge sits, and added back again. That is one whole layer. A modern language model is this same unit stacked several dozen times with different numbers in each copy, which is why models grow mostly by getting deeper rather than by acquiring new kinds of part.
prefill-vs-decode
Two different regimes: reading the prompt is one large parallel matrix multiply, writing the reply is a long series of tiny ones. One is compute-bound, the other memory-bound.
Running a model happens in two quite different phases. First it reads your whole prompt in a single pass, every word at once, which keeps the chip's arithmetic units fully busy and is over quickly. Then it writes the answer one word at a time, and each of those steps does very little arithmetic while having to haul the whole model out of memory, along with everything it has stored about the conversation so far, so the chip spends its time waiting on memory instead of calculating. That is the pause and then the steady trickle of words you see in a chat window, and it is why the writing half, not the reading half, is what makes a service expensive to run.
sampling
Greedy, temperature, top-k and top-p applied to the same distribution. Watch which words survive each filter, and how abruptly the tail gets cut away as you tighten it.
The model never picks a word. It produces a score for every entry in its token list, and something separate has to choose one: always taking the top score gives the same answer every time. Temperature is a number those scores are divided by before they are turned into percentages, and the effect is on the gaps between them β€” below one the gaps stretch and the leader takes nearly all the probability, above one they shrink and unlikely words get a real chance. Top-p works differently: sort the candidates, keep adding them to a shortlist until the shortlist covers, say, 90% of the probability, and draw from that. So temperature changes the odds and top-p changes who is allowed into the draw.
hyper-connections
Several parallel residual streams instead of one, with learned weights deciding which a block reads, which it writes, and how they mix. At one stream it is exactly the classic residual.
Every model of this kind carries one shared running total per word that each layer reads from and adds back into, and that single channel forces a compromise. Leave the total alone and training is stable, but it grows with depth until a layer's addition is a negligible share of it; rescale after every addition and each layer keeps its voice, but training turns fragile. Hyper-connections carry several such totals side by side and let the model learn, layer by layer, which to read, which to write into, and how much they blend with each other β€” so it can settle anywhere between those two extremes instead of the designer choosing once for the whole model. The price is carrying several of those totals instead of one.
sequence-packing
Several documents share one row. A block-diagonal mask keeps them apart. A mask that is true everywhere still trains, and tokens read across the document boundary.
Training rarely feeds one document per row. Several short documents are laid end to end in a single row so the hardware stays full. A block-diagonal mask lets each token read only inside its own document. Leave that mask open and the run still converges, while the model has learned to read across the boundary between two unrelated documents.

D β€” Mixture of Experts

moe-routing
A router scores every expert for every token and sends each token to the best few. Watch the load land unevenly, and watch tokens get dropped when an expert fills up.
A mixture-of-experts layer replaces the single per-word network with many smaller ones, called experts, plus a small scoring network β€” the router β€” that reads each word and picks the two it judges best suited. Only those two run, so the model can hold an enormous amount of knowledge while doing a fraction of the work for any one word. The catch is that each expert can only take so many words per run before it is full, and a word sent to a full expert simply gets nothing back from it β€” if both of its choices are full it skips the layer entirely. So a router with favourites does not merely waste capacity, it quietly discards work.
moe-balance
Two routes. Auxiliary-loss mode mixes a skewed router toward uniform as lambda rises from 0 to 1. Selection-bias mode offsets scores only to choose the top-k; the combine weight is the softmax of the raw selected scores and the auxiliary weight is 0. In bias mode both compare panes are that route.
Splitting a layer into many specialist sub-networks only pays off if the work spreads across them. Auxiliary-loss mode mixes a skewed router toward even traffic: lambda 0 leaves the skew, lambda 1 is uniform, and dragging a bar rescales that mix. Selection-bias mode adds a per-expert offset used only to choose the top few specialists. The combine weight is the softmax of the raw scores of the specialists that were chosen, the auxiliary weight is 0, an overloaded specialist bias decreases by the step, and an underloaded specialist bias increases by the step. In selection-bias mode both compare panes are that bias route.
per-token-compute
Easy tokens leave early, hard ones go round again, so the compute profile is ragged rather than rectangular. GPUs want uniform work, and the padding can cost more than the saving.
A language model does exactly the same amount of work on every word, whether it is a comma or the crux of the sentence. Several shipped designs let that vary: a scorer admits only some words to each layer and the rest skip past, or a word stops once the model is confident enough, or a hard word is sent round the same layers more than once. The arithmetic saved is real. The catch is that chips want every word in a batch doing the same thing at the same time, so ragged work must be padded back out to a uniform shape or shuffled into one β€” and there are settings where that overhead costs more than the skipped work saved.
expert-placement
Which GPU an expert lives on, which is a different question from which expert a token picks. Placement decides what crosses the interconnect, and one hot expert alone sets the step time.
A model too large for one chip is split across several, and where it is made of specialist sub-networks the natural split is to give each chip a few of them. A word whose chosen specialist lives on another chip must be shipped there and its answer shipped back, and it pays one trip per distinct chip it needs β€” so specialists that tend to be chosen together are cheap to keep on the same one. Demand is very uneven in practice, so a popular specialist sitting alone leaves its chip overloaded while the others idle, and the whole step waits for the slowest. The fixes are to keep copies of the busy ones on every chip, or to re-place them from observed traffic β€” and a copy costs its full weight on each chip that holds it.

E β€” Non-transformer sequence (SSM)

ssm-scan
A recurrent state swept along the sequence, where an input-dependent step size decides what to keep and what to forget. Constant memory per token, however long the sequence runs.
A model of the usual kind answers a question about earlier text by re-reading all of it, which gets slower the longer the text is. This is the other approach: keep one small fixed-size running summary and update it once per word, so each new word costs the same whether it is the tenth or the ten thousandth. What makes the modern version work is that the model decides, per word, how much to write in and how much to leave alone β€” a striking name is written hard, filler barely moves the summary. The cost is that the summary is all there is: whatever it did not keep cannot be recovered later, because the original words were never stored.
mamba-block
The complete block: project in, short convolution, gate, selective scan, gate again, project out. The scan is the only part that carries information along the sequence.
Instead of re-reading every past word, a model can carry one small fixed-size running summary and update it as it goes. This is the whole layer built around one. Each word's numbers are copied into two paths. The first blends the word with the two or three before it, then feeds the running summary that carries everything seen so far. The second turns into a set of volume knobs that multiply the first path, letting the layer turn parts of the result up or down, and what comes out is added onto the running total the rest of the model shares. Stack a few dozen of these and you have a language model that never builds a growing memory of past words.
gated-deltanet
Memory as a fixed-size matrix rather than a growing cache: a decay gate fades what is already stored, and a delta rule writes the new key-value pair over the top of it.
Attention remembers every past word and re-reads them all. This is the alternative: a fixed-size table of associations β€” this cue goes with that content β€” which never grows, however long the conversation runs. The trick that makes it usable is what happens when a cue already on file comes back: the model first erases what was stored under it, then writes the new content in its place, so a repeat updates the entry instead of stacking a second copy on top until the table turns to mush. Everything also fades slightly each step, so old entries eventually disappear. Fixed size is the whole point and the whole cost β€” the table holds only so much.
delta-rule-gates
One recurrence, three gates: a single decay for the whole memory, a per-channel rate so each feature fades at its own speed, then separate erase and write gates. Drag them apart.
Some models replace the ever-growing pile of notes on past words with a fixed-size memory that files a cue against its content. Three such designs keep exactly that memory and differ only in how they forget. The first fades the whole memory at one rate per step, which means you cannot hold one fact while dropping another β€” everything ages together. The next gives each of the memory's feature slots its own fading rate, so some can be held a long time while others clear quickly; but the strength with which it erases and the strength with which it writes are still one number doing both jobs at once. The newest splits that number in two, making how much old content survives and how much new content is committed separate decisions.
hybrid-by-layer
Mostly recurrent layers with full attention every so often. Only the attention layers need a cache, so the memory cost falls in proportion to how few of them there are.
A model is a stack of dozens of near-identical layers, and they do not all have to work the same way. Newer models make most of them the cheap kind that keeps a small fixed running summary, and place a full attention layer β€” the kind that stores notes on every past word and re-reads them β€” only every fourth or eighth position. Nearly all the memory a long conversation eats is those stored notes, so cutting how many layers keep any cuts the memory bill by about the same fraction. What is given up is exact recall: the summary layers work only from what they compressed, so the few attention layers carry the model's ability to quote the past precisely.

F β€” CNN / vision

convolution
A kernel slides across the input and every output pixel is one sum of products. Stride, padding and dilation decide what it covers and how much the image shrinks.
An image is a grid of numbers, and this is how a vision model examines one. A small grid of weights β€” nine numbers, say β€” is laid over a patch of the picture, each weight is multiplied by the number underneath it, and the total becomes one number in a new grid. Slide the little grid one step and repeat, and you have swept the whole image with one detector: the weights decide what it responds to, an edge running one way, or a patch of a certain colour. Three settings change what comes out: how far it jumps between stops, whether a border of zeros is added so the result does not shrink, and whether the weights are spread apart to cover more ground without using more of them.
receptive-field
Stack convolutions and each output sees a wider slice of the input. Dilation widens that view faster without adding weights β€” the dependency cone, drawn layer by layer.
A single image filter reads only three neighbouring positions, which is not enough to recognise anything. But the next layer's filter reads three outputs of the first, each of which already summarised its own three, so it indirectly depends on a wider stretch of the original picture β€” and that stretch widens by two more positions with every layer stacked. This page draws it along a single line for legibility; in a real image the same widening happens in both directions at once. That growing window is why a deep network built entirely from tiny filters can still respond to a whole face, and why depth buys reach rather than just more arithmetic. Spreading a filter's weights apart widens the window faster still, at the price of stepping over the pixels in between.
pooling
A window collapses to a single number, by maximum or by average. Downsampling is cheap and lossy: watch which cell actually survived, and what was discarded to get there.
After a filter has swept an image, the result is as large as the picture, which is more detail than the next stage needs. Pooling shrinks it: cover the grid with small non-overlapping squares and replace each one with a single number β€” either the largest value in it or the average of it. A two-by-two window stepping by two lands on half the width and half the height when the side length is even, so three quarters of the numbers are gone and everything downstream is four times cheaper. An odd side keeps only the windows that fit, which is under half. It also makes the network less fussy about exact placement, since a feature that shifts by a pixel usually lands in the same square. The cost is that you have thrown away where inside the square it was.
feature-maps
The channel activations of a convolutional stack layer by layer β€” edges, then textures, then parts. Paint on the input and watch which filters respond to what you drew.
A vision network does not look at a picture once; it builds a whole stack of pictures out of it, each made from the one below. The first stage here uses real edge detectors β€” a bright line running one way lights up one output and leaves the others dark. The stages above work on those edge pictures rather than on the original, and their filters here are stand-ins rather than trained ones, because what is being drawn is the compounding: whatever the second stage answers to is a combination of edges, and whatever the third answers to is a combination of those. Each stage is more abstract than the one below, and from the second onwards each is also smaller. That is how simple detectors add up to recognising an object.
batchnorm
Normalise each channel by its batch statistics, then scale and shift. Training uses the batch and inference uses a running average, and that mismatch is a classic source of bugs.
Numbers flowing through a deep network drift, one layer's outputs coming out ten times bigger than another's, and that makes training slow and fragile. This step fixes it by measuring, during training, the average and the spread of each channel β€” the picture one filter produces β€” across the current batch of images and dividing them out, so every channel arrives at the next layer on a comparable scale. Batches are small and noisy, so it also keeps a smoothed running estimate of those two numbers. That is the part that surprises people: once training is over there is no batch to measure, so the frozen estimate is used instead, and the network behaves slightly differently when you use it than it did while learning.
residual-block
A skip connection makes the block learn a correction instead of a replacement. That is what stops gradients vanishing with depth, and why very deep networks train at all.
Make a network deeper and, past a point, it gets worse β€” not from memorising its training data, just worse at everything, which is not what more capacity is supposed to do. The fix is to stop asking each block to produce its output from scratch. A copy of the input is carried straight past the block and added to whatever the block computed, so the block only has to supply a small correction, and doing nothing at all becomes an option it can take. That one change let vision networks go from around twenty layers to over a thousand. A follow-up paper, rather than the original, added the other half of the explanation: the copied-through path also gives the learning signal a clear route back to the earliest layers.
depthwise-separable
Split one convolution into a per-channel filter and a 1Γ—1 mix. The full-conv cost over that split grows with the output count and stays under the kernel area.
An ordinary image filter does two jobs at once: it looks at a patch of the picture, and it blends together all the channels stacked at each pixel. Doing both together costs the input channels times the output channels times the patch area β€” a product, and products grow fast. Splitting it in two turns that into a sum: first filter each channel by itself with no blending, then blend the channels at each single pixel with no patch. For a three-by-three filter the saving grows as you ask for more outputs, and it tops out just under nine times. A one-by-one kernel costs more than the filter it replaces. That climb, on the wide kernels, is most of why decent image models run on a phone. The cost is a slightly weaker operation, since the two jobs can no longer be tuned together.
patch-embedding
An image cut into fixed squares, each flattened and projected into a token. It is exactly a strided convolution β€” and it is how a transformer comes to read pixels at all.
The kind of model behind a chatbot reads a list of items, so an image has to become a list before one can look at it. It is cut into a grid of small squares β€” sixteen pixels on a side is common β€” and each square's raw pixel values are flattened into one long row and multiplied by a shared table that turns them into a row of numbers of a fixed length, exactly the kind of row a word becomes. From then on the model has no idea it is looking at a picture; it is doing what it does to a sentence. Smaller squares mean finer detail and a longer list. Halving the square size makes four times as many patches, and attention over those patches costs sixteen times as much. Once the class token is on the list, the same cut costs less than sixteen times.

G β€” Quantization / multimodal

quantization
Weights stored in four bits with a scale per group, then reconstructed on use. Watch the error against bit-width and group size, and watch one outlier ruin its whole group.
A model is billions of numbers, and how many bits each one is stored in decides whether it fits on your machine. Four bits is a quarter of sixteen, but each group also stores a scale and a zero-point, so at four bits the file is larger than that quarter. Four bits is only sixteen distinct values, so the numbers cannot be kept as they are. Instead a small group of neighbouring numbers β€” the model's weights β€” is taken, its smallest and largest noted, and each weight recorded as one of sixteen evenly spaced steps between them, along with the two extra numbers needed to undo that later. The rounding is the price, and it is worst when one freak large value stretches its group's range and coarsens every neighbour β€” which is why the groups are kept small, and why small groups give part of the saving back.
ternary-weights
Each weight rounds to βˆ’1, 0, or +1 and is stored with one scale. The reconstruction is that code times the scale. The readout sums the printed weights and the printed reconstructions.
Storing a weight as minus one, zero, or plus one turns a multiply into an add or a skip. One scale says how large those choices are. Weights that are small next to that scale round to zero and drop out of the sum. Weights that are large next to it clip to a sign, so the reconstruction cannot follow them. The drawn bar is the code times the printed scale, and the readout sums those printed numbers.
structured-sparsity
Every group of four weights keeps the two largest magnitudes. A zero loses to any nonzero. Ties keep the earlier index. The dropped count is the nonzero count minus the count that stayed, so a group of zeros drops nothing.
Every group of four neighbouring weights keeps at most two nonzeros, the two with the largest magnitude. A zero loses to any nonzero, and a tie keeps the earlier index. The dropped count is the nonzero count minus the count that stayed, so a group of zeros drops nothing and a group that already has two or fewer nonzeros keeps them.
vram-budget
Live memory arithmetic: weights, cache, activations and overhead against a real card. Drag the context length and watch which term is the one that actually overflows.
The size on a model's download page is not what it needs in order to run. Four things share the graphics card's memory: the weights themselves, fixed once you choose the model size and how many bits each number uses; the notes the model keeps on every word of the current conversation, which grow steadily as that conversation gets longer; scratch space for the work in progress; and a fixed slice the driver takes for itself. The middle one is why a model that loads happily still runs out of memory tens of thousands of words in β€” past some length the conversation's notes outweigh the model itself, and the limit you are hitting is the length rather than the model.
multimodal-inject
An encoder turns an image into vectors, a small projector reshapes them to token size, and they are spliced into the text sequence as though they had been typed.
There is no separate picture input on a language model. An image goes through its own network, which turns each piece of it into a row of numbers; those rows pass through a small translation step that reshapes them into exactly the shape a word becomes; and they are then dropped into the sequence of words at the point where the image was attached. From there the model treats them like any other item in the list β€” it never learns which ones came from pixels. That is why an attached photo eats part of the same budget your text does, and why sound can be added the same way with nothing else about the model changing.
vlm-connector
How a vision encoder’s patches actually become language-model tokens, and how many. Merge neighbours or resample to a fixed count β€” resolution is a token budget, not a quality dial.
Attaching a picture uses up part of the same budget your words do, and how much is decided by one small piece sitting between the image network and the language model. The simplest kind hands over one item per image patch, so the count climbs with the square of the resolution β€” double the width and you have four times as many. The second glues neighbouring patches together in blocks before handing them over, dividing the count by the block's area and giving up fine spatial detail. The third ignores resolution entirely: a fixed number of learned probes read the whole picture, so a huge image costs exactly what a small one does, and past a point extra pixels have nowhere to go.
rotation-quant
A rotation leaves the length of a vector unchanged and shrinks its largest entry. The same rotation has to hit the weight, or the product is a different one.
A few very large entries force a low-bit quantizer to spend its whole range on them, so everything else gets coarse. A Walsh-Hadamard rotation spreads one spike across every coordinate. The length of the vector is unchanged and the largest entry shrinks. The same rotation has to be applied to the weight. Rotate only the activation and the product is a different one.

H β€” End to end & training

forward-pass
One prompt to one next token through a small real transformer: tokenise, embed, attend, feed forward, project, sample. Step it and watch the residual stream change at each stage.
This runs a whole small model from end to end, rather than taking one part of it apart on its own. A few words go in, get looked up as rows of numbers, compare themselves against each other, pass one at a time through a small two-layer network, and at the end every word the model knows is given a score and one of them is picked. The strip down the left side is the through-line: each stage reads it, works out a small correction, and adds that back rather than overwriting it. The model here is deliberately tiny and its numbers are random, so the word it predicts is meaningless β€” what is real is the sequence of steps, and that sequence is what runs every time you press enter.
backprop
Gradients flow backwards through a small graph by the chain rule. Switch on descent and watch the loss fall to zero β€” the whole of training, at a scale you can actually follow.
Most demonstrations show a model using what it already knows. This one shows it learning. The model makes a guess, the page measures how far off it was, and then works backwards through each step asking one question of every number in it: if this number were slightly larger, would the error get better or worse, and by how much? That answer is the number's slope, and shifting each one a little way down its own slope makes the next guess better. Switch on descent and watch the error fall toward zero; run that same loop over billions of numbers instead of the handful here and you have training, because there is nothing else to it.
lora
The update is the product of two thin matrices. Lower the rank and the stored count falls, while a full-rank change stays out of reach. Merged adapters add no serving multiply.
Changing a whole weight matrix means storing a new number for every entry. A low-rank adapter stores the change as the product of two thin matrices, so the count falls with the rank. The product cannot represent a change that needs more directions than that rank. At serving time the product can be added into the base weight, which costs nothing extra, or left separate so a request can swap adapters and pay one thin multiply.
muon
A matrix gradient is orthogonalised so its singular values move toward one. Embeddings, the output head, and per-channel gains stay on a second optimizer.
Most optimizers scale each number on its own. Muon treats a two-dimensional gradient as a matrix and pulls its singular values toward one, so every direction of the update has the same strength. The iteration does not apply to an embedding table, the output head, or a per-channel gain, so a real recipe runs this update beside a second optimizer.
activation-recompute
Store every activation and spend the memory, or store none and pay a second forward. The combined cost has a minimum at a segment length in between.
A backward pass needs the activations the forward pass produced. Storing all of them uses one slot per layer and no extra forward. Storing only the input uses one slot and recomputes the stack. Checkpointing every few layers sits between those extremes, and the sum of memory and extra forward has a minimum there.
training-numerics
A loss scale lifts gradients into the narrow fp8 range. Too small and they flush. Too large and they overflow. The fp32 master copy is the memory price.
Training in a narrow format such as fp8 cannot hold a tiny gradient or a huge one. A loss scale multiplies the gradient before it is stored. Too small and the gradient flushes to zero. Too large and it overflows. The optimizer still steps a full-precision master copy of the weights, and that copy is the memory price of the narrow format.
quantization-aware-training
The forward pass rounds a high-precision weight onto a code and multiplies by the scale. The backward pass updates that high-precision weight as if the rounding derivative were 1, so the forward code stays put until a bin boundary.
The forward pass stores a high-precision weight, rounds it onto a code, and multiplies that code by the scale. The backward pass updates the high-precision weight by the full step, as if the rounding derivative were 1. Inside a flat bin the forward code stays put until the weight crosses a boundary. A scale of zero sends the forward value to zero, and the step still applies to the stored weight.
distillation
A soft target is the teacher distribution. When the teacher prefers the wrong class, the student is trained to copy that error. Temperature spreads the mass back.
A student can be trained to match the teacher's full distribution rather than a single correct label. When the teacher's top class is the wrong one, that soft target still puts most of its mass there, and the student copies the error at the same confidence. Raising the temperature spreads the mass, so the labelled truth gets a larger share.

I β€” Real-model grounding

real-embeddings
The default path embeds the words you type: load a trained model or stay on the labelled stand-in. The nested toggle draws constructed vectors whose leading prefix is the coarse part. Those vectors are not a truncation of the loaded model.
The default path turns each word you type into a row of numbers and draws how close every pair of rows is. Load the optional trained model, about 23 MB, with nothing sent anywhere, or stay on the labelled synthetic stand-in. When that trained model is loaded, nearby words land near each other because of the training. A nested toggle draws a different set of vectors built so the leading prefix is the coarse part: the prefix keeps a distinction that lives inside the cut and fails to separate a pair that differs only past the cut, while the full vector separates that pair. Those nested vectors are constructed for this demo. They are not a truncation of the loaded model.
real-attention
Real GPT-2 attention heads captured from a verified forward pass in the browser. Type a sentence and find the induction, previous-token and sink heads in the actual head map.
Inside a language model, each word looks at the other words and works out which of them matter to it. GPT-2 does that 144 separate times on every pass, and this page runs a real GPT-2 inside your browser so you can go hunting through all of them on a sentence you type. Some do a job you can recognise: one looks only at the word immediately before, and one spots a phrase that appeared earlier and points at whatever followed it last time. Those two are heads researchers have named; a third that parks on the very first word is this page's own measurement on this page's own sentence, not a named result. The real weights are about 550 MB and download only when you click β€” until then you get a labelled stand-in.
real-logits
The real next-token distribution from GPT-2 for a prefix you type, reshaped by temperature, top-k and top-p exactly as a sampler would. Checked against the reference implementation.
Type the start of a sentence and a real GPT-2, running in your own browser, gives you its actual score for every one of the 50,257 word-pieces it knows, turned into percentages. "the cat sat on the mat . the cat ran" really does come out as up / away / off / out, which is about as undecided as you would expect. The temperature, top-k and top-p controls are the same ones sitting behind the creativity slider in a chat app: they flatten the list, or cut it off after the best few, before anything is chosen. The model is roughly a 550 MB download and entirely optional β€” the page runs on made-up numbers until you ask for the real ones.
logit-lens
Apply the output head at every layer rather than only the last, and watch the prediction crystallise with depth. The early guesses are wrong in a way you can interpret.
A model's answer is not decided in one go: it passes through twelve layers in turn, each adding its own correction. This page stops at every layer and asks what word it would pick if it had to answer right now, so you can watch the guess settle as it goes deeper. Early layers mostly echo the word just typed, the middle ones wander, and the answer usually locks in near the top β€” though on an open-ended prompt nothing is settled until the final layer. That is why a practical trick like stopping early on easy inputs pays off, and why it goes wrong on hard ones. It runs a real GPT-2 in your browser, an optional download of about 550 MB, on a stand-in until you ask.
real-neurons
Which of a layer’s three thousand neurons fire for which tokens, from a real forward pass. This is the raw material of mechanistic interpretability rather than a diagram of it.
Inside each of GPT-2's twelve layers sit 3,072 small units, and for any given word a few of them switch on hard while most stay near zero. This page runs a real GPT-2 in your browser and shows which ones fired for which words in a sentence you type, with the single strongest one ringed. Some turn out to respond to something you can name β€” a topic, a piece of grammar β€” and plenty respond to nothing you can put into words at all. That is the raw material of the research trying to work out what is actually stored in these things, and it is why "nobody fully knows what is inside" is a statement about scale rather than mystery. The weights are about 550 MB and download only on request.
real-quant
Quantise one real GPT-2 weight tensor: its true distribution, its outliers, and the error you actually get at each bit-width and group size. Only that tensor is fetched, not the model.
A trained model is an enormous pile of numbers, and storing each one less precisely makes the model smaller and faster at the cost of getting it slightly wrong. This page takes one real block of GPT-2's numbers β€” fetching just that block, about 9 MB, rather than the whole model β€” and rounds it off in front of you, measuring how much accuracy is actually lost at 8, 4 or 3 bits per number, where four bits leaves only fifteen values to land on. Real weights turn out to be tightly bunched with a few far-out stragglers, which is why splitting them into small groups that each get their own scale helps so much. This is the decision behind "will the 4-bit version be good enough on my laptop?"
real-kv-cache
Watch the real cache grow as GPT-2 generates: actual cached keys per layer and head, one fresh column per token, with the memory figure climbing alongside it.
When a model writes a reply it goes one word at a time, and rather than re-read everything for each new word it keeps notes on the conversation so far and adds one column to them per word. This page runs a real GPT-2 in your browser and shows those notes filling up for real: the prompt fills them in one go, then every generated word appends another column, with the megabytes counted as you go. That growing pile is why a long conversation costs more than a short one, why there is a limit on how much a model will hold at once, and why the memory on a graphics card is the thing that runs out. About 550 MB, downloaded only if you click.
real-generate
A real GPT-2 writing text token by token in your browser, under greedy, temperature, top-k or top-p. Its greedy output matches the reference implementation exactly.
A real GPT-2 writing text in your browser, one word-piece at a time, with the loop laid bare: score every possible next piece, pick one, stick it on the end, start again. On its most predictable setting it is completely repeatable and gets stuck β€” the default prompt runs off into "up and down the hall and down the hall". Turn that off and the temperature and cut-off controls let chance back in, so the same prompt gives a different continuation each time you change the seed. Watching it is the fastest cure for believing a model plans a sentence before writing it: it only ever chooses the next piece. The model is about 550 MB and downloads on request.
real-vision
A real vision transformer classifying a real photograph in your browser: the image cut into patches, and the genuine top-five predictions that come back out of it.
The same machinery that reads text can be pointed at a picture, and this page runs a real image classifier in your browser to show it. The photo is cut into a grid of 196 small squares, each square is turned into numbers the way a word would be, and the model then treats them as if they were a sentence, ending with its top five guesses. The version it fetches is about 88 MB because the numbers inside it have been squeezed into a coarser format, which moves its confidence a little β€” around 90% on the cats photo where the full-size original gives 94% β€” without changing what it answers. It downloads only when you ask; before that you get a stand-in with the real grid.

J β€” Serving-time mechanisms

paged-attention
The cache in fixed-size blocks with a per-sequence table, instead of one reserved slab. Watch the reserved-but-unused tails vanish, and two requests share one prompt’s blocks.
A chat service has to keep, for every conversation it is holding open, the notes the model made while reading everything said so far. Give each conversation one solid stretch of memory big enough for the longest reply it might write and most of that stretch sits empty, while the leftovers between conversations are too small for anyone else to use. Handing out small fixed-size chunks instead means only the last chunk of a conversation is part-empty, and two people whose conversations opened with the same instructions can point at the very same chunks until their wording diverges. What it costs is bookkeeping: a lookup table per conversation saying where its chunks actually are.
radix-attention
Prompts inserted into a shared tree, so a common system prompt is stored once. A new request reuses the longest matching prefix and computes only its own suffix.
Many applications put the same long block of instructions at the top of every request, and the model's reading of that block comes out identical every time. So the server keeps what it has already read in a tree: requests that begin the same way share one path and split into branches where they start to differ. A new request follows the tree as far as it matches, gets that stretch for free, and pays only for the genuinely new tail. The limit is space β€” when the tree outgrows its memory the least recently used tip is dropped, and a request that would have matched it pays full price again.
kv-fusion
A prefix tree reuses a chunk only when the request starts with it. Fusion keeps a later chunk and recomputes a fraction of its tokens, leaving a residual error on the rest.
A prefix cache only helps when the reused text is at the very start of the request. A retrieved document, a tool result, or a passage pasted into the middle does not qualify, so the server reads the whole thing again. Fusion keeps the stored reading of that passage and recomputes a fraction of its tokens. The leftover error is the share of the mismatch that was not recomputed. It is 0.00 when the mismatch is 0.00 or the fraction is 1.00. Put the passage back at the start and the prefix cache reuses the whole chunk. It pays fewer tokens than fusion when that fraction is above zero, and the two pay the same when the fraction is 0.00.
rope-splice
A cached key still carries the position it was computed at. Rotating it by the gap to the new position makes the pairwise score match a key computed there.
The notes a model stores about a word include where that word sat. Move the same words later in a new request and those notes are about the old positions. The unrotated comparison is the cosine of the printed angle gap. It stays 1.000 when that gap prints as 0.0000. A printed gap of 0.0160 still scores 1.000, and a printed gap of 1.0000 scores 0.540. The fix is a rotation by exactly the number of places the passage moved. After that rotation the comparison matches a passage that had been read at the new spot.
unified-radix
One prefix match reuses full-attention KV for the whole match and sliding-window KV for only the tail that fits. A recurrent layer adds one checkpoint when the match exists, and with that layer off the checkpoint stays at zero.
Some models do not keep one kind of memory. A layer that looks at the whole prefix stores a note per word, a layer that only looks at a recent window stores just that window, and a recurrent layer stores a single running summary. One shared prefix can hand back all three from the same match: every matched word for the full layers, only the tail that still fits the window, and one summary, which is usable only when the match is longer than nothing. A match shorter than the window cannot invent extra window notes that were never stored.
kv-fabric
A private cache hits only on the machine that stored the prefix. A shared pool hits when any machine has, so a repeat on a different machine is no longer a miss.
Each machine can remember the prefixes it has already read, but a request only gets that memory if it is sent to the machine that holds it. Send the same opening to a different machine and the work is done again. A shared pool keeps one copy the whole cluster can see, so the second machine finds the prefix even though it never read it itself. One machine makes the two schemes identical. Several machines, and the same opening repeated on different ones, is where the shared pool pulls ahead.
continuous-batching
Static batching holds every slot until the longest sequence finishes; continuous batching refills a slot the moment it frees. Same arrivals, two schedulers, side by side.
A busy server answers many people at once by working on a group of requests together, producing one word for each of them per pass over the model. The simple version fixes that group at the start and holds every place in it until the slowest reply is finished, so a request that stopped after ten words keeps its seat warm while a neighbour writes a thousand. Refilling each place the instant it frees lets someone waiting in the queue start immediately, which keeps the hardware busy and shortens how long people wait to be served. It makes no single reply arrive faster β€” it makes far more of them happen at the same time.
chunked-prefill
A long prompt’s prefill split into budgeted chunks and interleaved with everyone else’s decoding. One knob, and it moves two different latencies in opposite directions.
Reading a prompt and writing a reply are different jobs, and a server does one round of work at a time. When someone pastes an enormous document, reading all of it in one round occupies the machine, and everybody else's reply stops mid-sentence until it is done. Cutting the reading into slices and putting one slice into each round, beside the next word for everyone else, keeps the other replies flowing. The cost lands on the person who pasted the document: their wait for a first word gets a little longer, because their reading is now spread over several rounds instead of taking one to itself.
speculative-decoding
A small model proposes several tokens and the large one checks them all in a single pass. Accepted tokens are nearly free β€” and a poor draft turns the whole thing into a loss.
Writing one word at a time barely uses a graphics card. The machine has to haul the whole model out of memory for each word, and there is almost nothing for it to calculate while it waits. Speculation fills that idle capacity: a small, fast model writes a guess at the next few words, and the big model checks them all in a single pass, which costs it barely more than producing one word would have. Words the big model agrees with are kept and were effectively free; at the first disagreement it writes its own word and the rest of the guess is thrown away. Guess badly, or use a helper that is not cheap enough, and you have paid for the guessing and gained nothing.
windowed-mtp
Draft heads read a sink plus a recent window, not the whole context. The target still checks every token, so a fact in the gap is accepted only at the blind rate.
A draft that guesses the next few words does not need the whole conversation in front of it. The opening and a recent stretch are enough for a local guess, and everything in the middle can stay unread. The big model still checks the guess against the full text, so a guess that depended on that missing middle is kept only as often as a blind guess. What changes is the draft's memory: it keeps the opening and the recent stretch, counts a token only once when those two overlap, and never keeps more tokens than the conversation has.
block-diffusion
A block drafter proposes several tokens at once. The first position is the sure one. Each later position is accepted less often, so a wider block has a weaker tail.
A block drafter does not guess one token at a time. It proposes a whole block in one parallel step. The first position is the one it is most sure of, and each later position is accepted less often. Widening the block does more work at once and lowers the chance that the tail of the block survives the check.
kv-eviction
A fixed memory budget under a growing context. A plain sliding window collapses; keeping the first couple of tokens rescues it almost entirely. Three policies, one score.
A model's notes on a conversation cannot grow forever, so eventually a server has to throw some of them away. Keeping only the most recent stretch is the obvious choice and it is the one that breaks: models put a large share of their attention on the opening few words whatever those words actually say, so discarding them wrecks everything after. Keeping a handful of opening words permanently, alongside the recent stretch, repairs most of it β€” on real models the published finding is that four of them suffice and that one or two do not. The other family of policies keeps whichever words the model has been looking at most, mixed with recent ones.
disaggregation
Prefill and decode on separate machines, because the two phases want opposite hardware. The cache transfer between them is drawn on the critical path, where it can become a loss.
Reading your prompt and writing the reply want different machines. Reading is one big burst of arithmetic over the whole prompt; writing produces a word at a time and spends most of its life hauling the model out of memory rather than calculating. Run both on one pool of machines and they get in each other's way, because a long prompt being read stalls every reply already in progress. So large deployments sometimes split the fleet and size each half for its own job. The catch is that the notes made while reading must then be shipped down a wire to the machine that writes, and a thin enough link costs more than the split saves.
attn-expert-split
Attention and the experts on separate machines. KV crosses once and grows with context. Hidden states cross every layer and grow with the batch. The larger ship flips.
There is a second way to put the two halves of a layer on different machines. Attention, which has to remember the conversation, stays on one pool. The experts, which do the heavy arithmetic, stay on another. What crosses the wire is then the hidden state, out and back, on every layer. That shipment grows with how many requests you batch and does not care how long each one is. The cache shipment of the other split does the opposite. A long context makes the cache the heavy parcel. A short context with a fat batch makes the hidden state heavier.
kv-quant
Squeeze the conversation’s memory rather than the weights. Four bits with a scale per group β€” and a single outlier stretches its group’s scale and spoils all of its neighbours.
As a conversation grows so do the notes the model keeps about every word said so far, and past a few tens of thousands of words those notes take up more room than the model itself. Storing each number in them with fewer bits is the cheapest way to buy a longer conversation without a bigger machine: numbers are held in small groups that share one scaling factor and are rounded back to full size when read. What you give up is exactness. A single unusually large value stretches its group's scale and makes every number beside it coarser, so which numbers are grouped together matters more than it sounds.
mla
Cache one small shared summary per token instead of full keys and values per head, then rebuild the detail on use. The cache collapses; the per-step arithmetic grows to pay for it.
Ordinary attention keeps a separate set of notes for each of the model's attention heads β€” often more than a hundred of them β€” for every word in the conversation, and that pile is what makes very long context expensive. This design stores one small summary per word instead, and rebuilds each head's notes from that summary at the moment they are needed. On DeepSeek-V3's shape, the page's own arithmetic puts the stored amount about fifty-seven times smaller. It is a trade rather than a free win: the rebuilding is extra multiplication on every word the model writes, so you pay in arithmetic for what you save in memory.
ring-attention
One sequence sharded across devices, with cached keys rotating around a ring so every query eventually meets every key. Send the next block while computing the current one, or the ring stalls.
Some documents are far too long to fit in the memory of any single chip. The work can be spread out instead: each chip permanently holds the questions for its own slice of the text, while the pieces of text travel around a ring of chips, so every question eventually meets every piece and no chip ever holds the whole document. Each chip carries a running total as pieces arrive, which is what lets the partial answers add up correctly at the end. Whether it pays comes down to the wiring: a chip sends the next piece on while still working on the current one, so if the arithmetic outlasts the transfer the wire is invisible, and if it does not every chip sits waiting.
context-extension
Pushing a model past its trained context. Interpolate every position and lose short-range resolution, or rescale only the slow dimensions whose full range was never seen. Both cost something.
A model is trained on documents up to some length, and positions past that are ones it has never seen. Position is encoded by turning each pair of a word's numbers through an angle that grows with how far into the text the word sits, some pairs turning quickly and some very slowly. The slow pairs never complete a full turn within the training length, so asking them about a position beyond it asks for an angle the model has no experience of. Every method for stretching a model slows some of those turns down until the longer text fits inside angles already seen β€” and every one pays the same price, because turning more slowly makes neighbouring words harder to tell apart.
constrained-decoding
A grammar compiled into a per-step mask over the whole vocabulary, so an illegal token cannot be sampled at all. Runs of forced characters skip the model entirely.
When an app needs a model's answer in a strict format β€” one another program can read, such as JSON β€” it does not ask nicely. At every step it works out which of the words the model could produce next would break the format, and makes those impossible to pick before the choice is made. Where the format leaves only one possible continuation, the software types those characters itself and skips the model entirely, which is faster than ordinary writing. The cost is that the format wins even when the model disagrees: push the model far enough away from the required shape and you get output that parses perfectly and means nothing.
parallelism
Tensor, pipeline, expert, and data parallel move different bytes. KV-parallel attention gathers sequence shards of the cache only when more than one device is in the strip. Data-parallel attention still crosses nothing. The ring that passes keys or queries is a different page.
A model too big for one chip has to be cut across several, and the cuts put different bytes on the wire. Tensor parallel splits each multiply and adds the slices back together. Pipeline parallel gives each chip a stack of layers and passes the work along. Expert parallel puts specialist sub-networks on different chips and ships each word to its specialist. Data-parallel attention copies the part that reads the conversation, so each chip serves its own users and that attention crosses nothing. KV-parallel is an attention choice on the same devices: each chip keeps a sequence shard of the cache. That gather moves cache bytes only when more than one chip is in the strip, and the quantity differs from an activation sum and from the expert-token shipment. With one chip the gather is zero. The ring that passes keys or queries around one sequence is a different page.
context-editing
Clearing old tool results from an agent’s history, which is cache eviction one layer up. The subtle cost: editing history invalidates the shared prefix everyone downstream was reusing.
An assistant that has been working for hours accumulates a huge record of everything it has read and every tool it has run, and eventually that record will not fit. Context editing throws away the old parts it no longer needs. The hidden price is that a service normally avoids re-reading a conversation from the start by keeping the earlier work ready, and that shortcut only survives while the earlier text is untouched β€” so deleting something from the middle forces everything after it to be read again at full price. Edit too eagerly and you pay that bill every turn, and if re-reading is cheap enough, never tidying up at all wins.
prefix-routing
The load balancer that knows which replica already holds your prefix. Follow the cache too strictly and every request piles onto one machine while the others sit idle.
A busy service runs many identical copies of a model, and something has to decide which copy answers you. The obvious choice is whichever is least busy, but each copy separately remembers work it has already done, so a request whose long standing instructions were already read by copy 2 gets sent to copy 3 and pays to read them all over again. A router that instead sends you where most of your text is already known avoids that β€” until it becomes a trap: everyone sharing one popular set of instructions is sent to the single machine holding them, which forms a queue while the others sit idle. What beats both is a router willing to abandon the shortcut when a machine gets busy.
hybrid-cache-allocator
Two memory shapes in one pool: KV pages that grow with every token, and fixed state slabs claimed up front. One split cannot satisfy both β€” concurrency and context pull opposite ways.
Newer models alternate two kinds of layer, and the memory each one needs behaves in opposite ways. One kind keeps a running note per word, so its memory grows for as long as the conversation goes on and is handed out a little at a time. The other keeps a fixed-size summary claimed in full the moment a conversation is accepted, whether it turns out to be two words long or two thousand. A server has one pool for both and one knob to divide it: give too much to the growing side and it cannot accept new conversations, give too much to the fixed side and conversations are accepted and then cut off partway through. For a demanding workload no setting satisfies both.
batch-invariance
Adding numbers in a different order gives a different answer, and a GPU picks its order from the batch shape. Same prompt, same seed, different reply β€” because of who else was served.
Ask a service the same question twice, with everything set to be repeatable, and you can still get two different answers. Adding up a long list of numbers gives a very slightly different result depending on the order you add them in, because every addition is rounded off. A chip splits that list across however many parallel workers the job's shape calls for, and the shape depends on how many other people's requests are in flight β€” so the last digits move with the traffic. When the top two candidate words are nearly tied, those digits pick the winner, and the two replies part company completely from there. Pinning the order fixes it and leaves part of the chip idle.
kv-tiering
The cache spilled down to host memory and then to disk. On a later hit, fetch it back or rebuild it from the text β€” whichever is cheaper, and which one that is flips with depth and distance.
A running conversation keeps the notes the model made about everything said so far, and the fastest memory on a graphics card is small. Rather than throw old notes away, a server can push them down into ordinary system memory and then onto disk. When they are wanted again there is a genuine choice: haul the bytes back up, which costs time in proportion to their size and the speed of the link, or work them out again from the original words, which costs arithmetic. Which is cheaper flips β€” a slow disk favours rebuilding, spare arithmetic favours it more, and notes from deep in a long conversation are the dearest to rebuild. Moving things down is never free: every transfer ties up the link.
suffix-decoding
Two proposals with no draft model. Suffix mode copies a continuation the tree has seen; repetition lengthens that match and novel prose backs off to one token. Jacobi mode writes the last context token plus a position index even when the tree has no match, then keeps only the prefix the reference would emit. It does not copy a repeated n-gram.
Two ways to propose several words without a second model, then keep only the prefix the target itself would have written. Suffix mode indexes text already seen and proposes whatever followed a match. Averaging four seeds, accepted length is longer when the text is fully repeated than when it is novel, and that curve is not higher at every step between them. One run on screen can stay flat or get shorter. Jacobi mode writes a lookahead window from the last context token plus a position index, and pools short runs from that trajectory even when the index has no match. It does not copy a repeated n-gram.
context-parallelism
Given a sequence split across devices, move the cached keys or move the queries. Reading a full prompt makes moving the keys cheaper at every setting here. Writing the reply makes moving the queries cheaper only while that batch sits left of the crossing, and it does not when the KV shards persist.
When one prompt is too long for a single chip, the text is divided among several, and each chip holds some of the words but must compare them against all the others. Exactly one of the two things being compared must travel: either the stored notes about the text move around the chips, or the questions being asked of them do. Both routes work out the same answer β€” it is a shipping decision, not an approximation. Reading a full prompt puts every question in that chip's share in flight at once, and moving the notes is cheaper at every setting here. Writing the reply makes moving the question cheaper only while those questions sit left of the crossing. A large batch on a short shard sits on the same side as the prompt, and so does leaving the notes in place: then only the new notes travel, the two curves never cross, and moving the notes wins for both halves.
ulysses
One exchange gives each device the full sequence for a subset of heads. Attention on that slice matches single-device attention for those heads. A second exchange restores sequence sharding. A head count not divisible by the device count is refused.
One exchange gives each device the full sequence for an equal share of the heads. Attention on that share matches attention computed on one device for those same heads. A second exchange puts each device back on its sequence shard, now with every head. When the head count does not divide by the device count, the exchange is refused. The sequence length does not have to divide evenly.
dual-batch-overlap
Split the batch and interleave the halves so one half’s network transfer hides behind the other half’s arithmetic. Split too far and the pieces are too small to hide anything.
When a model's specialist sub-networks are spread over many chips, every step has to ship each word out to the chip holding its specialist and ship the answer back, and while that is in flight the arithmetic units sit doing nothing. The fix is to split the batch of work in two and stagger the halves: while one half waits for its data to arrive, the other half computes, and then they swap. If each half's arithmetic lasts at least as long as the shipping it has to hide, the waiting disappears entirely. The catch is that splitting halves the arithmetic inside each piece while the fixed set-up cost of a transfer is paid again for every piece β€” so cut the work too finely and the step ends up slower than not splitting at all.

K β€” Diffusion & generative

diffusion-noise
Corrupt a sample by a known amount, then learn to predict what was added. The running guess of the clean image is blurry early because it is an average of everything it could be.
An image generator starts from a screen of random speckle and cleans it up into a picture, and this is where that ability comes from. In training you take a real photo, mix in a measured amount of speckle, and ask the network to say exactly what was added. Do that at every level of corruption, from a barely marked photo to something indistinguishable from static, and the network learns how to step back toward a real image from wherever it happens to be. The revealing part is what it guesses at the noisiest end: with almost nothing to go on it produces a blurry average of everything it was trained on, and real detail only appears as the picture gets cleaner.
diffusion-sampler
Generation is integrating a path, and the step count is how coarsely you walk it β€” chosen at generation time, not trained in. Deterministic and stochastic, side by side.
Image generators show a "steps" number, and it is not a quality setting the model was trained with. The generator is following a path from random speckle to a finished picture, and the step count is simply how many stops you make along the way β€” fewer, longer jumps cut the corners of the path. What that costs is subtle: the result does not look broken, it lands slightly off, which in a real picture means fine texture that is not quite right rather than an obvious mistake. Past a point more stops buy nothing. A second choice hides in the same loop: sprinkling fresh randomness at each stop pulls a drifting result back on track, but it no longer heads for one fixed destination β€” add stops to the steady version and it settles onto a single answer, while this one keeps landing somewhere slightly different.
guidance
Run the model with and without your prompt, then extrapolate away from the promptless answer. Adherence improves and then saturates, while variety collapses the whole way.
This is the dial that decides how literally an image generator follows your prompt. It works by running the model twice at every step β€” once with your words and once with them taken away β€” and then pushing away from the version that ignored you. At a setting of one you land exactly on what the model made of your prompt; higher settings carry on past that point in the same direction, and nothing in the arithmetic stops them anywhere sensible. So a high setting does not make the picture better, it makes it more stereotypically the prompt: colours blow out and everything you make starts to look like everything else. It also doubles the work, because every guided step is two runs instead of one β€” which is why newer work applies it only over a middle stretch of the steps, handing back some of that lost variety and paying for fewer runs.
dit
The transformer that replaced the U-Net in image models. Its trick is that conditioning modulates the normalisation, with the gate starting at zero so each block begins as an identity.
Current image and video generators are built from the same kind of network as a chatbot. The compressed sketch being cleaned up is cut into small square tiles, each tile is treated the way a word is treated, and the network lets the tiles look at one another exactly as a language model lets words look at one another. The one real difference is how your prompt gets in: instead of being more tiles to look at, the prompt is turned into a set of dials that stretch and shift each tile's own numbers before every stage. Those dials begin at zero, so a fresh network of this kind starts as a harmless pass-through and every layer learns its way in β€” which is what makes stacking dozens of them work.
latent-space
Generation runs in a compressed space, not in pixels, which is what makes it affordable. Whatever the encoder discards is gone before generation starts β€” a ceiling no sampling recovers.
Generating a picture would be unaffordable if the model worked on the actual pixels, because each of the dozens of clean-up passes would have to touch every one of them. So it does not. A separate compressor turns the image into a much smaller sketch first, the whole generating loop runs on that sketch, and only at the very end is it expanded back into pixels. The price is a ceiling nobody talks about: anything the compressor cannot hold β€” small text, one-pixel patterns, the finest texture β€” is gone before the first pass, and no amount of extra generating effort brings it back. Squeeze harder and you compute less and lose more; the saving and the loss are the same act.
few-step-distillation
Training a student to jump most of a fifty-step path in one, which is why real-time generation exists. It is paid for in variety: hold the prompt, sweep the seed, watch outputs repeat.
Early image generators needed dozens of passes to make one picture; the ones that update while you type need one to four. That is not the same model run more coarsely β€” it is a second model, trained to copy where the slow one ends up and leap most of the way there at once. What it costs is variety, for a reason you can watch: the fast model has limited capacity, so its answer ends up a blend of many of the slow model's answers, and a blend of many answers is much the same answer whatever random starting point you hand it. Change the starting point and the careful model gives you different pictures while the fast one keeps returning near-twins.
self-forcing
A few-step video model trained on the teacher drifts, one step of error per frame. Trained on its own frames, every frame stays at that one-step error.
A fast video model is usually taught by watching the slow model, frame after frame. The first frame comes out close. Each later frame is then a little wrong about a picture that was already a little wrong, so the error piles up and the clip drifts. Training it on frames it produced itself is noisier, and it stops the pile-up: every frame keeps just the error of a single step. With no error in that step, both ways stay flat.
teacache
A sampler step whose residual is under the threshold is skipped, and the drift is the sum of those residuals. The skip count stays put between residuals and rises when the threshold passes the next one. One skip is a quarter of a four-step schedule.
Neighbouring sampler steps often move the sample by a small residual. A step cache skips a step whose residual is under a threshold, and the drift is the sum of the residuals that were not applied. The skip count stays put between residuals and rises when the threshold passes the next one, and the drift rises with it. The same single skip is a quarter of a four-step schedule and a much smaller share of a long one, so the trick is harshest on the few-step models that already take big jumps.
video-time
Time is one more axis to patch and compress. Drag the resolution, frame rate and clip length and watch tokens climb into the hundreds of thousands, with attention cost growing as the square.
A few seconds of video costs far more to generate than a single picture, and the reason is arithmetic rather than anything exotic. Time is treated as simply a third direction to chop the clip along, so a clip becomes a pile of small blocks of space-and-time in the same way a picture becomes a grid of tiles. The network then compares every block against every other one, so the work grows as the square of how many there are β€” and a few seconds of ordinary video is already hundreds of thousands of blocks before anything is compressed. That is why heavy compression in both space and time is not a tidy optimisation but the thing that makes video generation possible at all.
audio-tokens
A waveform becomes a stack of codes: the first codebook carries the gist and each later one corrects what the previous missed. Drop the deepest and quality degrades instead of breaking.
A model produces one item at a time from a fixed list of possibilities, and sound is not that: it is a wave, tens of thousands of measurements a second. So it is converted twice over. First the wave is summarised into a few dozen snapshots per second; then each snapshot is described by a rough code picked from a fixed set, plus a second code for what the first one got wrong, plus a third for what those two still missed, and so on. Because every code only corrects the ones before it, dropping the last few coarsens the sound gently instead of ruining it. The cost is length: a minute of audio can run to tens of thousands of items, where the same budget holds hours of text.
ar-vs-diffusion-images
Predict image patches one at a time like text, or refine the whole canvas at once. Two cost axes that genuinely disagree, so the page reports both and stages no winner.
There are two genuinely different ways to make a picture and it is not settled which is better. One treats the image as a sequence: a fixed set of small tile patterns is agreed in advance, and the model writes out which tile goes where, one at a time, exactly the way it writes text. The other starts from random speckle and sharpens the whole canvas over and over, with no order at all. They do not even pay in the same currency β€” the first needs many passes that must happen strictly one after another but touches each place once, the second needs few passes but redoes every place on each of them β€” so which is cheaper depends on your hardware and how many requests you are handling at once.
diffusion-lm
Each step predicts every still-masked position under bidirectional attention. The masked count falls by one while any remain, and an empty mask stays empty. No causal cache is carried into the next step.
A diffusion language model fills a masked sentence from both directions. Each step scores every still-masked position from the whole sequence, including positions that come later, and unmasks the highest score. While any position stays masked the masked count falls by one, and an empty mask stays empty. The next step receives the updated tokens and the updated mask, and it receives no causal cache. This is not a drafter that proposes a tail and then accepts a prefix of it.

L β€” Reasoning

thinking-tokens
Reasoning is ordinary generation between two literal tokens, so the decoder can steer it. Suppress the stop token and it keeps thinking; force it early and it must answer now.
When a model "thinks before answering", nothing new is happening inside it. It is writing, exactly as it always writes, and the only difference is a pair of markers around the part meant to be working-out. Because the closing marker is just another word it might write, the amount of thinking is a setting the surrounding software controls: hold that marker down and the model carries on, often catching its own mistake; force it out early and the model has to answer from an unfinished thought. Each extra word of thinking costs one more word of time, but the benefit stops arriving sooner than you would guess β€” past the natural stopping point you buy a re-check, then groundless doubt, then a repetition loop, and an answer worse than the one it already had.
pass-at-k
Given one attempt the reinforcement-trained model wins. Given many, the original overtakes it β€” training sharpened what it will try rather than widening it, so the curves cross.
Some models are trained on problems whose answers can be checked automatically: a sum that is right or wrong, a program that passes its tests. The training pushes the model toward answers it already got right and away from everything else, which makes it markedly better when it gets one attempt. The uncomfortable finding is what happens when you give both the trained model and the untrained original many attempts and ask whether any of them succeeded β€” past a handful of tries the original catches up and goes ahead. Nothing new was taught; what narrowed was the range of things the model is willing to try, and correct-but-rare answers got squeezed out along with the wrong ones. One attempt is what ships, so the trade is usually still worth taking.
grpo-advantage
Score a group of attempts, subtract the group’s own mean, and that is the learning signal β€” no value network. If every attempt agrees, every advantage is exactly zero and nothing is learned.
This is the part of reasoning-model training you can actually watch. The model is handed one problem and made to attempt it several times over; each attempt is checked automatically and given a score, and then each score is compared not against a fixed target but against the average of its own siblings. Above the group average means do more of that, below means do less β€” the other attempts are the yardstick, which is why no separate scoring network is needed. The failure the page is built around is easy to reach by hand: if every attempt scores the same, all right or all wrong, every comparison comes out zero and the whole group teaches nothing, which is why trainers discard such groups and sample replacements.
verifier-selection
Spend one budget three ways: keep the best-scored attempt, take the most common answer, or search stepwise. With an imperfect judge, keeping the best gets WORSE as you sample more.
If you let a model try a problem several times, something still has to choose which answer comes back. One option is a second model trained to grade answers rather than produce them, keeping whichever it scores highest. That sounds obviously right and has a nasty property: the grader's opinion of an answer never changes, so every extra attempt is another chance to turn up a wrong answer it happens to like better, and past a point more attempts make the result worse. Simply returning whichever answer came up most often cannot fail that way, because it never consults a grader at all β€” but it fails its own way, when the model is confidently and consistently wrong. A third option spends the same budget on breadth partway through, keeping several promising part-finished attempts alive and dropping the rest as it goes.