File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -509,17 +509,27 @@ def inject_adapter(
509509 )
510510 elif not excluded_modules and unmatched_modules :
511511 # None of the targeted modules matched
512- raise ValueError (
512+ error_msg = (
513513 f"Target modules { peft_config .target_modules } not found in the base model. "
514514 f"Please check the target modules and try again."
515515 )
516+ if peft_config .layers_to_transform is not None :
517+ error_msg += f" Note: You specified 'layers_to_transform': { peft_config .layers_to_transform } ."
518+ if peft_config .layers_pattern is not None :
519+ error_msg += f" You also specified 'layers_pattern': { peft_config .layers_pattern } ."
520+ raise ValueError (error_msg )
516521 else :
517522 # Some modules did not match and some matched but were excluded
518- raise ValueError (
523+ error_msg = (
519524 "No modules were targeted for adaptation. "
520525 "This might be caused by a combination of mismatched target modules and excluded modules. "
521526 "Please check your `target_modules` and `exclude_modules` configuration."
522527 )
528+ if peft_config .layers_to_transform is not None :
529+ error_msg += f" Note: You specified 'layers_to_transform': { peft_config .layers_to_transform } ."
530+ if peft_config .layers_pattern is not None :
531+ error_msg += f" You also specified 'layers_pattern': { peft_config .layers_pattern } ."
532+ raise ValueError (error_msg )
523533
524534 elif hasattr (peft_config , "exclude_modules" ) and peft_config .exclude_modules and not excluded_modules :
525535 # exclude_modules was passed but was not used
You can’t perform that action at this time.
0 commit comments