lllyasviel/ControlNet · error · ValueError

Invalid beta parameter at index 0: {}

Error message

Invalid beta parameter at index 0: {}

What it means

Raised by the EMA-tracking AdamW optimizer when betas[0] (beta1, the decay rate for the first-moment/gradient moving average) is outside the half-open range [0.0, 1.0). Adam requires beta1 strictly below 1 so the exponential average remains well-defined; 1.0 or negatives abort construction.

Source

Thrown at ldm/util.py:101

    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)

    @torch.no_grad()
    def step(self, closure=None):

View on GitHub (pinned to ed85cd1e25)

Solutions

  1. Set beta1 to a valid value in [0, 1), typically 0.9 or 0.99 for diffusion training
  2. If a sweep produced it, constrain the sweep range to [0.5, 0.999]
  3. Validate betas before constructing: all(0.0 <= b < 1.0 for b in betas)

Example fix

# before
opt = AdamW(params, betas=(1.0, 0.999))
# after
opt = AdamW(params, betas=(0.9, 0.999))
Defensive patterns

Strategy: validation

Validate before calling

assert 0.0 <= betas[0] < 1.0, f'bad beta1: {betas[0]}'

Prevention

When it happens

Trigger: Constructing AdamW(params, betas=(1.0, 0.999)) or betas=(-0.1, 0.999), or configs where beta1 was set to 1.0 intending 'no decay'.

Common situations: Hyperparameter sweeps writing beta1=1.0, YAML configs copying a different optimizer's semantics, or arithmetic that scales beta1 past 1.

Related errors


AI-assisted analysis of lllyasviel/ControlNet@ed85cd1e25 (2026-08-27). Data as JSON: /api/errors/fa08383d92e6fa96. Report an issue: GitHub.