# Precision and quantization interview questions

> 7 precision and quantization interview questions for AI and ML engineer roles, each with a model answer.

Canonical: https://llmdojo.dev/interview/topic/quantization
Last updated: 2026-10-23

7 questions: 2 junior, 3 mid-level and 2 senior. Taught in [Precision and Quantization: Fewer Bytes per Weight](https://llmdojo.dev/learn/inference-optimization/precision-and-quantization).

## [How much memory do a model's weights take, and what does quantizing GPT-2 small to INT4 save?](https://llmdojo.dev/interview/q/how-much-memory-do-a-model-s-weights-take-and-what-does)

Level: Junior

Parameters × bits per weight ÷ 8. GPT-2 small's 124,439,808 weights take 497.8 MB in FP32 and 62.2 MB in INT4, an eighth, plus small per-group scales. Decode **reads every weight each step**, so **bytes per weight** set both the memory and the bytes each step moves.

## [FP16 and BF16 both use 16 bits. How do they differ, and how can loading a model in the wrong one hurt?](https://llmdojo.dev/interview/q/fp16-and-bf16-both-use-16-bits-how-do-they-differ-and)

Level: Junior

They **split the bits differently**: FP16 has 5 exponent and 10 fraction bits, BF16 8 and 7. **Exponent bits buy range**, fraction bits precision, so FP16 is finer but tops out at **65,504**, while BF16 keeps FP32's range. Llama 2 shipped in BF16; teams loading it in FP16 found quality much worse than advertised.

## [Explain absmax INT8 quantization. What's the worst-case rounding error, and what does a single outlier do?](https://llmdojo.dev/interview/q/explain-absmax-int8-quantization-what-s-the-worst-case-rounding-error-and)

Level: Mid-level

Divide each value by the group's **largest magnitude**, multiply by 127, round; store the integers plus one scale. A value moves at most half a step.

**Diagram: How a float becomes an INT8 with a scale**

1. Start with real weights: the first 12 of the 768 numbers in GPT-2's embedding row for the token " bank".
2. Find the largest magnitude in the group. Here it is 0.344.
3. Map it to the largest INT8 value, 127. The scale is the size of one integer step: 0.344 / 127, about 0.00271.
4. Divide every value by the scale and round to the nearest integer. 0.137 becomes 51.
5. Store the integers, one byte each, plus the one scale for the whole group.
6. To use a weight, multiply back: 51 × 0.00271 is 0.1381, not 0.137. That 0.0011 is the quantization error.
7. Rounding moves each value at most half a step, 0.00135 here. A bigger largest value means a bigger step and a bigger error for every value in the group.

Real values: 12 numbers from GPT-2's embedding row for " bank" (lib/labs/data/running-example.json, stored to 3 decimals). Method: absmax quantization, LLM.int8() (Dettmers et al., 2022), §2.1.

**One outlier widens the step** for its whole group: adding an invented value 20 times our largest GPT-2 weight took the step from 0.00271 to 0.0542, and the largest error on the real weights from 0.00126 to 0.027. Hence **per-block scales**.

## [You must serve an open 13B model on one 80 GB accelerator and want more concurrent conversations. Which quantization would you use, and what does it actually buy?](https://llmdojo.dev/interview/q/you-must-serve-an-open-13b-model-on-one-80-gb-accelerator)

Level: Senior

**Post-training, weight-only quantization**. I didn't train the model, PTQ is the common path frameworks offer in a few lines, and weight quantization affects quality more stably.

It buys **less than the byte ratio** suggests. For Llama 2 13B at 2,048 tokens with a 16-bit cache, INT4 weights take 6.5 GB instead of 26, so 43 conversations fit instead of 32: the cache takes most of the memory. Next lever: **shrink the cache**. Hands-On LLMs' rule of thumb: stay at 4 bits or above.

## [A colleague says INT4 weights will make decode eight times faster because they're eight times smaller. How do you respond?](https://llmdojo.dev/interview/q/a-colleague-says-int4-weights-will-make-decode-eight-times-faster-because)

Level: Senior

It's **a ceiling, not a forecast**. Batch-1 decode is bandwidth-bound, so time should track bytes read, but the **KV cache doesn't shrink**. Scaling our measured 9.1 ms CPU step by bytes gives about 1.3 ms at INT4: an estimate, not a measurement, with the cache now 13% of the bytes.

And the format needs **hardware and kernel support**: format conversion costs compute, and LLM.int8() claims only modest matrix-multiply speedups. I'd measure step time on our setup.

## [Implement FP32-to-int8 quantization in NumPy with a scale, zero point and clipping, and the matching dequantizer.](https://llmdojo.dev/interview/q/implement-fp32-to-int8-quantization-in-numpy-with-a-scale-zero-point)

Level: Mid-level

```python

def quantize(x, qmin=-128, qmax=127):
    lo, hi = min(x.min(), 0.0), max(x.max(), 0.0)
    scale = (hi - lo) / (qmax - qmin) or 1.0
    zp = int(np.clip(round(qmin - lo / scale),
                     qmin, qmax))
    q = np.round(x / scale) + zp
    return np.clip(q, qmin, qmax).astype(np.int8), scale, zp

def dequantize(q, scale, zp):
    return (q.astype(np.float32) - zp) * scale
```

Asymmetric quantization maps the observed range onto -128 to 127 with a scale and a **zero point**, keeping **0.0 exactly representable**. Interviewers check rounding before adding the zero point, clipping, the all-zero case, and outliers: one huge value stretches the scale and crushes the rest, so clip to a percentile or use **per-channel** scales.

## [Explain quantization-aware training, knowledge distillation, eval mode and contrastive learning. How would you verify that each one improved a production model?](https://llmdojo.dev/interview/q/explain-quantization-aware-training-knowledge-distillation-eval-mode-and-contrastive-learning-how)

Level: Mid-level

**Quantization-aware training** simulates low-precision rounding during fine-tuning, so accuracy holds better than post-training quantization. **Distillation** trains a small student on a teacher's soft outputs. Eval mode disables dropout and makes batch norm use running statistics; forgetting it corrupts metrics. Contrastive learning pulls matching pairs together in embedding space and pushes others apart. Verify each on a fixed held-out set and the target hardware: accuracy per slice, latency and memory versus the baseline.

## Related
- [All interview questions](https://llmdojo.dev/interview)
