Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
diffusers
Commits
22c1ba56
Unverified
Commit
22c1ba56
authored
Feb 06, 2023
by
psychedelicious
Committed by
GitHub
Feb 05, 2023
Browse files
Fix k_dpm_2 & k_dpm_2_a on MPS (#2241)
Needed to convert `timesteps` to `float32` a bit sooner. Fixes #1537
parent
7386e773
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py
...users/schedulers/scheduling_k_dpm_2_ancestral_discrete.py
+7
-7
src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py
src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py
+6
-7
No files found.
src/diffusers/schedulers/scheduling_k_dpm_2_ancestral_discrete.py
View file @
22c1ba56
...
...
@@ -161,16 +161,16 @@ class KDPM2AncestralDiscreteScheduler(SchedulerMixin, ConfigMixin):
# standard deviation of the initial noise distribution
self
.
init_noise_sigma
=
self
.
sigmas
.
max
()
timesteps
=
torch
.
from_numpy
(
timesteps
).
to
(
device
)
timesteps_interpol
=
self
.
sigma_to_t
(
sigmas_interpol
).
to
(
device
)
interleaved_timesteps
=
torch
.
stack
((
timesteps_interpol
[:
-
2
,
None
],
timesteps
[
1
:,
None
]),
dim
=-
1
).
flatten
()
timesteps
=
torch
.
cat
([
timesteps
[:
1
],
interleaved_timesteps
])
if
str
(
device
).
startswith
(
"mps"
):
# mps does not support float64
self
.
timesteps
=
timesteps
.
to
(
device
,
dtype
=
torch
.
float32
)
timesteps
=
torch
.
from_numpy
(
timesteps
)
.
to
(
device
,
dtype
=
torch
.
float32
)
else
:
self
.
timesteps
=
timesteps
timesteps
=
torch
.
from_numpy
(
timesteps
).
to
(
device
)
timesteps_interpol
=
self
.
sigma_to_t
(
sigmas_interpol
).
to
(
device
)
interleaved_timesteps
=
torch
.
stack
((
timesteps_interpol
[:
-
2
,
None
],
timesteps
[
1
:,
None
]),
dim
=-
1
).
flatten
()
self
.
timesteps
=
torch
.
cat
([
timesteps
[:
1
],
interleaved_timesteps
])
self
.
sample
=
None
...
...
src/diffusers/schedulers/scheduling_k_dpm_2_discrete.py
View file @
22c1ba56
...
...
@@ -149,18 +149,17 @@ class KDPM2DiscreteScheduler(SchedulerMixin, ConfigMixin):
# standard deviation of the initial noise distribution
self
.
init_noise_sigma
=
self
.
sigmas
.
max
()
timesteps
=
torch
.
from_numpy
(
timesteps
).
to
(
device
)
if
str
(
device
).
startswith
(
"mps"
):
# mps does not support float64
timesteps
=
torch
.
from_numpy
(
timesteps
).
to
(
device
,
dtype
=
torch
.
float32
)
else
:
timesteps
=
torch
.
from_numpy
(
timesteps
).
to
(
device
)
# interpolate timesteps
timesteps_interpol
=
self
.
sigma_to_t
(
sigmas_interpol
).
to
(
device
)
interleaved_timesteps
=
torch
.
stack
((
timesteps_interpol
[
1
:
-
1
,
None
],
timesteps
[
1
:,
None
]),
dim
=-
1
).
flatten
()
timesteps
=
torch
.
cat
([
timesteps
[:
1
],
interleaved_timesteps
])
if
str
(
device
).
startswith
(
"mps"
):
# mps does not support float64
self
.
timesteps
=
timesteps
.
to
(
torch
.
float32
)
else
:
self
.
timesteps
=
timesteps
self
.
timesteps
=
torch
.
cat
([
timesteps
[:
1
],
interleaved_timesteps
])
self
.
sample
=
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment