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
b47138dc
Commit
b47138dc
authored
Dec 29, 2021
by
Gustaf Ahdritz
Browse files
Fix TorchScripting bug, add command-line parameter for scripting
parent
e1142cf3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
openfold/model/primitives.py
openfold/model/primitives.py
+2
-1
train_openfold.py
train_openfold.py
+12
-7
No files found.
openfold/model/primitives.py
View file @
b47138dc
...
@@ -218,6 +218,7 @@ class Attention(nn.Module):
...
@@ -218,6 +218,7 @@ class Attention(nn.Module):
self
.
c_hidden
*
self
.
no_heads
,
self
.
c_q
,
init
=
"final"
self
.
c_hidden
*
self
.
no_heads
,
self
.
c_q
,
init
=
"final"
)
)
self
.
linear_g
=
None
if
self
.
gating
:
if
self
.
gating
:
self
.
linear_g
=
Linear
(
self
.
linear_g
=
Linear
(
self
.
c_q
,
self
.
c_hidden
*
self
.
no_heads
,
init
=
"gating"
self
.
c_q
,
self
.
c_hidden
*
self
.
no_heads
,
init
=
"gating"
...
@@ -282,7 +283,7 @@ class Attention(nn.Module):
...
@@ -282,7 +283,7 @@ class Attention(nn.Module):
# [*, Q, H, C_hidden]
# [*, Q, H, C_hidden]
o
=
o
.
transpose
(
-
2
,
-
3
)
o
=
o
.
transpose
(
-
2
,
-
3
)
if
self
.
gating
:
if
(
self
.
linear_g
is
not
None
)
:
g
=
self
.
sigmoid
(
self
.
linear_g
(
q_x
))
g
=
self
.
sigmoid
(
self
.
linear_g
(
q_x
))
# [*, Q, H, C_hidden]
# [*, Q, H, C_hidden]
g
=
g
.
view
(
g
.
shape
[:
-
1
]
+
(
self
.
no_heads
,
-
1
))
g
=
g
.
view
(
g
.
shape
[:
-
1
]
+
(
self
.
no_heads
,
-
1
))
...
...
train_openfold.py
View file @
b47138dc
...
@@ -2,7 +2,7 @@ import argparse
...
@@ -2,7 +2,7 @@ import argparse
import
logging
import
logging
import
os
import
os
#
os.environ["CUDA_VISIBLE_DEVICES"] = "5"
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
"
4,
5"
#os.environ["MASTER_ADDR"]="10.119.81.14"
#os.environ["MASTER_ADDR"]="10.119.81.14"
#os.environ["MASTER_PORT"]="42069"
#os.environ["MASTER_PORT"]="42069"
#os.environ["NODE_RANK"]="0"
#os.environ["NODE_RANK"]="0"
...
@@ -13,7 +13,7 @@ import time
...
@@ -13,7 +13,7 @@ import time
import
numpy
as
np
import
numpy
as
np
import
pytorch_lightning
as
pl
import
pytorch_lightning
as
pl
from
pytorch_lightning.callbacks.model_checkpoint
import
ModelCheckpoint
from
pytorch_lightning.callbacks.model_checkpoint
import
ModelCheckpoint
from
pytorch_lightning.plugins.training_type
import
DeepSpeedPlugin
from
pytorch_lightning.plugins.training_type
import
DeepSpeedPlugin
,
DDPPlugin
from
pytorch_lightning.plugins.environments
import
SLURMEnvironment
from
pytorch_lightning.plugins.environments
import
SLURMEnvironment
import
torch
import
torch
...
@@ -120,6 +120,7 @@ def main(args):
...
@@ -120,6 +120,7 @@ def main(args):
logging
.
info
(
"Successfully loaded model weights..."
)
logging
.
info
(
"Successfully loaded model weights..."
)
# TorchScript components of the model
# TorchScript components of the model
if
(
args
.
script_modules
):
script_preset_
(
model_module
)
script_preset_
(
model_module
)
#data_module = DummyDataLoader("batch.pickle")
#data_module = DummyDataLoader("batch.pickle")
...
@@ -172,7 +173,7 @@ def main(args):
...
@@ -172,7 +173,7 @@ def main(args):
cluster_environment
=
cluster_environment
,
cluster_environment
=
cluster_environment
,
)
)
elif
(
args
.
gpus
is
not
None
and
args
.
gpus
)
>
1
or
args
.
num_nodes
>
1
:
elif
(
args
.
gpus
is
not
None
and
args
.
gpus
)
>
1
or
args
.
num_nodes
>
1
:
strategy
=
"ddp"
strategy
=
DDPPlugin
(
find_unused_parameters
=
False
)
else
:
else
:
strategy
=
None
strategy
=
None
...
@@ -306,9 +307,13 @@ if __name__ == "__main__":
...
@@ -306,9 +307,13 @@ if __name__ == "__main__":
help
=
"Whether to load just model weights as opposed to training state"
help
=
"Whether to load just model weights as opposed to training state"
)
)
parser
.
add_argument
(
parser
.
add_argument
(
"--log_performance"
,
action
=
'store_true'
,
"--log_performance"
,
type
=
bool_type
,
default
=
False
,
help
=
"Measure performance"
help
=
"Measure performance"
)
)
parser
.
add_argument
(
"--script_modules"
,
type
=
bool_type
,
default
=
False
,
help
=
"Whether to TorchScript eligible components of them model"
)
parser
=
pl
.
Trainer
.
add_argparse_args
(
parser
)
parser
=
pl
.
Trainer
.
add_argparse_args
(
parser
)
# Disable the initial validation pass
# Disable the initial validation pass
...
...
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