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
3a4ed753
Commit
3a4ed753
authored
Apr 02, 2024
by
Jennifer
Browse files
Removes OF copy of zero_to_fp32.py favoring deepspeed.util version
parent
e4f9af23
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
608 deletions
+19
-608
scripts/convert_v1_to_v2_weights.py
scripts/convert_v1_to_v2_weights.py
+3
-1
scripts/zero_to_fp32.py
scripts/zero_to_fp32.py
+0
-598
train_openfold.py
train_openfold.py
+16
-9
No files found.
scripts/convert_v1_to_v2_weights.py
View file @
3a4ed753
...
@@ -22,7 +22,9 @@ import shutil
...
@@ -22,7 +22,9 @@ import shutil
import
torch
import
torch
from
openfold.utils.import_weights
import
convert_deprecated_v1_keys
from
openfold.utils.import_weights
import
convert_deprecated_v1_keys
from
zero_to_fp32
import
get_optim_files
,
parse_optim_states
,
get_model_state_file
from
deepspeed.utils.zero_to_fp32
import
(
get_optim_files
,
parse_optim_states
,
get_model_state_file
)
def
convert_v1_to_v2_weights
(
args
):
def
convert_v1_to_v2_weights
(
args
):
...
...
scripts/zero_to_fp32.py
deleted
100755 → 0
View file @
e4f9af23
This diff is collapsed.
Click to expand it.
train_openfold.py
View file @
3a4ed753
...
@@ -14,6 +14,7 @@ from pytorch_lightning.plugins.environments import MPIEnvironment
...
@@ -14,6 +14,7 @@ from pytorch_lightning.plugins.environments import MPIEnvironment
from
pytorch_lightning
import
seed_everything
from
pytorch_lightning
import
seed_everything
import
torch
import
torch
import
wandb
import
wandb
from
deepspeed.utils
import
zero_to_fp32
from
openfold.config
import
model_config
from
openfold.config
import
model_config
from
openfold.data.data_modules
import
OpenFoldDataModule
,
OpenFoldMultimerDataModule
from
openfold.data.data_modules
import
OpenFoldDataModule
,
OpenFoldMultimerDataModule
...
@@ -39,11 +40,6 @@ from openfold.utils.import_weights import (
...
@@ -39,11 +40,6 @@ from openfold.utils.import_weights import (
import_jax_weights_
,
import_jax_weights_
,
import_openfold_weights_
import_openfold_weights_
)
)
from
scripts.zero_to_fp32
import
(
get_fp32_state_dict_from_zero_checkpoint
,
get_global_step_from_zero_checkpoint
)
from
openfold.utils.logger
import
PerformanceLoggingCallback
from
openfold.utils.logger
import
PerformanceLoggingCallback
...
@@ -276,6 +272,18 @@ class OpenFoldWrapper(pl.LightningModule):
...
@@ -276,6 +272,18 @@ class OpenFoldWrapper(pl.LightningModule):
self
.
model
,
jax_path
,
version
=
model_version
self
.
model
,
jax_path
,
version
=
model_version
)
)
def
get_model_state_dict_from_ds_checkpoint
(
checkpoint_dir
):
latest_path
=
os
.
path
.
join
(
checkpoint_dir
,
'latest'
)
if
os
.
path
.
isfile
(
latest_path
):
with
open
(
latest_path
,
'r'
)
as
fd
:
tag
=
fd
.
read
().
strip
()
else
:
raise
ValueError
(
f
"Unable to find 'latest' file at
{
latest_path
}
"
)
ds_checkpoint_dir
=
os
.
path
.
join
(
checkpoint_dir
,
tag
)
_DS_CHECKPOINT_VERSION
=
2
# based on manual parsing of checkpoint files
state_file
=
zero_to_fp32
.
get_model_state_file
(
ds_checkpoint_dir
,
_DS_CHECKPOINT_VERSION
)
return
torch
.
load
(
state_file
)
def
main
(
args
):
def
main
(
args
):
if
(
args
.
seed
is
not
None
):
if
(
args
.
seed
is
not
None
):
...
@@ -297,7 +305,7 @@ def main(args):
...
@@ -297,7 +305,7 @@ def main(args):
if
args
.
resume_model_weights_only
:
if
args
.
resume_model_weights_only
:
# Load the checkpoint
# Load the checkpoint
if
os
.
path
.
isdir
(
args
.
resume_from_ckpt
):
if
os
.
path
.
isdir
(
args
.
resume_from_ckpt
):
sd
=
get_fp32_state_dict_from_zero_checkpoint
(
sd
=
zero_to_fp32
.
get_fp32_state_dict_from_zero_checkpoint
(
args
.
resume_from_ckpt
)
args
.
resume_from_ckpt
)
else
:
else
:
sd
=
torch
.
load
(
args
.
resume_from_ckpt
)
sd
=
torch
.
load
(
args
.
resume_from_ckpt
)
...
@@ -316,8 +324,7 @@ def main(args):
...
@@ -316,8 +324,7 @@ def main(args):
else
:
# Loads a checkpoint to start from a specific time step
else
:
# Loads a checkpoint to start from a specific time step
if
os
.
path
.
isdir
(
args
.
resume_from_ckpt
):
if
os
.
path
.
isdir
(
args
.
resume_from_ckpt
):
last_global_step
=
get_global_step_from_zero_checkpoint
(
sd
=
get_model_state_dict_from_ds_checkpoint
(
args
.
resume_from_ckpt
)
args
.
resume_from_ckpt
)
else
:
else
:
sd
=
torch
.
load
(
args
.
resume_from_ckpt
)
sd
=
torch
.
load
(
args
.
resume_from_ckpt
)
last_global_step
=
int
(
sd
[
'global_step'
])
last_global_step
=
int
(
sd
[
'global_step'
])
...
...
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