Cheat sheet · Module 5

Cheat sheet: ML systems and interviews

Machine Learning · Cheat sheet · ML systems and interviews

Open the moduleModule quiz

The pattern: an ML system is a model plus everything that feeds it, serves it, tests it and keeps it healthy, and every decision trades among quality, latency, cost and risk. Training a large model is first an accounting problem (where does the memory go?) and then a communication problem (what crosses the network?). Every technique swaps one resource for another: memory for compute, memory for network traffic, speed for numerical risk. An interview adds a third layer: in this course’s judgment, it grades what a listener can hear you work out in a short time, so the same facts need a structure you can say aloud.

ML system design (lesson 1)

Frame first. Ask whether ML is needed at all: do simple rules solve it well enough, is there a label or feedback signal, what does an error cost, is explainability required. Google’s Rules of ML say not to be afraid to launch without ML (rule 1) and to keep the first model simple and the infrastructure right (rule 4). Separate three layers: the business goal, the training objective (a loss) and the metrics (offline and online). The gap between the layers is where designs fail, so name one guardrail metric for every primary metric. State constraints before architecture: scale, latency budget, freshness, cost per request, privacy, behaviour when the system is down.

The nine steps (the minutes are a suggested split of a 35-minute round, a convention and not a rule):

StepMinutesSay
1. Clarify and frame4Users, goal, scale, latency, constraints, is ML needed
2. Data and labels4Sources, label definition, delay, noise, privacy, bias
3. Baseline2A rule or logistic regression, to set the bar
4. Features4User, item, context, aggregates; batch against real-time
5. Model5Candidates justified by latency, data size, interpretability
6. Offline evaluation3Metrics, time or group split, error analysis, calibration
7. Serving5Batch or online, latency budget, caching, fallbacks, cost
8. Online evaluation and rollout3A/B, guardrails, shadow, canary
9. Monitoring and risks5Drift, feedback loops, retraining, fairness, abuse

Say the trade-off (“the cost of this is…”), start with a baseline, and name the failure mode before the interviewer does.

Inference modes. Batch scores on a schedule and serves from a table (stale between runs). Online computes at request time (a hard latency budget). Streaming updates aggregates as events arrive (state, ordering, late events). Real systems mix them: slow embeddings in batch, fast aggregates streamed, final scoring online. Choose the slowest mode the product tolerates.

Capacity (Little’s law, L=λWL=\lambda W, requests in flight equal arrival rate times time in the system). Worked example, all assumptions stated: 5 million daily users, 4 sessions each and one request per session is 20,000,000 requests a day, 231.48 per second on average, and 694.44 at an assumed 3 times peak. At an assumed 0.060 s that is 41.7 in flight. One server handles 8 at once and is kept at 50%, so it carries 4, and ⌈41.7/4⌉=11\lceil 41.7/4\rceil=11 servers. At an assumed $0.40 per server-hour that is $105.60 a day, or $5.28 per million requests. Each assumption is a lever; the peak factor is the one most worth asking about. Memory is a second budget: 200,000 embeddings of 64 float32 values are 51.2 MB, but 100,000,000 of 128 values are 51.2 GB and no longer fit in one machine’s fast memory.

Latency is a distribution.

  • Serial steps add, parallel steps take the maximum: a 5 ms lookup then 10 ms and 40 ms fetches is 55 ms in series and 45 ms with the two fetches in parallel.
  • Budget percentiles, not means. In 20,000 simulated requests the median was 40.1 ms and the mean 45.2 ms, but p95 was 91.5 ms, p99 126.2 ms and the slowest 277.5 ms. Nearest-rank p99 is the value at rank ⌈p n/100⌉\lceil p\,n/100\rceil of the sorted list. Percentiles do not average: one server with p99 10 ms and another with 200 ms (100 requests each, 99 and 90 fast at 10 ms) have a mean p99 of 105 ms, yet the pooled p99 is 200 ms. Separately, a tail percentile from a small window is noisy, so measure it over one large window of all requests pooled.
  • Fan-out: ten independent calls that are each slow one time in a hundred give 1−0.9910=0.09561-0.99^{10}=0.0956 of requests at least one slow call. The simulation gave 0.1030. That gap is not sampling noise: the p99 threshold (126.2 ms) was estimated from 20,000 draws and is really the 98.92nd percentile of the simulated distribution, so each call exceeds it with probability 0.01077 and 1−0.9892310=0.10271-0.98923^{10}=0.1027. Estimating a tail percentile from a sample is itself noisy.
  • Timeout with fallback: a 100 ms timeout and a 5 ms fallback sent 3.20% of requests to the fallback and cut the slowest served request from 277.5 ms to 105.0 ms. The fallback rate is a metric: a rising one means users quietly get a worse product while accuracy looks fine.

