DeepSpeed
1663b5b5 - Normalize Gram Newton-Schulz inputs before casting to fp16 (#8533)

Commit
73 days ago
Normalize Gram Newton-Schulz inputs before casting to fp16 (#8533) `zeropower_via_gram_newtonschulz` cast to the compute dtype before normalizing. fp16 stops at 65504, so a finite fp32 gradient under a loss scale arrived at the iteration as inf, normalized to nan and left the whole matrix zero. A loss scale of 1e4 on gradients of order 1 already reaches that. Normalize first, then cast: fp16 inputs normalize in fp32 and come back to fp16, bf16 and fp32 normalize as they are. The iteration itself is unchanged and still runs in the compute dtype on a matrix already in [-1, 1]. Test: `DS_ACCELERATOR=cpu python -m pytest tests/unit/v1/ops/muon/test_muon_gram_normalization.py -q`. 12 of 13 fail before, 13 pass after, covering three shapes at scales 1e4 to 1e15 plus two real Muon training steps. The wider muon suite is 113 passed, 29 skipped. yapf and flake8 clean. Apple M2 Pro CPU, fp16 arithmetic selected explicitly. Signed-off-by: Vineeth Sai <vineethsai4444@gmail.com>
Author
Parents
Loading