Muon optimizer - #2639
Conversation
adapted lr logging such that it logs lr for each of the optimizer used
…rameters for Muon
|
@ankitpatnala : could you outline the hyperparams that are involved. How should the lr change between muon and AdamW? |
|
The optimizer:
# which optimizer to use: "adamw" or "muon"
# muon only optimizes 2D weight matrices of hidden layers; all other
# parameters (biases, norms, ...) are still optimized with adamw
name: muon
grad_clip: 1.0
weight_decay: 0.1
log_grad_norms: False
adamw :
# parameters are scaled by number of DDP workers
beta1 : 0.98125 # == 0.85 on 2 nodes x 4 gpus
beta2 : 0.9875 # == 0.90 on 2 nodes x 4 gpus
eps : 2e-08
muon:
# peak lr override for muon; null shares adamw's lr schedule (relies on
# adjust_lr_fn=match_rms_adamw's per-matrix scaling instead of a fixed multiplier)
lr_max: null
momentum: 0.95
nesterov: True
ns_steps: 5
eps: 1e-7
# "original" | "match_rms_adamw"
adjust_lr_fn: match_rms_adamwWhen it is set to grad_clip: 1.0
weight_decay: 0.1
log_grad_norms: FalseThe optimizer then explicitly checks whether each parameter is 2D (optimizer.py#L97):
adamw:
# parameters are scaled by number of DDP workers
beta1: 0.98125 # == 0.85 on 2 nodes x 4 gpus
beta2: 0.9875 # == 0.90 on 2 nodes x 4 gpus
eps: 2e-08
muon:
# peak lr override for muon; null shares adamw's lr schedule (relies on
# adjust_lr_fn=match_rms_adamw's per-matrix scaling instead of a fixed multiplier)
lr_max: null
momentum: 0.95
nesterov: True
ns_steps: 5
eps: 1e-7
# "original" | "match_rms_adamw"
adjust_lr_fn: match_rms_adamwIf learning_rate_scheduling:
lr_start: 1e-6
lr_max: 5e-5
lr_final_decay: 2e-6
lr_final: 0.0
num_steps_warmup: 256
num_steps_cooldown: 512
policy_warmup: "cosine"
policy_decay: "constant"
policy_cooldown: "linear"
parallel_scaling_policy: "sqrt"All other Muon parameters take their defaults from I tested roughly |
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def _adamw_betas_eps(optimizer_cfg, kappa: float) -> dict: |
There was a problem hiding this comment.
Only tangentially related to this PR, but do we want to remove this scaling of beta parameters with batch size because I think it makes setting those variables so much more complicated
There was a problem hiding this comment.
Should we then hardcode it for the 2-node, 4-GPU setup?
There was a problem hiding this comment.
We would need at least some evidence that it's neutral and doesn't affect skill.
|
Hey Ankit,
Adam: The optimizer step is nearly negligible, so not showing it here. Note: these are only qualitative, not quantitative results. For the latter, we could compare the peak memory consumption and throughput for a longer run. |
Thanks! Could we also try with the config with the GEOs that is more demanding in terms of memory to make sure we don't break configs that are currently working. |






Description
Implemented Muon optimizer
config/config_forecasting.ymlIssue Number
Closes #2638