Skip to content

Fix module update in strict mode #2321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2025
Merged

Fix module update in strict mode #2321

merged 2 commits into from
Jun 29, 2025

Conversation

awni
Copy link
Member

@awni awni commented Jun 29, 2025

Relevant test case shows the issue. If there is a non module type in a container then we have an issue during strict module because leaf_modules uses empty dictionaries for placeholders.

        class MyModel(nn.Module):
            def __init__(self):
                super().__init__()
                self.stuff = [nn.Linear(2, 2), 0, nn.Linear(2, 2)]

        m = MyModel()
        m.update_modules(m.leaf_modules())

@awni awni force-pushed the fix_strict_module_update branch from ff69ef5 to 0fcf6f7 Compare June 29, 2025 15:32
Copy link
Member

@angeloskath angeloskath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

@awni awni merged commit 33bf1a2 into main Jun 29, 2025
5 checks passed
@awni awni deleted the fix_strict_module_update branch June 29, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants