Skip to content

Commit 487eea9

Browse files
committed
remove unused try-except clause
Signed-off-by: Hongbin Liu <hongbinl@nvidia.com>
1 parent 776d224 commit 487eea9

1 file changed

Lines changed: 24 additions & 28 deletions

File tree

megatron/core/models/common/model_chunk_schedule_plan.py

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,34 +89,30 @@ def __init__(self, layer, event, chunk_state, comp_stream, comm_stream, extra_ar
8989
self._build_callable_nodes(event, comp_stream, comm_stream, extra_args)
9090

9191
def __del__(self):
92-
try:
93-
if hasattr(self, 'attn') and self.attn is not None:
94-
del self.attn
95-
self.attn = None
96-
if hasattr(self, 'post_attn') and self.post_attn is not None:
97-
del self.post_attn
98-
self.post_attn = None
99-
if hasattr(self, 'moe_dispatch') and self.moe_dispatch is not None:
100-
del self.moe_dispatch
101-
self.moe_dispatch = None
102-
if hasattr(self, 'mlp') and self.mlp is not None:
103-
del self.mlp
104-
self.mlp = None
105-
if hasattr(self, 'moe_combine') and self.moe_combine is not None:
106-
del self.moe_combine
107-
self.moe_combine = None
108-
if hasattr(self, 'mtp_post_process') and self.mtp_post_process is not None:
109-
del self.mtp_post_process
110-
self.mtp_post_process = None
111-
if hasattr(self, 'layer_state') and self.layer_state is not None:
112-
del self.layer_state
113-
self.layer_state = None
114-
115-
if hasattr(self, 'layer'):
116-
del self.layer
117-
118-
except Exception:
119-
pass
92+
if hasattr(self, 'attn') and self.attn is not None:
93+
del self.attn
94+
self.attn = None
95+
if hasattr(self, 'post_attn') and self.post_attn is not None:
96+
del self.post_attn
97+
self.post_attn = None
98+
if hasattr(self, 'moe_dispatch') and self.moe_dispatch is not None:
99+
del self.moe_dispatch
100+
self.moe_dispatch = None
101+
if hasattr(self, 'mlp') and self.mlp is not None:
102+
del self.mlp
103+
self.mlp = None
104+
if hasattr(self, 'moe_combine') and self.moe_combine is not None:
105+
del self.moe_combine
106+
self.moe_combine = None
107+
if hasattr(self, 'mtp_post_process') and self.mtp_post_process is not None:
108+
del self.mtp_post_process
109+
self.mtp_post_process = None
110+
if hasattr(self, 'layer_state') and self.layer_state is not None:
111+
del self.layer_state
112+
self.layer_state = None
113+
if hasattr(self, 'layer'):
114+
del self.layer
115+
120116

121117
def _build_callable_nodes(self, event, comp_stream, comm_stream, extra_args):
122118
"""

0 commit comments

Comments
 (0)