Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/diffusers/loaders/lora_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def get_active_adapters(self) -> list[str]:

for component in self._lora_loadable_modules:
model = getattr(self, component, None)
if model is not None and issubclass(model.__class__, ModelMixin):
if model is not None and issubclass(model.__class__, (ModelMixin, PreTrainedModel)):
for module in model.modules():
if isinstance(module, BaseTunerLayer):
active_adapters = module.active_adapters
Expand Down
12 changes: 12 additions & 0 deletions tests/pipelines/testing_utils/lora.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,18 @@ def test_simple_inference_with_text_denoiser_multi_adapter_weighted(self, base_p
msg="output with no lora and output with lora disabled should give same results",
)

def test_get_active_adapters_text_encoder_only(self):
"""
Tests that get_active_adapters correctly reports active adapters when only the text encoder has a LoRA attached.
"""
if not self.text_encoder_components:
pytest.skip("Skipping test as text encoder LoRAs are not currently supported.")

pipe = self.get_pipeline().to(torch_device)
self.add_adapters_to_pipeline(pipe, components=self.text_encoder_components, adapter_name="default")

assert pipe.get_active_adapters() == ["default"]

def test_get_adapters(self):
pipe = self.get_pipeline().to(torch_device)

Expand Down
Loading