Skip to content

Commit d7aef93

Browse files
committed
Fixed the CICD
Signed-off-by: Jingyu Xin <jingyux@nvidia.com>
1 parent 109c010 commit d7aef93

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

modelopt/torch/opt/dynamic.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,14 @@ def export(self) -> nn.Module:
584584
assert not is_dynamic, "Exported module must not be a DynamicModule anymore!"
585585
delattr(self, "_dm_attribute_manager")
586586

587+
# If this module had a monkey-patched forward before DynamicModule.convert(), we may have
588+
# overridden it by binding the dynamic forward onto the instance (to follow the MRO).
589+
# On final export, restore the original forward to avoid leaking a dynamic forward
590+
# (e.g., DistillationModel.forward) onto the exported (non-dynamic) module instance.
591+
if hasattr(self, "_forward_pre_dm"):
592+
setattr(self, "forward", getattr(self, "_forward_pre_dm"))
593+
delattr(self, "_forward_pre_dm")
594+
587595
return self
588596

589597
@classmethod

0 commit comments

Comments
 (0)