Skip to content

Commit b35d9eb

Browse files
authored
fix: avoid IndexError in BF16_Optimizer.destroy() when using DummyOptim (#7763)
fix: avoid IndexError in BF16_Optimizer.destroy() when using DummyOptim Short-circuit BF16_Optimizer.destroy() if using_real_optimizer is False. When initialized with optimizer=None (DummyOptim), bf16_groups remains empty, causing an IndexError when accessing it in destroy(). Resolves #7752
1 parent d7bb6f3 commit b35d9eb

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

deepspeed/runtime/bf16_optimizer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ def __init__(self,
103103
see_memory_usage('end bf16_ optimizer', force=True)
104104

105105
def destroy(self):
106+
if not self.using_real_optimizer:
107+
return
106108
for i, _ in enumerate(self.optimizer.param_groups):
107109
for p in self.bf16_groups[i]:
108110
if getattr(p, '_hp_mapping', None):

0 commit comments

Comments
 (0)