Two stages, two metrics. Candidate generation (two-tower embeddings with an approximate nearest-neighbour index such as HNSW, popular items, keyword search) is cheap and optimised for recall. The ranker orders the candidates for precision at the top. The re-ranker applies diversity, rules, fairness and exploration. The YouTube paper describes the same split of a candidate generation model and a ranking model. An approximate index can miss a true neighbour, so retrieval recall is measured, not assumed.

  • recall@k=∣top-k∩relevant∣/∣relevant∣\mathrm{recall@}k=\lvert\text{top-}k\cap\text{relevant}\rvert/\lvert\text{relevant}\rvert counts relevant items present, not their order. DCG@k=∑i=1kgi/log⁡2(i+1)\mathrm{DCG@}k=\sum_{i=1}^{k}g_i/\log_2(i+1) and NDCG@k=DCG@k/IDCG@k\mathrm{NDCG@}k=\mathrm{DCG@}k/\mathrm{IDCG@}k, so a perfect list scores 1. Gains 1 and 3 in that order give 1+3/log⁡23=2.8931+3/\log_2 3=2.893 against an ideal 3.631, so NDCG 0.797.
  • In the synthetic catalogue of 20,000 items, the retriever alone reached NDCG@10 of 0.214. Passing 50 candidates gave a final NDCG@10 of 0.472 (retriever recall 0.165) and 2,000 gave 0.903 (recall 0.613); ranking all 20,000 gave 0.944. A ranker cannot promote an item it never sees, so final quality is capped by retrieval recall, and more candidates cost ranker latency in proportion.

Four designs (same skeleton, different emphasis):

  • Recommender: cold start (popularity, content features, exploration slots), position bias (Rule 36: add a positional feature and give every candidate the same default at serving; or weight by estimated propensities as Joachims et al. do), feedback loops.
  • Search: query understanding, hybrid retrieval (keyword and embedding), a light ranker, then a heavier learning-to-rank model; NDCG@k and MRR offline.
  • Fraud: extreme imbalance, delayed and selective labels (a declined payment has no outcome, so keep a small random holdout of approvals), adversaries who adapt. With calibrated pp, loss LL from a missed fraud and friction FF from a false alarm, decline when p>F/(F+L)p>F/(F+L): 0.0476 for $80 and $4. Decide fail-open or fail-closed explicitly.
  • Ads: the click probability feeds an auction, so calibration matters as much as ranking. Value per impression is pCTR times bid: 0.02 times $1.50 is $0.03, and a pCTR overstated 2 times makes it $0.06.

Features and consistency. One feature definition for training and serving (re-use the code), log the features you served and train on them, and consider a feature store when many models share features and freshness matters. In Feast a feature view’s data source generates training datasets and also materialises values into the online store. For one model with a few features, a shared library and logged features may be enough.

Serving levers, cheapest and least risky first.

  • Cache: with Zipf-like traffic over 10,000 keys, an LRU cache of 1% of the keys served 0.391 of 200,000 requests and 10% served 0.675. Answers go stale, personalised results cache poorly, hit rate depends on traffic skew you must measure.
  • Batching: fixed cost per call, so throughput rises and latency rises. With 8 ms fixed and 0.5 ms per item, batch 1 takes 8.5 ms (117.6 items per second), batch 16 takes 16.0 ms (1000.0) and batch 64 takes 40.0 ms (1600.0). Under a 20 ms cap the best batch is 24 (1200.0). Time spent waiting for a batch to fill is extra and was ignored.
  • Quantisation: 100 million parameters go from 400 MB in 32-bit floats to 100 MB in 8-bit integers. Re-run offline evaluation on the quantised model. Distillation: a student trained to imitate a larger teacher, usually smaller and faster; you pay for training twice.

Rollout, monitoring, debt.

  • Rollout ladder: offline evaluation, shadow (scores, nothing acts), canary (small share of traffic), A/B (randomised, guardrails), ramp, with rollback from the canary and A/B stages. Keep the previous model deployable so rollback is a switch.
  • Monitor four layers, cheapest first (data quality, feature drift, score drift, performance once labels mature), plus latency percentiles, error and timeout rates and the fallback rate.
  • Feedback loop toy (ten items, one with a click rate of 0.15 and nine with 0.10): always showing the best observed item made item 7 the most shown in 14 of 100 runs and gave the most-shown item 0.998 of the impressions; exploring 10% of the time did so in 55 of 100 runs, with the most-shown item at 0.670. Remedies: an exploration or random holdout slice, logged propensities, evaluation on data the model did not influence.
  • Fallback ladder: full model, cheaper model, cached or popular default, rule; alert when below the top rung. Humans handle the uncertain middle band, limited by reviewer capacity.
  • ML technical debt (Sculley et al. abstract): boundary erosion, entanglement, hidden feedback loops, undeclared consumers, data dependencies, configuration issues, changes in the external world, system-level anti-patterns. Every part needs an owner, a test and a monitor.

Training at scale (lesson 2)

Memory per parameter (mixed-precision Adam). Weights and gradients in fp16 are 2 bytes each, and the optimizer states are an fp32 copy of the weights plus two fp32 moments, K=12K=12 bytes: (2+2+K)Ψ=16Ψ(2+2+K)\Psi=16\Psi bytes. A 1.5 billion parameter model needs 24 GB of state, 7 billion needs 112 GB (14 weights, 14 gradients, 84 optimizer) and 70 billion needs 1,120 GB. Pure fp32 with Adam is also 16 (4 + 4 + 8).

  • Optimizer states are three quarters of it. Activations come on top and grow with batch size and sequence length, not with the parameter count. In the ZeRO paper’s GPT-2 example (1.5 billion parameters) the activations were about 60 GB at sequence length 1,000 and batch 32 without checkpointing.
  • Fit is a yes-or-no question about the sum: state plus activations plus overhead against device memory. A model can fit its state and still run out of memory at a larger batch.
  • Plain data parallelism does not reduce memory per device; the ZeRO paper starts from the limit of about 1.4 billion parameters on 32 GB GPUs.

ZeRO and FSDP. Bytes per parameter by stage over NdN_d devices: stage 1 shards optimizer states, 4+12/Nd4+12/N_d; stage 2 adds gradients, 2+14/Nd2+14/N_d; stage 3 adds parameters, 16/Nd16/N_d. The paper’s stated effects are 4 times and 8 times less memory for stages 1 and 2 with the same communication as data parallelism (limits for large NdN_d), and memory falling linearly with NdN_d for stage 3 at about 50% more communication. Paper example, 7.5 billion parameters on 64 devices: 120, 31.4, 16.6 and 1.9 GB for stages 0 to 3.

  • FSDP FULL_SHARD is the stage 3 analogue (all-gather before forward and backward, reduce-scatter gradients); SHARD_GRAD_OP is stage 2; NO_SHARD is DDP; HYBRID_SHARD shards inside a node and replicates across nodes.
  • PyTorch 2.15 also has FSDP2, fully_shard, with per-parameter DTensor sharding along dimension 0; its documentation suggests FSDP1 users consider migrating, and reshard_after_forward=True gives the FULL_SHARD behaviour. Rule of thumb: DDP while state plus activations fit, sharding when they do not, at the price of communication and harder checkpoints.

