Repository navigation
feat(optim): heads_per_block for MLA up-projections (GLM-5 Muon Split) - #4119
Closed
faresobeid wants to merge 2 commits into
Closed
faresobeid wants to merge 2 commits into
faresobeid wants to merge 2 commits into
Conversation
…muona/muon-mla-split # Conflicts: # src/prime_rl/trainer/optim/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4114.
Extends
optim.heads_per_blockto MLA attention (GLM-5.x,glm_moe_dsa). The query up-projectionq_b_proj[H·qk_head_dim, q_lora] and the key/value up-projectionkv_b_proj[H·(qk_nope+v), kv_lora] are orthogonalized in blocks ofheads_per_blockheads. This is GLM-5's "Muon Split" for W_UQ/W_UK/W_UV (GLM-5 report, section 2).GlmMoeDsaForCausalLM.muon_head_partitionsreturns these blocks; with #4114 alone,glm_moe_dsaraises.q_a_proj,kv_a_proj_with_mqaando_projstay whole matrices. DefaultNoneis unchanged.Measurements
GLM-5, 4 layers, random init, 1 node of 8xH200,
offload = "none", optimizer step only, steady state, max over ranks:heads_per_blockmuon_orthogonalize_update). That costs about +11 ms per layer atheads_per_block = 1. Batching equal partitions in dion would remove this.rms_normpredicts: the squared parameter delta is 0.0153 after 4 steps in all three runs.Checks
ruff check,ruff format --check.tests/unit/test_configs.py -m "not gpu".Note
Medium Risk
Changes optimizer parameter partitioning for a specific model architecture; incorrect block boundaries would affect training dynamics but scope is limited to Muon +
heads_per_blockonglm_moe_dsa.Overview
Extends Muon
heads_per_blockto GLM MoE DSA sparse MLA (glm_moe_dsa), implementing GLM-5’s “Muon Split” on the query and key/value up-projections (q_b_proj,kv_b_proj) while leaving down-projections ando_projas single matrices.GlmMoeDsaAttention.muon_head_partitionsdefines per-head row blocks viahead_blocks;GlmMoeDsaForCausalLMaggregates them withattention_head_partitionsso the trainer can orthogonalize Muon updates on those weights (previously this path would fail for this model). Theheads_per_blockconfig docstring now documents MLA behavior; defaultNoneis unchanged.Reviewed by Cursor Bugbot for commit 41f92bf. Bugbot is set up for automated code reviews on this repo. Configure here.