Back to problems

Debug and fix a PyTorch Transformer training loop

Algorithm · OpenAI · Hard

A small PyTorch decoder-only language model is provided below. Although the training script appears to execute, the printed loss remains nearly constant across steps and occasionally becomes NaN. Examine the implementation and correct every issue in the architecture, attention computation, masking, numerical configuration, and optimization loop. Then complete the deliverables that follow. Faulty implementation: Deliverables: (A) Identify at least 12 distinct defects across…

Checking your access…