{"record":{"id":"f49f71156112aa35","repo":"huggingface/pytorch-image-models","slug":"adamw-lr-is-not-supported-with-tensor-lr-use-fall","errorCode":null,"errorMessage":"adamw_lr is not supported with tensor lr; use fallback_lr_scale instead.","messagePattern":"adamw_lr is not supported with tensor lr; use fallback_lr_scale instead\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/optim/muon.py","lineNumber":745,"sourceCode":"        \"\"\"\n        _validate_scalar(\"learning rate\", lr)\n        _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,","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/optim/muon.py#L727-L763","documentation":"The deprecated adamw_lr argument cannot be combined with a tensor-valued lr, because the constructor would need to compute fallback_lr_scale = adamw_lr / lr via tensor division, which is unsupported; the code raises instead and tells you to use fallback_lr_scale.","triggerScenarios":"Passing adamw_lr (deprecated) together with lr as a torch.Tensor (e.g. a schedule-free style tensor LR) to the Muon constructor.","commonSituations":"Migrating older timm Muon scripts that used adamw_lr while adopting tensor-LR training (schedule-free or per-step LR-as-tensor patterns).","solutions":["Replace adamw_lr with fallback_lr_scale=adamw_lr/lr computed as a float before constructing the optimizer","Pass a scalar lr if you must keep adamw_lr (it will still emit a FutureWarning)","Upgrade to the non-deprecated API to silence the warning path entirely"],"exampleFix":"# before\nopt = Muon(params, lr=lr_tensor, adamw_lr=1e-4)\n# after\nopt = Muon(params, lr=lr_tensor, fallback_lr_scale=1e-4 / base_lr)","handlingStrategy":"validation","validationCode":"if cfg.get('adamw_lr') is not None:\n    assert not torch.is_tensor(cfg['lr']), 'use fallback_lr_scale with tensor lr'","typeGuard":"def lr_is_tensor(x) -> bool:\n    return torch.is_tensor(x)","tryCatchPattern":null,"preventionTips":["Migrate off deprecated adamw_lr to fallback_lr_scale","Compute fallback_lr_scale as a float before construction"],"tags":["optimizer","muon","deprecation","tensor-lr"],"backgroundTag":"deprecated-argument-misuse","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}