Fix timesteps of DPMSolverMultistepScheduler. (#88)

There were minor differences in the timesteps because the linspace was
computed slightly differently. This PR makes the Swift implementation
identical to the current Python implementation in diffusers, which was
originally contributed by the DPM-Solver++ author.

See
https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_dpmsolver_multistep.py#L199-L204
for reference.
pull/89/head
Pedro Cuenca 1 year ago committed by GitHub
parent e07c4d00c3
commit e3db2ec99e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -77,7 +77,7 @@ public final class DPMSolverMultistepScheduler: Scheduler {
self.sigma_t = vForce.sqrt(vDSP.subtract([Float](repeating: 1, count: self.alphasCumProd.count), self.alphasCumProd))
self.lambda_t = zip(self.alpha_t, self.sigma_t).map { α, σ in log(α) - log(σ) }
self.timeSteps = linspace(0, Float(self.trainStepCount-1), stepCount).reversed().map { Int(round($0)) }
self.timeSteps = linspace(0, Float(self.trainStepCount-1), stepCount+1).dropFirst().reversed().map { Int(round($0)) }
}
/// Convert the model output to the corresponding type the algorithm needs.

Loading…
Cancel
Save