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
b4b6e903
Unverified
Commit
b4b6e903
authored
Aug 25, 2023
by
Aman Gupta Karmani
Committed by
GitHub
Aug 25, 2023
Browse files
add benchmark for xformers fa2 wrapper (#492)
parent
45ba93cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
benchmarks/benchmark_flash_attention.py
benchmarks/benchmark_flash_attention.py
+15
-3
No files found.
benchmarks/benchmark_flash_attention.py
View file @
b4b6e903
...
...
@@ -79,7 +79,8 @@ dropout_p = 0.0
methods
=
([
"Flash2"
,
"Pytorch"
]
+
([
"Triton"
]
if
attention_triton
is
not
None
else
[])
+
([
"xformers"
]
if
xops
is
not
None
else
[]))
+
([
"xformers.c"
]
if
xops
is
not
None
else
[])
+
([
"xformers.f"
]
if
xops
is
not
None
else
[]))
time_f
=
{}
time_b
=
{}
...
...
@@ -139,8 +140,19 @@ for causal in causal_vals:
attn_bias
=
xops
.
LowerTriangularMask
()
if
causal
else
None
,
op
=
(
xops
.
fmha
.
cutlass
.
FwOp
,
xops
.
fmha
.
cutlass
.
BwOp
)
)
time_f
[
config
,
"xformers"
]
=
f
time_b
[
config
,
"xformers"
]
=
b
time_f
[
config
,
"xformers.c"
]
=
f
time_b
[
config
,
"xformers.c"
]
=
b
if
xops
is
not
None
:
q
,
k
,
v
=
[
torch
.
randn
(
batch_size
,
seqlen
,
nheads
,
headdim
,
device
=
device
,
dtype
=
dtype
,
requires_grad
=
True
)
for
_
in
range
(
3
)]
f
,
b
=
time_fwd_bwd
(
xops
.
memory_efficient_attention
,
q
,
k
,
v
,
attn_bias
=
xops
.
LowerTriangularMask
()
if
causal
else
None
,
op
=
(
xops
.
fmha
.
flash
.
FwOp
,
xops
.
fmha
.
flash
.
BwOp
)
)
time_f
[
config
,
"xformers.f"
]
=
f
time_b
[
config
,
"xformers.f"
]
=
b
print
(
f
"### causal=
{
causal
}
, headdim=
{
headdim
}
, batch_size=
{
batch_size
}
, seqlen=
{
seqlen
}
###"
)
for
method
in
methods
:
...
...
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