You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Adapters attach to every quantized module instead of the adapter's targets: a standard partial PEFT LoRA (q_proj/v_proj) crashes the load, and LoRA weights for dense modules (e.g. lm_head) are silently dropped #4210
adapter/adapter.py:318-321 logs a warn(... not found) and then asserts lora_A is not None and lora_B is not None.
This has two effects:
(a) Every quantized module the adapter does not cover raises AssertionError. That includes lm_head when it is quantized but absent from the adapter.
(b) Adapter tensors for a module that stays a dense nn.Linear (lm_head, or a -: dynamic exclusion) are never applied, and nothing is logged.
Reproduce
importjson, torch, tempfile, safetensors.torchasstfromgptqmodelimportGPTQModel, BACKENDfromgptqmodel.adapter.adapterimportLora, AdapterCacheBASE="sliuau/Llama-3.2-3B_4bits_128group_size"A="<local snapshot of sliuau/llama-3.2-3b_4bits_128group_size_eora_rank64_mmlu_c4>"W=st.load_file(A+"/adapter_model.safetensors"); cfg=json.load(open(A+"/adapter_config.json"))
# (a) partial adapter: q_proj / v_proj onlyd=tempfile.mkdtemp()
st.save_file({k: vfork, vinW.items() if".q_proj."inkor".v_proj."ink}, d+"/adapter_model.safetensors")
json.dump({**cfg, "target_modules": ["q_proj", "v_proj"]}, open(d+"/adapter_config.json", "w"))
GPTQModel.load(BASE, adapter=Lora(path=d, rank=64), backend=BACKEND.GPTQ_TORCH, device="cuda:0")
# WARN Lora weights not found for model.layers.0.self_attn.k_proj# AssertionError: Adapter: `lora_A` and `lora_B` must both be present ... None and None# (b) adapter that also targets lm_head (lm_head not quantized)AdapterCache.reset(); e=tempfile.mkdtemp()
W["base_model.model.lm_head.lora_A.weight"] =torch.randn(64, 3072, dtype=torch.float16) *.05W["base_model.model.lm_head.lora_B.weight"] =torch.randn(128256, 64, dtype=torch.float16) *.05st.save_file(W, e+"/adapter_model.safetensors")
json.dump({**cfg, "target_modules": cfg["target_modules"] + ["lm_head"]}, open(e+"/adapter_config.json", "w"))
m=GPTQModel.load(BASE, adapter=Lora(path=e, rank=64), backend=BACKEND.GPTQ_TORCH, device="cuda:0")
print(type(m.model.lm_head).__name__, getattr(m.model.lm_head, "adapter", None)) # Linear None -> delta silently skipped
Expected
Follow PEFT semantics:
modules outside target_modules, or with no keys, get no adapter;
adapter weights for dense targets are applied, or at least warned about or raised on.
Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix(adapter): honour PEFT target modules and apply dense targets (#4210…