{"record":{"id":"8cec042b9232ae4f","repo":"huggingface/pytorch-image-models","slug":"cannot-compute-fallback-lr-scale-from-adamw-lr-whe","errorCode":null,"errorMessage":"Cannot compute fallback_lr_scale from adamw_lr when lr=0","messagePattern":"Cannot compute fallback_lr_scale from adamw_lr when lr=0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/optim/muon.py","lineNumber":747,"sourceCode":"        _validate_scalar(\"weight_decay\", weight_decay)\n        _validate_scalar(\"momentum\", momentum, max_value=1.0)\n        _validate_scalar(\"epsilon\", eps)\n        if conv_mode not in [\"flatten\", \"batched\"]:\n            raise ValueError(f\"Invalid conv_mode: {conv_mode}\")\n        if algo not in [\"muon\", \"adamuon\"]:\n            raise ValueError(f\"Invalid algo: {algo}. Must be 'muon' or 'adamuon'\")\n\n        if adamw_lr is not None:\n            warnings.warn(\n                \"adamw_lr is deprecated, use fallback_lr_scale=adamw_lr/lr instead. \"\n                \"adamw_lr will be removed in a future release.\",\n                FutureWarning,\n                stacklevel=2,\n            )\n            if torch.is_tensor(lr):\n                raise ValueError(\"adamw_lr is not supported with tensor lr; use fallback_lr_scale instead.\")\n            if lr == 0:\n                raise ValueError(\"Cannot compute fallback_lr_scale from adamw_lr when lr=0\")\n            fallback_lr_scale = adamw_lr / lr\n\n        defaults = dict(\n            lr=lr,\n            weight_decay=weight_decay,\n            momentum=momentum,\n            nesterov=nesterov,\n            ns_steps=ns_steps,\n            ns_coefficients=ns_coefficients,\n            eps=eps,\n            safety_factor=safety_factor,\n            adjust_lr_fn=adjust_lr_fn,\n            conv_mode=conv_mode,\n            normalize_spatial=normalize_spatial,\n            fallback_lr_scale=fallback_lr_scale,\n            betas=betas,\n            algo=algo,\n            scale_eps=scale_eps,","sourceCodeStart":729,"sourceCodeEnd":765,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/optim/muon.py#L729-L765","documentation":"When the deprecated adamw_lr is supplied, Muon derives fallback_lr_scale = adamw_lr / lr; with lr == 0 this division is undefined, so the constructor rejects the combination.","triggerScenarios":"Passing adamw_lr together with lr=0 to the Muon constructor.","commonSituations":"Configs where lr is zeroed out (freeze phase, warmup start) while adamw_lr is still set from an earlier configuration.","solutions":["Set fallback_lr_scale explicitly instead of adamw_lr","Use a nonzero lr (e.g. 1e-6) if a zero LR phase is needed, and manage warmup via a scheduler","Remove adamw_lr entirely if fallback scaling is not needed"],"exampleFix":"# before\nopt = Muon(params, lr=0, adamw_lr=1e-4)\n# after\nopt = Muon(params, lr=1e-3, fallback_lr_scale=0.1)  # scale managed via scheduler","handlingStrategy":"validation","validationCode":"if cfg.get('adamw_lr') is not None:\n    assert cfg['lr'] != 0 and not torch.is_tensor(cfg['lr'])","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set fallback_lr_scale directly instead of relying on adamw_lr/lr derivation","Avoid zero lr at construction; drive warmup with a scheduler"],"tags":["optimizer","muon","deprecation","division-by-zero"],"backgroundTag":"deprecated-argument-misuse","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}