Code Reading — 400-line PyTorch Refactor

Asked at OpenAI · Coding Questions · Difficulty: Medium · Last asked Mar 9, 2026

A 400+ line PyTorch file is provided; complete 3 parts + 1 bonus. The round emphasizes **understanding existing code and extending it** (not from-scratch implementation, not bug-fixing). The codebase is the noisy-annotator classifier seen in other ML coding rounds, but the format is *code reading + refactoring*. Interviewers drill **time/space complexity of the existing code** — e.g. "what's the complexity of `A @ B`?" with follow-ups on attention / conv / batched matmul. The file is messy by design; you're judged on how quickly you orient and where you ask questions.

Loading the problem…