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
04c9a86a
Unverified
Commit
04c9a86a
authored
Aug 02, 2022
by
ver217
Committed by
GitHub
Aug 02, 2022
Browse files
[zero] ZeroDDP supports controlling outputs' dtype (#1399)
parent
4e98e938
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
colossalai/nn/parallel/data_parallel.py
colossalai/nn/parallel/data_parallel.py
+9
-2
No files found.
colossalai/nn/parallel/data_parallel.py
View file @
04c9a86a
...
@@ -202,12 +202,17 @@ class ZeroDDP(ColoDDP):
...
@@ -202,12 +202,17 @@ class ZeroDDP(ColoDDP):
module (torch.nn.Module): Module to apply ZeRO-DP.
module (torch.nn.Module): Module to apply ZeRO-DP.
gemini_manager (GeminiManager): Manages the chunk manager and heterogeneous momery space.
gemini_manager (GeminiManager): Manages the chunk manager and heterogeneous momery space.
For more details, see the API reference of ``GeminiManager``.
For more details, see the API reference of ``GeminiManager``.
force_outputs_fp32 (bool): If set to True, outputs will be fp32. Otherwise, outputs will be fp16. Defaults to False.
"""
"""
def
__init__
(
self
,
module
:
torch
.
nn
.
Module
,
gemini_manager
:
GeminiManager
)
->
None
:
def
__init__
(
self
,
module
:
torch
.
nn
.
Module
,
gemini_manager
:
GeminiManager
,
force_outputs_fp32
:
bool
=
False
)
->
None
:
super
().
__init__
(
module
,
process_group
=
gemini_manager
.
chunk_manager
.
process_group
)
super
().
__init__
(
module
,
process_group
=
gemini_manager
.
chunk_manager
.
process_group
)
self
.
gemini_manager
=
gemini_manager
self
.
gemini_manager
=
gemini_manager
self
.
chunk_manager
=
gemini_manager
.
chunk_manager
self
.
chunk_manager
=
gemini_manager
.
chunk_manager
self
.
force_outputs_fp32
=
force_outputs_fp32
self
.
param_op_hook
=
ZeROHookV2
(
gemini_manager
)
self
.
param_op_hook
=
ZeROHookV2
(
gemini_manager
)
self
.
fp32_params
:
List
[
ColoParameter
]
=
[]
self
.
fp32_params
:
List
[
ColoParameter
]
=
[]
self
.
overflow_counter
=
0
self
.
overflow_counter
=
0
...
@@ -235,7 +240,9 @@ class ZeroDDP(ColoDDP):
...
@@ -235,7 +240,9 @@ class ZeroDDP(ColoDDP):
with
ParamOpHookManager
.
use_hooks
(
self
.
param_op_hook
):
with
ParamOpHookManager
.
use_hooks
(
self
.
param_op_hook
):
outputs
=
self
.
module
(
*
args
,
**
kwargs
)
outputs
=
self
.
module
(
*
args
,
**
kwargs
)
self
.
chunk_manager
.
exec_lazy_release
()
self
.
chunk_manager
.
exec_lazy_release
()
return
_cast_float
(
outputs
,
torch
.
float
)
if
self
.
force_outputs_fp32
:
return
_cast_float
(
outputs
,
torch
.
float
)
return
outputs
def
_setup_grads_ptr
(
self
):
def
_setup_grads_ptr
(
self
):
for
p
in
self
.
module
.
parameters
():
for
p
in
self
.
module
.
parameters
():
...
...
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