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
91a59998
"docs/vscode:/vscode.git/clone" did not exist on "bce9499ed33f7a8359bbb568c7ee18d72e8aa731"
Unverified
Commit
91a59998
authored
Jun 15, 2022
by
Frank Lee
Committed by
GitHub
Jun 15, 2022
Browse files
[ddp] supported customized torch ddp configuration (#1123)
parent
fcf55777
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
2 deletions
+9
-2
colossalai/initialize.py
colossalai/initialize.py
+9
-2
No files found.
colossalai/initialize.py
View file @
91a59998
...
...
@@ -343,6 +343,9 @@ def initialize(model: nn.Module,
mode
=
amp_mode
,
amp_config
=
cfg_
)
# get torch ddp config
torch_ddp_cfg
=
gpc
.
config
.
get
(
'torch_ddp'
,
dict
())
# gradient handler
gradient_handler_cfg
=
gpc
.
config
.
get
(
'gradient_handler'
,
None
)
if
gradient_handler_cfg
is
None
:
...
...
@@ -368,12 +371,16 @@ def initialize(model: nn.Module,
elif
is_using_sequence
():
model
=
DDP
(
model
,
process_group
=
gpc
.
get_group
(
ParallelMode
.
SEQUENCE_DP
),
device_ids
=
[
torch
.
cuda
.
current_device
()])
device_ids
=
[
torch
.
cuda
.
current_device
()],
**
torch_ddp_cfg
)
if
verbose
:
logger
.
info
(
'Model is using torch.nn.parallel.DistributedDataParallel for Sequence Parallelism'
,
ranks
=
[
0
])
elif
is_using_ddp
()
and
not
is_using_pp
()
and
amp_mode
!=
AMP_TYPE
.
NAIVE
:
model
=
DDP
(
model
,
process_group
=
gpc
.
get_group
(
ParallelMode
.
DATA
),
device_ids
=
[
torch
.
cuda
.
current_device
()])
model
=
DDP
(
model
,
process_group
=
gpc
.
get_group
(
ParallelMode
.
DATA
),
device_ids
=
[
torch
.
cuda
.
current_device
()],
**
torch_ddp_cfg
)
if
verbose
:
logger
.
info
(
'Model is using torch.nn.parallel.DistributedDataParallel for Data Parallelism'
,
ranks
=
[
0
])
elif
is_using_ddp
():
...
...
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