Fix set_timesteps: torch.flip instead of tensor [::-1] - #16
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
set_timestepsreversed a torch tensor with[::-1], which raises (torchhas no negative-step slicing). Every scaffold inherited that from the template.Replaced the reversal with
torch.flip(..., dims=[0])in:templates/scheduler/scheduling_TEMPLATE.pyexamples/scaffolded_scheduler/scheduling_ddpm_lite.pysrc/diffusers/schedulers/scheduling_euler_lite.pystep()staysTODO(engineer)— no sampler math. There is noscheduling_heun_lite.pyin this kit.Also added the missing dtype assertion on
test_scheduling_euler_lite.pyso TEST002 is 0 findings.Convention gate
Tests run
With
torch 2.14.0+cpuanddiffusers 0.40.0. Behavioral tests (test_timesteps_count,test_output_type,test_same_seed_same_output,test_config_roundtrip) passed on bothddpm_liteandeuler_lite— they did not skip.unittest log
To show artifacts inline, enable in settings.