Batch size and learning rate. Linear scaling rule: multiply the batch by kk, multiply the rate by kk, keep the rest, and warm up gradually (5 epochs in the ImageNet runs). Goyal et al. saw stable error from batch 64 to 8,192 and a rise after, with divergence beyond 64k; that is one task and one model family. Illustration: 0.1 at batch 256 and a batch of 8,192 give k=32k=32 and a target of 3.2, reached after 5,000 warmup steps. Above the critical batch size (Kaplan et al.) more data per step buys little. Adam is often tuned differently, so re-tune at a new batch size.

Gradient accumulation. Add the micro-batch gradients and step once. For mean losses g=∑j(nj/N) gjg=\sum_j (n_j/N)\,g_j: weight each micro-batch mean by its sample count and divide by the total once.

  • Mistakes: forgetting to divide (the sum is too large by the number of chunks), weighting a short last chunk equally, and layers that look across the batch. Batch norm still takes its statistics from the micro-batch; layer norm and RMS norm work per sample and are unaffected.
  • Token-level losses: sum the token losses in each micro-batch and divide by the number of non-padding tokens of the whole effective batch. The mean of per-micro-batch mean losses is a different number (Hugging Face found this mismatch in its Trainer).
  • With DDP, no_sync() skips the all-reduce on the non-final micro-batches. The effective batch is micro-batch times accumulation steps times processes, and the optimizer steps once per effective batch.

Mixed precision. fp32 master weights keep small updates: in fp16, 1.0+0.00011.0+0.0001 rounds back to 1.0, so 100 such updates leave a weight at 1.0 where an fp32 running sum reaches 1.0100. Loss scaling lifts small gradients out of the flush-to-zero range: a gradient of 10−810^{-8} is 0 at scale 1 and comes back at scale 1,024; the fp16 maximum is 65,504, so too large a scale overflows to infinity. Unscale before the optimizer step and before clip_grad_norm_, keep the scale constant while accumulating, and use a dynamic scale (GradScaler defaults: start 65,536, growth 2, back-off 0.5, growth interval 2,000 steps). bf16 keeps fp32’s 8 exponent bits and has a 7-bit fraction: fp32 range, less precision, so many teams skip loss scaling; master weights and fp32 accumulation still matter. A model pre-trained in bf16 may overflow in fp16.

Communication and parallelism.

  • DDP: every device holds the full model, gradients are averaged by a bucketed all-reduce overlapped with the backward pass, and every process must reduce the buckets in the same order.
  • Ring all-reduce time is about 2(n−1)nSB\tfrac{2(n-1)}{n}\tfrac{S}{B}, close to 2S/B2S/B whatever nn is; a central collect-and-send design costs 2(n−1)S/B2(n-1)S/B. For 14 GB at an assumed 50 GB/s the ring takes 0.28 s on 2 devices, 0.490 on 8 and 0.559 on 1,024, against 0.56, 3.92 and 572.88 for the central design. A step that computes in 0.3 s and waits 0.56 s is communication-bound.
  • Tensor parallelism splits matrices inside each layer and talks inside every layer, so it belongs on the fast links inside a server (Megatron-LM trained transformers up to 8.3 billion parameters on 512 GPUs). Pipeline parallelism puts groups of layers on different devices and passes activations between them. Narayanan et al. report that a poor combination of tensor and pipeline parallelism cost up to 2 times in throughput, even with fast links between servers.
  • Pipeline bubble with pp stages and mm microbatches: (p−1)/(m+p−1)(p-1)/(m+p-1) of the step is idle. For 4 stages with 1, 4, 16 and 64 microbatches: 0.75, 0.429, 0.158, 0.045. For 8 stages: 0.875, 0.636, 0.304, 0.099. To stay at or below 10%, 2 stages need 9 microbatches, 4 need 27, 8 need 63, 16 need 135. More stages need a bigger batch, which the critical batch size limits. Narayanan et al. give (p−1)/m(p-1)/m relative to ideal compute (a different base), and as much as 50% of the time can go to flushing the pipeline.

