{"record":{"id":"e536f616f99f85e6","repo":"Comfy-Org/ComfyUI","slug":"eta-must-be-0-for-reverse-sampling","errorCode":null,"errorMessage":"eta must be 0 for reverse sampling","messagePattern":"eta must be 0 for reverse sampling","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy/k_diffusion/sampling.py","lineNumber":530,"sourceCode":"        return x_2, eps_cache\n\n    def dpm_solver_3_step(self, x, t, t_next, r1=1 / 3, r2=2 / 3, eps_cache=None):\n        eps_cache = {} if eps_cache is None else eps_cache\n        h = t_next - t\n        eps, eps_cache = self.eps(eps_cache, 'eps', x, t)\n        s1 = t + r1 * h\n        s2 = t + r2 * h\n        u1 = x - self.sigma(s1) * (r1 * h).expm1() * eps\n        eps_r1, eps_cache = self.eps(eps_cache, 'eps_r1', u1, s1)\n        u2 = x - self.sigma(s2) * (r2 * h).expm1() * eps - self.sigma(s2) * (r2 / r1) * ((r2 * h).expm1() / (r2 * h) - 1) * (eps_r1 - eps)\n        eps_r2, eps_cache = self.eps(eps_cache, 'eps_r2', u2, s2)\n        x_3 = x - self.sigma(t_next) * h.expm1() * eps - self.sigma(t_next) / r2 * (h.expm1() / h - 1) * (eps_r2 - eps)\n        return x_3, eps_cache\n\n    def dpm_solver_fast(self, x, t_start, t_end, nfe, eta=0., s_noise=1., noise_sampler=None):\n        noise_sampler = default_noise_sampler(x, seed=self.extra_args.get(\"seed\", None)) if noise_sampler is None else noise_sampler\n        if not t_end > t_start and eta:\n            raise ValueError('eta must be 0 for reverse sampling')\n\n        m = math.floor(nfe / 3) + 1\n        ts = torch.linspace(t_start, t_end, m + 1, device=x.device)\n\n        if nfe % 3 == 0:\n            orders = [3] * (m - 2) + [2, 1]\n        else:\n            orders = [3] * (m - 1) + [nfe % 3]\n\n        for i in range(len(orders)):\n            eps_cache = {}\n            t, t_next = ts[i], ts[i + 1]\n            if eta:\n                sd, su = get_ancestral_step(self.sigma(t), self.sigma(t_next), eta)\n                t_next_ = torch.minimum(t_end, self.t(sd))\n                su = (self.sigma(t_next) ** 2 - self.sigma(t_next_) ** 2) ** 0.5\n            else:\n                t_next_, su = t_next, 0.","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/k_diffusion/sampling.py#L512-L548","documentation":"Raised by DPMSolver.dpm_solver_fast. DPM-Solver-Fast integrates from t_start (high sigma) toward t_end; eta adds stochastic noise whose Brownian correction is only defined in the forward (denoising) direction. If t_end <= t_start (a reverse pass) and eta is nonzero, the solver refuses instead of producing incorrect SDE dynamics.","triggerScenarios":"Calling sample_dpm_fast with eta > 0 while sigma_max < sigma_min (reversed bounds), or programmatically invoking dpm_solver_fast(x, t_start, t_end) with t_end < t_start and eta != 0.","commonSituations":"Custom nodes swapping sigma_min/sigma_max arguments; scripts reusing sample_dpm_adaptive/fast argument order from another sampler; experiments that try to run the diffusion process 'backwards' (adding noise) with eta left at default 1.","solutions":["Pass bounds in denoising order: sigma_max first (e.g. 14.6) then sigma_min (e.g. 0.03)","If you truly need reverse integration, set eta=0.0 and s_noise handling accordingly","Double-check custom sampler wrappers for swapped positional args"],"exampleFix":"# before\nsample_dpm_fast(model, x, sigma_min=14.6, sigma_max=0.03, n=20, eta=1.0)\n# after\nsample_dpm_fast(model, x, sigma_min=0.03, sigma_max=14.6, n=20, eta=1.0)","handlingStrategy":"validation","validationCode":"assert sigma_max > sigma_min > 0, 'bounds must be in denoising order and positive'\nif sigma_max < sigma_min:\n    eta = 0.0\nsample_dpm_fast(model, x, sigma_min, sigma_max, n, eta=eta)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep sigma_max (large) first and sigma_min (small) second in dpm_fast/adaptive calls","Force eta=0 whenever running reverse integration"],"tags":["sampling","dpm-solver","eta","argument-order","sde"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}