Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
01150186
Commit
01150186
authored
Jul 20, 2023
by
comfyanonymous
Browse files
Print errors and continue when lora weights are not compatible.
parent
4760c293
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
comfy/sd.py
comfy/sd.py
+13
-3
No files found.
comfy/sd.py
View file @
01150186
...
@@ -376,7 +376,10 @@ class ModelPatcher:
...
@@ -376,7 +376,10 @@ class ModelPatcher:
mat3
=
v
[
3
].
float
().
to
(
weight
.
device
)
mat3
=
v
[
3
].
float
().
to
(
weight
.
device
)
final_shape
=
[
mat2
.
shape
[
1
],
mat2
.
shape
[
0
],
mat3
.
shape
[
2
],
mat3
.
shape
[
3
]]
final_shape
=
[
mat2
.
shape
[
1
],
mat2
.
shape
[
0
],
mat3
.
shape
[
2
],
mat3
.
shape
[
3
]]
mat2
=
torch
.
mm
(
mat2
.
transpose
(
0
,
1
).
flatten
(
start_dim
=
1
),
mat3
.
transpose
(
0
,
1
).
flatten
(
start_dim
=
1
)).
reshape
(
final_shape
).
transpose
(
0
,
1
)
mat2
=
torch
.
mm
(
mat2
.
transpose
(
0
,
1
).
flatten
(
start_dim
=
1
),
mat3
.
transpose
(
0
,
1
).
flatten
(
start_dim
=
1
)).
reshape
(
final_shape
).
transpose
(
0
,
1
)
weight
+=
(
alpha
*
torch
.
mm
(
mat1
.
flatten
(
start_dim
=
1
),
mat2
.
flatten
(
start_dim
=
1
))).
reshape
(
weight
.
shape
).
type
(
weight
.
dtype
)
try
:
weight
+=
(
alpha
*
torch
.
mm
(
mat1
.
flatten
(
start_dim
=
1
),
mat2
.
flatten
(
start_dim
=
1
))).
reshape
(
weight
.
shape
).
type
(
weight
.
dtype
)
except
Exception
as
e
:
print
(
"ERROR"
,
key
,
e
)
elif
len
(
v
)
==
8
:
#lokr
elif
len
(
v
)
==
8
:
#lokr
w1
=
v
[
0
]
w1
=
v
[
0
]
w2
=
v
[
1
]
w2
=
v
[
1
]
...
@@ -407,7 +410,10 @@ class ModelPatcher:
...
@@ -407,7 +410,10 @@ class ModelPatcher:
if
v
[
2
]
is
not
None
and
dim
is
not
None
:
if
v
[
2
]
is
not
None
and
dim
is
not
None
:
alpha
*=
v
[
2
]
/
dim
alpha
*=
v
[
2
]
/
dim
weight
+=
alpha
*
torch
.
kron
(
w1
,
w2
).
reshape
(
weight
.
shape
).
type
(
weight
.
dtype
)
try
:
weight
+=
alpha
*
torch
.
kron
(
w1
,
w2
).
reshape
(
weight
.
shape
).
type
(
weight
.
dtype
)
except
Exception
as
e
:
print
(
"ERROR"
,
key
,
e
)
else
:
#loha
else
:
#loha
w1a
=
v
[
0
]
w1a
=
v
[
0
]
w1b
=
v
[
1
]
w1b
=
v
[
1
]
...
@@ -424,7 +430,11 @@ class ModelPatcher:
...
@@ -424,7 +430,11 @@ class ModelPatcher:
m1
=
torch
.
mm
(
w1a
.
float
().
to
(
weight
.
device
),
w1b
.
float
().
to
(
weight
.
device
))
m1
=
torch
.
mm
(
w1a
.
float
().
to
(
weight
.
device
),
w1b
.
float
().
to
(
weight
.
device
))
m2
=
torch
.
mm
(
w2a
.
float
().
to
(
weight
.
device
),
w2b
.
float
().
to
(
weight
.
device
))
m2
=
torch
.
mm
(
w2a
.
float
().
to
(
weight
.
device
),
w2b
.
float
().
to
(
weight
.
device
))
weight
+=
(
alpha
*
m1
*
m2
).
reshape
(
weight
.
shape
).
type
(
weight
.
dtype
)
try
:
weight
+=
(
alpha
*
m1
*
m2
).
reshape
(
weight
.
shape
).
type
(
weight
.
dtype
)
except
Exception
as
e
:
print
(
"ERROR"
,
key
,
e
)
return
weight
return
weight
def
unpatch_model
(
self
):
def
unpatch_model
(
self
):
...
...
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