Implement-from-Scratch Coding
21 questionsDONEUNLOCKEDLOCKED
Inference Coding Interview Questions
The coding round of an inference loop: grouped-query attention with a cache, online-softmax attention, a paged block allocator, a continuous batching scheduler, a lossless speculative verifier, top-p sampling, RoPE, INT4 packing and Triton kernels.
Worked answers on inference mechanisms, with calculations, implementation details, and follow-up questions.
You have 5 free answers unlocked here.Sign in free for 5 more · 11 are premium.
01–09Foundationsthe physics and terms an interviewer will not stop to define0/9 done
10–17Core loopsthe standard questions of this round, worked end to end0/8 done
18–21Field scenariosproduction incidents and capacity problems with the inputs left incomplete0/4 done
The concepts behind Implement-from-Scratch Coding
The ideas these answers lean on. Foundation concepts are free to read; the advanced ones are Premium.
Foundational
Attention With a KV Cache, From ScratchA from-scratch implementation of causal multi-head attention with grouped-query KV heads and a KV cache, in about 35 lines of numpy. Covers the offset causal mask when queries are fewer than keys, why the cache turns quadratic recompute into linear work, and the tests an interviewer runs against it.Advanced
Property-Testing Engine ComponentsHow to test serving-engine code the way graders do: state invariants, generate random operation sequences, compare against a slow reference within a tolerance derived from the number format, and shrink failures to a minimal repro. Includes a runnable stateful test for a KV block pool.🔒 Premium
Advanced
Sampling: Temperature, Top-k and Top-pHow LLM token sampling works and how to implement it correctly: temperature rescales logits, top-k keeps the k largest, top-p keeps the smallest prefix of the sorted distribution reaching probability p. Covers order of operations, ties at the cutoff, temperature 0, fully masked vocabularies and the cost at full vocabulary size.🔒 Premium
Unlock all 21 answers · ₹2,000 / $25
Every worked answer and derivation in all 12 topics, every concept page, and the full practice-test bank.
6 months · One payment · No auto-renewal