File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -532,10 +532,12 @@ def set_adapters(
532532
533533 invalid_components = sorted (components_passed - lora_components )
534534 if invalid_components :
535- raise ValueError (
535+ logger . warning (
536536 f"The following components in `adapter_weights` are not part of the pipeline: { invalid_components } . "
537- f"Available components that are LoRA-compatible: { self ._lora_loadable_modules } "
537+ f"Available components that are LoRA-compatible: { self ._lora_loadable_modules } . So, weights belonging "
538+ "to the invalid components will be removed and ignored."
538539 )
540+ adapter_weights = {k : v for k , v in adapter_weights .items () if k not in invalid_components }
539541
540542 adapter_names = [adapter_names ] if isinstance (adapter_names , str ) else adapter_names
541543 adapter_weights = copy .deepcopy (adapter_weights )
Original file line number Diff line number Diff line change @@ -1148,12 +1148,14 @@ def test_multiple_wrong_adapter_name_raises_error(self):
11481148 )
11491149
11501150 scale_with_wrong_components = {"foo" : 0.0 , "bar" : 0.0 , "tik" : 0.0 }
1151- with self .assertRaises (ValueError ) as err_context :
1151+ logger = logging .get_logger ("diffusers.loaders.lora_base" )
1152+ logger .setLevel (30 )
1153+ with CaptureLogger (logger ) as cap_logger :
11521154 pipe .set_adapters ("adapter-1" , adapter_weights = scale_with_wrong_components )
11531155
11541156 wrong_components = sorted (set (scale_with_wrong_components .keys ()))
1155- msg = f"The following components in `adapter_weights` are not part of the pipeline: { wrong_components } "
1156- self .assertTrue (msg in str (err_context . exception ))
1157+ msg = f"The following components in `adapter_weights` are not part of the pipeline: { wrong_components } . "
1158+ self .assertTrue (msg in str (cap_logger . out ))
11571159
11581160 # test this works.
11591161 pipe .set_adapters ("adapter-1" )
You can’t perform that action at this time.
0 commit comments