From 90d911a569e7a67304d17347573bb10d9f5545d7 Mon Sep 17 00:00:00 2001 From: Tai An Date: Mon, 13 Apr 2026 21:16:11 -0700 Subject: [PATCH] fix(LTXEulerAncestralRFScheduler): add monotonicity validation for explicit sigma schedules When sigmas are provided explicitly, validate that the schedule is monotonically non-increasing before accepting it. A non-monotone schedule causes alpha_down < 0 in step(), which silently corrupts denoising without raising an error. Fixes #13411 --- .../schedulers/scheduling_ltx_euler_ancestral_rf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/diffusers/schedulers/scheduling_ltx_euler_ancestral_rf.py b/src/diffusers/schedulers/scheduling_ltx_euler_ancestral_rf.py index 453c8515c301..caa904f20a1a 100644 --- a/src/diffusers/schedulers/scheduling_ltx_euler_ancestral_rf.py +++ b/src/diffusers/schedulers/scheduling_ltx_euler_ancestral_rf.py @@ -233,6 +233,14 @@ def set_timesteps( if sigmas_tensor.ndim != 1: raise ValueError(f"`sigmas` must be a 1D tensor, got shape {tuple(sigmas_tensor.shape)}.") + if len(sigmas_tensor) > 1 and not torch.all(sigmas_tensor[:-1] >= sigmas_tensor[1:]): + raise ValueError( + "`sigmas` must be monotonically non-increasing (each sigma must be >= the next). " + "A non-monotone sigma schedule violates the CONST parametrization invariant of " + "LTXEulerAncestralRFScheduler: `step()` computes `sigma_down` from adjacent pairs, " + "and a schedule increase causes `alpha_down < 0`, which corrupts denoising silently." + ) + if sigmas_tensor[-1].abs().item() > 1e-6: logger.warning( "The last sigma in the schedule is not zero (%.6f). "