Efficiency and reliability.

  • Activation checkpointing keeps kk boundaries and recomputes the rest: peak k+⌈n/k⌉k+\lceil n/k\rceil units, best near n\sqrt n (100 layers: 100 units down to 20 with k=10k=10). The cost is one extra forward pass, about a third more compute if backward is twice forward. Chen et al. cut a 1,000-layer residual network from 48 GB to 7 GB for about 30% more time. PyTorch saves and restores the random state for dropout by default.
  • Data loading: step time is max⁡(C, L/W)\max(C,\,L/W) for compute time CC, load time LL per batch and WW workers. With C=0.25C=0.25 s and L=0.9L=0.9 s, 1 to 4 workers give 0.9, 0.45, 0.3 and 0.25 s, with the accelerator busy 28%, 56%, 83% and 100%. Symptoms of a loader bottleneck: low utilisation, step time that falls as workers are added, step time independent of the model. Profile first.
  • Checkpoints hold weights, optimizer states, schedule position and step count, data-loader position and random states. Interval I∗=2wMI^\ast=\sqrt{2wM} for write time ww and mean time between failures MM: 3 and 360 minutes give 46.5 minutes and 12.9% of time lost, against 60.7% at every 5 minutes and 34.6% at every 240; the curve is flat near its minimum (13.3% at 60 minutes). Distributed Checkpoint writes one file per rank at least and reshards at load time.
  • Reproducibility: PyTorch does not guarantee identical results across releases, commits, platforms or between CPU and GPU, even with the same seed. Deterministic algorithms can be slower. Aim for repeatable experiments (config, code version, seed and data order logged) and compare several seeds.

Compute and scaling.

  • Training takes about C≈6NDC\approx6ND FLOPs: 2N for the forward pass per token, about 4N for the backward. It ignores the attention term and counts non-embedding parameters. days=C/(G P u⋅86,400)\text{days}=C/(G\,P\,u\cdot86{,}400) for GG devices of peak PP at utilisation uu. A 7 billion parameter model on 101210^{12} tokens is 4.2×10224.2\times10^{22} FLOPs; at an assumed 300 TFLOP/s and 40% that is 3.96 days on 1,024 devices and 15.82 days on 256. State the assumptions; real utilisation comes from measurement. Inference costs about 2N2N per token, 1.4×10101.4\times10^{10} for 7 billion.
  • Kaplan et al.: loss follows a power law in model size, data and compute. Hoffmann et al. (over 400 models): scale model size and tokens in equal proportion. Chinchilla (70B on 1.4 trillion tokens) used the compute of Gopher (280B on 300 billion tokens) and reached 67.5% on MMLU, more than 7 points above Gopher.
  • 20 tokens per parameter is Chinchilla’s ratio (1.4×1012/70×1091.4\times10^{12}/70\times10^9; Gopher about 1.07), one result and not a law: the paper fits the frontier three ways. A model that will serve many requests may be better trained smaller and longer.
  • Check 6ND6ND against the paper: Chinchilla gives 5.88×10235.88\times10^{23} and Gopher 5.04×10235.04\times10^{23}, but Hoffmann et al. give 5.76e23 FLOPs for Gopher’s budget, so the rule is 12.5% low for Gopher and 2.1% high for Chinchilla. For models up to 6.8B parameters their own counts against 6ND6ND give ratios of 0.99 to 1.10. Fine for planning, not for billing.

The interview playbook (lesson 3)

Rounds (a common industry pattern; ask the recruiter what each covers): ML fundamentals (the ladder), ML coding (clarify, simple version, edge cases, then speed), ML system design (the nine steps), applied or case (the ten-step method), project deep dive (STAR with measured numbers), behavioural (STAR with an owner and a lesson). Real loops mix them. Huyen (2019) is one author’s experience, and two statements in this sheet rest on it: interviewers often care more about how you answer than about objective correctness, and almost all the companies she talked to ask at least one open-ended systems design question. Nothing here is a company-specific claim.

