[Qwen3 VL] Add LoRA support for Qwen 3 VL (#12165)

This commit is contained in:
Jonah Bernard
2025-11-03 20:32:54 -08:00
committed by GitHub
parent 48d6bea1ea
commit a209fb05c1
4 changed files with 259 additions and 0 deletions
+8
View File
@@ -14,6 +14,7 @@
# ==============================================================================
"""Inference-only Qwen3-VL model compatible with HuggingFace weights."""
import logging
import re
from functools import lru_cache, partial
from typing import Callable, Iterable, List, Optional, Tuple, Union
@@ -691,6 +692,13 @@ class Qwen3VLForConditionalGeneration(nn.Module):
def get_input_embeddings(self):
return self.model.embed_tokens
_lora_pattern = re.compile(
r"^model\.layers\.(\d+)\.(?:self_attn|mlp)\.(?:qkv_proj|o_proj|down_proj|gate_up_proj)$"
)
def should_apply_lora(self, module_name: str) -> bool:
return bool(self._lora_pattern.match(module_name))
def forward(
self,
input_ids: torch.Tensor,