Skip to content

Commit c66fdaf

Browse files
HollowMan6tohtana
andauthored
Make sure it's not None before offloading contiguous_grad_buffer (#7227)
Resolves #7223 When DeepCompile is enabled in ZeRO-3, contiguous_grad_buffer is released, so we should check and make sure it's not None before we continue. https://github.com/deepspeedai/DeepSpeed/blob/227a60c0c412ddf4619401b5d8d9d1674aee17b5/deepspeed/compile/init_z3.py#L22-L25 Signed-off-by: Hollow Man <[email protected]> Co-authored-by: Masahiro Tanaka <[email protected]>
1 parent 625ea52 commit c66fdaf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

deepspeed/runtime/zero/stage3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2915,7 +2915,8 @@ def needs_offload(target):
29152915

29162916
# contiguous bucket
29172917
if needs_offload(OffloadStateTypeEnum.contiguous_grad_buffer):
2918-
if hasattr(self, "_DeepSpeedZeroOptimizer_Stage3__ipg_bucket_flat_buffer"):
2918+
if hasattr(self, "_DeepSpeedZeroOptimizer_Stage3__ipg_bucket_flat_buffer"
2919+
) and self.__ipg_bucket_flat_buffer is not None:
29192920
# Record properties like shape, strides, etc. as a meta tensor
29202921
self.grad_buffer_meta = self.__ipg_bucket_flat_buffer.to("meta")
29212922
self.__ipg_bucket_flat_buffer = None

0 commit comments

Comments
 (0)