Skip to content

Make scale_by_muon work on a params tree without weight_dimension_numbers - #1901

Open
vineethsaivs wants to merge 1 commit into
google-deepmind:mainfrom
vineethsaivs:fix/scale-by-muon-default-dim-nums
Open

vineethsaivs wants to merge 1 commit into
google-deepmind:mainfrom
vineethsaivs:fix/scale-by-muon-default-dim-nums

Conversation

@vineethsaivs

Copy link
Copy Markdown

contrib.scale_by_muon() with its default weight_dimension_numbers=None crashes on any params tree (a dict, say), so the documented default is unusable.

The update tree-maps the orthogonalization over (mu_hat, resolved_weight_dim_nums). With None, that second argument is a bare None, which does not match the params tree, and jax raises ValueError: pytree structure error: different types at key path. muon() hides this because it always builds its own dim nums.

When weight_dimension_numbers is None, the update now uses a tree of per-leaf Nones, so every leaf is orthogonalized as a matrix. A non-matrix leaf now gets the intended "must have shape (m, n) or dim nums" error instead of the pytree one.

On {'w': (4, 3), 'v': (3, 2)}, scale_by_muon().update(...) raised on main and now returns the same updates as an explicit MuonDimensionNumbers(0, 1) tree. The new test_scale_by_muon_defaults_to_matrices_for_a_params_tree fails on main and passes here; _muon_test.py (33 passed) and _common_test.py (512 passed, 4 skipped) pass.

…bers

With the default weight_dimension_numbers=None, the update tree-mapped a bare None against the params tree and failed with a pytree structure error. None now means every leaf is orthogonalized as a matrix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant