Skip to content

Conversation

@sayakpaul
Copy link
Member

@sayakpaul sayakpaul commented Jun 16, 2025

What does this PR do?

Currently, there's a significant overlap between these two methods:

def load_lora_adapter(

def _load_lora_into_text_encoder(

This makes it challenging to incorporate new changes as the developer has to remember to propagate the changes in both locations. Hence, this PR factors out the common things from both of the places and turns them into utility functions. IMO, it also helps to make both the loading functions a bit cleaner to read.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@sayakpaul sayakpaul requested review from BenjaminBossan and DN6 June 16, 2025 04:07
@sayakpaul sayakpaul marked this pull request as ready for review June 16, 2025 04:07
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 this to reduce code duplication. I only have nits, overall LGTM.

@sayakpaul sayakpaul requested a review from BenjaminBossan June 16, 2025 10:29
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, LGTM.



@contextlib.contextmanager
def _lora_loading_context(_pipeline):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense as a context manager, but I don't see it being applied anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

@BenjaminBossan and I decided to remove its use because we preferred more explicit code to handle offloading.

@sayakpaul sayakpaul requested a review from DN6 June 19, 2025 02:36
@sayakpaul sayakpaul merged commit fb57c76 into main Jun 19, 2025
33 checks passed
@sayakpaul sayakpaul deleted the load-lora-method-refactor branch June 19, 2025 07:36
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