Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
renzhc
diffusers_dcu
Commits
0ca7b681
Unverified
Commit
0ca7b681
authored
Feb 14, 2024
by
Younes Belkada
Committed by
GitHub
Feb 14, 2024
Browse files
[`PEFT` / `docs`] Add a note about torch.compile (#6864)
* Update using_peft_for_inference.md * add more explanation
parent
3cf4f9c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
docs/source/en/tutorials/using_peft_for_inference.md
docs/source/en/tutorials/using_peft_for_inference.md
+19
-0
No files found.
docs/source/en/tutorials/using_peft_for_inference.md
View file @
0ca7b681
...
...
@@ -165,6 +165,25 @@ list_adapters_component_wise
{
"text_encoder"
:
[
"toy"
,
"pixel"
],
"unet"
:
[
"toy"
,
"pixel"
],
"text_encoder_2"
:
[
"toy"
,
"pixel"
]}
```
## Compatibility with `torch.compile`
If you want to compile your model with
`torch.compile`
make sure to first fuse the LoRA weights into the base model and unload them.
```
py
pipe
.
load_lora_weights
(
"nerijs/pixel-art-xl"
,
weight_name
=
"pixel-art-xl.safetensors"
,
adapter_name
=
"pixel"
)
pipe
.
load_lora_weights
(
"CiroN2022/toy-face"
,
weight_name
=
"toy_face_sdxl.safetensors"
,
adapter_name
=
"toy"
)
pipe
.
set_adapters
([
"pixel"
,
"toy"
],
adapter_weights
=
[
0.5
,
1.0
])
# Fuses the LoRAs into the Unet
pipe
.
fuse_lora
()
pipe
.
unload_lora_weights
()
pipe
=
torch
.
compile
(
pipe
)
prompt
=
"toy_face of a hacker with a hoodie, pixel art"
image
=
pipe
(
prompt
,
num_inference_steps
=
30
,
generator
=
torch
.
manual_seed
(
0
)).
images
[
0
]
```
## Fusing adapters into the model
You can use PEFT to easily fuse/unfuse multiple adapters directly into the model weights (both UNet and text encoder) using the [
`~diffusers.loaders.LoraLoaderMixin.fuse_lora`
] method, which can lead to a speed-up in inference and lower VRAM usage.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment