Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
GuanhuaWang committed Apr 14, 2024
1 parent 5da0da8 commit 8edeea6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions deepspeed/runtime/zero/stage_1_and_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,14 @@ def __init__(self,
if not fp16_master_weights_and_gradients:
weights_partition = self.parallel_partitioned_bit16_groups[i][partition_id].to(
self.device).clone().float().detach()
if self.cpu_offload:
self.single_partition_of_fp32_groups.append(get_accelerator().pin_memory(weights_partition))
else:
self.single_partition_of_fp32_groups.append(weights_partition)
else:
weights_partition_half = self.parallel_partitioned_bit16_groups[i][partition_id].to(
weights_partition = self.parallel_partitioned_bit16_groups[i][partition_id].to(
self.device).clone().half().detach()
if self.cpu_offload:
self.single_partition_of_fp32_groups.append(get_accelerator().pin_memory(weights_partition_half))
else:
self.single_partition_of_fp32_groups.append(weights_partition_half)

if self.cpu_offload:
weights_partition = get_accelerator().pin_memory(weights_partition)

self.single_partition_of_fp32_groups.append(weights_partition)

# Set local optimizer to have flat params of its own partition.
# After this, the local optimizer will only contain its own partition of params.
Expand Down

0 comments on commit 8edeea6

Please sign in to comment.