Diff: origin/master...HEAD, staged and unstaged changes
Total: 15 lines
Missing: 7 lines
Coverage: 53%
Source File
Diff Coverage (%)
Missing Lines
hyper_parallel/core/optimizer/muon.py
53.3%
240,547-549,561-562,564
hyper_parallel/core/optimizer/muon.py
236237238239240241242243244
Both modes support distinct update and buffer coefficients. """advanced=_resolve_muon_advanced_options(advanced_options)ifmomentum_modenotin("legacy","vanilla"):raiseValueError(f"momentum_mode must be 'legacy' or 'vanilla', got {momentum_mode!r}")ifns_variantnotin("legacy","asym5","custom"):raiseValueError(
543544545546547548549550551552553
# m_for_update = (1 - momentum1) * grad + momentum1 * m_old# m_new = (1 - momentum2) * grad + momentum2 * m_old# Fold the Nesterov interpolation into one lerp with momentum1 squared.# pylint: disable=protected-accessupdate_momentum=momentum1**2ifgroup["nesterov"]elsemomentum1local_us=torch._foreach_lerp(grads,bufs,weight=update_momentum)torch._foreach_lerp_(bufs,grads,weight=1-momentum2)elifself._update_muon_momentum_mode=="legacy":# Match muon_update_core():# m_for_update = grad + momentum1 * m_old# m_new = grad + momentum2 * m_old
557558559560561562563564565566567
torch._foreach_mul_(bufs,momentum2)torch._foreach_add_(bufs,grads)ifgroup["nesterov"]:torch._foreach_mul_(local_us,momentum1)torch._foreach_add_(local_us,grads)else:raiseValueError("Muon._update_muon_momentum_mode must be 'vanilla' or 'legacy', "f"got {self._update_muon_momentum_mode!r}")