-
Notifications
You must be signed in to change notification settings - Fork 6k
fix: missing AutoencoderKL lora adapter #9807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -36,7 +36,9 @@ | |||
backend_empty_cache, | ||||
enable_full_determinism, | ||||
floats_tensor, | ||||
is_peft_available, | ||||
load_hf_numpy, | ||||
require_peft_backend, | ||||
require_torch_accelerator, | ||||
require_torch_accelerator_with_fp16, | ||||
require_torch_gpu, | ||||
|
@@ -50,6 +52,10 @@ | |||
from ..test_modeling_common import ModelTesterMixin, UNetTesterMixin | ||||
|
||||
|
||||
if is_peft_available(): | ||||
from peft import LoraConfig | ||||
|
||||
|
||||
enable_full_determinism() | ||||
|
||||
|
||||
|
@@ -263,6 +269,38 @@ def test_output_pretrained(self): | |||
|
||||
self.assertTrue(torch_all_close(output_slice, expected_output_slice, rtol=1e-2)) | ||||
|
||||
@require_peft_backend | ||||
def test_lora_adapter(self): | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be decorated with:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @beniz seems like this was not resolved? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sayakpaul ah apologies, may have forgot to push to repo. Done. Thanks for your vigilance. |
||||
init_dict, inputs_dict = self.prepare_init_args_and_inputs_for_common() | ||||
vae = self.model_class(**init_dict) | ||||
|
||||
target_modules_vae = [ | ||||
"conv1", | ||||
"conv2", | ||||
"conv_in", | ||||
"conv_shortcut", | ||||
"conv", | ||||
"conv_out", | ||||
"skip_conv_1", | ||||
"skip_conv_2", | ||||
"skip_conv_3", | ||||
"skip_conv_4", | ||||
"to_k", | ||||
"to_q", | ||||
"to_v", | ||||
"to_out.0", | ||||
] | ||||
vae_lora_config = LoraConfig( | ||||
r=16, | ||||
init_lora_weights="gaussian", | ||||
target_modules=target_modules_vae, | ||||
) | ||||
|
||||
vae.add_adapter(vae_lora_config, adapter_name="vae_lora") | ||||
active_lora = vae.active_adapters() | ||||
self.assertTrue(len(active_lora) == 1) | ||||
self.assertTrue(active_lora[0] == "vae_lora") | ||||
|
||||
|
||||
class AsymmetricAutoencoderKLTests(ModelTesterMixin, UNetTesterMixin, unittest.TestCase): | ||||
model_class = AsymmetricAutoencoderKL | ||||
|
Uh oh!
There was an error while loading. Please reload this page.