LoRA (original) (raw)

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, for example) or a Transformer (SD3Transformer2DModel, for example). There are several classes for loading LoRA weights:

To learn more about how to load LoRA weights, see the LoRA loading guide.

LoraBaseMixin

class diffusers.loaders.lora_base.LoraBaseMixin

< source >

( )

Utility class for handling LoRAs.

delete_adapters

< source >

( adapter_names: typing.Union[typing.List[str], str] )

Parameters

Delete an adapter’s LoRA layers from the pipeline.

Example:

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")

Disables the active LoRA layers of the pipeline.

Example:

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()

Enables the active LoRA layers of the pipeline.

Example:

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

< source >

( **kwargs )

Parameters

Hotswap adapters without triggering recompilation of a model or if the ranks of the loaded adapters are different.

fuse_lora

< source >

( components: typing.List[str] = [] lora_scale: float = 1.0 safe_fusing: bool = False adapter_names: typing.Optional[typing.List[str]] = None **kwargs )

Parameters

Fuses the LoRA parameters into the original parameters of the corresponding blocks.

This is an experimental API.

Example:

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)

Gets the list of the current active adapters.

Example:

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()

Gets the current list of all available adapters in the pipeline.

set_adapters

< source >

( 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

Set the currently active adapters for use in the pipeline.

Example:

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

< source >

( adapter_names: typing.List[str] device: typing.Union[torch.device, str, int] )

Parameters

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

< source >

( components: typing.List[str] = [] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

Unloads the LoRA parameters.

Examples:

pipeline.unload_lora_weights() ...

write_lora_layers

< source >

( state_dict: typing.Dict[str, torch.Tensor] save_directory: str is_main_process: bool weight_name: str save_function: typing.Callable safe_serialization: bool lora_adapter_metadata: typing.Optional[dict] = None )

Writes the state dict of the LoRA layers (optionally with metadata) to disk.

StableDiffusionLoraLoaderMixin

class diffusers.loaders.StableDiffusionLoraLoaderMixin

< source >

( )

Load LoRA layers into Stable Diffusion UNet2DConditionModel andCLIPTextModel.

load_lora_into_text_encoder

< source >

( state_dict network_alphas text_encoder prefix = None lora_scale = 1.0 adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into text_encoder

load_lora_into_unet

< source >

( state_dict network_alphas unet adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into unet.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.unet andself.text_encoder.

All kwargs are forwarded to self.lora_state_dict.

See lora_state_dict() for more details on how the state dict is loaded.

See load_lora_into_unet() for more details on how the state dict is loaded into self.unet.

See load_lora_into_text_encoder() for more details on how the state dict is loaded into self.text_encoder.

lora_state_dict

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] unet_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None text_encoder_lora_layers: typing.Dict[str, torch.nn.modules.module.Module] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True unet_lora_adapter_metadata = None text_encoder_lora_adapter_metadata = None )

Parameters

Save the LoRA parameters corresponding to the UNet and text encoder.

StableDiffusionXLLoraLoaderMixin

class diffusers.loaders.StableDiffusionXLLoraLoaderMixin

< source >

( )

Load LoRA layers into Stable Diffusion XL UNet2DConditionModel,CLIPTextModel, andCLIPTextModelWithProjection.

load_lora_into_text_encoder

< source >

( state_dict network_alphas text_encoder prefix = None lora_scale = 1.0 adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into text_encoder

load_lora_into_unet

< source >

( state_dict network_alphas unet adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into unet.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.unet andself.text_encoder.

All kwargs are forwarded to self.lora_state_dict.

See lora_state_dict() for more details on how the state dict is loaded.

See load_lora_into_unet() for more details on how the state dict is loaded into self.unet.

See load_lora_into_text_encoder() for more details on how the state dict is loaded into self.text_encoder.

lora_state_dict

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] unet_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None text_encoder_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None text_encoder_2_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True unet_lora_adapter_metadata = None text_encoder_lora_adapter_metadata = None text_encoder_2_lora_adapter_metadata = None )

Parameters

Save the LoRA parameters corresponding to the UNet and text encoder.

SD3LoraLoaderMixin

class diffusers.loaders.SD3LoraLoaderMixin

< source >

( )

Load LoRA layers into SD3Transformer2DModel,CLIPTextModel, andCLIPTextModelWithProjection.

Specific to StableDiffusion3Pipeline.

load_lora_into_text_encoder

< source >

( state_dict network_alphas text_encoder prefix = None lora_scale = 1.0 adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into text_encoder

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.unet andself.text_encoder.

All kwargs are forwarded to self.lora_state_dict.

See 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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None text_encoder_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None text_encoder_2_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata = None text_encoder_lora_adapter_metadata = None text_encoder_2_lora_adapter_metadata = None )

Parameters

Save the LoRA parameters corresponding to the UNet and text encoder.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer', 'text_encoder', 'text_encoder_2'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

FluxLoraLoaderMixin

class diffusers.loaders.FluxLoraLoaderMixin

< source >

( )

Load LoRA layers into FluxTransformer2DModel,CLIPTextModel.

Specific to StableDiffusion3Pipeline.

load_lora_into_text_encoder

< source >

( state_dict network_alphas text_encoder prefix = None lora_scale = 1.0 adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into text_encoder

load_lora_into_transformer

< source >

( state_dict network_alphas transformer adapter_name = None metadata = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder.

All kwargs are forwarded to self.lora_state_dict.

See 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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] return_alphas: bool = False **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None text_encoder_lora_layers: typing.Dict[str, torch.nn.modules.module.Module] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata = None text_encoder_lora_adapter_metadata = None )

Parameters

Save the LoRA parameters corresponding to the UNet and text encoder.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer', 'text_encoder'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

unload_lora_weights

< source >

( reset_to_overwritten_params = False )

Parameters

Unloads the LoRA parameters.

Examples:

pipeline.unload_lora_weights() ...

CogVideoXLoraLoaderMixin

class diffusers.loaders.CogVideoXLoraLoaderMixin

< source >

( )

Load LoRA layers into CogVideoXTransformer3DModel. Specific to CogVideoXPipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

Mochi1LoraLoaderMixin

class diffusers.loaders.Mochi1LoraLoaderMixin

< source >

( )

Load LoRA layers into MochiTransformer3DModel. Specific to MochiPipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

AuraFlowLoraLoaderMixin

class diffusers.loaders.AuraFlowLoraLoaderMixin

< source >

( )

Load LoRA layers into AuraFlowTransformer2DModel Specific to AuraFlowPipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer', 'text_encoder'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

LTXVideoLoraLoaderMixin

class diffusers.loaders.LTXVideoLoraLoaderMixin

< source >

( )

Load LoRA layers into LTXVideoTransformer3DModel. Specific to LTXPipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

SanaLoraLoaderMixin

class diffusers.loaders.SanaLoraLoaderMixin

< source >

( )

Load LoRA layers into SanaTransformer2DModel. Specific to SanaPipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

HunyuanVideoLoraLoaderMixin

class diffusers.loaders.HunyuanVideoLoraLoaderMixin

< source >

( )

Load LoRA layers into HunyuanVideoTransformer3DModel. Specific to HunyuanVideoPipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

Lumina2LoraLoaderMixin

class diffusers.loaders.Lumina2LoraLoaderMixin

< source >

( )

Load LoRA layers into Lumina2Transformer2DModel. Specific to Lumina2Text2ImgPipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

CogView4LoraLoaderMixin

class diffusers.loaders.CogView4LoraLoaderMixin

< source >

( )

Load LoRA layers into WanTransformer3DModel. Specific to CogView4Pipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

WanLoraLoaderMixin

class diffusers.loaders.WanLoraLoaderMixin

< source >

( )

Load LoRA layers into WanTransformer3DModel. Specific to WanPipeline and [WanImageToVideoPipeline].

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

AmusedLoraLoaderMixin

class diffusers.loaders.AmusedLoraLoaderMixin

< source >

( )

load_lora_into_transformer

< source >

( state_dict network_alphas transformer adapter_name = None metadata = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

save_lora_weights

< source >

( save_directory: typing.Union[str, os.PathLike] text_encoder_lora_layers: typing.Dict[str, torch.nn.modules.module.Module] = None transformer_lora_layers: typing.Dict[str, torch.nn.modules.module.Module] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True )

Parameters

Save the LoRA parameters corresponding to the UNet and text encoder.

HiDreamImageLoraLoaderMixin

class diffusers.loaders.HiDreamImageLoraLoaderMixin

< source >

( )

Load LoRA layers into HiDreamImageTransformer2DModel. Specific to HiDreamImagePipeline.

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

WanLoraLoaderMixin

class diffusers.loaders.WanLoraLoaderMixin

< source >

( )

Load LoRA layers into WanTransformer3DModel. Specific to WanPipeline and [WanImageToVideoPipeline].

load_lora_into_transformer

< source >

( state_dict transformer adapter_name = None _pipeline = None low_cpu_mem_usage = False hotswap: bool = False metadata = None )

Parameters

This will load the LoRA layers specified in state_dict into transformer.

load_lora_weights

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] adapter_name: typing.Optional[str] = None hotswap: bool = False **kwargs )

Parameters

Load LoRA weights specified in pretrained_model_name_or_path_or_dict into self.transformer andself.text_encoder. All kwargs are forwarded to self.lora_state_dict. Seelora_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

< source >

( pretrained_model_name_or_path_or_dict: typing.Union[str, typing.Dict[str, torch.Tensor]] **kwargs )

Parameters

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

< source >

( save_directory: typing.Union[str, os.PathLike] transformer_lora_layers: typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None is_main_process: bool = True weight_name: str = None save_function: typing.Callable = None safe_serialization: bool = True transformer_lora_adapter_metadata: typing.Optional[dict] = None )

Parameters

Save the LoRA parameters corresponding to the transformer.

unfuse_lora

< source >

( components: typing.List[str] = ['transformer'] **kwargs )

Parameters

Reverses the effect ofpipe.fuse_lora().

This is an experimental API.

< > Update on GitHub