Skip to content
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

Prevent assignments of FX modules to model #1143

Closed

Conversation

pablomlago
Copy link
Collaborator

@pablomlago pablomlago commented Dec 30, 2024

Reason for this PR

When replacing a module by a RotatedModule in fused_rotation_no_fx via a ModuleInstanceToModuleInstance rewriter, a tying between the model and its FX counterpart is created, as the replaced module in the model will point to a RotatedModule which, itself, points to module of the FX model. This is an inconsistency which is problematic when registering parametrizations, for instance.

Changes Made in this PR

Create a new type of rewriter for wrapping a module with a new class, which, itself, contains an instance to the original module. This rewriter is less general than ModuleInstanceToModuleInstance, but it is more transparent for this specific use-case.

Testing Summary

To be added.

Risk Highlight

  • This PR includes code from another work (please detail).
  • This PR contains API-breaking changes.
  • This PR depends on work in another PR (please provide links/details).
  • This PR introduces new dependencies (please detail).
  • There are coverage gaps not covered by tests.
  • Documentation updates required in subsequent PR.

Checklist

  • Code comments added to any hard-to-understand areas, if applicable.
  • Changes generate no new warnings.
  • Updated any relevant tests, if applicable.
  • No conflicts with destination dev branch.
  • I reviewed my own code changes.
  • Initial CI/CD passing.
  • 1+ reviews given, and any review issues addressed and approved.
  • Post-review full CI/CD passing.

@pablomlago
Copy link
Collaborator Author

This could be solved alternatively by reassigning the attribute "layer" in RotatedModule in fix_rewriters to point to the updated old_module_instance. I chose to implement a different rewriter as it feels more transparent.

@pablomlago pablomlago closed this Jan 12, 2025
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.

1 participant