Interview question bank
Explain the mechanism and why it is useful before naming an equation. Answer aloud, then check the response.
Why separate prefill from decode?
Prefill processes the known prompt in parallel. Decode repeatedly processes a new position against stored history. Their shapes and bottlenecks differ, so they need separate measurements.
What does a KV cache save?
It avoids recomputing the causal prefix’s keys and values. It does not eliminate reading history for each new query, and cache reuse requires unchanged weights, positions, masks, and input dependencies.
Why is the cache a correctness concern?
Stale, misplaced, or wrongly rotated entries change the context a query sees. Incremental logits should agree with a full forward pass under the same model and numerical tolerance.
Why does efficient attention still have a cost?
Tiling avoids large intermediate storage, but exact dense attention still performs the allowed comparisons. During decode, memory traffic or other operations may dominate.
Why quantize?
A discrete representation can reduce weight storage and transfer. It introduces approximation, metadata, and backend requirements, so smaller files do not automatically mean faster or equally accurate inference.
Why use finer quantization groups?
A shared scale must accommodate every value in its group. Smaller groups can represent local ranges better, especially around outliers, but need more scale metadata and suitable kernels.
Why inspect a checkpoint’s config before coding?
Dimensions alone are insufficient. Pairing, normalization, bias, KV sharing, activation, and template conventions determine the function the saved tensors represent.
Why are state-dictionary names insufficient for weight mapping?
Names identify tensors, but the local implementation must also match their roles, layout, orientation, and any fused ordering. A wrong mapping can load without a shape error.
Why is plausible generated text a weak parity test?
Many incorrect implementations still produce fluent continuations. Comparing logits under identical input reveals differences before sampling amplifies them.
How do you localize a parity failure?
Compare intermediate outputs in execution order and find the first disagreement. Then inspect that operation’s inputs and conventions rather than changing the entire model at once.
Why are tokenizer and chat template part of the model?
They create the exact IDs and role boundaries the checkpoint learned. The same visible sentence under another serialization can mean a different input to the network.
What makes an inference benchmark interpretable?
It fixes prompt and output lengths, batch, precision, backend, and measurement boundaries. It separates startup, prefill, and decode and checks output quality alongside time and memory.
Exercises
One filled dot is a short explanation, two require diagnosis, and three require a system design. Draw the relevant mechanism before checking the solution.
E1. ●○○ Explain why weight quantization may leave long-context memory use high.
E2. ●○○ Why can visible control-token text behave differently from a special token?
E3. ●●○ A decoder works without caching but fails with caching. Describe a diagnosis.
E4. ●●○ A quantized model loads and runs faster but chooses the wrong tool. What does the benchmark miss?
E5. ●●● Plan a weight-port validation from checkpoint to local decoder.
E6. ●●● Design a benchmark that distinguishes prefill speed from generation speed.
Worked solutions
Follow the reasoning, including the assumption that makes each answer valid.
E1. The KV cache is separate from model weights and grows with retained history. Quantizing weights does not change the cache dtype automatically. Temporary buffers and allocator overhead also remain.
E2. The tokenizer may split the visible spelling into ordinary pieces unless it recognizes the registered special token. Inspect IDs rather than inferring a boundary from how the prompt looks.
E3. Hold input IDs and settings fixed. Compare next-token logits after the same prefix, then check cache append positions, key rotation, mask alignment, and retained length. Inspect the first layer that differs before testing generated sentences.
E4. Latency alone does not establish a useful deployment. Evaluate the actual task, including tool choice, arguments, and stopping behavior. Compare with the unquantized model under the same template and runtime to attribute the regression.
E5. Record the exact config and tokenizer. Map tensors by operation, checking orientation and fused ordering. Compare embeddings and block intermediates with the reference, then logits and cached continuation. Validate serialization and stop markers before reporting end-to-end behavior.
E6. Measure prompt processing separately from incremental output under fixed conditions. Warm up the backend and synchronize the timing boundary. Sweep relevant prompt lengths and batches, record cache and peak memory, and verify parity. State whether tokenization, loading, and sampling are included.