OpenAI·Machine Learning Engineer·Technical Phone Screen
- Derive the gradient of the loss with respect to each weight matrix W_j in a block that computes Z = W_1 * W_2 * ... * W_n * X, where there is no nonlinearity inside the block. Show why the formula takes the form it does, not just what the formula is.
- Verify that the gradient you derived for W_j actually has the same shape as W_j itself, and show how the batch dimension gets contracted away.
- Describe an efficient implementation of the backward pass that computes all n gradients in O(n) matrix products instead of O(n^2). How do you avoid recomputing overlapping prefix and suffix products?
- How does the backward pass change if you also need the gradient with respect to the input X?
- If two of the matrices in the chain are tied (the same parameter appears at two positions j and k), how does the gradient for that shared parameter change?
- With a large number of matrices in the chain, what numerical issues arise from repeated matrix products and how would you address them?
“This was the core question and it took up most of the session.”