FreeExam

Transformer basics

An MLOps interview on the memory, numerics, and artifacts a transformer train or serve stack depends on.

These prompts are original practice. They are not questions from a named employer or a live hiring loop.

  1. 1.The attention score matrix for one head grows with which power of the sequence length, and which other factors multiply that memory?

  2. 2.What is the shape of the token embedding table, and what does a longer sequence or a larger vocabulary do to the score matrix?

  3. 3.How does feed-forward activation memory scale with sequence length?

  4. 4.Besides sequence length, which width sets the feed-forward activation's size?

  5. 5.Which attention tensor is quadratic in the sequence length?

  6. 6.A causal mask blocks future positions. What does that do to the number of score pairs?

  7. 7.What does a materialized logit tensor grow with?

  8. 8.What happens to Adam moment storage if the sequence gets longer and the parameters stay the same?

  9. 9.What shape is a parameter's gradient tensor?

  10. 10.What does the KV cache store, and which factors set its bytes?

  11. 11.During single-token decode, what is the shape of one head's new scores?

  12. 12.Where is the heavy attention work in prefill, and where is it in decode?

  13. 13.Why does paged attention store the KV cache in blocks?

  14. 14.A paged KV cache holds a fixed number of tokens per block. How many blocks does one sequence use?

  15. 15.How do a rectangular batched cache and a paged cache treat padding?

  16. 16.What does FlashAttention change, and what architecture does it leave in place?

  17. 17.How does the FlashAttention backward pass obtain the scores it needs?

  18. 18.What is the memory difference between a causal flag inside the kernel and a dense additive mask?

  19. 19.How many bytes does one element use in bf16, fp16, and fp32?

  20. 20.How do bf16 and fp16 differ in range and mantissa, and which one more often needs loss scaling?

  21. 21.Why must a large negative attention mask be chosen carefully when the scores are in fp16?

  22. 22.Why do softmax implementations subtract the maximum score before the exponential?

  23. 23.What scale is applied to attention scores before the softmax, and what is it for?

  24. 24.What should the token cross-entropy consume?

  25. 25.Why is Adam's stored state larger than the weights alone?

  26. 26.What extra weight copy does mixed-precision training commonly keep?

  27. 27.What is lost if a mixed-precision run saves only the bf16 weights?

  28. 28.What extra state does dynamic loss scaling add to an exact fp16 resume?

  29. 29.What does gradient checkpointing recompute, and what does it leave unchanged?

  30. 30.How is activation checkpointing different from a checkpoint file?

  31. 31.Does a longer sequence make the saved weight file larger?

  32. 32.What does each of these parallel splits cut?

  33. 33.When the only splits are data parallel, tensor parallel, and pipeline parallel, what is the data-parallel degree?

  34. 34.When do data parallel and tensor parallel move data?

  35. 35.What keeps data-parallel replicas on the same weights?

  36. 36.What crosses a pipeline-stage boundary during a training step?

  37. 37.What happens in a pipeline step that has only one microbatch?

  38. 38.What does each ZeRO stage shard?

  39. 39.Which memory does ZeRO leave on the rank that runs the forward?

  40. 40.When ZeRO stage 3 runs a layer, where are that layer's full parameters?

  41. 41.What does offloading Adam's moments to the CPU change?

  42. 42.What is the global batch, counted in sequences?

  43. 43.Which batch size sets activation memory on one device?

  44. 44.What activation memory does sequential gradient accumulation hold at one time?

  45. 45.Equal microbatches each produce a mean gradient, and those gradients are summed over N accumulation steps. What does the update need?

  46. 46.When does gradient accumulation step the optimizer, and what does the learning-rate schedule count?

  47. 47.What does a larger batch change about an optimizer step, and which width does it leave alone?

  48. 48.Which tokenizer can serve a finished set of weights?

  49. 49.Which tokenizer must evaluation use when it reports a token-level loss?

  50. 50.Why are token-level losses from two tokenizers not the same unit?

  51. 51.Can a chat template change the ids when the weights and the vocab are unchanged?

  52. 52.What must a BPE tokenizer artifact include besides the vocab list?

  53. 53.Where do the RoPE base and the maximum position come from at load?

  54. 54.How are standard RoPE frequencies obtained?

  55. 55.Which attention vectors does RoPE rotate?

  56. 56.How does a learned absolute position table differ from RoPE inside the weight file?

  57. 57.Which architecture fields have to be known before weight tensors can be placed into a module?

  58. 58.What does the tied-embedding flag tell a loader?

  59. 59.How does loading safetensors differ from loading a pickle checkpoint?

  60. 60.What does a sharded weight directory need besides the shard files themselves?

  61. 61.What metadata does a tensor-parallel weight shard need so it can be loaded?

  62. 62.What does one pipeline-parallel checkpoint contain?

  63. 63.Can one rank's ZeRO stage-3 file be loaded as a normal full model?

  64. 64.What must a checkpoint contain to load the model, to resume training, and to resume exactly?

  65. 65.What does a serving bundle need, and what does a generate call leave unread?

  66. 66.Besides the packed integers, what must a quantized weight artifact include?

  67. 67.What does weight quantization change, and what does it leave alone?

  68. 68.A file stores one fused QKV projection. What must the loader respect when it splits that matrix?

  69. 69.What is the fused QKV output width under grouped-query attention?

  70. 70.What divisibility does standard multi-head attention need between d_model and the head count?

  71. 71.What divisibility does standard grouped-query attention need?

  72. 72.Which head count does KV-cache memory grow with?

  73. 73.How many weight matrices does a gated feed-forward block such as SwiGLU have?

  74. 74.What does tying the input embedding to the output projection store?

  75. 75.Which embedding rows get dense Adam moments?

  76. 76.Which parameters receive Adam moments?

  77. 77.What has to change in the weights when the tokenizer gains a new special token?

  78. 78.What goes wrong if you pad each row to the longest row and also train on the pad id?

  79. 79.Where is a padding mask applied, relative to the softmax?

  80. 80.What does the softmax produce if every key for a query is masked?

  81. 81.How is the next-token training label aligned with the logits?

  82. 82.What extra mask does packing several documents into one sequence need?

  83. 83.Packed documents already cannot attend across the boundary. What can the label shift still do?

  84. 84.How should position ids be set when independent documents share one packed row?

  85. 85.What does an ignore index on a label change?

  86. 86.During supervised fine-tuning, where do prompt tokens go when the loss is only on the answer?

  87. 87.How does a per-token mean loss differ from a per-sequence mean?

  88. 88.What is the perplexity of a token model?

  89. 89.Is a teacher-forced training loss the same number as a metric on sampled text?

  90. 90.How should a string metric turn ids into text?

  91. 91.When is dropout applied?

  92. 92.In a left-padded decode batch, which token should receive position 0?

  93. 93.What does temperature do to the logits before a sample is drawn?

  94. 94.How do top-k and top-p decide which tokens may be sampled?

  95. 95.What are temperature, top-k, and top-p, relative to the weights and to a generation metric?

  96. 96.Besides the checkpoint and the sampler settings, what determines a sampled generation?

  97. 97.What does constrained decoding change when it enforces a grammar or a schema?

  98. 98.Which id stops a generate loop that checks for end of sequence?

  99. 99.How does speculative decoding produce tokens?

  100. 100.Under the standard speculative acceptance rule, which distribution do the kept tokens follow?

  101. 101.What must a draft model share with the target for its proposals to be checkable?

  102. 102.How does the target check a draft that contains several tokens?

  103. 103.When can speculative decoding cost more than decoding the target alone?

  104. 104.When can continuous batching accept another request, and what does it not do to the two prompts?

  105. 105.What happens in a continuous batch when one sequence emits end of sequence?

  106. 106.What does chunked prefill do with a long prompt?

  107. 107.What does replaying a CUDA graph require of the tensors it uses?

  108. 108.What do embedding parameters grow with, compared with attention projection parameters?