Skip to content

fix: reject DoRA and other unsupported PEFT adapter features (#4211) - #4276

Merged
Qubitium merged 1 commit into
mainfrom
pr/4211
Nov 16, 2026
Merged

Qubitium merged 1 commit into
mainfrom
pr/4211

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Summary

DoRA adapters (use_dora: true) used to load without error and then run as plain LoRA, because LoraConfig only rejected DoRA when megatron_config was also set. The same silent-accept path dropped other PEFT features (use_qalora, alora_invocation_tokens, target_parameters, CORDA), and Lora.post_init consumed only lora_A / lora_B, ignoring lora_magnitude_vector, trained biases, and modules_to_save tensors.

This change fails closed: unsupported adapter semantics now raise a ValueError before any tensor is applied, while metadata-only keys from newer PEFT versions are logged as a warning instead of disappearing.

What Changed

  • gptqmodel/adapter/peft.py
    • LoraConfig.__post_init__: reject use_dora unconditionally (previously only with Megatron), plus bias != "none", non-empty modules_to_save, and non-empty layer_replication.
    • LoraConfig.from_pretrained: reject enabled PEFT feature keys that change adapter math (use_qalora, alora_invocation_tokens, target_parameters, corda_config/use_corda) and warn (once) for unknown metadata keys such as peft_version / inference_mode instead of silently dropping them.
  • gptqmodel/adapter/adapter.py
    • Added _reject_unsupported_adapter_tensors and called it from Lora.post_init (config/magnitude-vector region only) to reject checkpoints carrying lora_magnitude_vector, modules_to_save tensors, or adapter .bias tensors even when the config does not declare them.
  • tests/test_adapter_unsupported_peft.py (new): DoRA rejected with and without Megatron (direct and via adapter_config.json), magnitude vector rejected without the flag, bias/modules_to_save rejected via config and tensors, unknown key warns and still loads, unsupported feature keys raise, and a plain LoRA still loads with the correct folded scale.

No change to the target-module gating/assert path owned by #4210.

Tests

export GPTQ_BYPASS_SAFETY_CHECKS=1 PYTHONPATH=$PWD CUDA_VISIBLE_DEVICES=
python3 -m pytest tests/test_adapter_unsupported_peft.py -q
# 15 passed

python3 -m pytest tests/test_adapter_config.py tests/test_adapter_case_sensitive.py \
  tests/test_adapter_scaling.py tests/test_adapter_cache_lifecycle.py \
  tests/test_adapter_remote_security.py tests/test_adapter_unsupported_peft.py -q
# 97 passed, 1 skipped

python3 -m pytest tests/test_eora.py tests/test_eora_weight_lifecycle.py -q
# 6 passed

python3 -m ruff check gptqmodel/adapter/peft.py gptqmodel/adapter/adapter.py tests/test_adapter_unsupported_peft.py
# All checks passed!

CPU-only (CUDA_VISIBLE_DEVICES=); no GPU/model download needed for these adapter-config and tensor-path tests. Real DoRA/aLoRA/QALoRA checkpoints were not downloaded — their rejection is covered by synthetic configs/tensors.

Model Support / Module Plan

N/A — no new model types or registry entries.

Fixes #4211

@Qubitium
Qubitium merged commit 8010760 into main Nov 16, 2026
6 checks passed
@Qubitium
Qubitium deleted the pr/4211 branch November 16, 2026 07:11
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.

[BUG] DoRA adapters (use_dora: true) load without error but run as plain LoRA; other unsupported PEFT fields are silently accepted

1 participant