[](#lora)LoRA ============= LoRA is a fast and lightweight training method that inserts and trains a significantly smaller number of parameters instead of all the model parameters. This produces a smaller file (~100 MBs) and makes it easier to quickly train a model to learn a new concept. LoRA weights are typically loaded into the denoiser, text encoder or both. The denoiser usually corresponds to a UNet ([UNet2DConditionModel](/docs/diffusers/v0.34.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel), for example) or a Transformer ([SD3Transformer2DModel](/docs/diffusers/v0.34.0/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel), for example). There are several classes for loading LoRA weights: * `StableDiffusionLoraLoaderMixin` provides functions for loading and unloading, fusing and unfusing, enabling and disabling, and more functions for managing LoRA weights. This class can be used with any model. * `StableDiffusionXLLoraLoaderMixin` is a [Stable Diffusion (SDXL)](../../api/pipelines/stable_diffusion/stable_diffusion_xl) version of the `StableDiffusionLoraLoaderMixin` class for loading and saving LoRA weights. It can only be used with the SDXL model. * `SD3LoraLoaderMixin` provides similar functions for [Stable Diffusion 3](https://huggingface.co/blog/sd3). * `FluxLoraLoaderMixin` provides similar functions for [Flux](https://huggingface.co/docs/diffusers/main/en/api/pipelines/flux). * `CogVideoXLoraLoaderMixin` provides similar functions for [CogVideoX](https://huggingface.co/docs/diffusers/main/en/api/pipelines/cogvideox). * `Mochi1LoraLoaderMixin` provides similar functions for [Mochi](https://huggingface.co/docs/diffusers/main/en/api/pipelines/mochi). * `AuraFlowLoraLoaderMixin` provides similar functions for [AuraFlow](https://huggingface.co/fal/AuraFlow). * `LTXVideoLoraLoaderMixin` provides similar functions for [LTX-Video](https://huggingface.co/docs/diffusers/main/en/api/pipelines/ltx_video). * `SanaLoraLoaderMixin` provides similar functions for [Sana](https://huggingface.co/docs/diffusers/main/en/api/pipelines/sana). * `HunyuanVideoLoraLoaderMixin` provides similar functions for [HunyuanVideo](https://huggingface.co/docs/diffusers/main/en/api/pipelines/hunyuan_video). * `Lumina2LoraLoaderMixin` provides similar functions for [Lumina2](https://huggingface.co/docs/diffusers/main/en/api/pipelines/lumina2). * `WanLoraLoaderMixin` provides similar functions for [Wan](https://huggingface.co/docs/diffusers/main/en/api/pipelines/wan). * `CogView4LoraLoaderMixin` provides similar functions for [CogView4](https://huggingface.co/docs/diffusers/main/en/api/pipelines/cogview4). * `AmusedLoraLoaderMixin` is for the [AmusedPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/amused#diffusers.AmusedPipeline). * `HiDreamImageLoraLoaderMixin` provides similar functions for [HiDream Image](https://huggingface.co/docs/diffusers/main/en/api/pipelines/hidream) * `LoraBaseMixin` provides a base class with several utility methods to fuse, unfuse, unload, LoRAs and more. To learn more about how to load LoRA weights, see the [LoRA](../../using-diffusers/loading_adapters#lora) loading guide. [](#diffusers.loaders.lora_base.LoraBaseMixin)LoraBaseMixin ----------------------------------------------------------- ### class diffusers.loaders.lora\_base.LoraBaseMixin [](#diffusers.loaders.lora_base.LoraBaseMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L462) ( ) Utility class for handling LoRAs. #### delete\_adapters [](#diffusers.loaders.lora_base.LoraBaseMixin.delete_adapters)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L826) ( adapter\_names: typing.Union\[typing.List\[str\], str\] ) Parameters * [](#diffusers.loaders.lora_base.LoraBaseMixin.delete_adapters.adapter_names)**adapter\_names** (`Union[List[str], str]`) — The names of the adapters to delete. Delete an adapter’s LoRA layers from the pipeline. [](#diffusers.loaders.lora_base.LoraBaseMixin.delete_adapters.example) Example: Copied from diffusers import AutoPipelineForText2Image import torch pipeline = AutoPipelineForText2Image.from\_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch\_dtype=torch.float16 ).to("cuda") pipeline.load\_lora\_weights( "jbilcke-hf/sdxl-cinematic-1", weight\_name="pytorch\_lora\_weights.safetensors", adapter\_names="cinematic" ) pipeline.delete\_adapters("cinematic") #### disable\_lora [](#diffusers.loaders.lora_base.LoraBaseMixin.disable_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L766) ( ) Disables the active LoRA layers of the pipeline. [](#diffusers.loaders.lora_base.LoraBaseMixin.disable_lora.example) Example: Copied from diffusers import AutoPipelineForText2Image import torch pipeline = AutoPipelineForText2Image.from\_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch\_dtype=torch.float16 ).to("cuda") pipeline.load\_lora\_weights( "jbilcke-hf/sdxl-cinematic-1", weight\_name="pytorch\_lora\_weights.safetensors", adapter\_name="cinematic" ) pipeline.disable\_lora() #### enable\_lora [](#diffusers.loaders.lora_base.LoraBaseMixin.enable_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L796) ( ) Enables the active LoRA layers of the pipeline. [](#diffusers.loaders.lora_base.LoraBaseMixin.enable_lora.example) Example: Copied from diffusers import AutoPipelineForText2Image import torch pipeline = AutoPipelineForText2Image.from\_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch\_dtype=torch.float16 ).to("cuda") pipeline.load\_lora\_weights( "jbilcke-hf/sdxl-cinematic-1", weight\_name="pytorch\_lora\_weights.safetensors", adapter\_name="cinematic" ) pipeline.enable\_lora() #### enable\_lora\_hotswap [](#diffusers.loaders.lora_base.LoraBaseMixin.enable_lora_hotswap)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L948) ( \*\*kwargs ) Parameters * [](#diffusers.loaders.lora_base.LoraBaseMixin.enable_lora_hotswap.target_rank)**target\_rank** (`int`) — The highest rank among all the adapters that will be loaded. * [](#diffusers.loaders.lora_base.LoraBaseMixin.enable_lora_hotswap.check_compiled)**check\_compiled** (`str`, _optional_, defaults to `"error"`) — How to handle a model that is already compiled. The check can return the following messages: * “error” (default): raise an error * “warn”: issue a warning * “ignore”: do nothing Hotswap adapters without triggering recompilation of a model or if the ranks of the loaded adapters are different. #### fuse\_lora [](#diffusers.loaders.lora_base.LoraBaseMixin.fuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L520) ( components: typing.List\[str\] = \[\]lora\_scale: float = 1.0safe\_fusing: bool = Falseadapter\_names: typing.Optional\[typing.List\[str\]\] = None\*\*kwargs ) Parameters * [](#diffusers.loaders.lora_base.LoraBaseMixin.fuse_lora.components)**components** — (`List[str]`): List of LoRA-injectable components to fuse the LoRAs into. * [](#diffusers.loaders.lora_base.LoraBaseMixin.fuse_lora.lora_scale)**lora\_scale** (`float`, defaults to 1.0) — Controls how much to influence the outputs with the LoRA parameters. * [](#diffusers.loaders.lora_base.LoraBaseMixin.fuse_lora.safe_fusing)**safe\_fusing** (`bool`, defaults to `False`) — Whether to check fused weights for NaN values before fusing and if values are NaN not fusing them. * [](#diffusers.loaders.lora_base.LoraBaseMixin.fuse_lora.adapter_names)**adapter\_names** (`List[str]`, _optional_) — Adapter names to be used for fusing. If nothing is passed, all active adapters will be fused. Fuses the LoRA parameters into the original parameters of the corresponding blocks. This is an experimental API. [](#diffusers.loaders.lora_base.LoraBaseMixin.fuse_lora.example) Example: Copied from diffusers import DiffusionPipeline import torch pipeline = DiffusionPipeline.from\_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch\_dtype=torch.float16 ).to("cuda") pipeline.load\_lora\_weights("nerijs/pixel-art-xl", weight\_name="pixel-art-xl.safetensors", adapter\_name="pixel") pipeline.fuse\_lora(lora\_scale=0.7) #### get\_active\_adapters [](#diffusers.loaders.lora_base.LoraBaseMixin.get_active_adapters)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L864) ( ) Gets the list of the current active adapters. [](#diffusers.loaders.lora_base.LoraBaseMixin.get_active_adapters.example) Example: Copied from diffusers import DiffusionPipeline pipeline = DiffusionPipeline.from\_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", ).to("cuda") pipeline.load\_lora\_weights("CiroN2022/toy-face", weight\_name="toy\_face\_sdxl.safetensors", adapter\_name="toy") pipeline.get\_active\_adapters() #### get\_list\_adapters [](#diffusers.loaders.lora_base.LoraBaseMixin.get_list_adapters)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L897) ( ) Gets the current list of all available adapters in the pipeline. #### set\_adapters [](#diffusers.loaders.lora_base.LoraBaseMixin.set_adapters)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L667) ( adapter\_names: typing.Union\[typing.List\[str\], str\]adapter\_weights: typing.Union\[float, typing.Dict, typing.List\[float\], typing.List\[typing.Dict\], NoneType\] = None ) Parameters * [](#diffusers.loaders.lora_base.LoraBaseMixin.set_adapters.adapter_names)**adapter\_names** (`List[str]` or `str`) — The names of the adapters to use. * [](#diffusers.loaders.lora_base.LoraBaseMixin.set_adapters.adapter_weights)**adapter\_weights** (`Union[List[float], float]`, _optional_) — The adapter(s) weights to use with the UNet. If `None`, the weights are set to `1.0` for all the adapters. Set the currently active adapters for use in the pipeline. [](#diffusers.loaders.lora_base.LoraBaseMixin.set_adapters.example) Example: Copied from diffusers import AutoPipelineForText2Image import torch pipeline = AutoPipelineForText2Image.from\_pretrained( "stabilityai/stable-diffusion-xl-base-1.0", torch\_dtype=torch.float16 ).to("cuda") pipeline.load\_lora\_weights( "jbilcke-hf/sdxl-cinematic-1", weight\_name="pytorch\_lora\_weights.safetensors", adapter\_name="cinematic" ) pipeline.load\_lora\_weights("nerijs/pixel-art-xl", weight\_name="pixel-art-xl.safetensors", adapter\_name="pixel") pipeline.set\_adapters(\["cinematic", "pixel"\], adapter\_weights=\[0.5, 0.5\]) #### set\_lora\_device [](#diffusers.loaders.lora_base.LoraBaseMixin.set_lora_device)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L919) ( adapter\_names: typing.List\[str\]device: typing.Union\[torch.device, str, int\] ) Parameters * [](#diffusers.loaders.lora_base.LoraBaseMixin.set_lora_device.adapter_names)**adapter\_names** (`List[str]`) — List of adapters to send device to. * [](#diffusers.loaders.lora_base.LoraBaseMixin.set_lora_device.device)**device** (`Union[torch.device, str, int]`) — Device to send the adapters to. Can be either a torch device, a str or an integer. Moves the LoRAs listed in `adapter_names` to a target device. Useful for offloading the LoRA to the CPU in case you want to load multiple adapters and free some GPU memory. #### unfuse\_lora [](#diffusers.loaders.lora_base.LoraBaseMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L610) ( components: typing.List\[str\] = \[\]\*\*kwargs ) Parameters * [](#diffusers.loaders.lora_base.LoraBaseMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.lora_base.LoraBaseMixin.unfuse_lora.unfuse_unet)**unfuse\_unet** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. * [](#diffusers.loaders.lora_base.LoraBaseMixin.unfuse_lora.unfuse_text_encoder)**unfuse\_text\_encoder** (`bool`, defaults to `True`) — Whether to unfuse the text encoder LoRA parameters. If the text encoder wasn’t monkey-patched with the LoRA parameters then it won’t have any effect. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. #### unload\_lora\_weights [](#diffusers.loaders.lora_base.LoraBaseMixin.unload_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L497) ( ) Unloads the LoRA parameters. [](#diffusers.loaders.lora_base.LoraBaseMixin.unload_lora_weights.example) Examples: Copied \>>> \# Assuming \`pipeline\` is already loaded with the LoRA parameters. \>>> pipeline.unload\_lora\_weights() \>>> ... #### write\_lora\_layers [](#diffusers.loaders.lora_base.LoraBaseMixin.write_lora_layers)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_base.py#L971) ( state\_dict: typing.Dict\[str, torch.Tensor\]save\_directory: stris\_main\_process: boolweight\_name: strsave\_function: typing.Callablesafe\_serialization: boollora\_adapter\_metadata: typing.Optional\[dict\] = None ) Writes the state dict of the LoRA layers (optionally with metadata) to disk. [](#diffusers.loaders.StableDiffusionLoraLoaderMixin)StableDiffusionLoraLoaderMixin ----------------------------------------------------------------------------------- ### class diffusers.loaders.StableDiffusionLoraLoaderMixin [](#diffusers.loaders.StableDiffusionLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L126) ( ) Load LoRA layers into Stable Diffusion [UNet2DConditionModel](/docs/diffusers/v0.34.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel) and [`CLIPTextModel`](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel). #### load\_lora\_into\_text\_encoder [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L414) ( state\_dictnetwork\_alphastext\_encoderprefix = Nonelora\_scale = 1.0adapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The key should be prefixed with an additional `text_encoder` to distinguish between unet lora layers. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.text_encoder)**text\_encoder** (`CLIPTextModel`) — The text encoder model to load the LoRA layers into. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.prefix)**prefix** (`str`) — Expected prefix of the `text_encoder` in the `state_dict`. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.lora_scale)**lora\_scale** (`float`) — How much to scale the output of the lora linear layer before it is added with the output of the regular lora layer. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `text_encoder` #### load\_lora\_into\_unet [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L353) ( state\_dictnetwork\_alphasunetadapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet.unet)**unet** (`UNet2DConditionModel`) — The UNet model to load the LoRA layers into. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `unet`. #### load\_lora\_weights [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L136) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights.hotswap)**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: Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See [load\_lora\_into\_unet()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet) for more details on how the state dict is loaded into `self.unet`. See [load\_lora\_into\_text\_encoder()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder) for more details on how the state dict is loaded into `self.text_encoder`. #### lora\_state\_dict [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L237) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 10 parameters Parameters * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.weight_name)**weight\_name** (`str`, _optional_, defaults to None) — Name of the serialized state dict file. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L472) ( save\_directory: typing.Union\[str, os.PathLike\]unet\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Nonetext\_encoder\_lora\_layers: typing.Dict\[str, torch.nn.modules.module.Module\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Trueunet\_lora\_adapter\_metadata = Nonetext\_encoder\_lora\_adapter\_metadata = None ) Expand 8 parameters Parameters * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.unet_lora_layers)**unet\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `unet`. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.text_encoder_lora_layers)**text\_encoder\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `text_encoder`. Must explicitly pass the text encoder LoRA state dict because it comes from 🤗 Transformers. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.unet_lora_adapter_metadata)**unet\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the unet to be serialized with the state dict. * [](#diffusers.loaders.StableDiffusionLoraLoaderMixin.save_lora_weights.text_encoder_lora_adapter_metadata)**text\_encoder\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the text encoder to be serialized with the state dict. Save the LoRA parameters corresponding to the UNet and text encoder. [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin)StableDiffusionXLLoraLoaderMixin --------------------------------------------------------------------------------------- ### class diffusers.loaders.StableDiffusionXLLoraLoaderMixin [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L610) ( ) Load LoRA layers into Stable Diffusion XL [UNet2DConditionModel](/docs/diffusers/v0.34.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel), [`CLIPTextModel`](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel), and [`CLIPTextModelWithProjection`](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModelWithProjection). #### load\_lora\_into\_text\_encoder [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L900) ( state\_dictnetwork\_alphastext\_encoderprefix = Nonelora\_scale = 1.0adapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The key should be prefixed with an additional `text_encoder` to distinguish between unet lora layers. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.text_encoder)**text\_encoder** (`CLIPTextModel`) — The text encoder model to load the LoRA layers into. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.prefix)**prefix** (`str`) — Expected prefix of the `text_encoder` in the `state_dict`. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.lora_scale)**lora\_scale** (`float`) — How much to scale the output of the lora linear layer before it is added with the output of the regular lora layer. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_text_encoder.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `text_encoder` #### load\_lora\_into\_unet [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L838) ( state\_dictnetwork\_alphasunetadapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet.unet)**unet** (`UNet2DConditionModel`) — The UNet model to load the LoRA layers into. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_into_unet.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `unet`. #### load\_lora\_weights [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L621) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See [load\_lora\_into\_unet()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_unet) for more details on how the state dict is loaded into `self.unet`. See [load\_lora\_into\_text\_encoder()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_into_text_encoder) for more details on how the state dict is loaded into `self.text_encoder`. #### lora\_state\_dict [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L721) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 10 parameters Parameters * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.weight_name)**weight\_name** (`str`, _optional_, defaults to None) — Name of the serialized state dict file. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L959) ( save\_directory: typing.Union\[str, os.PathLike\]unet\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Nonetext\_encoder\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Nonetext\_encoder\_2\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Trueunet\_lora\_adapter\_metadata = Nonetext\_encoder\_lora\_adapter\_metadata = Nonetext\_encoder\_2\_lora\_adapter\_metadata = None ) Expand 10 parameters Parameters * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.unet_lora_layers)**unet\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `unet`. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.text_encoder_lora_layers)**text\_encoder\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `text_encoder`. Must explicitly pass the text encoder LoRA state dict because it comes from 🤗 Transformers. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.text_encoder_2_lora_layers)**text\_encoder\_2\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `text_encoder_2`. Must explicitly pass the text encoder LoRA state dict because it comes from 🤗 Transformers. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.unet_lora_adapter_metadata)**unet\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the unet to be serialized with the state dict. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.text_encoder_lora_adapter_metadata)**text\_encoder\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the text encoder to be serialized with the state dict. * [](#diffusers.loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights.text_encoder_2_lora_adapter_metadata)**text\_encoder\_2\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the second text encoder to be serialized with the state dict. Save the LoRA parameters corresponding to the UNet and text encoder. [](#diffusers.loaders.SD3LoraLoaderMixin)SD3LoraLoaderMixin ----------------------------------------------------------- ### class diffusers.loaders.SD3LoraLoaderMixin [](#diffusers.loaders.SD3LoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1113) ( ) Load LoRA layers into [SD3Transformer2DModel](/docs/diffusers/v0.34.0/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel), [`CLIPTextModel`](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel), and [`CLIPTextModelWithProjection`](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModelWithProjection). Specific to [StableDiffusion3Pipeline](/docs/diffusers/v0.34.0/en/api/pipelines/stable_diffusion/stable_diffusion_3#diffusers.StableDiffusion3Pipeline). #### load\_lora\_into\_text\_encoder [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1362) ( state\_dictnetwork\_alphastext\_encoderprefix = Nonelora\_scale = 1.0adapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The key should be prefixed with an additional `text_encoder` to distinguish between unet lora layers. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.text_encoder)**text\_encoder** (`CLIPTextModel`) — The text encoder model to load the LoRA layers into. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.prefix)**prefix** (`str`) — Expected prefix of the `text_encoder` in the `state_dict`. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.lora_scale)**lora\_scale** (`float`) — How much to scale the output of the lora linear layer before it is added with the output of the regular lora layer. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_text_encoder.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `text_encoder` #### load\_lora\_into\_transformer [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1312) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`SD3Transformer2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1224) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.SD3LoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.unet` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1126) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.SD3LoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1421) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Nonetext\_encoder\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Nonetext\_encoder\_2\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata = Nonetext\_encoder\_lora\_adapter\_metadata = Nonetext\_encoder\_2\_lora\_adapter\_metadata = None ) Expand 10 parameters Parameters * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.text_encoder_lora_layers)**text\_encoder\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `text_encoder`. Must explicitly pass the text encoder LoRA state dict because it comes from 🤗 Transformers. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.text_encoder_2_lora_layers)**text\_encoder\_2\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `text_encoder_2`. Must explicitly pass the text encoder LoRA state dict because it comes from 🤗 Transformers. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.text_encoder_lora_adapter_metadata)**text\_encoder\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the text encoder to be serialized with the state dict. * [](#diffusers.loaders.SD3LoraLoaderMixin.save_lora_weights.text_encoder_2_lora_adapter_metadata)**text\_encoder\_2\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the second text encoder to be serialized with the state dict. Save the LoRA parameters corresponding to the UNet and text encoder. #### unfuse\_lora [](#diffusers.loaders.SD3LoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1559) ( components: typing.List\[str\] = \['transformer', 'text\_encoder', 'text\_encoder\_2'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.SD3LoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.SD3LoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. * [](#diffusers.loaders.SD3LoraLoaderMixin.unfuse_lora.unfuse_text_encoder)**unfuse\_text\_encoder** (`bool`, defaults to `True`) — Whether to unfuse the text encoder LoRA parameters. If the text encoder wasn’t monkey-patched with the LoRA parameters then it won’t have any effect. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.FluxLoraLoaderMixin)FluxLoraLoaderMixin ------------------------------------------------------------- ### class diffusers.loaders.FluxLoraLoaderMixin [](#diffusers.loaders.FluxLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1922) ( ) Load LoRA layers into [FluxTransformer2DModel](/docs/diffusers/v0.34.0/en/api/models/flux_transformer#diffusers.FluxTransformer2DModel), [`CLIPTextModel`](https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel). Specific to [StableDiffusion3Pipeline](/docs/diffusers/v0.34.0/en/api/pipelines/stable_diffusion/stable_diffusion_3#diffusers.StableDiffusion3Pipeline). #### load\_lora\_into\_text\_encoder [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2326) ( state\_dictnetwork\_alphastext\_encoderprefix = Nonelora\_scale = 1.0adapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The key should be prefixed with an additional `text_encoder` to distinguish between unet lora layers. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.text_encoder)**text\_encoder** (`CLIPTextModel`) — The text encoder model to load the LoRA layers into. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.prefix)**prefix** (`str`) — Expected prefix of the `text_encoder` in the `state_dict`. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.lora_scale)**lora\_scale** (`float`) — How much to scale the output of the lora linear layer before it is added with the output of the regular lora layer. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_text_encoder.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `text_encoder` #### load\_lora\_into\_transformer [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2217) ( state\_dictnetwork\_alphastransformeradapter\_name = Nonemetadata = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = False ) Parameters * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`FluxTransformer2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2092) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — \`Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.FluxLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1935) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]return\_alphas: bool = False\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.FluxLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2385) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Nonetext\_encoder\_lora\_layers: typing.Dict\[str, torch.nn.modules.module.Module\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata = Nonetext\_encoder\_lora\_adapter\_metadata = None ) Expand 8 parameters Parameters * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.text_encoder_lora_layers)**text\_encoder\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `text_encoder`. Must explicitly pass the text encoder LoRA state dict because it comes from 🤗 Transformers. * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. * [](#diffusers.loaders.FluxLoraLoaderMixin.save_lora_weights.text_encoder_lora_adapter_metadata)**text\_encoder\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the text encoder to be serialized with the state dict. Save the LoRA parameters corresponding to the UNet and text encoder. #### unfuse\_lora [](#diffusers.loaders.FluxLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2518) ( components: typing.List\[str\] = \['transformer', 'text\_encoder'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.FluxLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. #### unload\_lora\_weights [](#diffusers.loaders.FluxLoraLoaderMixin.unload_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2539) ( reset\_to\_overwritten\_params = False ) Parameters * [](#diffusers.loaders.FluxLoraLoaderMixin.unload_lora_weights.reset_to_overwritten_params)**reset\_to\_overwritten\_params** (`bool`, defaults to `False`) — Whether to reset the LoRA-loaded modules to their original params. Refer to the [Flux documentation](https://huggingface.co/docs/diffusers/main/en/api/pipelines/flux) to learn more. Unloads the LoRA parameters. [](#diffusers.loaders.FluxLoraLoaderMixin.unload_lora_weights.example) Examples: Copied \>>> \# Assuming \`pipeline\` is already loaded with the LoRA parameters. \>>> pipeline.unload\_lora\_weights() \>>> ... [](#diffusers.loaders.CogVideoXLoraLoaderMixin)CogVideoXLoraLoaderMixin ----------------------------------------------------------------------- ### class diffusers.loaders.CogVideoXLoraLoaderMixin [](#diffusers.loaders.CogVideoXLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2994) ( ) Load LoRA layers into [CogVideoXTransformer3DModel](/docs/diffusers/v0.34.0/en/api/models/cogvideox_transformer3d#diffusers.CogVideoXTransformer3DModel). Specific to [CogVideoXPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/cogvideox#diffusers.CogVideoXPipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3160) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`CogVideoXTransformer3DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3101) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3002) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.CogVideoXLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3211) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.CogVideoXLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3315) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.CogVideoXLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.Mochi1LoraLoaderMixin)Mochi1LoraLoaderMixin ----------------------------------------------------------------- ### class diffusers.loaders.Mochi1LoraLoaderMixin [](#diffusers.loaders.Mochi1LoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3333) ( ) Load LoRA layers into [MochiTransformer3DModel](/docs/diffusers/v0.34.0/en/api/models/mochi_transformer3d#diffusers.MochiTransformer3DModel). Specific to [MochiPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/mochi#diffusers.MochiPipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3500) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`MochiTransformer3DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3441) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.Mochi1LoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3341) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.Mochi1LoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3551) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.Mochi1LoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.Mochi1LoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3657) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.Mochi1LoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.Mochi1LoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.AuraFlowLoraLoaderMixin)AuraFlowLoraLoaderMixin --------------------------------------------------------------------- ### class diffusers.loaders.AuraFlowLoraLoaderMixin [](#diffusers.loaders.AuraFlowLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1580) ( ) Load LoRA layers into [AuraFlowTransformer2DModel](/docs/diffusers/v0.34.0/en/api/models/aura_flow_transformer2d#diffusers.AuraFlowTransformer2DModel) Specific to [AuraFlowPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/aura_flow#diffusers.AuraFlowPipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1747) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`AuraFlowTransformer2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1688) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1588) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.AuraFlowLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1798) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.AuraFlowLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L1904) ( components: typing.List\[str\] = \['transformer', 'text\_encoder'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.AuraFlowLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.LTXVideoLoraLoaderMixin)LTXVideoLoraLoaderMixin --------------------------------------------------------------------- ### class diffusers.loaders.LTXVideoLoraLoaderMixin [](#diffusers.loaders.LTXVideoLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3675) ( ) Load LoRA layers into [LTXVideoTransformer3DModel](/docs/diffusers/v0.34.0/en/api/models/ltx_video_transformer3d#diffusers.LTXVideoTransformer3DModel). Specific to [LTXPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/ltx_video#diffusers.LTXPipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3844) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`LTXVideoTransformer3DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3785) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3683) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.LTXVideoLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L3895) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.LTXVideoLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4001) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.LTXVideoLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.SanaLoraLoaderMixin)SanaLoraLoaderMixin ------------------------------------------------------------- ### class diffusers.loaders.SanaLoraLoaderMixin [](#diffusers.loaders.SanaLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4019) ( ) Load LoRA layers into [SanaTransformer2DModel](/docs/diffusers/v0.34.0/en/api/models/sana_transformer2d#diffusers.SanaTransformer2DModel). Specific to [SanaPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/sana#diffusers.SanaPipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4186) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`SanaTransformer2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4127) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.SanaLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4027) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.SanaLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.SanaLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4237) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.SanaLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.SanaLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.SanaLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.SanaLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.SanaLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.SanaLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.SanaLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4343) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.SanaLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.SanaLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin)HunyuanVideoLoraLoaderMixin ----------------------------------------------------------------------------- ### class diffusers.loaders.HunyuanVideoLoraLoaderMixin [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4361) ( ) Load LoRA layers into [HunyuanVideoTransformer3DModel](/docs/diffusers/v0.34.0/en/api/models/hunyuan_video_transformer_3d#diffusers.HunyuanVideoTransformer3DModel). Specific to [HunyuanVideoPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/hunyuan_video#diffusers.HunyuanVideoPipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4530) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`HunyuanVideoTransformer3DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4471) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4369) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading original format HunyuanVideo LoRA checkpoints. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4581) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4687) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.HunyuanVideoLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.Lumina2LoraLoaderMixin)Lumina2LoraLoaderMixin ------------------------------------------------------------------- ### class diffusers.loaders.Lumina2LoraLoaderMixin [](#diffusers.loaders.Lumina2LoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4705) ( ) Load LoRA layers into [Lumina2Transformer2DModel](/docs/diffusers/v0.34.0/en/api/models/lumina2_transformer2d#diffusers.Lumina2Transformer2DModel). Specific to `Lumina2Text2ImgPipeline`. #### load\_lora\_into\_transformer [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4875) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`Lumina2Transformer2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4816) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.Lumina2LoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4713) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.Lumina2LoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L4926) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.Lumina2LoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.Lumina2LoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5032) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.Lumina2LoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.Lumina2LoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.CogView4LoraLoaderMixin)CogView4LoraLoaderMixin --------------------------------------------------------------------- ### class diffusers.loaders.CogView4LoraLoaderMixin [](#diffusers.loaders.CogView4LoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5445) ( ) Load LoRA layers into [WanTransformer3DModel](/docs/diffusers/v0.34.0/en/api/models/wan_transformer_3d#diffusers.WanTransformer3DModel). Specific to [CogView4Pipeline](/docs/diffusers/v0.34.0/en/api/pipelines/cogview4#diffusers.CogView4Pipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5612) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`CogView4Transformer2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5553) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.CogView4LoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5453) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.CogView4LoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.CogView4LoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5663) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.CogView4LoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.CogView4LoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.CogView4LoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.CogView4LoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.CogView4LoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.CogView4LoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.CogView4LoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5769) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.CogView4LoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.CogView4LoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.WanLoraLoaderMixin)WanLoraLoaderMixin ----------------------------------------------------------- ### class diffusers.loaders.WanLoraLoaderMixin [](#diffusers.loaders.WanLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5050) ( ) Load LoRA layers into [WanTransformer3DModel](/docs/diffusers/v0.34.0/en/api/models/wan_transformer_3d#diffusers.WanTransformer3DModel). Specific to [WanPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/wan#diffusers.WanPipeline) and `[WanImageToVideoPipeline`\]. #### load\_lora\_into\_transformer [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5270) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`WanTransformer3DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5207) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5058) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5321) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.WanLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5427) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.WanLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.AmusedLoraLoaderMixin)AmusedLoraLoaderMixin ----------------------------------------------------------------- ### class diffusers.loaders.AmusedLoraLoaderMixin [](#diffusers.loaders.AmusedLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2819) ( ) #### load\_lora\_into\_transformer [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2824) ( state\_dictnetwork\_alphastransformeradapter\_name = Nonemetadata = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = False ) Parameters * [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer.network_alphas)**network\_alphas** (`Dict[str, float]`) — The value of the network alpha used for stable learning and preventing underflow. This value has the same meaning as the `--network_alpha` option in the kohya-ss trainer script. Refer to [this link](https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning). * [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`UVit2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.AmusedLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### save\_lora\_weights [](#diffusers.loaders.AmusedLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L2939) ( save\_directory: typing.Union\[str, os.PathLike\]text\_encoder\_lora\_layers: typing.Dict\[str, torch.nn.modules.module.Module\] = Nonetransformer\_lora\_layers: typing.Dict\[str, torch.nn.modules.module.Module\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = True ) Parameters * [](#diffusers.loaders.AmusedLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.AmusedLoraLoaderMixin.save_lora_weights.unet_lora_layers)**unet\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `unet`. * [](#diffusers.loaders.AmusedLoraLoaderMixin.save_lora_weights.text_encoder_lora_layers)**text\_encoder\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `text_encoder`. Must explicitly pass the text encoder LoRA state dict because it comes from 🤗 Transformers. * [](#diffusers.loaders.AmusedLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.AmusedLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.AmusedLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. Save the LoRA parameters corresponding to the UNet and text encoder. [](#diffusers.loaders.HiDreamImageLoraLoaderMixin)HiDreamImageLoraLoaderMixin ----------------------------------------------------------------------------- ### class diffusers.loaders.HiDreamImageLoraLoaderMixin [](#diffusers.loaders.HiDreamImageLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5787) ( ) Load LoRA layers into [HiDreamImageTransformer2DModel](/docs/diffusers/v0.34.0/en/api/models/hidream_image_transformer#diffusers.HiDreamImageTransformer2DModel). Specific to [HiDreamImagePipeline](/docs/diffusers/v0.34.0/en/api/pipelines/hidream#diffusers.HiDreamImagePipeline). #### load\_lora\_into\_transformer [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5956) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`HiDreamImageTransformer2DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5897) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5795) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L6007) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L6113) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.HiDreamImageLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [](#diffusers.loaders.WanLoraLoaderMixin)WanLoraLoaderMixin ----------------------------------------------------------- ### class diffusers.loaders.WanLoraLoaderMixin [](#diffusers.loaders.WanLoraLoaderMixin)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5050) ( ) Load LoRA layers into [WanTransformer3DModel](/docs/diffusers/v0.34.0/en/api/models/wan_transformer_3d#diffusers.WanTransformer3DModel). Specific to [WanPipeline](/docs/diffusers/v0.34.0/en/api/pipelines/wan#diffusers.WanPipeline) and `[WanImageToVideoPipeline`\]. #### load\_lora\_into\_transformer [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5270) ( state\_dicttransformeradapter\_name = None\_pipeline = Nonelow\_cpu\_mem\_usage = Falsehotswap: bool = Falsemetadata = None ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.state_dict)**state\_dict** (`dict`) — A standard state dict containing the lora layer parameters. The keys can either be indexed directly into the unet or prefixed with an additional `unet` which can be used to distinguish between text encoder lora layers. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.transformer)**transformer** (`WanTransformer3DModel`) — The Transformer model to load the LoRA layers into. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_into_transformer.metadata)**metadata** (`dict`) — Optional LoRA adapter metadata. When supplied, the `LoraConfig` arguments of `peft` won’t be derived from the state dict. This will load the LoRA layers specified in `state_dict` into `transformer`. #### load\_lora\_weights [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5207) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]adapter\_name: typing.Optional\[str\] = Nonehotswap: bool = False\*\*kwargs ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.adapter_name)**adapter\_name** (`str`, _optional_) — Adapter name to be used for referencing the loaded adapter model. If not specified, it will use `default_{i}` where i is the total number of adapters being loaded. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.low_cpu_mem_usage)**low\_cpu\_mem\_usage** (`bool`, _optional_) — Speed up model loading by only loading the pretrained LoRA weights and not initializing the random weights. * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.hotswap)**hotswap** (`bool`, _optional_) — See [load\_lora\_weights()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.load_lora_weights). * [](#diffusers.loaders.WanLoraLoaderMixin.load_lora_weights.kwargs)**kwargs** (`dict`, _optional_) — See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict). Load LoRA weights specified in `pretrained_model_name_or_path_or_dict` into `self.transformer` and `self.text_encoder`. All kwargs are forwarded to `self.lora_state_dict`. See [lora\_state\_dict()](/docs/diffusers/v0.34.0/en/api/loaders/lora#diffusers.loaders.StableDiffusionLoraLoaderMixin.lora_state_dict) for more details on how the state dict is loaded. See `~loaders.StableDiffusionLoraLoaderMixin.load_lora_into_transformer` for more details on how the state dict is loaded into `self.transformer`. #### lora\_state\_dict [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5058) ( pretrained\_model\_name\_or\_path\_or\_dict: typing.Union\[str, typing.Dict\[str, torch.Tensor\]\]\*\*kwargs ) Expand 9 parameters Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.pretrained_model_name_or_path_or_dict)**pretrained\_model\_name\_or\_path\_or\_dict** (`str` or `os.PathLike` or `dict`) — Can be either: * A string, the _model id_ (for example `google/ddpm-celebahq-256`) of a pretrained model hosted on the Hub. * A path to a _directory_ (for example `./my_model_directory`) containing the model weights saved with [ModelMixin.save\_pretrained()](/docs/diffusers/v0.34.0/en/api/models/overview#diffusers.ModelMixin.save_pretrained). * A [torch state dict](https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict). * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.cache_dir)**cache\_dir** (`Union[str, os.PathLike]`, _optional_) — Path to a directory where a downloaded pretrained model configuration is cached if the standard cache is not used. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.force_download)**force\_download** (`bool`, _optional_, defaults to `False`) — Whether or not to force the (re-)download of the model weights and configuration files, overriding the cached versions if they exist. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.proxies)**proxies** (`Dict[str, str]`, _optional_) — A dictionary of proxy servers to use by protocol or endpoint, for example, `{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}`. The proxies are used on each request. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.local_files_only)**local\_files\_only** (`bool`, _optional_, defaults to `False`) — Whether to only load local model weights and configuration files or not. If set to `True`, the model won’t be downloaded from the Hub. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.token)**token** (`str` or _bool_, _optional_) — The token to use as HTTP bearer authorization for remote files. If `True`, the token generated from `diffusers-cli login` (stored in `~/.huggingface`) is used. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.revision)**revision** (`str`, _optional_, defaults to `"main"`) — The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier allowed by Git. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.subfolder)**subfolder** (`str`, _optional_, defaults to `""`) — The subfolder location of a model file within a larger model repository on the Hub or locally. * [](#diffusers.loaders.WanLoraLoaderMixin.lora_state_dict.return_lora_metadata)**return\_lora\_metadata** (`bool`, _optional_, defaults to False) — When enabled, additionally return the LoRA adapter metadata, typically found in the state dict. Return state dict for lora weights and the network alphas. We support loading A1111 formatted LoRA checkpoints in a limited capacity. This function is experimental and might change in the future. #### save\_lora\_weights [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5321) ( save\_directory: typing.Union\[str, os.PathLike\]transformer\_lora\_layers: typing.Dict\[str, typing.Union\[torch.nn.modules.module.Module, torch.Tensor\]\] = Noneis\_main\_process: bool = Trueweight\_name: str = Nonesave\_function: typing.Callable = Nonesafe\_serialization: bool = Truetransformer\_lora\_adapter\_metadata: typing.Optional\[dict\] = None ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.save_directory)**save\_directory** (`str` or `os.PathLike`) — Directory to save LoRA parameters to. Will be created if it doesn’t exist. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.transformer_lora_layers)**transformer\_lora\_layers** (`Dict[str, torch.nn.Module]` or `Dict[str, torch.Tensor]`) — State dict of the LoRA layers corresponding to the `transformer`. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.is_main_process)**is\_main\_process** (`bool`, _optional_, defaults to `True`) — Whether the process calling this is the main process or not. Useful during distributed training and you need to call this function on all processes. In this case, set `is_main_process=True` only on the main process to avoid race conditions. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.save_function)**save\_function** (`Callable`) — The function to use to save the state dictionary. Useful during distributed training when you need to replace `torch.save` with another method. Can be configured with the environment variable `DIFFUSERS_SAVE_MODE`. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.safe_serialization)**safe\_serialization** (`bool`, _optional_, defaults to `True`) — Whether to save the model using `safetensors` or the traditional PyTorch way with `pickle`. * [](#diffusers.loaders.WanLoraLoaderMixin.save_lora_weights.transformer_lora_adapter_metadata)**transformer\_lora\_adapter\_metadata** — LoRA adapter metadata associated with the transformer to be serialized with the state dict. Save the LoRA parameters corresponding to the transformer. #### unfuse\_lora [](#diffusers.loaders.WanLoraLoaderMixin.unfuse_lora)[< source \>](https://github.com/huggingface/diffusers/blob/v0.34.0/src/diffusers/loaders/lora_pipeline.py#L5427) ( components: typing.List\[str\] = \['transformer'\]\*\*kwargs ) Parameters * [](#diffusers.loaders.WanLoraLoaderMixin.unfuse_lora.components)**components** (`List[str]`) — List of LoRA-injectable components to unfuse LoRA from. * [](#diffusers.loaders.WanLoraLoaderMixin.unfuse_lora.unfuse_transformer)**unfuse\_transformer** (`bool`, defaults to `True`) — Whether to unfuse the UNet LoRA parameters. Reverses the effect of [`pipe.fuse_lora()`](https://huggingface.co/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraBaseMixin.fuse_lora). This is an experimental API. [< \> Update on GitHub](https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/loaders/lora.md) LoRA