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
1a4edd19
"git@developer.sourcefind.cn:OpenDAS/nni.git" did not exist on "cd3a912a07c2187fcd9e81205da35b97746b76f3"
Commit
1a4edd19
authored
Feb 10, 2023
by
comfyanonymous
Browse files
Fix overflow issue with inplace softmax.
parent
509c7dfc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
0 deletions
+1
-0
comfy/ldm/modules/sub_quadratic_attention.py
comfy/ldm/modules/sub_quadratic_attention.py
+1
-0
No files found.
comfy/ldm/modules/sub_quadratic_attention.py
View file @
1a4edd19
...
@@ -158,6 +158,7 @@ def _get_attention_scores_no_kv_chunking(
...
@@ -158,6 +158,7 @@ def _get_attention_scores_no_kv_chunking(
del
attn_scores
del
attn_scores
except
OOM_EXCEPTION
:
except
OOM_EXCEPTION
:
print
(
"ran out of memory while running softmax in _get_attention_scores_no_kv_chunking, trying slower in place softmax instead"
)
print
(
"ran out of memory while running softmax in _get_attention_scores_no_kv_chunking, trying slower in place softmax instead"
)
attn_scores
-=
attn_scores
.
max
(
dim
=-
1
,
keepdim
=
True
).
values
torch
.
exp
(
attn_scores
,
out
=
attn_scores
)
torch
.
exp
(
attn_scores
,
out
=
attn_scores
)
summed
=
torch
.
sum
(
attn_scores
,
dim
=-
1
,
keepdim
=
True
)
summed
=
torch
.
sum
(
attn_scores
,
dim
=-
1
,
keepdim
=
True
)
attn_scores
/=
summed
attn_scores
/=
summed
...
...
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