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
0dea1407
Unverified
Commit
0dea1407
authored
Apr 24, 2022
by
ver217
Committed by
GitHub
Apr 24, 2022
Browse files
[hotfix] add deconstructor for stateful tensor (#848)
* add deconstructor for stateful tensor * fix colo init context
parent
0f7ed8c1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
12 deletions
+20
-12
colossalai/gemini/gemini_context.py
colossalai/gemini/gemini_context.py
+14
-11
colossalai/gemini/stateful_tensor.py
colossalai/gemini/stateful_tensor.py
+5
-0
colossalai/utils/model/colo_init_context.py
colossalai/utils/model/colo_init_context.py
+1
-1
No files found.
colossalai/gemini/gemini_context.py
View file @
0dea1407
...
...
@@ -33,13 +33,16 @@ class GeminiMemoryManager(object):
def
register_new_instance
(
self
):
self
.
_cnter
+=
1
def
delete_instance
(
self
):
self
.
_cnter
-=
1
def
print_info
(
self
):
print
(
f
"Total number:
{
self
.
total_number
}
"
,
print
(
f
"Total number:
{
self
.
total_number
}
"
,
f
"Total CPU memory occupation:
{
self
.
total_mem
[
'cpu'
]
}
"
,
f
"Total CUDA memory occupation:
{
self
.
total_mem
[
'cuda'
]
}
\n
"
,
sep
=
'
\n
'
)
f
"Total CUDA memory occupation:
{
self
.
total_mem
[
'cuda'
]
}
\n
"
,
sep
=
'
\n
'
)
for
state
in
self
.
states_cls
:
print
(
f
"
{
state
}
: C
P
U memory occupation:
{
self
.
state_mem
[
'c
p
u'
][
state
]
}
"
,
f
"
{
state
}
: CUDA memory occupation:
{
self
.
state_mem
[
'cuda'
][
state
]
}
\n
"
,
sep
=
'
\n
'
)
print
(
f
"
{
state
}
: CPU memory occupation:
{
self
.
state_mem
[
'cpu'
][
state
]
}
"
,
f
"
{
state
}
: CU
DA
memory occupation:
{
self
.
state_mem
[
'cu
da
'
][
state
]
}
\n
"
,
sep
=
'
\n
'
)
colossalai/gemini/stateful_tensor.py
View file @
0dea1407
...
...
@@ -202,3 +202,8 @@ class StatefulTensor(object):
# update the information of each state
manager
.
state_mem
[
from_type
][
state
]
-=
size
manager
.
state_mem
[
to_type
][
state
]
+=
size
def
__del__
(
self
):
self
.
set_null
()
StatefulTensor
.
GST_MGR
.
delete_instance
()
del
self
colossalai/utils/model/colo_init_context.py
View file @
0dea1407
...
...
@@ -12,7 +12,7 @@ class ColoInitContext(InsertPostInitMethodToModuleSubClasses):
super
().
__init__
()
self
.
_lazy_memory_allocate
=
lazy_memory_allocate
def
_post_init_method
(
self
,
module
:
torch
.
nn
.
Module
):
def
_post_init_method
(
self
,
module
:
torch
.
nn
.
Module
,
*
args
,
**
kwargs
):
"""
The function to call at the end of the constructor of each module.
FIXME(fjr) The module may be passed to this function multiple times?
...
...
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