huggingface/pytorch-image-models · error · ValueError
Coefficient list cannot be empty
Error message
Coefficient list cannot be empty
What it means
Thrown by resolve_ns_coefficients in timm's Muon optimizer when the coefficients argument is a sequence of triples but contains zero items. At least one coefficient triple is required.
Source
Thrown at timm/optim/muon.py:1055
if not is_seq(value):
raise TypeError(
"Coefficients must be a preset name (str), a 3-sequence (a,b,c), "
"or a sequence of 3-sequences."
)
# Decide single triple vs list-of-triples by structure
if len(value) == 3 and all(is_real(v) for v in value): # type: ignore[index]
return [as_coeff(value)] # single triple -> wrap
# Otherwise treat as list/tuple of triples
out = []
for i, item in enumerate(value): # type: ignore[assignment]
if not is_seq(item):
raise TypeError(f"Item {i} is not a sequence: {item!r}")
out.append(as_coeff(item))
if not out:
raise ValueError("Coefficient list cannot be empty")
return out
View on GitHub (pinned to 9a5261e31b)
Solutions
- Ensure the coefficient list has at least one (a,b,c) triple
- If dynamically generated, add a fallback default triple when the list would be empty
Example fix
# before coeffs = [] # built dynamically, ended empty Muon(params, ns_coefficients=coeffs) # after coeffs = coeffs or [(0.9, 0.95, 0.5)] Muon(params, ns_coefficients=coeffs)
Defensive patterns
Strategy: validation
Validate before calling
assert len(ns_coefficients) > 0, 'coefficient list must not be empty'
Prevention
- Default dynamically built lists to at least one triple
- Log list lengths when building per-layer configs
When it happens
Trigger: Passing ns_coefficients=[] to timm.optim.Muon/AdamMuon.
Common situations: Programmatically building a per-layer coefficient list that ends up empty (e.g. no layers matched a filter).
Related errors
- Preset '{value}' is empty or invalid
- Coefficients must be a preset name (str), a 3-sequence (a,b,
- Item {i} is not a sequence: {item!r}
- Invalid learning rate: {}
- Invalid learning rate: {lr}
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/394c8d289da7d9af.
Report an issue: GitHub.