-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update PEFT -> Kohya conversion logic to support SDXL LoRA conversion…
…s. Prior to this change, attempting to convert an SDXL LoRA would have skipped all of the text encoder LoRA weights.
- Loading branch information
Showing
2 changed files
with
69 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/invoke_training/training/_shared/stable_diffusion/test_lora_checkpoint_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from invoke_training.training._shared.stable_diffusion.lora_checkpoint_utils import ( | ||
convert_sd_peft_checkpoint_to_kohya_state_dict, | ||
) | ||
|
||
|
||
def test_convert_sd_peft_checkpoint_to_kohya_state_dict_raise_on_empty_directory(tmp_path: Path): | ||
with pytest.raises(ValueError, match="No checkpoint files found in directory"): | ||
convert_sd_peft_checkpoint_to_kohya_state_dict( | ||
in_checkpoint_dir=tmp_path, out_checkpoint_file=tmp_path / "out.safetensors" | ||
) | ||
|
||
|
||
def test_convert_sd_peft_checkpoint_to_kohya_state_dict_raise_on_unexpected_subdirectory(tmp_path: Path): | ||
subdirectory = tmp_path / "subdir" | ||
subdirectory.mkdir() | ||
|
||
with pytest.raises(ValueError, match=f"Unrecognized checkpoint directory: '{subdirectory}'."): | ||
convert_sd_peft_checkpoint_to_kohya_state_dict( | ||
in_checkpoint_dir=tmp_path, out_checkpoint_file=tmp_path / "out.safetensors" | ||
) |