{"record":{"id":"9819c7271b39755b","repo":"huggingface/pytorch-image-models","slug":"invalid-conv-mode-conv-mode","errorCode":null,"errorMessage":"Invalid conv_mode: {conv_mode}","messagePattern":"Invalid conv_mode: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/optim/muon.py","lineNumber":733,"sourceCode":"            # Simple usage - automatically uses Muon for 2D+ params, AdamW for 1D\n            optimizer = Muon(model.parameters(), lr=0.02)\n\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,","sourceCodeStart":715,"sourceCodeEnd":751,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/optim/muon.py#L715-L751","documentation":"The Muon optimizer validates conv_mode — the strategy for mapping >2-D convolution weights to 2D matrices — and only accepts \"flatten\" or \"batched\"; anything else is rejected at construction.","triggerScenarios":"Muon(params, conv_mode='reshape') or any string other than the two supported ones.","commonSituations":"Guessing mode names; stale configs from a different Muon implementation (Keller Jordan's original used different knobs); copy-paste between projects.","solutions":["Use conv_mode=\"flatten\" (spatial dims folded into input dim) or \"batched\" (spatial slices batched) — batched is generally recommended for large spatial dims","Remove the invalid key from your config"],"exampleFix":"# before\nopt = Muon(model.parameters(), conv_mode=\"reshape\")\n# after\nopt = Muon(model.parameters(), conv_mode=\"batched\")","handlingStrategy":"validation","validationCode":"assert cfg.conv_mode in (\"flatten\", \"batched\"), 'invalid Muon conv_mode'","typeGuard":"def is_valid_conv_mode(m: str) -> bool:\n    return m in (\"flatten\", \"batched\")","tryCatchPattern":null,"preventionTips":["Validate config strings against the allowed set before constructing the optimizer","Pin the timm version whose Muon API you coded against"],"tags":["optimizer","muon","conv-mode","enum-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}