There is a diffusion pipeline from diffusers: [code] I want to unload it. How to do so?
- User
There is a diffusion pipeline from diffusers:
pipe = StableDiffusion3Pipeline.from_pretrained(...) pipe.load_lora_weights(lora_weights_path, weight_name='some tag')I want to unload it. How to do so?
Assistant
To unload LoRA weights from a
StableDiffusion3Pipelinein Hugging Face Diffusers, use theunload_lora_weights()method:pipe.unload_lora_weights()This removes all LoRA parameters from the pipeline's UNet and text encoders, reverting them to their original state[3][11].
For temporary disabling (without full unloading), use:
pipe.disable_lora()Key details:
- Complete removal:
unload_lora_weights()deletes LoRA layers from memory[3][11] - Multi-adapter support: Specify
adapter_nameif you loaded multiple LoRA adapters[3] - Compatibility: Works with both SD3 and SDXL pipelines[3][11]
Example workflow:
# Load LoRA pipe.load_lora_weights(lora_weights_path, weight_name='some_tag') # Generate image with LoRA image = pipe(...).images # Unload LoRA completely pipe.unload_lora_weights() # Pipeline now behaves like original SD3 without LoRA vanilla_image = pipe(...).imagesFor advanced use cases, you can also fuse/unfuse LoRA weights using
fuse_lora()andunfuse_lora()for performance optimizations[3][11].- Complete removal:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.