Skip to content

Discrepancy in scheduler offset usage #465

@natolambert

Description

@natolambert

What API design would you like to have changed or added to the library? Why?

@jonatanklosko brought up an issue with some confusing code (why are alphas indexed differently across PNDMScheduler and DDIMScheduler), and some inconsistency in the offset usage.

Two questions:

  1. Why does only one shift by offset?
  2. Can offset be changed from an arbitrary int to a bool setting that shifts by 1 (the integer shift is more confusing if the only use case is stable diffusion inference with offset = 1)

Discussion began in #444, see here

alpha_prod_t = self.alphas_cumprod[timestep + 1 - self._offset]
alpha_prod_t_prev = self.alphas_cumprod[timestep_prev + 1 - self._offset]

alpha_prod_t = self.alphas_cumprod[timestep]
alpha_prod_t_prev = self.alphas_cumprod[prev_timestep] if prev_timestep >= 0 else self.final_alpha_cumprod

I can tell you that the PNDMScheduler and DDIMScheduler have indexed the alpha's differently for a while. Before introducing offset, PNDMScheduler had

alpha_prod_t = self.alphas_cumprod[timestep + 1]
alpha_prod_t_prev = self.alphas_cumprod[timestep_prev + 1]

And DDIMScheduler had

alpha_prod_t = self.alphas_cumprod[timestep]
alpha_prod_t_prev = self.alphas_cumprod[timestep_prev]

At minimum, we can figure this out and document better!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions