PEFT target-module names depend on model architecture; Llama/Qwen-style q_proj names may not exist in BLOOM or GPT-NeoX models.
Diagnose PEFT Target modules not found errors using model architecture, named_modules, q_proj/v_proj differences, regex, all-linear and version compatibility.
PEFT target-module names depend on model architecture; Llama/Qwen-style q_proj names may not exist in BLOOM or GPT-NeoX models.
Current PEFT supports `target_modules='all-linear'` for QLoRA-style training, reducing architecture-specific manual naming.
New PEFT issues around target_modules string parsing still appeared in May 2026, so version differences are real.
The error means PEFT cannot find the requested layer names in the model graph. It is usually an architecture/configuration problem rather than a CUDA problem.
Do not blindly copy `['q_proj','v_proj']` from another architecture. Inspect `model.named_modules()` and group actual linear/attention layer suffixes. You may find names such as `query_key_value`, `c_attn` or `Wqkv`.
python - <<'PY'
from collections import Counter
# model already loaded
mods=[]
for n,m in model.named_modules():
if m.__class__.__name__ in {'Linear','Conv1D'}:
mods.append(n)
print('\n'.join(mods[:200]))
print(Counter(x.split('.')[-1] for x in mods))
PY
Many Llama-like models expose q/k/v/o projections separately. BLOOM uses fused query_key_value, GPT-2-like models may use c_attn, and other architectures differ. Target modules must follow the actual architecture.
For QLoRA-style SFT targeting all linear layers, `all-linear` is more robust than maintaining architecture-specific suffix lists. Still inspect model-specific output or multimodal projection behavior.
In PEFT, a string may be treated as regex while a list uses exact/end-suffix matching. Complex regex behavior can differ across versions. Validate with simple suffixes or `all-linear` first.
Loading a headless base class such as `LlamaModel` instead of `AutoModelForCausalLM` can expose a different graph and lead to mismatches. Model class and task type should align.
Record PEFT, Transformers and Torch versions from the last working environment. Compare module lists and serialized config after upgrades. 2026 PEFT issues show parsing regressions can happen.
After the error disappears, verify trainable parameter counts and inspect a few layers for LoRA A/B modules. Zero or unexpectedly huge trainable counts indicate a bad target selection.
python - <<'PY'
# peft_model.print_trainable_parameters()
# for n,p in peft_model.named_parameters():
# if p.requires_grad: print(n, p.numel())
PY
First use the model's official example/config, second inspect named_modules, third consider all-linear for QLoRA. Copying target lists from another architecture should be the last option.
| Architecture | Example name | Note |
|---|---|---|
| Llama/Qwen-like | q_proj, k_proj, v_proj, o_proj | Separate projections |
| BLOOM-like | query_key_value | Fused QKV |
| GPT-2-like | c_attn | Conv1D/fused |
| QLoRA general | all-linear | Architecture-robust start |
Do not blindly upgrade packages in a working training environment. Record GPU, driver, CUDA/PyTorch runtime, Transformers, Accelerate, PEFT, TRL, bitsandbytes/Diffusers, model revision and dataset fingerprint for every run. Reproduce minimally before changing production training.
No. They are common in certain architectures; inspect the actual model graph.
No. It is a strong QLoRA default but model-specific layers still need review.
Evaluate model size, precision, context, batch, LoRA/QLoRA or full fine-tuning and multi-GPU needs together instead of choosing by GPU name alone.