Skip to content

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.

@sayakpaul
Copy link
Member Author

@DN6 a gentle ping.

@sayakpaul sayakpaul merged commit 7acf834 into main May 9, 2025
29 checks passed
@sayakpaul sayakpaul deleted the enable-hotswap-testing-ci branch May 9, 2025 05:59
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