Debug and fix practice problems
16 problems · 0 solved
Every problem here starts with code that runs but is wrong. The statement says what the function should do, the starter has one realistic bug, and the tests catch it. These are the bugs that show up in real training loops, eval scripts and agents: a softmax that overflows, LayerNorm over the wrong axis, a causal mask that hides the diagonal, Adam without bias correction, a learning rate stuck at zero from integer division, a scaler fit on test data, a KV cache that grows the wrong axis and a chat history shared between users. Read the spec first, run the tests, then find the line that breaks it. Debugging is most of the job, and interviews increasingly hand you broken code instead of a blank file.
Easy 9
- Fix the softmax that returns nan
- Fix the LayerNorm that normalises the wrong axis
- Fix the cross-entropy that returns inf
- Fix the F1 score that crashes on empty predictions
- Fix the agent memory shared between conversations
- Fix the warmup schedule stuck at zero
- Fix top-k retrieval that returns the worst matches
- Fix accuracy computed with the wrong argmax axis
- Fix inverted dropout with the wrong scalePro