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
ColossalAI
Commits
5a916c0a
Commit
5a916c0a
authored
Dec 29, 2022
by
oahzxl
Browse files
add print
parent
1d7ca023
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
autochunk_benchmark.py
autochunk_benchmark.py
+18
-18
No files found.
autochunk_benchmark.py
View file @
5a916c0a
import
copy
import
time
import
torch
import
torch.nn.functional
as
F
import
pytest
import
torch.fx
import
torch.multiprocessing
as
mp
from
torch.fx
import
GraphModule
from
chunk_codegen
import
ChunkCodeGen
from
colossalai.fx
import
ColoTracer
import
colossalai
from
colossalai.utils
import
free_port
from
colossalai.core
import
global_context
as
gpc
from
colossalai.fx.graph_module
import
ColoGraphModule
from
colossalai.fx.passes.meta_info_prop
import
MetaInfoProp
,
TensorMetadata
from
colossalai.fx.passes.meta_info_prop
import
MetaInfoProp
from
colossalai.fx.profiler
import
MetaTensor
from
evoformer.evoformer
import
evoformer_base
from
chunk_codegen
import
ChunkCodeGen
import
time
def
_benchmark_evoformer
(
model
:
torch
.
nn
.
Module
,
node
,
pair
):
loop
=
10
def
_benchmark_evoformer
(
model
:
torch
.
nn
.
Module
,
node
,
pair
,
title
):
torch
.
cuda
.
reset_peak_memory_stats
()
now_mem
=
torch
.
cuda
.
memory_allocated
()
/
1024
**
2
loop
=
16
with
torch
.
no_grad
():
for
_
in
range
(
loop
//
4
):
model
(
node
,
pair
)
...
...
@@ -28,7 +25,12 @@ def _benchmark_evoformer(model: torch.nn.Module, node, pair):
model
(
node
,
pair
)
torch
.
cuda
.
synchronize
()
time2
=
time
.
time
()
return
(
time2
-
time1
)
/
loop
new_max_mem
=
torch
.
cuda
.
max_memory_allocated
()
/
1024
**
2
print
(
"%s: time %.4fs, mem %dMB"
%
(
title
,
(
time2
-
time1
)
/
loop
,
new_max_mem
-
now_mem
)
)
def
benchmark_evoformer
():
...
...
@@ -69,10 +71,8 @@ def benchmark_evoformer():
code
=
graph
.
python_code
(
"self"
).
src
print
(
code
)
time_gm
=
_benchmark_evoformer
(
gm
,
node
,
pair
)
print
(
"gm %.4fs"
%
time_gm
)
time_openfold
=
_benchmark_evoformer
(
model
,
node
,
pair
)
print
(
"openfold %.4fs"
%
time_openfold
)
_benchmark_evoformer
(
gm
,
node
,
pair
,
"autochunk"
)
_benchmark_evoformer
(
model
,
node
,
pair
,
"openfold"
)
if
__name__
==
"__main__"
:
...
...
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