Skip to content

Commit

Permalink
fix condition to extend cache
Browse files Browse the repository at this point in the history
  • Loading branch information
tohtana committed May 1, 2024
1 parent b3c0750 commit 822aeee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deepspeed/runtime/pipe/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ def _allocate_buffers(self, shapes_and_dtypes, requires_grad=False, num_buffers=

def _allocate_or_extend_buffers(self, idx, shape, dtype):
numel = reduce(mul, shape) if len(shape) > 0 else 1
if len(self._grad_layer_buf) <= idx or self._grad_layer_buf[idx].numel() > numel:
if len(self._grad_layer_buf) <= idx or self._grad_layer_buf[idx].numel() < numel:
new_buf = self._allocate_buffer(shape, dtype=dtype, num_buffers=1)[0]
if len(self._grad_layer_buf) <= idx:
self._grad_layer_buf.append(new_buf)
Expand Down

0 comments on commit 822aeee

Please sign in to comment.