lllyasviel/ControlNet · error · ValueError
Invalid epsilon value: {}
Error message
Invalid epsilon value: {} What it means
Raised by the EMA-tracking AdamW optimizer in ldm/util.py when the epsilon parameter is negative (eps < 0.0). eps is the numerical-stability term added to denominators in Adam-style updates; any negative value aborts optimizer construction, matching torch.optim.AdamW's validation.
Source
Thrown at ldm/util.py:99
def get_obj_from_str(string, reload=False):
module, cls = string.rsplit(".", 1)
if reload:
module_imp = importlib.import_module(module)
importlib.reload(module_imp)
return getattr(importlib.import_module(module, package=None), cls)
class AdamWwithEMAandWings(optim.Optimizer):
# credit to https://gist.github.com/crowsonkb/65f7265353f403714fce3b2595e0b298
def __init__(self, params, lr=1.e-3, betas=(0.9, 0.999), eps=1.e-8, # TODO: check hyperparameters before using
weight_decay=1.e-2, amsgrad=False, ema_decay=0.9999, # ema decay to match previous code
ema_power=1., param_names=()):
"""AdamW that saves EMA versions of the parameters."""
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]))
if not 0.0 <= weight_decay:
raise ValueError("Invalid weight_decay value: {}".format(weight_decay))
if not 0.0 <= ema_decay <= 1.0:
raise ValueError("Invalid ema_decay value: {}".format(ema_decay))
defaults = dict(lr=lr, betas=betas, eps=eps,
weight_decay=weight_decay, amsgrad=amsgrad, ema_decay=ema_decay,
ema_power=ema_power, param_names=param_names)
super().__init__(params, defaults)
def __setstate__(self, state):
super().__setstate__(state)
for group in self.param_groups:
group.setdefault('amsgrad', False)
View on GitHub (pinned to ed85cd1e25)
Solutions
- Fix the sign: eps should be a small positive float like 1e-8
- Validate config values before constructing the optimizer (assert eps > 0)
- Sanity-check the hyperparameter dict with a small lint step in training scripts
Example fix
# before opt = AdamW(params, eps=-1e-8) # after opt = AdamW(params, eps=1e-8)
Defensive patterns
Strategy: validation
Validate before calling
assert 0.0 <= eps, f'bad eps: {eps}' Prevention
- Keep eps as a fixed literal like 1e-8 in configs
- Lint config files for negative numeric values
- Unit-test config loading against the optimizer constructor
When it happens
Trigger: Constructing AdamW(params, eps=-1e-8) or pulling eps from a config where it was mistyped or computed as negative.
Common situations: Copy-pasted hyperparameter blocks with sign typos, config generation scripts that subtract instead of add, or argparse values entered with a stray minus.
Related errors
- Invalid learning rate: {}
- Invalid beta parameter at index 0: {}
- Invalid beta parameter at index 1: {}
- Invalid weight_decay value: {}
- Invalid ema_decay value: {}
AI-assisted analysis of lllyasviel/ControlNet@ed85cd1e25 (2026-08-27).
Data as JSON: /api/errors/b48fbd16dea43477.
Report an issue: GitHub.