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
65f723bb
"vscode:/vscode.git/clone" did not exist on "39b8e4430ebe84c409163b9970145b0d7d53a36c"
Commit
65f723bb
authored
Jul 23, 2024
by
Tri Dao
Browse files
Split bwd into more .cu files to speed up compilation
parent
5ca83a9c
Changes
89
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
121 additions
and
29 deletions
+121
-29
csrc/flash_attn/flash_api.cpp
csrc/flash_attn/flash_api.cpp
+3
-1
csrc/flash_attn/src/flash.h
csrc/flash_attn/src/flash.h
+1
-1
csrc/flash_attn/src/flash_bwd_hdim128_bf16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim128_bf16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim128_bf16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim128_bf16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim128_fp16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim128_fp16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim128_fp16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim128_fp16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim160_bf16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim160_bf16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim160_bf16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim160_bf16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim160_fp16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim160_fp16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim160_fp16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim160_fp16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim192_bf16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim192_bf16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim192_bf16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim192_bf16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim192_fp16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim192_fp16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim192_fp16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim192_fp16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim256_bf16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim256_bf16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim256_bf16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim256_bf16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim256_fp16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim256_fp16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim256_fp16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim256_fp16_sm80.cu
+3
-3
csrc/flash_attn/src/flash_bwd_hdim32_bf16_causal_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim32_bf16_causal_sm80.cu
+10
-0
csrc/flash_attn/src/flash_bwd_hdim32_bf16_sm80.cu
csrc/flash_attn/src/flash_bwd_hdim32_bf16_sm80.cu
+3
-3
No files found.
csrc/flash_attn/flash_api.cpp
View file @
65f723bb
...
...
@@ -800,7 +800,9 @@ mha_varlen_fwd(at::Tensor &q, // total_q x num_heads x head_size, total_q := \s
void
run_mha_bwd
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
FP16_SWITCH
(
!
params
.
is_bf16
,
[
&
]
{
HEADDIM_SWITCH
(
params
.
d
,
[
&
]
{
run_mha_bwd_
<
elem_type
,
kHeadDim
>
(
params
,
stream
);
BOOL_SWITCH
(
params
.
is_causal
,
Is_causal
,
[
&
]
{
run_mha_bwd_
<
elem_type
,
kHeadDim
,
Is_causal
>
(
params
,
stream
);
});
});
});
}
...
...
csrc/flash_attn/src/flash.h
View file @
65f723bb
...
...
@@ -192,4 +192,4 @@ struct Flash_bwd_params : public Flash_fwd_params {
template
<
typename
T
,
int
Headdim
,
bool
Is_causal
>
void
run_mha_fwd_
(
Flash_fwd_params
&
params
,
cudaStream_t
stream
);
template
<
typename
T
,
int
Headdim
,
bool
Is_causal
>
void
run_mha_fwd_splitkv_dispatch
(
Flash_fwd_params
&
params
,
cudaStream_t
stream
);
template
<
typename
T
,
int
Headdim
>
void
run_mha_bwd_
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
);
template
<
typename
T
,
int
Headdim
,
bool
Is_causal
>
void
run_mha_bwd_
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
);
csrc/flash_attn/src/flash_bwd_hdim128_bf16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
128
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim128
<
cutlass
::
bfloat16_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim128_bf16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
128
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim128
<
cutlass
::
bfloat16_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
128
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim128
<
cutlass
::
bfloat16_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim128_fp16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
128
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim128
<
cutlass
::
half_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim128_fp16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
128
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim128
<
cutlass
::
half_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
half_t
,
128
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim128
<
cutlass
::
half_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim160_bf16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
160
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim160
<
cutlass
::
bfloat16_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim160_bf16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
160
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim160
<
cutlass
::
bfloat16_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
160
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim160
<
cutlass
::
bfloat16_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim160_fp16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
160
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim160
<
cutlass
::
half_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim160_fp16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
160
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim160
<
cutlass
::
half_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
half_t
,
160
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim160
<
cutlass
::
half_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim192_bf16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
192
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim192
<
cutlass
::
bfloat16_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim192_bf16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
192
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim192
<
cutlass
::
bfloat16_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
192
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim192
<
cutlass
::
bfloat16_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim192_fp16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
192
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim192
<
cutlass
::
half_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim192_fp16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
192
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim192
<
cutlass
::
half_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
half_t
,
192
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim192
<
cutlass
::
half_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim256_bf16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
256
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim256
<
cutlass
::
bfloat16_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim256_bf16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
256
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim256
<
cutlass
::
bfloat16_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
256
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim256
<
cutlass
::
bfloat16_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim256_fp16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
256
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim256
<
cutlass
::
half_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim256_fp16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
half_t
,
256
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim256
<
cutlass
::
half_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
half_t
,
256
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim256
<
cutlass
::
half_t
,
false
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim32_bf16_causal_sm80.cu
0 → 100644
View file @
65f723bb
// Copyright (c) 2024, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
32
,
true
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim32
<
cutlass
::
bfloat16_t
,
true
>
(
params
,
stream
);
}
csrc/flash_attn/src/flash_bwd_hdim32_bf16_sm80.cu
View file @
65f723bb
// Copyright (c) 202
3
, Tri Dao.
// Copyright (c) 202
4
, Tri Dao.
// Splitting the different head dimensions to different files to speed up compilation.
// This file is auto-generated. See "generate_kernels.py"
#include "flash_bwd_launch_template.h"
template
<
>
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
32
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim32
<
cutlass
::
bfloat16_t
>
(
params
,
stream
);
void
run_mha_bwd_
<
cutlass
::
bfloat16_t
,
32
,
false
>
(
Flash_bwd_params
&
params
,
cudaStream_t
stream
)
{
run_mha_bwd_hdim32
<
cutlass
::
bfloat16_t
,
false
>
(
params
,
stream
);
}
Prev
1
2
3
4
5
Next
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