Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
21effd62
Commit
21effd62
authored
Nov 29, 2022
by
brkirch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add workaround for using MPS with torchsde
parent
98ca437e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
sd_samplers.py
modules/sd_samplers.py
+14
-0
No files found.
modules/sd_samplers.py
View file @
21effd62
...
@@ -6,6 +6,7 @@ import tqdm
...
@@ -6,6 +6,7 @@ import tqdm
from
PIL
import
Image
from
PIL
import
Image
import
inspect
import
inspect
import
k_diffusion.sampling
import
k_diffusion.sampling
import
torchsde._brownian.brownian_interval
import
ldm.models.diffusion.ddim
import
ldm.models.diffusion.ddim
import
ldm.models.diffusion.plms
import
ldm.models.diffusion.plms
from
modules
import
prompt_parser
,
devices
,
processing
,
images
from
modules
import
prompt_parser
,
devices
,
processing
,
images
...
@@ -367,6 +368,19 @@ class TorchHijack:
...
@@ -367,6 +368,19 @@ class TorchHijack:
return
torch
.
randn_like
(
x
)
return
torch
.
randn_like
(
x
)
# MPS fix for randn in torchsde
def
torchsde_randn
(
size
,
dtype
,
device
,
seed
):
if
device
.
type
==
'mps'
:
generator
=
torch
.
Generator
(
devices
.
cpu
)
.
manual_seed
(
int
(
seed
))
return
torch
.
randn
(
size
,
dtype
=
dtype
,
device
=
devices
.
cpu
,
generator
=
generator
)
.
to
(
device
)
else
:
generator
=
torch
.
Generator
(
device
)
.
manual_seed
(
int
(
seed
))
return
torch
.
randn
(
size
,
dtype
=
dtype
,
device
=
device
,
generator
=
generator
)
torchsde
.
_brownian
.
brownian_interval
.
_randn
=
torchsde_randn
class
KDiffusionSampler
:
class
KDiffusionSampler
:
def
__init__
(
self
,
funcname
,
sd_model
):
def
__init__
(
self
,
funcname
,
sd_model
):
denoiser
=
k_diffusion
.
external
.
CompVisVDenoiser
if
sd_model
.
parameterization
==
"v"
else
k_diffusion
.
external
.
CompVisDenoiser
denoiser
=
k_diffusion
.
external
.
CompVisVDenoiser
if
sd_model
.
parameterization
==
"v"
else
k_diffusion
.
external
.
CompVisDenoiser
...
...
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