You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TCDScheduler advances the generator on the final step of a strength-truncated custom schedule #15288
When TCDScheduler uses a non-empty custom timestep schedule truncated by strength < 1, its actual final step advances the supplied random generator
when eta > 0.
For example, timesteps=[999, 499, 19] with strength=0.5 leaves only [19],
but num_inference_steps remains 3. The final-step check uses the original
step count and enters the noise-sampling branch.
In the tested case, the terminal output stays the same because the noise
coefficient is zero, but the generator state changes. Subsequent draws using
the same generator therefore differ.
I expected the actual final step to leave the generator state unchanged,
consistent with the scheduler's comment that noise is not used on the final
timestep.
A possible fix is to decide whether another step exists using the length of self.timesteps. I have tested a candidate fix and can provide it for review.
I tested a candidate fix that checks whether another step exists using the
actual length of self.timesteps.
On CPU, I compared it with the baseline across custom and standard schedules,
three prediction types, both set_alpha_to_one values, three eta values,
and both return formats. In the 48 truncated-schedule cases with eta > 0,
the baseline advanced the generator on the terminal step. The candidate fix
preserved its state. The terminal samples were identical, while subsequent
random draws differed.
The candidate patch applies cleanly to commit 43e30028af5120d8b0868cb6975b9fad39cc4fab. I can prepare a PR with the
fix and a regression test if the approach looks appropriate.
Confirming on the current release — diffusers 0.43.0, torch 2.14.0+cpu, Linux x86_64 (your report is 0.44.0.dev0 on Windows):
Your exact repro gives the same result here: actual timesteps [19], num_inference_steps still 3, RNG state preserved: False, and the next draw matches your log exactly ([-0.2934, -2.1788, 0.5684, -1.0845] against control [1.5410, -0.2934, ...]).
One added measurement, a multi-step schedule, to show where the boundary sits:
Custom timesteps [999, 799, 599, 399, 199] at strength 1.0 (no truncation): 5 steps advance the generator by exactly 4 draws — the final step draws nothing, as documented.
The same schedule at strength 0.6 (truncated to [599, 399, 199], num_inference_steps still 5): 3 steps advance it by 3 draws — the actual final step draws noise it does not use.
So the stale count is set in set_timesteps, which truncates the schedule but keeps the pre-truncation num_inference_steps (there is a # TODO: also reset self.num_inference_steps? at that spot), and step() then trusts that count for its final-step check. Deciding finality from len(self.timesteps), as you suggest, fixes both shapes above; only resetting the count after truncation would leave step() trusting a number that a custom schedule can still desync from the schedule itself.
Activity
twojian commentedon Nov 14, 2026
I tested a candidate fix that checks whether another step exists using the
actual length of
self.timesteps.On CPU, I compared it with the baseline across custom and standard schedules,
three prediction types, both
set_alpha_to_onevalues, threeetavalues,and both return formats. In the 48 truncated-schedule cases with
eta > 0,the baseline advanced the generator on the terminal step. The candidate fix
preserved its state. The terminal samples were identical, while subsequent
random draws differed.
The candidate patch applies cleanly to commit
43e30028af5120d8b0868cb6975b9fad39cc4fab. I can prepare a PR with thefix and a regression test if the approach looks appropriate.
1OF1Research commentedon Nov 14, 2026
Confirming on the current release — diffusers 0.43.0, torch 2.14.0+cpu, Linux x86_64 (your report is 0.44.0.dev0 on Windows):
Your exact repro gives the same result here: actual timesteps
[19],num_inference_stepsstill 3, RNG state preserved: False, and the next draw matches your log exactly ([-0.2934, -2.1788, 0.5684, -1.0845]against control[1.5410, -0.2934, ...]).One added measurement, a multi-step schedule, to show where the boundary sits:
[999, 799, 599, 399, 199]at strength 1.0 (no truncation): 5 steps advance the generator by exactly 4 draws — the final step draws nothing, as documented.[599, 399, 199],num_inference_stepsstill 5): 3 steps advance it by 3 draws — the actual final step draws noise it does not use.So the stale count is set in
set_timesteps, which truncates the schedule but keeps the pre-truncationnum_inference_steps(there is a# TODO: also reset self.num_inference_steps?at that spot), andstep()then trusts that count for its final-step check. Deciding finality fromlen(self.timesteps), as you suggest, fixes both shapes above; only resetting the count after truncation would leavestep()trusting a number that a custom schedule can still desync from the schedule itself.test(tcd): drop pre-truncation num_inference_steps assertion