huggingface/pytorch-image-models · error · ValueError
Invalid beta parameter at index 0: {}
Error message
Invalid beta parameter at index 0: {} What it means
Mars requires beta1 (betas[0]) to satisfy 0 <= beta1 < 1, the standard constraint for exponential-moving-average decay coefficients. Values outside this range produce non-convergent momentum estimates.
Source
Thrown at timm/optim/mars.py:117
self,
params: ParamsT,
lr: float = 3e-3,
betas: Tuple[float, float] = (0.9, 0.99),
eps: float = 1e-8,
weight_decay: float = 0.,
gamma: float = 0.025,
mars_type: str = "adamw",
optimize_1d: bool = False,
lr_1d_factor: float = 1.0,
betas_1d: Optional[Tuple[float, float]] = None,
caution: bool = False
):
if not 0.0 <= lr:
raise ValueError("Invalid learning rate: {}".format(lr))
if not 0.0 <= eps:
raise ValueError("Invalid epsilon value: {}".format(eps))
if not 0.0 <= betas[0] < 1.0:
raise ValueError("Invalid beta parameter at index 0: {}".format(betas[0]))
if not 0.0 <= betas[1] < 1.0:
raise ValueError("Invalid beta parameter at index 1: {}".format(betas[1]))
assert mars_type in ["adamw", "lion"], "MARS type not supported"
defaults = dict(
lr=lr,
betas=betas,
eps=eps,
weight_decay=weight_decay,
mars_type=mars_type,
gamma=gamma,
optimize_1d=optimize_1d,
lr_1d_factor=lr_1d_factor,
betas_1d=betas_1d or betas,
caution=caution,
)
super(Mars, self).__init__(params, defaults)
View on GitHub (pinned to 9a5261e31b)
Solutions
- Use betas with beta1 in [0,1), e.g. (0.9, 0.999)
- Verify you passed (beta1, beta2) in the right order
- Check Mars-specific betas_1d if you also configure the 1D param group
Example fix
# before opt = Mars(model.parameters(), betas=(1.0, 0.999)) # after opt = Mars(model.parameters(), betas=(0.9, 0.999))
Defensive patterns
Strategy: validation
Validate before calling
b1, b2 = cfg.betas assert 0 <= b1 < 1 and 0 <= b2 < 1, 'betas must be in [0,1)'
Type guard
def are_valid_betas(betas: tuple) -> bool:
return (len(betas) == 2 and all(isinstance(b, (int, float)) and 0 <= b < 1 for b in betas)) Prevention
- Validate betas tuple order and bounds in config schema
- Remember both betas and betas_1d are validated
When it happens
Trigger: Calling Mars(params, betas=(1.0, 0.999)) or betas=(-0.1, 0.999); beta1=1 is explicitly rejected.
Common situations: Copying betas from a config where beta1 was set to 1 for 'full momentum'; ordering mixups passing (beta2, beta1).
Related errors
- Invalid beta parameter at index 1: {}
- Invalid learning rate: {}
- Invalid epsilon value: {}
- Momentum {momentum} must be in the range [0,1]
- Learning rate {lr} must be positive
AI-assisted analysis of huggingface/pytorch-image-models@9a5261e31b (2026-08-27).
Data as JSON: /api/errors/56dc30577a71c6f6.
Report an issue: GitHub.