Skip to content

Fix set_timesteps: torch.flip instead of tensor [::-1] - #16

Merged
alex-16moro merged 1 commit into
mainfrom
cursor/scheduler-flip-timesteps-3eed
Sep 20, 2026
Merged

alex-16moro merged 1 commit into
mainfrom
cursor/scheduler-flip-timesteps-3eed

Conversation

@alex-16moro

@alex-16moro alex-16moro commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

set_timesteps reversed a torch tensor with [::-1], which raises (torch has no negative-step slicing). Every scaffold inherited that from the template.

Replaced the reversal with torch.flip(..., dims=[0]) in:

  • templates/scheduler/scheduling_TEMPLATE.py
  • examples/scaffolded_scheduler/scheduling_ddpm_lite.py
  • src/diffusers/schedulers/scheduling_euler_lite.py

step() stays TODO(engineer) — no sampler math. There is no scheduling_heun_lite.py in this kit.

Also added the missing dtype assertion on test_scheduling_euler_lite.py so TEST002 is 0 findings.

Convention gate

python3 tools/convention_check.py examples/scaffolded_scheduler src/diffusers/schedulers/scheduling_euler_lite.py
# 2 file(s) scanned, 0 findings

python3 tools/convention_check.py --all
# 18 file(s) scanned, 0 findings

Tests run

python3 -m unittest discover -s tests -t .
# Ran 52 tests in ~17s
# OK
# skipped_count 0

With torch 2.14.0+cpu and diffusers 0.40.0. Behavioral tests (test_timesteps_count, test_output_type, test_same_seed_same_output, test_config_roundtrip) passed on both ddpm_lite and euler_lite — they did not skip.

unittest log

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

Torch tensors do not support negative-step slicing. Every scaffold copied
the template's [::-1], so set_timesteps raised at runtime. Flip along dim 0
instead. Leave step() as TODO(engineer).

Co-authored-by: ale93.moro <ale93.moro@gmail.com>
@alex-16moro
alex-16moro marked this pull request as ready for review September 20, 2026 11:12
@alex-16moro
alex-16moro merged commit a3a4d89 into main Sep 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants