Skip to content

Conversation

@johnrachwan123
Copy link
Member

@johnrachwan123 johnrachwan123 commented May 7, 2025

Description

This PR adds the possibility to compile the module lists inside of a model instead of the full forward. The benefits are:

  1. The compilation is 2x faster
  2. There is less chance of it failing due to graph breaks

Related Issue

None.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Ran on different combinations.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

None.

Copy link
Member

@johannaSommer johannaSommer left a comment

Choose a reason for hiding this comment

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

There is a small typo but approving already, looks great! 🥳

@johannaSommer
Copy link
Member

maybe one more idea: in case we can not find a module list, should we raise a warning?

Copy link
Collaborator

@nifleisch nifleisch left a comment

Choose a reason for hiding this comment

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

Great work on this PR!
One thing I’m worried about is that limiting compilation to only ModuleList instances means some modules may remain uncompiled. This could be problematic when applying quantization since the uncompiled quantized modules can be very slow. Still, since this compile mode is optional I it should be good for now.

@johnrachwan123
Copy link
Member Author

Great work on this PR! One thing I’m worried about is that limiting compilation to only ModuleList instances means some modules may remain uncompiled. This could be problematic when applying quantization since the uncompiled quantized modules can be very slow. Still, since this compile mode is optional I it should be good for now.

Good point, maybe in the future we can extend this to compile all the known torch layers.

@johnrachwan123 johnrachwan123 merged commit 0c1bf83 into main May 14, 2025
6 checks passed
@johnrachwan123 johnrachwan123 deleted the feat/add-option-for-compilation-for-module-lists branch May 14, 2025 12:33
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.

4 participants