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
5d5031e9
Unverified
Commit
5d5031e9
authored
Jul 28, 2022
by
ver217
Committed by
GitHub
Jul 28, 2022
Browse files
fix zero ddp state dict (#1378)
parent
0c1a16ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
colossalai/nn/parallel/data_parallel.py
colossalai/nn/parallel/data_parallel.py
+5
-1
No files found.
colossalai/nn/parallel/data_parallel.py
View file @
5d5031e9
...
@@ -314,14 +314,18 @@ class ZeroDDP(ColoDDP):
...
@@ -314,14 +314,18 @@ class ZeroDDP(ColoDDP):
module
module
"""
"""
chunks
=
self
.
chunk_manager
.
get_chunks
(
self
.
fp32_params
)
chunks
=
self
.
chunk_manager
.
get_chunks
(
self
.
fp32_params
)
chunks_orig_device_type
=
[]
for
chunk
in
chunks
:
for
chunk
in
chunks
:
chunks_orig_device_type
.
append
(
chunk
.
device_type
)
self
.
chunk_manager
.
access_chunk
(
chunk
)
self
.
chunk_manager
.
access_chunk
(
chunk
)
for
(
name
,
p
),
fp32_p
in
zip
(
self
.
named_parameters
(),
self
.
fp32_params
):
for
(
name
,
p
),
fp32_p
in
zip
(
self
.
named_parameters
(),
self
.
fp32_params
):
if
p
is
not
None
:
if
p
is
not
None
:
rec_p
=
fp32_p
.
clone
()
if
fp32_p
.
device
.
type
==
'cpu'
else
fp32_p
.
cpu
()
rec_p
=
fp32_p
.
clone
()
if
fp32_p
.
device
.
type
==
'cpu'
else
fp32_p
.
cpu
()
destination
[
prefix
+
name
]
=
rec_p
if
keep_vars
else
rec_p
.
detach
()
destination
[
prefix
+
name
]
=
rec_p
if
keep_vars
else
rec_p
.
detach
()
for
chunk
in
chunks
:
for
orig_dvice_type
,
chunk
in
zip
(
chunks
_orig_device_type
,
chunks
)
:
self
.
chunk_manager
.
release_chunk
(
chunk
)
self
.
chunk_manager
.
release_chunk
(
chunk
)
if
not
chunk
.
is_empty
and
orig_dvice_type
==
'cpu'
:
self
.
chunk_manager
.
move_chunk
(
chunk
,
torch
.
device
(
'cpu'
))
for
name
,
buf
in
self
.
named_buffers
():
for
name
,
buf
in
self
.
named_buffers
():
if
buf
is
not
None
and
name
not
in
self
.
_non_persistent_buffers_set
:
if
buf
is
not
None
and
name
not
in
self
.
_non_persistent_buffers_set
:
destination
[
prefix
+
name
]
=
buf
if
keep_vars
else
buf
.
detach
()
destination
[
prefix
+
name
]
=
buf
if
keep_vars
else
buf
.
detach
()
...
...
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