5.3.18 · D1MLOps & Deployment

Foundations — LLM serving (vLLM, quantized inference)

1,719 words8 min readBack to topic

This page assumes nothing. If the parent note used a symbol, a word, or a picture without explaining it, we build it here first. Read this before the parent topic.


1. What is a "token"?

We will use these letters for counting tokens and model size — memorise the picture, not the letter:

Symbol Plain words The picture
sequence length = how many tokens so far number of train carriages
batch = how many separate conversations at once how many trains on parallel tracks
number of layers in the model how many times the train passes through the "thinking machine"
width of each token's vector how many numbers describe one carriage
bytes per number (FP16 = 2) weight of storing one number

2. What is a "vector" and ?

Look at the figure: one token (one carriage) is a tall stack of numbers. When the parent note writes , it means every single token drags a list of 5120 floating-point numbers behind it.


3. What is a "byte" and "precision"?


4. Attention — WHY we need a "KV cache"

The parent note keeps saying Keys, Values, queries. Here is where they come from, from zero. (Full detail lives in Attention Mechanism — we only build what this topic needs.)


5. What is a "head" (and why not )?


6. What does "memory-bound" vs "compute-bound" mean?


7. What is "quantization" at the number level?

Here is the number of bits, and is the number of gaps between tick marks. INT4: , gaps.


8. What is "batching"?


Prerequisite map

Token = numbered text chunk

Vector of d_model numbers

Query Key Value per token

KV cache stores past K and V

Byte and precision p

Quantization few ticks

Memory-bound decode

Batching reuse weights

LLM Serving vLLM and Quantized Inference

Read the arrows as "you need this before that." Everything funnels into the parent topic node T.


Equipment checklist

A token is
a number representing a chunk of text (word or word-piece).
A vector is
an ordered list of numbers; each token is a vector of length .
means
how many numbers describe one token.
, , stand for
sequence length (tokens), batch (parallel conversations), number of layers.
(precision) means
bytes per number — FP16 = 2, INT8 = 1, INT4 = 0.5.
Query / Key / Value are
per-token lists: what I seek / what I offer / the info I hand over.
The KV cache exists to
avoid recomputing past Keys and Values every decode step (trades memory for compute).
KV-cache size formula
.
Why not
heads sum to , so all heads' storage adds back to the full width.
Memory-bound vs compute-bound
slow part is moving data vs slow part is doing arithmetic.
Prefill is
reading the whole prompt at once — compute-bound.
Decode is
writing one token at a time — memory-bound.
Quantization is
snapping real numbers to a small set of allowed levels to save bytes.
Scale formula
.
Why batching helps throughput
weights read once are reused across many conversations.