{"record":{"id":"aadf28dc6d853ef9","repo":"huggingface/pytorch-image-models","slug":"unknown-coefficients-preset-value-valid-optio","errorCode":null,"errorMessage":"Unknown coefficients preset '{value}'. Valid options: {valid}","messagePattern":"Unknown coefficients preset '(.+?)'\\. Valid options: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"timm/optim/muon.py","lineNumber":1032,"sourceCode":"\ndef resolve_ns_coefficients(\n        value: Union[str, Sequence[float], Sequence[Sequence[float]]],\n        presets: Mapping[str, Sequence[Sequence[float]]]\n) -> List[Tuple[float, float, float]]:\n    # tiny helpers (kept inline for succinctness)\n    is_seq = lambda x: isinstance(x, Sequence) and not isinstance(x, (str, bytes))\n    is_real = lambda x: isinstance(x, numbers.Real) and not isinstance(x, bool)\n\n    def as_coeff(x: Sequence[float]) -> Tuple[float, float, float]:\n        if not is_seq(x) or len(x) != 3 or not all(is_real(v) for v in x):\n            raise ValueError(f\"Coefficient must be length-3 of real numbers, got: {x!r}\")\n        a, b, c = x  # type: ignore[misc]\n        return float(a), float(b), float(c)\n\n    if isinstance(value, str):\n        if value not in presets:\n            valid = \", \".join(sorted(presets.keys()))\n            raise ValueError(f\"Unknown coefficients preset '{value}'. Valid options: {valid}\")\n        seq = presets[value]\n        if not is_seq(seq) or len(seq) == 0:\n            raise ValueError(f\"Preset '{value}' is empty or invalid\")\n        return [as_coeff(item) for item in seq]  # validate & cast\n\n    if not is_seq(value):\n        raise TypeError(\n            \"Coefficients must be a preset name (str), a 3-sequence (a,b,c), \"\n            \"or a sequence of 3-sequences.\"\n        )\n\n    # Decide single triple vs list-of-triples by structure\n    if len(value) == 3 and all(is_real(v) for v in value):  # type: ignore[index]\n        return [as_coeff(value)]  # single triple -> wrap\n\n    # Otherwise treat as list/tuple of triples\n    out = []\n    for i, item in enumerate(value):  # type: ignore[assignment]","sourceCodeStart":1014,"sourceCodeEnd":1050,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/optim/muon.py#L1014-L1050","documentation":"Muon ships named presets of Newton–Schulz coefficient schedules; requesting a preset name that is not in the registry raises this error, listing the valid options.","triggerScenarios":"Calling Muon(params, ns_coefficients='shampoo') or resolve_ns_coefficients('typical') — any string not among the built-in preset keys.","commonSituations":"Guessing preset names; presets renamed/removed between timm versions; configs copied from other Muon implementations.","solutions":["Use one of the preset names listed in the error message (the valid sorted keys)","Pass an explicit list of coefficient triples instead of a preset name","Check the installed timm version's muon.py for the current preset registry"],"exampleFix":"# before\nMuon(params, ns_coefficients=\"fast\")\n# after\nMuon(params, ns_coefficients=\"modular\")  # use a name from the error's valid list","handlingStrategy":"validation","validationCode":"from timm.optim.muon import resolve_ns_coefficients\ntry:\n    resolve_ns_coefficients(cfg.ns_coefficients)\nexcept ValueError as e:\n    raise SystemExit(f'bad ns_coefficients: {e}')","typeGuard":"def is_valid_preset(name: str, presets: dict) -> bool:\n    return name in presets","tryCatchPattern":"try:\n    opt = Muon(params, ns_coefficients=cfg.preset)\nexcept ValueError as e:\n    if 'preset' in str(e):\n        print(e)  # lists valid options; fall back to default\n        opt = Muon(params)\n    else:\n        raise","preventionTips":["Dry-run resolve_ns_coefficients on config load to surface valid preset names","Pin timm version to keep the preset registry stable"],"tags":["optimizer","muon","newton-schulz","preset","enum-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}