deepspeedai / deepspeedai/DeepSpeed
[REQUEST] DeepSpeed Zero3 swap off gradients unnecessarily when swap_optimizer is True
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 43.1k
- Forks
- 5k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 112
Description
** DeepSpeed Zero3 swap off gradients unnecessarily when swap_optimizer is True
According to the function DeepSpeedZeroOptimizer_Stage3.partition_grads in
https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/runtime/zero/stage3.py#L1194, gradients are accumulated into tensors holding by self.__param_id_to_grad_partition, so why bother swap out gradients in gradient accumulation boundary?
https://github.com/microsoft/DeepSpeed/blob/master/deepspeed/runtime/zero/stage3.py#L1258
if self.offload_optimizer and self.swap_optimizer:
for i in offload_fp32_gradients.keys():
self.optimizer_swapper.swap_out_gradients(parameter=self.fp32_partitioned_groups_flat[i],
gradient_offsets=offload_fp32_offsets[i],
gradient_tensors=offload_fp32_gradients[i])
I'm quite confused by this, please help me out. thanks!
@tjruwase
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in deepspeed/runtime/zero/stage3.py at DeepSpeedZeroOptimizer_Stage3.partition_grads, especially the gradient accumulation boundary around the cited lines. Trace self.__param_id_to_grad_partition, offload_fp32_gradients, and the optimizer_swapper.swap_out_gradients call to determine whether the swap is necessary when swap_optimizer is enabled. Done means explaining the behavior and identifying whether a code change is warranted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- distributed-systems, machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100