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
9b861808
Commit
9b861808
authored
Jul 19, 2022
by
Gustaf Ahdritz
Browse files
Make DeepSpeed optional
parent
15b75e49
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
openfold/utils/checkpointing.py
openfold/utils/checkpointing.py
+9
-2
No files found.
openfold/utils/checkpointing.py
View file @
9b861808
...
@@ -12,7 +12,10 @@
...
@@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
deepspeed
deepspeed_is_installed
=
importlib
.
util
.
find_spec
(
"deepspeed"
)
is
not
None
if
(
deepspeed_is_installed
):
import
deepspeed
import
torch
import
torch
import
torch.utils.checkpoint
import
torch.utils.checkpoint
from
typing
import
Any
,
Tuple
,
List
,
Callable
,
Optional
from
typing
import
Any
,
Tuple
,
List
,
Callable
,
Optional
...
@@ -23,7 +26,11 @@ BLOCK_ARGS = List[BLOCK_ARG]
...
@@ -23,7 +26,11 @@ BLOCK_ARGS = List[BLOCK_ARG]
def
get_checkpoint_fn
():
def
get_checkpoint_fn
():
if
(
deepspeed
.
checkpointing
.
is_configured
()):
deepspeed_is_configured
=
(
deepspeed_is_installed
and
deepspeed
.
checkpointing
.
is_configured
()
)
if
(
deepspeed_is_configured
):
checkpoint
=
deepspeed
.
checkpointing
.
checkpoint
checkpoint
=
deepspeed
.
checkpointing
.
checkpoint
else
:
else
:
checkpoint
=
torch
.
utils
.
checkpoint
.
checkpoint
checkpoint
=
torch
.
utils
.
checkpoint
.
checkpoint
...
...
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