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

[Feature Request] Unable to Unload or Swap adapters at runtime #1108

Open
chimezie opened this issue Nov 18, 2024 · 2 comments
Open

[Feature Request] Unable to Unload or Swap adapters at runtime #1108

chimezie opened this issue Nov 18, 2024 · 2 comments

Comments

@chimezie
Copy link
Contributor

Currently, adapters can be loaded with:

model.load_weights('/path/to/weights', strict=False)

However, there is no way to either unload the weights:

model.unload_weights()

or to swap in a new one dynamically:

model.swap_weights('/path/to/other/weights')

This is useful for several use cases, including DPO loss calculation & Dynamically serving LoRA Adapters

@awni
Copy link
Member

awni commented Nov 19, 2024

You can swap adapters like so:

model.load_weights("adapters1.safetensors"), strict=False)

# Swap to new adapters
model.load_weights("adapters2.safetensors"), strict=False)

For unloading weights.. it really depends what you want to do. If you just want to delete the entire model.. simply delete it:

del model

Though maybe for that you could say more about the use case..

@chimezie
Copy link
Contributor Author

chimezie commented Nov 19, 2024

Sweet. For unloading, what I had in mind was for making the combination of using model.load_weights(..) followed by model.unload_weights(..) an idempotent operation. So, I can run LoRA on a model for a bit (making a new adapter), then, during loss calculations, run some evaluations comparing results from the original model vs. the adaptation without keeping a redundant copy of the original, and continue until the LoRA is completed.

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

No branches or pull requests

2 participants