The ten steps: 1 clarify, 2 assume, 3 baseline, 4 metric, 5 data, 6 model, 7 evaluation, 8 failure modes, 9 trade-offs, 10 monitoring. Frame (steps 1 to 4) takes the first three or four minutes by this course’s suggestion; the model is step 6. Say the step names aloud, and if time runs low say which you are compressing. When stuck: restate, take the smallest case, name a baseline, ask a question, and admit a forgotten formula rather than invent one.

The ladder for a concept: intuition (one sentence a non-specialist could repeat), maths (the one formula that carries it), code (how to check it), pitfall (when it fails). The pitfall rung shows experience.

Debug in an order (Karpathy: training fails silently, so make failures loud):

SymptomFirst step
Loss NaNFind the first non-finite step; check inputs and labels, then the learning rate
Loss flat from step 1Overfit a tiny batch (a few examples, possibly two); check that a CC-class softmax starts near ln⁡C\ln C
Score too goodAudit the split and features with three checks (below)
Offline up, A/B flatCheck the experiment (assignment, sample ratio, power), then logged serving features against training features
Train low, validation highLearning curve: variance, so more data or regularisation
Train error itself highBias: bigger model, better features, longer training
  • Rules of ML rule 37 splits skew into training against holdout, holdout against next-day data, and next-day against live data; the same example should give the same result in training and serving. Rule 29: save and log the serving-time features.
  • Leak checks, and what each can miss: shuffle the labels and rerun the whole pipeline (catches preprocessing that uses labels, such as target encoding or selection fitted on all rows; misses a feature that copies the outcome, which falls to chance after the shuffle); count ids shared between the splits (group leaks); look at the top feature (proxies written after the outcome). Simulated AUCs: honest feature on shuffled labels 0.503; proxy 1.000, then 0.469 shuffled; target-encoded noise 0.758, then 0.784 shuffled, and 0.443 out of fold. A random row split put 0.950 of validation rows’ patients in training; a split by patient gave 0.000.
  • Scikit-learn splitters: KFold does not shuffle by default and the first n % k folds are one row larger; TimeSeriesSplit exists because other methods would train on the future and evaluate on the past.

Sanity checks.

  • Base rate: PPV=πs/(πs+(1−π)f)\mathrm{PPV}=\pi s/(\pi s+(1-\pi)f). Natural frequencies for 10,000 people, 1% sick, 99% sensitivity and a 5% false-positive rate: 99 sick and 495 healthy test positive, so 99 of 594, or 16.7%, are sick.
  • Majority baseline: 100 frauds in 10,000 give 0.99 for always predicting legitimate, so a model at 0.992 is 0.002 above doing nothing; its precision and recall of 0.60 each tell the story.
  • Parameters and FLOPs: a dense layer has ninnout+noutn_{in}n_{out}+n_{out} parameters and a forward pass costs about 2Bninnout2Bn_{in}n_{out} for a batch of BB. Widths 784, 256, 128, 10 give 235,146 parameters (0.94 MB at 4 bytes) and 469,504 operations per example; at an assumed sustained 10 GFLOP/s a batch of 64 takes about 3.0 ms. Give a range and the assumption, not a false decimal.

Uncertainty. Wilson interval for a proportion (statsmodels lists it beside the normal approximation). 182 of 200 gives 0.862 to 0.942 and 176 of 200 gives 0.828 to 0.918; they overlap, and a two-proportion z test treating the scores as independent gives 0.98, below 1.96. With 2,000 items each the intervals are 0.897 to 0.922 and 0.865 to 0.894 (z = 3.09), and z first passes 1.96 at 803 items per model. Both models are scored on the same items, so use a paired test on the disagreements. An interval covers sampling noise only, not leakage or a test set unlike production.

