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
da407684
Commit
da407684
authored
Jan 06, 2023
by
oahzxl
Browse files
rename
parent
c3d72f7d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
20 deletions
+19
-20
colossalai/autochunk/autochunk_codegen.py
colossalai/autochunk/autochunk_codegen.py
+3
-3
colossalai/autochunk/estiamte_memory.py
colossalai/autochunk/estiamte_memory.py
+1
-2
colossalai/autochunk/search_chunk.py
colossalai/autochunk/search_chunk.py
+7
-7
colossalai/autochunk/select_chunk.py
colossalai/autochunk/select_chunk.py
+5
-5
colossalai/autochunk/trace_index.py
colossalai/autochunk/trace_index.py
+2
-2
tests/test_autochunk/benchmark_autochunk.py
tests/test_autochunk/benchmark_autochunk.py
+1
-1
No files found.
colossalai/autochunk/autochunk_codegen.py
View file @
da407684
...
@@ -17,7 +17,7 @@ from torch.fx.node import Argument, Node, _get_qualified_name, _type_repr, map_a
...
@@ -17,7 +17,7 @@ from torch.fx.node import Argument, Node, _get_qualified_name, _type_repr, map_a
import
colossalai
import
colossalai
from
.
chunk_region_search
import
ChunkRegion
Search
from
.
search_chunk
import
Search
Chunk
from
.utils
import
delete_free_var_from_last_use
,
find_idx_by_name
,
get_node_shape
from
.utils
import
delete_free_var_from_last_use
,
find_idx_by_name
,
get_node_shape
CODEGEN_AVAILABLE
=
True
CODEGEN_AVAILABLE
=
True
...
@@ -103,7 +103,7 @@ def emit_code_with_chunk(
...
@@ -103,7 +103,7 @@ def emit_code_with_chunk(
nodes
,
nodes
,
emit_node_func
,
emit_node_func
,
delete_unused_value_func
,
delete_unused_value_func
,
chunk_region_search
:
ChunkRegion
Search
,
chunk_region_search
:
Search
Chunk
,
chunk_infos
,
chunk_infos
,
):
):
"""Emit code with nested activation checkpoint
"""Emit code with nested activation checkpoint
...
@@ -220,7 +220,7 @@ if CODEGEN_AVAILABLE:
...
@@ -220,7 +220,7 @@ if CODEGEN_AVAILABLE:
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
=
ChunkRegion
Search
(
self
.
chunk_region_search
=
Search
Chunk
(
meta_graph
,
max_memory
,
print_mem
meta_graph
,
max_memory
,
print_mem
)
)
self
.
chunk_infos
=
self
.
chunk_region_search
.
search_region
()
self
.
chunk_infos
=
self
.
chunk_region_search
.
search_region
()
...
...
colossalai/autochunk/
memory_
estiamtor.py
→
colossalai/autochunk/estiamt
e_mem
or
y
.py
View file @
da407684
...
@@ -6,7 +6,6 @@ from torch.fx.node import Node, map_arg
...
@@ -6,7 +6,6 @@ from torch.fx.node import Node, map_arg
from
colossalai.fx.profiler
import
activation_size
,
parameter_size
from
colossalai.fx.profiler
import
activation_size
,
parameter_size
from
.index_tracer
import
IndexTracer
from
.utils
import
(
from
.utils
import
(
delete_free_var_from_last_use
,
delete_free_var_from_last_use
,
find_idx_by_name
,
find_idx_by_name
,
...
@@ -15,7 +14,7 @@ from .utils import (
...
@@ -15,7 +14,7 @@ from .utils import (
)
)
class
Memory
Estimator
(
object
):
class
Estimat
eMem
or
y
(
object
):
def
__init__
(
self
)
->
None
:
def
__init__
(
self
)
->
None
:
pass
pass
...
...
colossalai/autochunk/
chunk_region_
search.py
→
colossalai/autochunk/search
_chunk
.py
View file @
da407684
import
copy
import
copy
from
.
chunk_selector
import
Chunk
Select
or
from
.
select_chunk
import
Select
Chunk
from
.
index_tracer
import
IndexTracer
,
ReorderGraph
from
.
trace_index
import
TraceIndex
,
ReorderGraph
from
.
memory_
estiamtor
import
Memory
Estimator
from
.estiamt
e_mem
or
y
import
Estimat
eMem
or
y
from
.utils
import
(
from
.utils
import
(
get_node_shape
,
get_node_shape
,
is_non_compute_node
,
is_non_compute_node
,
...
@@ -10,15 +10,15 @@ from .utils import (
...
@@ -10,15 +10,15 @@ from .utils import (
)
)
class
ChunkRegion
Search
(
object
):
class
Search
Chunk
(
object
):
def
__init__
(
self
,
gm
,
max_memory
=
None
,
print_mem
=
False
)
->
None
:
def
__init__
(
self
,
gm
,
max_memory
=
None
,
print_mem
=
False
)
->
None
:
self
.
gm
=
gm
self
.
gm
=
gm
self
.
print_mem
=
print_mem
self
.
print_mem
=
print_mem
self
.
index_tracer
=
Index
Tracer
(
list
(
gm
.
graph
.
nodes
))
self
.
index_tracer
=
Trace
Index
(
list
(
gm
.
graph
.
nodes
))
self
.
index_tracer
.
trace_index
()
self
.
index_tracer
.
trace_index
()
self
.
reorder_graph
=
ReorderGraph
(
self
.
index_tracer
)
self
.
reorder_graph
=
ReorderGraph
(
self
.
index_tracer
)
self
.
memory_estimator
=
Memory
Estimator
()
self
.
memory_estimator
=
Estimat
eMem
or
y
()
self
.
chunk_selector
=
Chunk
Select
or
(
self
.
chunk_selector
=
Select
Chunk
(
self
.
index_tracer
,
self
.
memory_estimator
,
self
.
reorder_graph
,
max_memory
=
max_memory
self
.
index_tracer
,
self
.
memory_estimator
,
self
.
reorder_graph
,
max_memory
=
max_memory
)
)
...
...
colossalai/autochunk/
chunk_selector
.py
→
colossalai/autochunk/
select_chunk
.py
View file @
da407684
from
.
index_tracer
import
IndexTracer
,
ReorderGraph
from
.
trace_index
import
TraceIndex
,
ReorderGraph
from
.
memory_
estiamtor
import
Memory
Estimator
from
.estiamt
e_mem
or
y
import
Estimat
eMem
or
y
from
.utils
import
is_non_compute_node
from
.utils
import
is_non_compute_node
class
Chunk
Select
or
(
object
):
class
Select
Chunk
(
object
):
def
__init__
(
def
__init__
(
self
,
self
,
index_tracer
:
Index
Tracer
,
index_tracer
:
Trace
Index
,
memory_estimator
:
Memory
Estimator
,
memory_estimator
:
Estimat
eMem
or
y
,
reorder_graph
:
ReorderGraph
,
reorder_graph
:
ReorderGraph
,
max_memory
=
None
,
max_memory
=
None
,
):
):
...
...
colossalai/autochunk/
index_tracer
.py
→
colossalai/autochunk/
trace_index
.py
View file @
da407684
...
@@ -10,7 +10,7 @@ from .utils import (
...
@@ -10,7 +10,7 @@ from .utils import (
)
)
class
Index
Tracer
(
object
):
class
Trace
Index
(
object
):
def
__init__
(
self
,
node_list
)
->
None
:
def
__init__
(
self
,
node_list
)
->
None
:
self
.
node_list
=
node_list
self
.
node_list
=
node_list
self
.
idx_trace_list
=
self
.
_init_idx_trace_list
()
self
.
idx_trace_list
=
self
.
_init_idx_trace_list
()
...
@@ -982,7 +982,7 @@ class IndexTracer(object):
...
@@ -982,7 +982,7 @@ class IndexTracer(object):
class
ReorderGraph
(
object
):
class
ReorderGraph
(
object
):
def
__init__
(
self
,
index_tracer
:
Index
Tracer
)
->
None
:
def
__init__
(
self
,
index_tracer
:
Trace
Index
)
->
None
:
self
.
index_tracer
=
index_tracer
self
.
index_tracer
=
index_tracer
self
.
all_reorder_map
=
{
i
:
i
for
i
in
range
(
len
(
self
.
index_tracer
.
idx_trace_list
))}
self
.
all_reorder_map
=
{
i
:
i
for
i
in
range
(
len
(
self
.
index_tracer
.
idx_trace_list
))}
...
...
tests/test_autochunk/benchmark_autochunk.py
View file @
da407684
...
@@ -104,7 +104,7 @@ def benchmark_evoformer():
...
@@ -104,7 +104,7 @@ def benchmark_evoformer():
model
=
evoformer_base
().
cuda
()
model
=
evoformer_base
().
cuda
()
# build autochunk model
# build autochunk model
# max_memory = 1000
0
# MB fit memory mode
# max_memory = 1000 # MB fit memory mode
max_memory
=
None
# min memory mode
max_memory
=
None
# min memory mode
autochunk
=
_build_autochunk
(
evoformer_base
().
cuda
(),
max_memory
,
node
,
pair
)
autochunk
=
_build_autochunk
(
evoformer_base
().
cuda
(),
max_memory
,
node
,
pair
)
...
...
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