[optim][muon] fix momentum buffer aliasing in Newton-Schulz (#194664)
`_zeropower_via_newtonschulz` happens in-place. * before: `grad.bfloat16()` returns itself when already bfloat16, and then normalized it in place via `div_` * after: use `grad.to(dtype=torch.bfloat16, copy=True)` so the input is never aliased Pull Request resolved: https://github.com/pytorch/pytorch/pull/194664 Approved by: https://github.com/janeyx99
W
Wei Feng committed
4e1ffee606abbdf229dcaab6e58b6aeba5a011d8
Parent: 0c588e3
Committed by PyTorch MergeBot <pytorchmergebot@users.noreply.github.com>
on 8/25/2026, 8:39:54 PM