TensoriumInterview preparation
← Home

Core concepts · 62 topics

A guided path through the ideas behind modern LLMs.

Read the stages in order: how text becomes a prediction, what happens inside the Transformer block, how a model learns, then serving, scale, and post-training. Every topic names what to know first, then gives the intuition, the math with concrete numbers, the common misconception, and a self-check. Already comfortable with the basics? Switch to By area and jump straight to a topic.

New to machine learning? Start here instead.

These topics work best as a refresher; they assume ideas like probability and loss. Begin with three short beginner lessons (tokens, embeddings, next-token prediction), then the visual walkthrough for attention and the Transformer.

Finish line: You can explain how text becomes a prediction and what training does to improve that prediction.

Topic 31 of 62 · Generating and serving

Quantization: memory vs quality

Medium

How does quantization map weights or activations into lower bit-widths, and why doesn’t 4-bit weight quantization always make inference 4× faster?

Why this mattersReducing weight or KV precision cuts capacity and memory traffic, provided the hardware kernels support the format and sensitive outlier channels are handled.

1 · Start with the intuition

Quantization compresses continuous floating-point numbers (such as 16-bit BF16/FP16) into a small grid of low-bit integers or floats (such as INT8, FP8, or INT4) using a scale factor s (and an optional zero-point z). Storing weights in 4 bits instead of 16 bits cuts raw weight memory and weight HBM traffic by nearly 4×—which speeds up memory-bandwidth-bound decode at small batch sizes—but it does not speed up compute-bound prefill unless the activations are also quantized to a format supported by faster low-precision tensor cores (like FP8), and dequantization overhead plus KV cache traffic still remain.

2 · How the mechanism works

Mechanism step 1 of 3 · no question to answer

Calibrate scale (per-channel / group)

Choose a scale s (e.g., per output channel or per group of 64–128 weights) so outlier values do not crush the resolution of normal values.

Next, we will look at: Round & clip to integer grid. Move on when this operation makes sense.

Visualizing the behavior

Round-to-nearest on a grid of step s = 0.1

Derived
00.10.20.30.40.500.10.20.30.40.5real value xdequantized x̂ = s·round(x/s)0.26 → 0.30 (error 0.04)
  • exact (x̂ = x)
  • quantized
Every value snaps to the nearest step, so the error is at most s/2 = 0.05. The scale s is set by the largest value in the group, which is why one outlier makes s large for everyone.

Raw weight storage for 7B parameters (decimal GB)

Derived
FP16 / BF16
14.0 GB
INT8
7.0 GB
4-bit
3.5 GB
4-bit + FP16 scale per 128
≈ 3.6 GB
Group scales add 16 bits per 128 weights, about 0.125 bits per parameter. Excludes KV cache, activations and runtime overhead, and fewer bytes do not automatically mean faster kernels.