Skip to content

Apply floored weight decay per stacked same-shape run in Muon - #1290

Open
zsqdx wants to merge 1 commit into
lightvector:masterfrom
zsqdx:train-muon-stacked-wd
Open

zsqdx wants to merge 1 commit into
lightvector:masterfrom
zsqdx:train-muon-stacked-wd

Conversation

@zsqdx

@zsqdx zsqdx commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

When set_weight_decay_floor_norms is active, _apply_updates_with_weight_decay runs one vector_norm launch per floored parameter. Since parameters in batched Muon/Aurora chunks and in size-sorted groups already form contiguous runs of identical shapes, we can apply the exact same per-output-channel floored decay once per run.

  • Adds _decay_stacked_run_ in python/muon/muon.py, gated by KATAGO_MUON_STACKED_WD (default 1).
  • Covers both the single-device batched path (_step_muon_params_batched) and the distributed bf16-gather apply path (_apply_muon_updates), falling back cleanly to _apply_updates_with_weight_decay for singleton or unfloored runs.
  • Caches per-run floor tensors and clears the cache whenever set_weight_decay_floor_norms is called.
  • Adds CPU-only unit tests in python/tests/test_floored_weight_decay.py covering both orientations, 1x1 conv shapes, rows below floor, all-zero rows, and _apply_muon_updates.

Numerics & Measurements

Measured on RTX PRO 6000 Blackwell (b11c768h12nbt3tflrs-fson-silu, batch 160, FP16 AMP + Aurora + -wd-floor-frac 0.05):

  • Optimizer kernel launches: 1238 → 808 per step
  • Step time: -0.95% (leave-one-out)
  • Parity: bitwise identical to the per-parameter path in GPU unit checks across linear, transposed, and 1x1 conv shapes on both single-device and _apply_muon_updates (DDP speed itself not separately benchmarked).

(Note: ported cleanly onto current master and syntax-checked locally on macOS; the newly added CPU tests in test_floored_weight_decay.py mirror the GPU unit tests above and have not yet been re-run via pytest after porting.)

This branch has not been deployed

No deployments
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