Skip to content

Commit 91a9986

Browse files
authored
pipe/_exec_backward_pass: fix immediate grad update (#5605)
dont call update_hp_grads in _exec_backward_pass incase of immediate grad update, as it would be called as part of bwd hooks
1 parent ac935c7 commit 91a9986

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

deepspeed/runtime/pipe/engine.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ def _exec_backward_pass(self, buffer_id):
852852

853853
if self.using_bf16_optimizer and not self.is_last_stage():
854854
# manually call because we don't call optimizer.backward()
855-
self.optimizer.update_hp_grads(clear_lp_grads=False)
855+
if not self._config.bfloat16_immediate_grad_update:
856+
self.optimizer.update_hp_grads(clear_lp_grads=False)
856857

857858
# Free up the memory from the output of forward()
858859
self.pipe_buffers['output_tensors'][buffer_id] = None

0 commit comments

Comments
 (0)