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
8a634af2
Commit
8a634af2
authored
Jan 06, 2023
by
oahzxl
Browse files
close mem and code print
parent
1a6d2a74
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
7 deletions
+10
-7
colossalai/autochunk/autochunk_codegen.py
colossalai/autochunk/autochunk_codegen.py
+2
-2
colossalai/autochunk/chunk_region_search.py
colossalai/autochunk/chunk_region_search.py
+7
-4
tests/test_autochunk/benchmark_autochunk.py
tests/test_autochunk/benchmark_autochunk.py
+1
-1
No files found.
colossalai/autochunk/autochunk_codegen.py
View file @
8a634af2
...
@@ -214,13 +214,13 @@ def emit_code_with_chunk(
...
@@ -214,13 +214,13 @@ def emit_code_with_chunk(
if
CODEGEN_AVAILABLE
:
if
CODEGEN_AVAILABLE
:
class
AutoChunkCodeGen
(
CodeGen
):
class
AutoChunkCodeGen
(
CodeGen
):
def
__init__
(
self
,
meta_graph
,
max_memory
=
None
):
def
__init__
(
self
,
meta_graph
,
max_memory
=
None
,
print_mem
=
False
):
super
().
__init__
()
super
().
__init__
()
self
.
meta_graph
=
meta_graph
self
.
meta_graph
=
meta_graph
self
.
max_memory
=
max_memory
self
.
max_memory
=
max_memory
self
.
meta_node
=
list
(
meta_graph
.
graph
.
nodes
)
self
.
meta_node
=
list
(
meta_graph
.
graph
.
nodes
)
# find the chunk regions
# find the chunk regions
self
.
chunk_region_search
=
ChunkRegionSearch
(
meta_graph
,
max_memory
)
self
.
chunk_region_search
=
ChunkRegionSearch
(
meta_graph
,
max_memory
,
print_mem
)
self
.
chunk_infos
=
self
.
chunk_region_search
.
search_region
()
self
.
chunk_infos
=
self
.
chunk_region_search
.
search_region
()
def
_gen_python_code
(
def
_gen_python_code
(
...
...
colossalai/autochunk/chunk_region_search.py
View file @
8a634af2
...
@@ -6,8 +6,9 @@ from .utils import is_non_compute_node, is_non_compute_node_except_placeholder,
...
@@ -6,8 +6,9 @@ from .utils import is_non_compute_node, is_non_compute_node_except_placeholder,
class
ChunkRegionSearch
(
object
):
class
ChunkRegionSearch
(
object
):
def
__init__
(
self
,
gm
,
max_memory
=
None
)
->
None
:
def
__init__
(
self
,
gm
,
max_memory
=
None
,
print_mem
=
False
)
->
None
:
self
.
gm
=
gm
self
.
gm
=
gm
self
.
print_mem
=
print_mem
self
.
index_tracer
=
IndexTracer
(
list
(
gm
.
graph
.
nodes
))
self
.
index_tracer
=
IndexTracer
(
list
(
gm
.
graph
.
nodes
))
self
.
index_tracer
.
trace_index
()
self
.
index_tracer
.
trace_index
()
self
.
memory_estimator
=
MemoryEstimator
(
self
.
index_tracer
)
self
.
memory_estimator
=
MemoryEstimator
(
self
.
index_tracer
)
...
@@ -204,8 +205,10 @@ class ChunkRegionSearch(object):
...
@@ -204,8 +205,10 @@ class ChunkRegionSearch(object):
)
)
if
self
.
_stop_search
(
init_mem_peak
,
mem_peak
):
if
self
.
_stop_search
(
init_mem_peak
,
mem_peak
):
break
break
self
.
memory_estimator
.
estimate_chunk_inference_mem
(
if
self
.
print_mem
:
self
.
index_tracer
.
node_list
,
chunk_infos
,
print_mem
=
True
self
.
print_mem
=
False
)
self
.
memory_estimator
.
estimate_chunk_inference_mem
(
self
.
index_tracer
.
node_list
,
chunk_infos
,
print_mem
=
True
)
return
chunk_infos
return
chunk_infos
tests/test_autochunk/benchmark_autochunk.py
View file @
8a634af2
...
@@ -64,7 +64,7 @@ def _build_autochunk(model, max_memory, node, pair):
...
@@ -64,7 +64,7 @@ def _build_autochunk(model, max_memory, node, pair):
)
)
# set code_gen
# set code_gen
codegen
=
AutoChunkCodeGen
(
gm_prop
,
max_memory
)
codegen
=
AutoChunkCodeGen
(
gm_prop
,
max_memory
,
print_mem
=
False
)
graph
.
set_codegen
(
codegen
)
graph
.
set_codegen
(
codegen
)
gm
=
ColoGraphModule
(
model
,
graph
)
gm
=
ColoGraphModule
(
model
,
graph
)
gm
.
recompile
()
gm
.
recompile
()
...
...
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