Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
851c3d51
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
大约 1 年 前同步成功
通知
1785
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
851c3d51
编写于
3月 09, 2024
作者:
K
Kohaku-Blueleaf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bugs for torch.nn.MultiheadAttention
上级
12bcacf4
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
4 deletion
+13
-4
extensions-builtin/Lora/network.py
extensions-builtin/Lora/network.py
+7
-1
extensions-builtin/Lora/networks.py
extensions-builtin/Lora/networks.py
+6
-3
未找到文件。
extensions-builtin/Lora/network.py
浏览文件 @
851c3d51
...
...
@@ -117,6 +117,12 @@ class NetworkModule:
if
hasattr
(
self
.
sd_module
,
'weight'
):
self
.
shape
=
self
.
sd_module
.
weight
.
shape
elif
isinstance
(
self
.
sd_module
,
nn
.
MultiheadAttention
):
# For now, only self-attn use Pytorch's MHA
# So assume all qkvo proj have same shape
self
.
shape
=
self
.
sd_module
.
out_proj
.
weight
.
shape
else
:
self
.
shape
=
None
self
.
ops
=
None
self
.
extra_kwargs
=
{}
...
...
@@ -146,7 +152,7 @@ class NetworkModule:
self
.
alpha
=
weights
.
w
[
"alpha"
].
item
()
if
"alpha"
in
weights
.
w
else
None
self
.
scale
=
weights
.
w
[
"scale"
].
item
()
if
"scale"
in
weights
.
w
else
None
self
.
dora_scale
=
weights
.
w
[
"dora_scale"
]
if
"dora_scale"
in
weights
.
w
else
None
self
.
dora_scale
=
weights
.
w
.
get
(
"dora_scale"
,
None
)
self
.
dora_mean_dim
=
tuple
(
i
for
i
in
range
(
len
(
self
.
shape
))
if
i
!=
1
)
def
multiplier
(
self
):
...
...
extensions-builtin/Lora/networks.py
浏览文件 @
851c3d51
...
...
@@ -429,9 +429,12 @@ def network_apply_weights(self: Union[torch.nn.Conv2d, torch.nn.Linear, torch.nn
if
isinstance
(
self
,
torch
.
nn
.
MultiheadAttention
)
and
module_q
and
module_k
and
module_v
and
module_out
:
try
:
with
torch
.
no_grad
():
updown_q
,
_
=
module_q
.
calc_updown
(
self
.
in_proj_weight
)
updown_k
,
_
=
module_k
.
calc_updown
(
self
.
in_proj_weight
)
updown_v
,
_
=
module_v
.
calc_updown
(
self
.
in_proj_weight
)
# Send "real" orig_weight into MHA's lora module
qw
,
kw
,
vw
=
self
.
in_proj_weight
.
chunk
(
3
,
0
)
updown_q
,
_
=
module_q
.
calc_updown
(
qw
)
updown_k
,
_
=
module_k
.
calc_updown
(
kw
)
updown_v
,
_
=
module_v
.
calc_updown
(
vw
)
del
qw
,
kw
,
vw
updown_qkv
=
torch
.
vstack
([
updown_q
,
updown_k
,
updown_v
])
updown_out
,
ex_bias
=
module_out
.
calc_updown
(
self
.
out_proj
.
weight
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录