Skip to content

Commit

Permalink
[Misc] Adjust max_position_embeddings for LoRA compatibility (#8957)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeejeelee authored Sep 30, 2024
1 parent be76e5a commit 1cabfce
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions vllm/worker/model_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,17 @@ def load_model(self) -> None:
assert supports_lora(
self.model
), f"{self.model.__class__.__name__} does not support LoRA yet."

if supports_multimodal(self.model):
logger.warning("Regarding multimodal models, vLLM currently "
"only supports adding LoRA to language model.")
# It's necessary to distinguish between the max_position_embeddings
# of VLMs and LLMs.
if hasattr(self.model.config, "max_position_embeddings"):
max_pos_embeddings = self.model.config.max_position_embeddings
else:
max_pos_embeddings = (
self.model.config.text_config.max_position_embeddings)

self.lora_manager = LRUCacheWorkerLoRAManager(
self.scheduler_config.max_num_seqs,
Expand All @@ -1049,8 +1057,7 @@ def load_model(self) -> None:
self.device,
self.model.embedding_modules,
self.model.embedding_padding_modules,
max_position_embeddings=self.model.config.
max_position_embeddings,
max_position_embeddings=max_pos_embeddings,
)
self.model = self.lora_manager.create_lora_manager(self.model)

Expand Down

0 comments on commit 1cabfce

Please sign in to comment.