{"record":{"id":"b48fbd16dea43477","repo":"lllyasviel/ControlNet","slug":"invalid-epsilon-value","errorCode":null,"errorMessage":"Invalid epsilon value: {}","messagePattern":"Invalid epsilon value: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ldm/util.py","lineNumber":99,"sourceCode":"\ndef get_obj_from_str(string, reload=False):\n    module, cls = string.rsplit(\".\", 1)\n    if reload:\n        module_imp = importlib.import_module(module)\n        importlib.reload(module_imp)\n    return getattr(importlib.import_module(module, package=None), cls)\n\n\nclass AdamWwithEMAandWings(optim.Optimizer):\n    # credit to https://gist.github.com/crowsonkb/65f7265353f403714fce3b2595e0b298\n    def __init__(self, params, lr=1.e-3, betas=(0.9, 0.999), eps=1.e-8,  # TODO: check hyperparameters before using\n                 weight_decay=1.e-2, amsgrad=False, ema_decay=0.9999,   # ema decay to match previous code\n                 ema_power=1., param_names=()):\n        \"\"\"AdamW that saves EMA versions of the parameters.\"\"\"\n        if not 0.0 <= lr:\n            raise ValueError(\"Invalid learning rate: {}\".format(lr))\n        if not 0.0 <= eps:\n            raise ValueError(\"Invalid epsilon value: {}\".format(eps))\n        if not 0.0 <= betas[0] < 1.0:\n            raise ValueError(\"Invalid beta parameter at index 0: {}\".format(betas[0]))\n        if not 0.0 <= betas[1] < 1.0:\n            raise ValueError(\"Invalid beta parameter at index 1: {}\".format(betas[1]))\n        if not 0.0 <= weight_decay:\n            raise ValueError(\"Invalid weight_decay value: {}\".format(weight_decay))\n        if not 0.0 <= ema_decay <= 1.0:\n            raise ValueError(\"Invalid ema_decay value: {}\".format(ema_decay))\n        defaults = dict(lr=lr, betas=betas, eps=eps,\n                        weight_decay=weight_decay, amsgrad=amsgrad, ema_decay=ema_decay,\n                        ema_power=ema_power, param_names=param_names)\n        super().__init__(params, defaults)\n\n    def __setstate__(self, state):\n        super().__setstate__(state)\n        for group in self.param_groups:\n            group.setdefault('amsgrad', False)\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/lllyasviel/ControlNet/blob/ed85cd1e25a5ed592f7d8178495b4483de0331bf/ldm/util.py#L81-L117","documentation":"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.","triggerScenarios":"Constructing AdamW(params, eps=-1e-8) or pulling eps from a config where it was mistyped or computed as negative.","commonSituations":"Copy-pasted hyperparameter blocks with sign typos, config generation scripts that subtract instead of add, or argparse values entered with a stray minus.","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"],"exampleFix":"# before\nopt = AdamW(params, eps=-1e-8)\n# after\nopt = AdamW(params, eps=1e-8)","handlingStrategy":"validation","validationCode":"assert 0.0 <= eps, f'bad eps: {eps}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["optimizer","adamw","epsilon","diffusion-training","validation"],"backgroundTag":"invalid-optimizer-hyperparameter","analyzedSha":"ed85cd1e25a5ed592f7d8178495b4483de0331bf","analyzedAt":"2026-08-27T12:58:54.167Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}