{"record":{"id":"c02f2f79885c5863","repo":"huggingface/pytorch-image-models","slug":"invalid-algo-algo-must-be-muon-or-adamuon","errorCode":null,"errorMessage":"Invalid algo: {algo}. Must be 'muon' or 'adamuon'","messagePattern":"Invalid algo: (.+?)\\. Must be 'muon' or 'adamuon'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/optim/muon.py","lineNumber":735,"sourceCode":"\n            # Use AdaMuon algorithm for adaptive scaling\n            optimizer = Muon(model.parameters(), lr=6e-4, algo=\"adamuon\")\n\n            # Manual control over parameter groups\n            optimizer = Muon([\n                {'params': weight_matrices, 'lr': 0.02},\n                {'params': biases, 'use_fallback': True, 'lr': 3e-4}, # use AdamW if use_fallback=True\n            ])\n            ```\n        \"\"\"\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,","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/optim/muon.py#L717-L753","documentation":"The Muon optimizer's algo parameter selects the core update: \"muon\" (pure Newton–Schulz orthogonalization) or \"adamuon\" (Adam-style update combined with orthogonalization). Other values are rejected in __init__.","triggerScenarios":"Muon(params, algo='adam') or any string besides 'muon'/'adamuon'.","commonSituations":"Assuming the optimizer supports a plain 'adam' mode; typos; configs from forks of the Muon codebase with different algo names.","solutions":["Use algo=\"muon\" (default) or algo=\"adamuon\" as needed","If you wanted plain AdamW behavior for some params, rely on the built-in fallback branch (or use timm's AdamW) instead of an invalid algo string"],"exampleFix":"# before\nopt = Muon(model.parameters(), algo=\"adam\")\n# after\nopt = Muon(model.parameters(), algo=\"adamuon\")","handlingStrategy":"validation","validationCode":"assert cfg.algo in (\"muon\", \"adamuon\"), 'invalid Muon algo'","typeGuard":"def is_valid_algo(a: str) -> bool:\n    return a in (\"muon\", \"adamuon\")","tryCatchPattern":null,"preventionTips":["Use Literal types for optimizer config fields","Rely on the fallback mechanism for AdamW-style updates instead of invalid algo strings"],"tags":["optimizer","muon","algo","enum-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}