@@ -197,20 +197,6 @@ def get_peft_kwargs(
197197        "lora_bias" : lora_bias ,
198198    }
199199
200-     # Example: try load FusionX LoRA into Wan VACE 
201-     exclude_modules  =  _derive_exclude_modules (model_state_dict , peft_state_dict , adapter_name )
202-     if  exclude_modules :
203-         if  not  is_peft_version (">=" , "0.14.0" ):
204-             msg  =  """ 
205- It seems like there are certain modules that need to be excluded when initializing `LoraConfig`. Your current `peft` 
206- version doesn't support passing an `exclude_modules` to `LoraConfig`. Please update it by running `pip install -U 
207- peft`. For most cases, this can be completely ignored. But if it seems unexpected, please file an issue - 
208- https://github.com/huggingface/diffusers/issues/new 
209-             """ 
210-             logger .debug (msg )
211-         else :
212-             lora_config_kwargs .update ({"exclude_modules" : exclude_modules })
213- 
214200    return  lora_config_kwargs 
215201
216202
@@ -388,27 +374,3 @@ def _maybe_warn_for_unhandled_keys(incompatible_keys, adapter_name):
388374
389375    if  warn_msg :
390376        logger .warning (warn_msg )
391- 
392- 
393- def  _derive_exclude_modules (model_state_dict , peft_state_dict , adapter_name = None ):
394-     """ 
395-     Derives the modules to exclude while initializing `LoraConfig` through `exclude_modules`. It works by comparing the 
396-     `model_state_dict` and `peft_state_dict` and adds a module from `model_state_dict` to the exclusion set if it 
397-     doesn't exist in `peft_state_dict`. 
398-     """ 
399-     if  model_state_dict  is  None :
400-         return 
401-     all_modules  =  set ()
402-     string_to_replace  =  f"{ adapter_name }   if  adapter_name  else  "" 
403- 
404-     for  name  in  model_state_dict .keys ():
405-         if  string_to_replace :
406-             name  =  name .replace (string_to_replace , "" )
407-         if  "."  in  name :
408-             module_name  =  name .rsplit ("." , 1 )[0 ]
409-             all_modules .add (module_name )
410- 
411-     target_modules_set  =  {name .split (".lora" )[0 ] for  name  in  peft_state_dict .keys ()}
412-     exclude_modules  =  list (all_modules  -  target_modules_set )
413- 
414-     return  exclude_modules 
0 commit comments