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
gaoqiong
flash-attention
Commits
1b9facac
Commit
1b9facac
authored
Oct 14, 2022
by
Tri Dao
Browse files
Fix QKV interface to allocate output in Python
parent
5badfb78
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
flash_attn/flash_attn_interface.py
flash_attn/flash_attn_interface.py
+3
-2
No files found.
flash_attn/flash_attn_interface.py
View file @
1b9facac
...
@@ -47,8 +47,9 @@ class FlashAttnQKVPackedFunc(torch.autograd.Function):
...
@@ -47,8 +47,9 @@ class FlashAttnQKVPackedFunc(torch.autograd.Function):
if
softmax_scale
is
None
:
if
softmax_scale
is
None
:
softmax_scale
=
qkv
.
shape
[
-
1
]
**
(
-
0.5
)
softmax_scale
=
qkv
.
shape
[
-
1
]
**
(
-
0.5
)
out
,
softmax_lse
,
S_dmask
=
_flash_attn_forward
(
out
,
softmax_lse
,
S_dmask
=
_flash_attn_forward
(
qkv
[:,
0
],
qkv
[:,
1
],
qkv
[:,
2
],
cu_seqlens
,
cu_seqlens
,
max_seqlen
,
max_seqlen
,
qkv
[:,
0
],
qkv
[:,
1
],
qkv
[:,
2
],
torch
.
empty_like
(
qkv
[:,
0
]),
cu_seqlens
,
cu_seqlens
,
dropout_p
,
softmax_scale
,
causal
=
causal
,
return_softmax
=
return_softmax
max_seqlen
,
max_seqlen
,
dropout_p
,
softmax_scale
,
causal
=
causal
,
return_softmax
=
return_softmax
)
)
ctx
.
save_for_backward
(
qkv
,
out
,
softmax_lse
,
cu_seqlens
,
rng_state
)
ctx
.
save_for_backward
(
qkv
,
out
,
softmax_lse
,
cu_seqlens
,
rng_state
)
ctx
.
dropout_p
=
dropout_p
ctx
.
dropout_p
=
dropout_p
...
...
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