Skip to content

Commit

Permalink
[test] add no master test for low level zero plugin (hpcaitech#4934)
Browse files Browse the repository at this point in the history
  • Loading branch information
KKZ20 authored and flybird11111 committed Oct 18, 2023
1 parent 40ef091 commit 5c03cd4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion colossalai/nn/optimizer/cpu_adam.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@


class CPUAdam(NVMeOptimizer):
"""Implements Adam algorithm.
"""
Implements Adam algorithm.
Supports parameters updating on both GPU and CPU, depending on the device of parameters.
But the parameters and gradients should on the same device:
Expand Down
9 changes: 7 additions & 2 deletions tests/test_zero/test_low_level/test_zero1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def exam_zero_1_2():


@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.
1. zero: use sharded optimizer and fp16 parameters
Expand All @@ -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
# level 1 and 2 will produce exactly the same results
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)
Expand Down

0 comments on commit 5c03cd4

Please sign in to comment.