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
6bbc5323
You need to sign in or sign up before continuing.
Unverified
Commit
6bbc5323
authored
Mar 15, 2024
by
Markus Krimmel
Committed by
GitHub
Mar 15, 2024
Browse files
fix: cast the alibi slopes to torch.float32 (#846)
parent
4a73e903
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
flash_attn/modules/mha.py
flash_attn/modules/mha.py
+4
-0
No files found.
flash_attn/modules/mha.py
View file @
6bbc5323
...
@@ -101,6 +101,8 @@ class FlashSelfAttention(nn.Module):
...
@@ -101,6 +101,8 @@ class FlashSelfAttention(nn.Module):
assert
qkv
.
is_cuda
assert
qkv
.
is_cuda
causal
=
self
.
causal
if
causal
is
None
else
causal
causal
=
self
.
causal
if
causal
is
None
else
causal
unpadded
=
cu_seqlens
is
not
None
unpadded
=
cu_seqlens
is
not
None
if
self
.
alibi_slopes
is
not
None
:
self
.
alibi_slopes
=
self
.
alibi_slopes
.
to
(
torch
.
float32
)
if
unpadded
:
if
unpadded
:
assert
cu_seqlens
.
dtype
==
torch
.
int32
assert
cu_seqlens
.
dtype
==
torch
.
int32
assert
max_seqlen
is
not
None
assert
max_seqlen
is
not
None
...
@@ -185,6 +187,8 @@ class FlashCrossAttention(nn.Module):
...
@@ -185,6 +187,8 @@ class FlashCrossAttention(nn.Module):
assert
q
.
is_cuda
and
kv
.
is_cuda
assert
q
.
is_cuda
and
kv
.
is_cuda
causal
=
self
.
causal
if
causal
is
None
else
causal
causal
=
self
.
causal
if
causal
is
None
else
causal
unpadded
=
cu_seqlens
is
not
None
unpadded
=
cu_seqlens
is
not
None
if
self
.
alibi_slopes
is
not
None
:
self
.
alibi_slopes
=
self
.
alibi_slopes
.
to
(
torch
.
float32
)
if
unpadded
:
if
unpadded
:
assert
cu_seqlens
.
dtype
==
torch
.
int32
assert
cu_seqlens
.
dtype
==
torch
.
int32
assert
max_seqlen
is
not
None
assert
max_seqlen
is
not
None
...
...
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