Skip to content

fix: support peft >= 0.19 in gptqmodel peft utils - #171

Merged
kmehant merged 2 commits into
mainfrom
fix/peft-019-compat
Oct 1, 2026
Merged

kmehant merged 2 commits into
mainfrom
fix/peft-019-compat

Conversation

@dushyantbehl

Copy link
Copy Markdown
Collaborator

peft 0.19 made two breaking changes that prevent this module from being imported or used:

  1. peft.peft_model.PEFT_TYPE_TO_MODEL_MAPPING was renamed to PEFT_TYPE_TO_TUNER_MAPPING with no back-compat alias, so the module-level import raised ImportError on peft >= 0.19.

  2. GPTQLoraLinear.__init__ gained config as a required positional argument. On peft < 0.19 no such parameter exists and the previously passed lora_config= keyword was absorbed and discarded by **kwargs (LoRA hyperparameters reach the layer via **kwargs from LoraModel._create_and_replace, so nothing was lost).

Both are handled without pinning a peft version: the mapping import falls back to the new name, and the constructor call is selected from the installed signature via inspect. Verified against peft 0.18.1, 0.19.1, 0.20.0 and 0.21.1 - the correct branch is chosen and the resulting call binds on each.

peft 0.19 made two breaking changes that prevent this module from being
imported or used:

1. `peft.peft_model.PEFT_TYPE_TO_MODEL_MAPPING` was renamed to
   `PEFT_TYPE_TO_TUNER_MAPPING` with no back-compat alias, so the
   module-level import raised ImportError on peft >= 0.19.

2. `GPTQLoraLinear.__init__` gained `config` as a required positional
   argument. On peft < 0.19 no such parameter exists and the previously
   passed `lora_config=` keyword was absorbed and discarded by **kwargs
   (LoRA hyperparameters reach the layer via **kwargs from
   LoraModel._create_and_replace, so nothing was lost).

Both are handled without pinning a peft version: the mapping import falls
back to the new name, and the constructor call is selected from the
installed signature via inspect. Verified against peft 0.18.1, 0.19.1,
0.20.0 and 0.21.1 - the correct branch is chosen and the resulting call
binds on each.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Dushyant Behl <myselfdushyantbehl@gmail.com>
Signed-off-by: Dushyant Behl <myselfdushyantbehl@gmail.com>
@kmehant
kmehant merged commit 614312e into main Oct 1, 2026
9 checks passed
@dushyantbehl
dushyantbehl deleted the fix/peft-019-compat branch October 1, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants