Implement a mixed-precision loop (bf16 compute, fp32 master weights) with loss scaling on

Optimization & Training Dynamics5 / 5

Chapter 075 / 5

Optimization & Training Dynamics

Implement a mixed-precision loop (bf16 compute, fp32 master weights) with loss scaling on

Super-hard

Implement a mixed-precision loop (bf16 compute, fp32 master weights) with loss scaling on a toy MLP, including a deliberate overflow and recovery.

Target interface
forward_backward(master, x, y, loss_scale)

Implement the function/class skeleton in the editor. Any correct approach is accepted.

Hints0 / 2
Reference solution
Your own code stays in the editor.