lllyasviel/ControlNet · error · ValueError

Invalid beta parameter at index 1: {}

Error message

Invalid beta parameter at index 1: {}

What it means

Raised by the EMA-tracking AdamW optimizer when betas[1] (beta2, the decay rate for the second-moment/squared-gradient moving average) is outside [0.0, 1.0). beta2 must be strictly below 1; values like 1.0 or negatives abort construction.

Source

Thrown at ldm/util.py:103

        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):
        """Performs a single optimization step.
        Args:

View on GitHub (pinned to ed85cd1e25)

Solutions

  1. Set beta2 to a valid value in [0, 1), typically 0.999 (or 0.99 / 0.9999 variants)
  2. Check the tuple isn't transposed or malformed in the config
  3. Validate betas programmatically before constructing the optimizer

Example fix

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

Strategy: validation

Validate before calling

assert 0.0 <= betas[1] < 1.0, f'bad beta2: {betas[1]}'

Prevention

When it happens

Trigger: Constructing AdamW(params, betas=(0.9, 1.0)) or betas=(0.9, -0.999); commonly beta2=1.0 from configs tuned for other optimizers or sweep bounds off by one.

Common situations: Config files specifying beta2 as 1 to 'disable' second-moment decay, sweep scripts generating inclusive upper bounds of 1.0, or transposed betas tuples.

Related errors


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