@@ -83,8 +83,7 @@ def load_lora_weights(
8383 hotswap : bool = False ,
8484 ** kwargs ,
8585 ):
86- """
87- Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and
86+ """Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and
8887 `self.text_encoder`.
8988
9089 All kwargs are forwarded to `self.lora_state_dict`.
@@ -108,11 +107,12 @@ def load_lora_weights(
108107 Speed up model loading by only loading the pretrained LoRA weights and not initializing the random
109108 weights.
110109 hotswap : (`bool`, *optional*)
111- Defaults to `False`. Whether to substitute an existing adapter with the newly loaded adapter in-place.
112- This means that, instead of loading an additional adapter, this will take the existing adapter weights
113- and replace them with the weights of the new adapter. This can be faster and more memory efficient.
114- However, the main advantage of hotswapping is that when the model is compiled with torch.compile,
115- loading the new adapter does not require recompilation of the model.
110+ Defaults to `False`. Whether to substitute an existing (LoRA) adapter with the newly loaded adapter
111+ in-place. This means that, instead of loading an additional adapter, this will take the existing
112+ adapter weights and replace them with the weights of the new adapter. This can be faster and more
113+ memory efficient. However, the main advantage of hotswapping is that when the model is compiled with
114+ torch.compile, loading the new adapter does not require recompilation of the model. When using
115+ hotswapping, the passed `adapter_name` should be the name of an already loaded adapter.
116116
117117 If the new adapter and the old adapter have different ranks and/or LoRA alphas (i.e. scaling), you need
118118 to call an additional method before loading the adapter:
@@ -126,10 +126,12 @@ def load_lora_weights(
126126 # optionally compile the model now
127127 ```
128128
129- There are some limitations to this technique, which are documented here:
129+ Note that hotswapping adapters of the text encoder is not yet supported. There are some further
130+ limitations to this technique, which are documented here:
130131 https://huggingface.co/docs/peft/main/en/package_reference/hotswap
131132 kwargs (`dict`, *optional*):
132133 See [`~loaders.StableDiffusionLoraLoaderMixin.lora_state_dict`].
134+
133135 """
134136 if not USE_PEFT_BACKEND :
135137 raise ValueError ("PEFT backend is required for this method." )
@@ -320,11 +322,12 @@ def load_lora_into_unet(
320322 Speed up model loading only loading the pretrained LoRA weights and not initializing the random
321323 weights.
322324 hotswap : (`bool`, *optional*)
323- Defaults to `False`. Whether to substitute an existing adapter with the newly loaded adapter in-place.
324- This means that, instead of loading an additional adapter, this will take the existing adapter weights
325- and replace them with the weights of the new adapter. This can be faster and more memory efficient.
326- However, the main advantage of hotswapping is that when the model is compiled with torch.compile,
327- loading the new adapter does not require recompilation of the model.
325+ Defaults to `False`. Whether to substitute an existing (LoRA) adapter with the newly loaded adapter
326+ in-place. This means that, instead of loading an additional adapter, this will take the existing
327+ adapter weights and replace them with the weights of the new adapter. This can be faster and more
328+ memory efficient. However, the main advantage of hotswapping is that when the model is compiled with
329+ torch.compile, loading the new adapter does not require recompilation of the model. When using
330+ hotswapping, the passed `adapter_name` should be the name of an already loaded adapter.
328331
329332 If the new adapter and the old adapter have different ranks and/or LoRA alphas (i.e. scaling), you need
330333 to call an additional method before loading the adapter:
@@ -338,7 +341,8 @@ def load_lora_into_unet(
338341 # optionally compile the model now
339342 ```
340343
341- There are some limitations to this technique, which are documented here:
344+ Note that hotswapping adapters of the text encoder is not yet supported. There are some further
345+ limitations to this technique, which are documented here:
342346 https://huggingface.co/docs/peft/main/en/package_reference/hotswap
343347 """
344348 if not USE_PEFT_BACKEND :
@@ -405,13 +409,17 @@ def load_lora_into_text_encoder(
405409 Speed up model loading by only loading the pretrained LoRA weights and not initializing the random
406410 weights.
407411 hotswap : (`bool`, *optional*)
408- Defaults to `False`. Whether to substitute an existing adapter with the newly loaded adapter in-place.
409- This means that, instead of loading an additional adapter, this will take the existing adapter weights
410- and replace them with the weights of the new adapter. This can be faster and more memory efficient.
411- However, the main advantage of hotswapping is that when the model is compiled with torch.compile,
412- loading the new adapter does not require recompilation of the model. If the new adapter and the old
413- adapter have different ranks and/or LoRA alphas (i.e. scaling), you need to call an additional method
414- before loading the adapter:
412+ hotswap : (`bool`, *optional*)
413+ Defaults to `False`. Whether to substitute an existing (LoRA) adapter with the newly loaded adapter
414+ in-place. This means that, instead of loading an additional adapter, this will take the existing
415+ adapter weights and replace them with the weights of the new adapter. This can be faster and more
416+ memory efficient. However, the main advantage of hotswapping is that when the model is compiled with
417+ torch.compile, loading the new adapter does not require recompilation of the model. When using
418+ hotswapping, the passed `adapter_name` should be the name of an already loaded adapter.
419+
420+ If the new adapter and the old adapter have different ranks and/or LoRA alphas (i.e. scaling), you need
421+ to call an additional method before loading the adapter:
422+
415423 ```py
416424 pipeline = ... # load diffusers pipeline
417425 max_rank = ... # the highest rank among all LoRAs that you want to load
@@ -420,7 +428,9 @@ def load_lora_into_text_encoder(
420428 pipeline.load_lora_weights(file_name)
421429 # optionally compile the model now
422430 ```
423- There are some limitations to this technique, which are documented here:
431+
432+ Note that hotswapping adapters of the text encoder is not yet supported. There are some further
433+ limitations to this technique, which are documented here:
424434 https://huggingface.co/docs/peft/main/en/package_reference/hotswap
425435 """
426436 _load_lora_into_text_encoder (
@@ -809,11 +819,12 @@ def load_lora_into_unet(
809819 Speed up model loading only loading the pretrained LoRA weights and not initializing the random
810820 weights.
811821 hotswap : (`bool`, *optional*)
812- Defaults to `False`. Whether to substitute an existing adapter with the newly loaded adapter in-place.
813- This means that, instead of loading an additional adapter, this will take the existing adapter weights
814- and replace them with the weights of the new adapter. This can be faster and more memory efficient.
815- However, the main advantage of hotswapping is that when the model is compiled with torch.compile,
816- loading the new adapter does not require recompilation of the model.
822+ Defaults to `False`. Whether to substitute an existing (LoRA) adapter with the newly loaded adapter
823+ in-place. This means that, instead of loading an additional adapter, this will take the existing
824+ adapter weights and replace them with the weights of the new adapter. This can be faster and more
825+ memory efficient. However, the main advantage of hotswapping is that when the model is compiled with
826+ torch.compile, loading the new adapter does not require recompilation of the model. When using
827+ hotswapping, the passed `adapter_name` should be the name of an already loaded adapter.
817828
818829 If the new adapter and the old adapter have different ranks and/or LoRA alphas (i.e. scaling), you need
819830 to call an additional method before loading the adapter:
@@ -827,7 +838,8 @@ def load_lora_into_unet(
827838 # optionally compile the model now
828839 ```
829840
830- There are some limitations to this technique, which are documented here:
841+ Note that hotswapping adapters of the text encoder is not yet supported. There are some further
842+ limitations to this technique, which are documented here:
831843 https://huggingface.co/docs/peft/main/en/package_reference/hotswap
832844 """
833845 if not USE_PEFT_BACKEND :
0 commit comments