[Bugfix][LoRA] Reject PEFT adapter features vLLM does not implement (#60225)

Signed-off-by: suraj <surajsharan85@gmail.com>
Co-authored-by: linitra24 <renshuang.zhou@daocloud.io>
This commit is contained in:
Suraj Sharan
2026-10-09 16:39:58 +04:00
committed by GitHub
co-authored by linitra24
parent c17fadcfdc
commit 1ee69dde9c
5 changed files with 83 additions and 1 deletions
+40
View File
@@ -33,6 +33,14 @@ class PEFTHelper:
use_rslora: bool = field(default=False)
# True to use Weight-Decomposed Low-Rank Adaptation (DoRA, see: https://arxiv.org/abs/2402.09353)
use_dora: bool = field(default=False)
# PEFT features that change the adapter's semantics and that vLLM does not
# implement. They are read only to reject such adapters.
lora_bias: bool = field(default=False)
init_lora_weights: bool | str = field(default=True)
alora_invocation_tokens: list[int] | None = field(default=None)
layer_replication: list[list[int]] | None = field(default=None)
use_bdlora: dict | None = field(default=None)
use_qalora: bool = field(default=False)
# Extra vllm field, start with 'vllm_' to avoid conflict
vllm_lora_scaling_factor: float = field(default=1.0)
vllm_max_position_embeddings: int | None = field(default=False)
@@ -52,8 +60,40 @@ class PEFTHelper:
)
if self.use_dora:
error_msg.append("vLLM does not yet support DoRA.")
if self.lora_bias:
error_msg.append("vLLM does not support LoRA bias (lora_bias).")
if not self._init_is_supported():
error_msg.append(
f"vLLM does not support init_lora_weights={self.init_lora_weights!r}."
" Inits such as PiSSA, OLoRA, CorDA and LoftQ modify the base model"
" weights when PEFT loads the adapter. Convert it to a regular LoRA"
" adapter with PEFT's path_initial_model_for_weight_conversion, or"
" set init_lora_weights to true if the served base model already"
" contains the modified weights."
)
if self.alora_invocation_tokens:
error_msg.append("vLLM does not support Activated LoRA (aLoRA).")
if self.layer_replication:
error_msg.append("vLLM does not support layer_replication.")
if self.use_bdlora:
error_msg.append("vLLM does not support block-diagonal LoRA (BD-LoRA).")
if self.use_qalora:
error_msg.append("vLLM does not support QALoRA.")
return error_msg
def _init_is_supported(self) -> bool:
# These inits only set the initial adapter weights, so a saved adapter
# loads in PEFT as a plain LoRA. lora_ga modifies the base weights only
# during training, when its gradients are attached.
init = self.init_lora_weights
return not isinstance(init, str) or init.lower() in (
"gaussian",
"eva",
"orthogonal",
"mica",
"lora_ga",
)
def __post_init__(self):
if self.r <= 0:
raise ValueError(f"LoRA rank `r` must be a positive integer, got {self.r}.")
+1 -1
View File
@@ -205,7 +205,7 @@ def parse_fine_tuned_lora_name(
parts = name.split(".")
if (parts[-1] == "weight" or parts[-1] == "bias") and len(parts) >= 2:
if parts[-2] in ["lora_A", "lora_B"]:
if parts[-2] in ["lora_A", "lora_B"] and parts[-1] == "weight":
new_name = ".".join(parts[start_index:-2])
return new_name, parts[-2] == "lora_A"
# For modules_to_save in classification.