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
1d536d7d
"ppocr/vscode:/vscode.git/clone" did not exist on "62a01f7e30acfe739f008aa0870348ecfb6fcdff"
Commit
1d536d7d
authored
Jul 09, 2024
by
Tri Dao
Browse files
Minor cleanup of softcapping
parent
beb2bf2a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
12 deletions
+4
-12
csrc/flash_attn/flash_api.cpp
csrc/flash_attn/flash_api.cpp
+2
-2
csrc/flash_attn/src/flash_fwd_kernel.h
csrc/flash_attn/src/flash_fwd_kernel.h
+2
-10
No files found.
csrc/flash_attn/flash_api.cpp
View file @
1d536d7d
...
...
@@ -106,9 +106,9 @@ void set_params_fprop(Flash_fwd_params ¶ms,
#endif
if
(
softcap
>
0.0
)
{
params
.
softcap
=
softmax_scale
/
softcap
;
params
.
scale_softmax
=
softcap
;
params
.
scale_softmax
=
softcap
;
params
.
scale_softmax_log2
=
softcap
*
M_LOG2E
;
}
else
{
}
else
{
// Remove potential NaN
params
.
softcap
=
0.0
;
params
.
scale_softmax
=
softmax_scale
;
...
...
csrc/flash_attn/src/flash_fwd_kernel.h
View file @
1d536d7d
...
...
@@ -24,17 +24,9 @@ using namespace cute;
template
<
typename
Engine
,
typename
Layout
>
__forceinline__
__device__
void
apply_softcap
(
Tensor
<
Engine
,
Layout
>
&
tensor
,
const
float
softcap
){
static_assert
(
Layout
::
rank
==
3
,
"Only support 3D Tensor"
);
static_assert
(
decltype
(
size
<
0
>
(
tensor
))
::
value
==
4
,
"First dimension must be 4"
);
#pragma unroll
for
(
int
i
=
0
;
i
<
size
<
0
>
(
tensor
);
++
i
){
// MMA
#pragma unroll
for
(
int
mi
=
0
;
mi
<
size
<
1
>
(
tensor
);
++
mi
){
#pragma unroll
for
(
int
nj
=
0
;
nj
<
size
<
2
>
(
tensor
);
++
nj
){
tensor
(
i
,
mi
,
nj
)
=
cutlass
::
fast_tanh
(
tensor
(
i
,
mi
,
nj
)
*
softcap
);
}
}
for
(
int
i
=
0
;
i
<
size
(
tensor
);
++
i
)
{
tensor
(
i
)
=
cutlass
::
fast_tanh
(
tensor
(
i
)
*
softcap
);
}
}
...
...
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