ML Debugging (Transformer)

Asked at OpenAI · Deep Learning & Architectures · Difficulty: Hard · Last asked Mar 20, 2026

A small GPT-style transformer in PyTorch is meant to learn next-character prediction on a handful of short strings, with causal self-attention and key/value-cache decoding. Four bugs were injected, and each one is marked in the code with a `BUG` label. Find them, explain the damage each one does, and fix them. Then adapt the model to a different task.

Loading the problem…