Skip to content

Commit 5db54f8

Browse files
YangQun1loadams
authored andcommitted
BF16 optimizer: Clear lp grads after updating hp grads in hook (deepspeedai#5328)
This fix is to solve: - Previous iteration's lp grads will still alive during the next iteration's forward. This increases the memory footprint. - The hook behavior is not aligned to its name accumulate_hp_grads_and_remove_lp Co-authored-by: qunyang <quyang@habana.ai> Co-authored-by: Logan Adams <114770087+loadams@users.noreply.github.com>
1 parent 7df0857 commit 5db54f8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

deepspeed/runtime/bf16_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def param_groups(self):
517517

518518
def accumulate_hp_grads_and_remove_lp(self, lp_param, group_idx, param_idx):
519519
assert self.immediate_grad_update
520-
self._update_hp_grad(lp_param, group_idx, param_idx, clear_lp_grads=False)
520+
self._update_hp_grad(lp_param, group_idx, param_idx, clear_lp_grads=True)
521521

522522
def create_grad_acc_hooks(self):
523523
self.grad_accs = []

0 commit comments

Comments
 (0)