Trending
EXPLAINER

Transformers, and why AI models need so much memory bandwidth

Reading guide Step 75 of 112 · AI chips

Almost every AI chatbot is built on the transformer, a design Google researchers published in 2017. Transformers turned out to be limited less by how fast chips can calculate than by how fast they can fetch numbers from memory. That “memory wall” is why HBM became the most valuable product Samsung and SK hynix make.

Key takeaways

  • The transformer, published by Google researchers in 2017, is the design behind nearly every chatbot. Its key step, attention, links each word to the words before it.
  • When a chatbot writes, each new token requires reading essentially the whole model from memory. Memory speed, not calculating speed, usually sets the pace.
  • Over about 20 years, peak chip computing power grew about 60,000 times; memory bandwidth grew only about 100 times. Researchers call the gap the memory wall.
  • That is why AI chips are surrounded by HBM, and why SK hynix, Samsung, and Micron cannot make enough of it.

In June 2017, eight researchers at Google posted a paper with a catchy title, “Attention Is All You Need”. It described a new kind of neural network for translating languages, called the transformer, which beat the best existing systems after “training for 3.5 days on eight GPUs.” Almost every large language model since, from GPT to Claude, Gemini, and Llama, is a transformer. This piece explains, without math, how a transformer works and why it puts so much pressure on memory chips. For the units transformers work in, see What is a token?

How a transformer works

A transformer turns text into tokens, and each token into a long list of numbers. These lists then pass through dozens of identical layers. Each layer does two things:

  • Attention. Every token looks back at the tokens before it and decides how much each matters. In “The chip overheated because it was overclocked,” attention is what links “it” to “chip.”
  • A feed-forward step. Each token’s numbers are multiplied by large grids of learned numbers, the model’s parameters or weights, which store what it learned in training.

Both steps are mostly matrix multiplication, the kind of math GPUs and TPUs are built for. A model with 70 billion parameters has 70 billion of these numbers, which take about 140 gigabytes at 16 bits each, our arithmetic. Meta’s Llama 3.1 70B, for example, has 80 layers, its published settings show.

Writing one token: every layer, every weight Tokens so far“The chip overheated…” attentionfeed-forwardattentionfeed-forwardattentionfeed-forwardattentionfeed-forward… 80 layers in Llama 3.1 70B One new tokenthen repeat HBM memory: weights (about 140 GB)plus the KV cache of the conversation read again for every new token
Simplified. 140 GB is 70 billion parameters at 16 bits, our arithmetic. Drawing: ChipDecoder.

Why writing is slow: one token at a time

A transformer reads a whole prompt at once, which keeps the chip busy. But it writes its answer one token at a time, and each new token has to pass through every layer, which means fetching every weight from memory again. For a single user, the chip spends most of its time waiting for numbers to arrive, not calculating. Researchers at UC Berkeley found that this writing step, called decoding, is limited mainly by memory bandwidth, at least when a chip serves few users at once, in their paper “AI and Memory Wall”. Serving many users together helps, because one fetch of the weights can be shared, but each user’s conversation still needs memory of its own.

That per-user memory is the KV cache: numbers the model saves for every token in the conversation so far, so attention does not have to recompute them. For Llama 3.1 70B at 16 bits, it takes 320 KiB per token, MinIO’s sizing guide shows. A short chat is small, but a 128,000-token conversation, a long document or a coding session, needs about 40 GiB, and 128 such conversations at 64,000 tokens need about 2.5 TiB.

Memory for one conversation’s KV cache (Llama 3.1 70B)4K tokens1.25 GiB32K tokens10 GiB128K tokens40 GiB Model weightsabout 140 GB 320 KiB per token at 16 bits. Many users at once each need their own cache.
Sources: MinIO KV cache sizing guide; weights are our arithmetic. Chart: ChipDecoder.

The memory wall

The deeper problem is that calculation has raced ahead of memory for decades. Over about 20 years, peak server computing power grew about 60,000 times, or 3 times every two years, while DRAM bandwidth grew about 100 times, or 1.6 times every two years, and the links between chips about 30 times, the Berkeley team found. Meanwhile the parameter counts of large language models grew about 410 times every two years. Each new chip can do far more math per byte it can fetch.

The memory wall: growth over about 20 yearsPeak computing powerabout 60,000x3x every two yearsDRAM bandwidthabout 100x1.6x every two yearsLinks between chipsabout 30x1.4x every two years Bars use a logarithmic scale; on a normal scale the bottom two would be invisible.
Source: Gholami et al., “AI and Memory Wall,” UC Berkeley (2024). Chart: ChipDecoder.

Chipmakers attack the wall from several sides:

  • HBM. Stacking DRAM chips beside the processor gives far more bandwidth than ordinary memory; see What is HBM?
  • Smaller numbers. Storing weights in 8 or 4 bits instead of 16 halves or quarters the data to fetch; see What FP8 and FP4 mean.
  • Fewer weights per token. Mixture-of-experts models use only a slice of their weights for each token; see Mixture of experts.
  • Memory that computes. Doing some math inside the memory chip itself avoids moving data at all; see Processing in memory.

What it means for Korea

The memory wall is, in effect, Korea’s business case. Because transformers are limited by how fast numbers move, every new AI chip carries more and faster HBM: Nvidia’s Rubin, for example, has 288 gigabytes of HBM4. SK hynix and Samsung together supply most of the world’s HBM, and the shortage has pushed memory to more than half of all chip sales this year by the industry’s own forecast; see the memory shortage and Samsung vs. SK hynix in HBM.

What to watch next

  • Longer conversations. As models handle longer documents and agents run for hours, KV caches grow, pushing demand for memory beyond HBM, into SOCAMM modules and flash storage; see AI and flash storage.
  • New designs. Researchers are testing alternatives to attention that need less memory, but none has displaced the transformer.

Sources

FAQs

What is a transformer in AI?

A neural network design, published by Google researchers in 2017, that processes text as tokens and uses a mechanism called attention to work out how each token relates to every other. GPT, Claude, Gemini, and Llama are all transformers.

What is attention?

The step in which a transformer compares each token with the tokens before it and decides how much each one matters, so that, for example, “it” can be linked to the right noun earlier in a sentence.

Why do transformers need so much memory bandwidth?

To write each new token, a chatbot must read essentially all of the model’s billions of numbers from memory, plus its notes on the conversation so far. The calculation itself is quick; fetching the numbers is the slow part.

What is the memory wall?

The growing gap between how fast chips can calculate and how fast memory can feed them. Over about 20 years, peak computing power grew about 60,000 times while memory bandwidth grew about 100 times, researchers at UC Berkeley found.

What is the KV cache?

The numbers a transformer saves for every token already in the conversation, so it does not have to recompute them. For a 70 billion parameter model it takes about 320 KiB per token, or about 40 GiB for a 128,000-token conversation.