huggingface / huggingface/diffusers

Lora Hotswap no clear documentation

Aperta
#11,423 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
stale
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

Hello everyone.

Here is the scenario I have.

I have say 10 LoRAs that I would like to load and use depending on the request.

Option one:
using `load_lora_weights` - reads from the disk and moves to device: expensive operation

Option two:
load all loras and weights of non-used LoRAS with `set_adapters` method to 0.0. Not practical since the forward pass becomes expensive. Since all LoRAS are still loaded.

Option three:
Find an elegant way of loading LoRAs to CPU and then moving them to GPU as needed. While I was trying to do that, I saw the new parameter of hotswapping in hte load_lora_weights method. And this is what is described in the documentation:

hotswap — (bool, optional) Defaults to False. Whether to substitute an existing (LoRA) adapter with the newly loaded adapter in-place. This means that, instead of loading an additional adapter, this will take the existing adapter weights and replace them with the weights of the new adapter. This can be faster and more memory efficient. However, the main advantage of hotswapping is that when the model is compiled with torch.compile, loading the new adapter does not require recompilation of the model. When using hotswapping, the passed adapter_name should be the name of an already loaded adapter. **If the new adapter and the old adapter have different ranks and/or LoRA alphas (i.e. scaling), you need to call an additional method before loading the adapter**

could someone help me out here and name the mysterious function to be called?

and optionally would be great if someone could help me with my scenario.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start with the documentation for load_lora_weights and set_adapters, then trace the hotswap behavior and its interaction with torch.compile. Clarify which additional method is required when adapter ranks or LoRA alphas differ, and document how the described CPU/GPU loading scenario should be handled.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python, pytorch
Ambito
documentation, machine-learning
Tipo di issue
Documentazione
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.