Skip to content
class

NoMatchingPeftModuleError

extendsPeftErrorValueError
NoMatchingPeftModuleError()

An adapter's targets matched no module, or no parameter, of the model.

Raised when target_modules (or target_parameters, or modules_to_save) selects nothing, which most often points at a misconfiguration. It subclasses ValueError, which was raised before it existed, so except ValueError keeps catching it; code that adds such an adapter on purpose can catch this class (or PeftError) and go on.

Examples

>>> import lucid.nn as nn
>>> from lucid.peft import LoraConfig, NoMatchingPeftModuleError, get_peft_model
>>> try:
...     get_peft_model(nn.Sequential(nn.Linear(2, 2)), LoraConfig(target_modules=["missing"]))
... except NoMatchingPeftModuleError as error:
...     isinstance(error, ValueError)
True

Used by 3