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.


227a60c0c4/deepspeed/compile/init_z3.py (L22-L25)

Signed-off-by: Hollow Man <hollowman@opensuse.org>
Co-authored-by: Masahiro Tanaka <81312776+tohtana@users.noreply.github.com>
This commit is contained in:
ℍ𝕠𝕝𝕝𝕠𝕨 𝕄𝕒𝕟
2025-04-18 09:49:51 +03:00
committed by GitHub
parent 625ea528d1
commit c66fdaf3c9

View File

@ -2915,7 +2915,8 @@ class DeepSpeedZeroOptimizer_Stage3(ZeROOptimizer):
# contiguous bucket
if needs_offload(OffloadStateTypeEnum.contiguous_grad_buffer):
if hasattr(self, "_DeepSpeedZeroOptimizer_Stage3__ipg_bucket_flat_buffer"):
if hasattr(self, "_DeepSpeedZeroOptimizer_Stage3__ipg_bucket_flat_buffer"
) and self.__ipg_bucket_flat_buffer is not None:
# Record properties like shape, strides, etc. as a meta tensor
self.grad_buffer_meta = self.__ipg_bucket_flat_buffer.to("meta")
self.__ipg_bucket_flat_buffer = None