{"record":{"id":"b4a9136062206bc9","repo":"huggingface/pytorch-image-models","slug":"item-i-is-not-a-sequence-item-r","errorCode":null,"errorMessage":"Item {i} is not a sequence: {item!r}","messagePattern":"Item (.+?) is not a sequence: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"timm/optim/muon.py","lineNumber":1052,"sourceCode":"        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]\n        if not is_seq(item):\n            raise TypeError(f\"Item {i} is not a sequence: {item!r}\")\n        out.append(as_coeff(item))\n    if not out:\n        raise ValueError(\"Coefficient list cannot be empty\")\n    return out\n","sourceCodeStart":1034,"sourceCodeEnd":1057,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/optim/muon.py#L1034-L1057","documentation":"Thrown by resolve_ns_coefficients in timm's Muon optimizer when the coefficients argument is treated as a list of triples but one of its elements is not itself a sequence. Each item must be indexable as a 3-sequence.","triggerScenarios":"Passing ns_coefficients=[0.9, 0.95, 0.5, 1.0] (four scalars, so not detected as a single triple) — the first item 0.9 is not a sequence, raising TypeError with i=0. Also triggered by lists mixing floats and tuples.","commonSituations":"Passing a flat list of numbers whose length is not 3 or whose items are all scalars; nesting mistakes when building per-layer coefficient lists.","solutions":["Wrap scalars into triples: [(0.9, 0.95, 0.5)] instead of [0.9, 0.95, 0.5]","If a single triple is intended, pass the tuple directly not inside a list","Check each item with isinstance(item, (list, tuple)) before constructing the argument"],"exampleFix":"# before\nMuon(params, ns_coefficients=[0.9, 0.95, 0.5])\n\n# after\nMuon(params, ns_coefficients=[(0.9, 0.95, 0.5)])","handlingStrategy":"type-guard","validationCode":"assert all(isinstance(item, (list, tuple)) and len(item) == 3 for item in ns_coefficients), 'each item must be a 3-tuple'","typeGuard":"def is_list_of_triples(v) -> bool:\n    return isinstance(v, (list, tuple)) and all(isinstance(i, (list, tuple)) for i in v)","tryCatchPattern":null,"preventionTips":["Wrap single triples in a list only when batching per-tensor coefficients","Unit-test coefficient construction helpers"],"tags":["timm","muon-optimizer","typeerror","nesting"],"backgroundTag":"invalid-optimizer-argument","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}