# ValueError: Target modules ['q_proj', 'v_proj'] not found in the base model. Available modules: ['query', 'value', 'key', 'output']

- **ID:** `huggingface/lora-target-modules-mismatch`
- **Domain:** huggingface
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The LoRA configuration specifies target module names that do not match the actual naming convention of the base model's linear layers, often due to model architecture differences (e.g., LLaMA vs GPT-2).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| peft>=0.7.0 | active | — | — |
| transformers>=4.35.0 | active | — | — |

## Workarounds

1. **Print the model's module names to find correct targets: for name, module in model.named_modules(): if 'linear' in str(type(module)).lower(): print(name). Then set target_modules to the discovered names.** (95% success)
   ```
   Print the model's module names to find correct targets: for name, module in model.named_modules(): if 'linear' in str(type(module)).lower(): print(name). Then set target_modules to the discovered names.
   ```
2. **Use 'all-linear' as target_modules if supported by PEFT version, but verify with a small test run first.** (80% success)
   ```
   Use 'all-linear' as target_modules if supported by PEFT version, but verify with a small test run first.
   ```

## Dead Ends

- **Guessing module names based on other models (e.g., using 'q_proj' for a model that uses 'query')** — Module names are model-specific; guessing leads to repeated mismatches. Must inspect the model's actual layer names. (80% fail)
- **Setting target_modules to 'all-linear' without checking compatibility** — While 'all-linear' often works, it may include modules that are not suitable for LoRA (e.g., output projection in some architectures), causing training instability or poor performance. (40% fail)
