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
c7aa319b
Unverified
Commit
c7aa319b
authored
Oct 18, 2023
by
Zhongkai Zhao
Committed by
GitHub
Oct 18, 2023
Browse files
[test] add no master test for low level zero plugin (#4934)
parent
1f5d2e80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
colossalai/nn/optimizer/cpu_adam.py
colossalai/nn/optimizer/cpu_adam.py
+2
-1
tests/test_zero/test_low_level/test_zero1_2.py
tests/test_zero/test_low_level/test_zero1_2.py
+7
-2
No files found.
colossalai/nn/optimizer/cpu_adam.py
View file @
c7aa319b
...
@@ -9,7 +9,8 @@ from .nvme_optimizer import NVMeOptimizer
...
@@ -9,7 +9,8 @@ from .nvme_optimizer import NVMeOptimizer
class
CPUAdam
(
NVMeOptimizer
):
class
CPUAdam
(
NVMeOptimizer
):
"""Implements Adam algorithm.
"""
Implements Adam algorithm.
Supports parameters updating on both GPU and CPU, depending on the device of parameters.
Supports parameters updating on both GPU and CPU, depending on the device of parameters.
But the parameters and gradients should on the same device:
But the parameters and gradients should on the same device:
...
...
tests/test_zero/test_low_level/test_zero1_2.py
View file @
c7aa319b
...
@@ -106,7 +106,8 @@ def exam_zero_1_2():
...
@@ -106,7 +106,8 @@ def exam_zero_1_2():
@
parameterize
(
"dtype"
,
[
torch
.
float16
,
torch
.
bfloat16
])
@
parameterize
(
"dtype"
,
[
torch
.
float16
,
torch
.
bfloat16
])
def
exam_zero_1_torch_ddp
(
world_size
,
dtype
:
torch
.
dtype
):
@
parameterize
(
"master_weights"
,
[
True
,
False
])
def
exam_zero_1_torch_ddp
(
world_size
,
dtype
:
torch
.
dtype
,
master_weights
:
bool
):
"""
"""
In this test, two pairs of model and optimizers are created.
In this test, two pairs of model and optimizers are created.
1. zero: use sharded optimizer and fp16 parameters
1. zero: use sharded optimizer and fp16 parameters
...
@@ -131,7 +132,11 @@ def exam_zero_1_torch_ddp(world_size, dtype: torch.dtype):
...
@@ -131,7 +132,11 @@ def exam_zero_1_torch_ddp(world_size, dtype: torch.dtype):
# in `check_sharded_param_consistency.py`, we will test whether
# in `check_sharded_param_consistency.py`, we will test whether
# level 1 and 2 will produce exactly the same results
# level 1 and 2 will produce exactly the same results
zero_optimizer
=
LowLevelZeroOptimizer
(
zero_optimizer
=
LowLevelZeroOptimizer
(
zero_optimizer
,
overlap_communication
=
True
,
initial_scale
=
1
,
reduce_bucket_size
=
1024
*
1024
zero_optimizer
,
overlap_communication
=
True
,
initial_scale
=
1
,
reduce_bucket_size
=
1024
*
1024
,
master_weights
=
master_weights
,
)
)
torch_optimizer
=
torch
.
optim
.
SGD
(
torch_model
.
parameters
(),
lr
=
1
)
torch_optimizer
=
torch
.
optim
.
SGD
(
torch_model
.
parameters
(),
lr
=
1
)
...
...
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