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
OpenDAS
OpenFold
Commits
a0985761
"runtime/rust/vscode:/vscode.git/clone" did not exist on "7f85dcc3f616d5d4a77ccb89bf7e5f1abe9888c9"
Commit
a0985761
authored
Oct 03, 2023
by
Christina Floristean
Browse files
Remove scale when using ds kernel
parent
6ebcd8b4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
openfold/model/primitives.py
openfold/model/primitives.py
+7
-3
run_pretrained_openfold.py
run_pretrained_openfold.py
+1
-1
tests/test_deepspeed_evo_attention.py
tests/test_deepspeed_evo_attention.py
+1
-3
No files found.
openfold/model/primitives.py
View file @
a0985761
...
...
@@ -379,7 +379,8 @@ class Attention(nn.Module):
def
_prep_qkv
(
self
,
q_x
:
torch
.
Tensor
,
kv_x
:
torch
.
Tensor
,
transpose_qkv_dims
:
bool
=
True
transpose_qkv_dims
:
bool
=
True
,
apply_scale
:
bool
=
True
)
->
Tuple
[
torch
.
Tensor
,
torch
.
Tensor
,
torch
.
Tensor
]:
...
...
@@ -399,7 +400,8 @@ class Attention(nn.Module):
k
=
k
.
transpose
(
-
2
,
-
3
)
v
=
v
.
transpose
(
-
2
,
-
3
)
q
/=
math
.
sqrt
(
self
.
c_hidden
)
if
apply_scale
:
q
/=
math
.
sqrt
(
self
.
c_hidden
)
return
q
,
k
,
v
...
...
@@ -486,7 +488,9 @@ class Attention(nn.Module):
# DeepSpeed attention kernel expects Q/K/V of shape [*, Q/K, H, C_hidden]
# All other attention modules expect Q/K/V of shape [*, H, Q/K, C_hidden]
q
,
k
,
v
=
self
.
_prep_qkv
(
q_x
,
kv_x
,
transpose_qkv_dims
=
not
use_deepspeed_evo_attention
)
q
,
k
,
v
=
self
.
_prep_qkv
(
q_x
,
kv_x
,
transpose_qkv_dims
=
not
use_deepspeed_evo_attention
,
apply_scale
=
not
use_deepspeed_evo_attention
)
if
is_fp16_enabled
():
use_memory_efficient_kernel
=
False
...
...
run_pretrained_openfold.py
View file @
a0985761
...
...
@@ -355,7 +355,7 @@ if __name__ == "__main__":
help
=
"""Postfix for output prediction filenames"""
)
parser
.
add_argument
(
"--data_random_seed"
,
type
=
str
,
default
=
None
"--data_random_seed"
,
type
=
int
,
default
=
None
)
parser
.
add_argument
(
"--skip_relaxation"
,
action
=
"store_true"
,
default
=
False
,
...
...
tests/test_deepspeed_evo_attention.py
View file @
a0985761
...
...
@@ -15,9 +15,6 @@
"""
Unit tests to compare components of OpenFold run with the DeepSpeed memory-efficient
attention kernel, DS4Sci_EvoformerAttention vs. a stock PyTorch attention implementation.
Note: Some tests are temporarily disabled while we investigate discrepancies related
to using fused attention.
"""
import
torch
...
...
@@ -159,6 +156,7 @@ class TestDeepSpeedKernel(unittest.TestCase):
with
torch
.
no_grad
():
with
torch
.
cuda
.
amp
.
autocast
(
dtype
=
torch
.
bfloat16
):
model
=
compare_utils
.
get_global_pretrained_openfold
()
model
.
globals
.
use_deepspeed_evo_attention
=
False
out_repro
=
model
(
batch
)
# Enable kernel
...
...
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