Projects. STAR is Situation, Task, Action, Result; one university career centre suggests about 20%, 10%, 60% and 10% of the time and quantified results. For ML add the baseline, the evaluation design and what you would change. Never present a number you did not measure, and say when a figure came from a tutorial’s dataset. Admitting a flaw you found is a strength; a flaw you defended and the interviewer finds is not.

Practice. Daily 90-second drills answered aloud, a weekly full mock (a suggested 45-minute split, not a rule: 5 minutes for the introduction and a project, 12 for fundamentals, 25 for design or coding, 3 for your questions), and a one-line rule for each miss, re-answered cold a few days later. Do not memorise answers word for word.

Provenance. Every practice question carries a label: Common industry pattern, or Generated practice. None of the lesson’s questions is Verified company-specific, because none is tied to a named company with a source.

Choosing a remedy

SymptomFirst checkLikely fix
Design answer reads as a list of componentsDid you frame, baseline and name a metric first?Run the nine steps; say trade-offs and failure modes aloud
Latency requirement is about a share of requestsPercentiles over a large pooled window, fan-out widthParallelise calls, timeouts with fallbacks, watch the fallback rate
Final ranking quality plateausRetriever recall at the candidate countImprove retrieval or pass more candidates, and pay in ranker latency
Serving too slow or costlyCache hit rate, batch size, precisionLevers cheapest first, then re-run offline evaluation
Offline win, no online winExperiment, then served against training featuresOne feature definition, logged serving features
Same few items dominate more each weekIs training data chosen by the previous model?Exploration or random holdout slice, logged propensities
Out of memoryIs it state or activations?Shard state (ZeRO, FSDP); checkpoint activations or shrink the micro-batch
Accelerator idleUtilisation, loader workers, communication timeMore workers, overlap communication, fewer bytes
Loss NaN in fp16First non-finite step, loss scaleDynamic scaling, lower rate, warmup, clipping on unscaled gradients
Accumulated loss differs from the big-batch lossShort chunks, padding, batch normWeight by size; divide by total non-padding tokens
Long run keeps losing workWrite time and failure rateInterval near 2wM\sqrt{2wM}; test a resume before the run
Validation score far above baselinesShuffled labels, shared ids, top featureGroup or time split, preprocessing inside the training fold
Two models differ by a few pointsTest size, interval, shared itemsPaired comparison or more test data

Quick answers

  • How much memory does Adam training need? 16 bytes per parameter in mixed precision, before activations.
  • DDP or FSDP? DDP while the state and activations fit; FSDP or ZeRO sharding when they do not, paying communication.
  • Why does fp16 need master weights and loss scaling? Small updates vanish in 16 bits, and small gradients flush to zero.
  • Is 6ND exact? No. It ignores attention and embeddings, and against the paper’s Gopher figure it is 12.5% low; use it for planning.
  • Is 20 tokens per parameter a law? No, it is Chinchilla’s ratio under one setup, and serving cost can favour smaller and longer.
  • Why not budget the mean latency? The tail decides the experience, and fan-out multiplies it.
  • When do you not use ML? When simple rules do well enough or there is no label or feedback signal yet. Ship the rule baseline and collect labels while it runs.
  • How do you answer an open question? The ten steps, said aloud, with the frame (steps 1 to 4) before any model.
  • What does the shuffled-label check not catch? A feature that is itself a copy of the outcome.

Traps

naming a transformer in the first minute · a metric without a baseline · “average latency is the number to budget” · averaging per-server p99s · dismissing the fan-out gap as noise · “a better ranker fixes poor candidates” · skipping the offline evaluation of a quantised model · dividing accumulated gradients by the wrong count · averaging per-micro-batch token losses · treating accumulation as exactly a bigger batch for batch norm · loss scaling that changes the learning rate · “more GPUs always make training faster” · quoting 6ND as a bill · treating 20 tokens per parameter as a law · bit-identical reproducibility promises · treating the shuffled-label check as a full leak test · false precision from 200 test items · a project story that hides what failed · memorising answers word for word · claiming a company asks something without a source.