Skip to content

[Tests] Enable more general testing for torch.compile() with LoRA hotswapping #11322

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

sayakpaul
Copy link
Member

What does this PR do?

@BenjaminBossan shipped a great feature in #9453. We decided to add tests only for the Unet2DConditionModel. However, we support LoRA hotswapping with torch.compile() for all models subclassed with PeftAdapterMixin.

This PR refactors the TestLoraHotSwappingForModel class to make it more generally available to the model test classes. I believe this is nice to have as this feature is for power users and for users who use diffusers in production environments.

Currently, this PR adds LoraHotSwappingForModelTesterMixin (revised name) to the test classes of Unet2DConditionModel and FluxTransformer2DModel as I think those are the most popular ones having significant usage.

I think we can open the rest of the models for community contributions.

@yiyixuxu FYI.

@sayakpaul sayakpaul requested review from BenjaminBossan and DN6 April 15, 2025 04:13
Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

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

Thanks for refactoring the tests to make them modular and align them better with the diffusers testing style. I don't have anything to add, just a few nits. I was not sure if the tests are run in the CI so I ran them locally and they all passed (they took 2 min 7 sec).

@sayakpaul
Copy link
Member Author

I was not sure if the tests are run in the CI so I ran them locally and they all passed (they took 2 min 7 sec).

Just added it to our nightly CI: 4b11ab2.

@DN6
Copy link
Collaborator

DN6 commented Apr 22, 2025

Just a question. Why not place these under the LoRA tests in the nightlys? The compile image isn't actually needed anymore. It was only a workaround for issues we were facing with Python 3.8 and torch.compile. Since the base images now using 3.10, we should be okay to have them run there.

@sayakpaul
Copy link
Member Author

@DN6 good point. Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants