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
354c0f90
Commit
354c0f90
authored
Mar 09, 2022
by
jiaruifang
Committed by
Frank Lee
Mar 11, 2022
Browse files
polish code
parent
4d94cd51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
tests/test_zero_data_parallel/test_shard_model_v2.py
tests/test_zero_data_parallel/test_shard_model_v2.py
+5
-2
No files found.
tests/test_zero_data_parallel/test_shard_model_v2.py
View file @
354c0f90
...
...
@@ -44,7 +44,9 @@ def run_fwd_bwd_no_criterion(model, data, label, enable_autocast=False):
def
run_dist
(
rank
,
world_size
,
port
):
colossalai
.
launch
(
config
=
CONFIG
,
rank
=
rank
,
world_size
=
world_size
,
host
=
'localhost'
,
port
=
port
,
backend
=
'nccl'
)
test_models
=
[
'repeated_computed_layers'
,
'resnet18'
,
'bert'
]
test_models
=
[
'bert'
]
# repeated_computed_layers resnet18
shard_strategy
=
TensorShardStrategy
()
for
model_name
in
test_models
:
get_components_func
=
non_distributed_component_funcs
.
get_callable
(
model_name
)
...
...
@@ -58,11 +60,12 @@ def run_dist(rank, world_size, port):
if
i
>
2
:
break
if
model_name
==
'bert'
:
if
criterion
is
None
:
data
,
label
=
data
.
cuda
(),
label
.
cuda
()
run_fwd_bwd_no_criterion
(
model
,
data
,
label
,
False
)
run_fwd_bwd_no_criterion
(
zero_model
,
data
,
label
,
False
)
else
:
# FIXME() data can be interger!
data
,
label
=
data
.
half
().
cuda
(),
label
.
cuda
()
run_fwd_bwd
(
model
,
data
,
label
,
criterion
,
False
)
run_fwd_bwd
(
zero_model
,
data
,
label
,
criterion
,
False
)
...
...
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