Skip to content

Commit 6988214

Browse files
hmellorliuzijing2014
authored andcommitted
Improve static type checking in LoRAModelRunnerMixin (vllm-project#17104)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Zijing Liu <liuzijing2014@gmail.com>
1 parent 4101ad5 commit 6988214

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

vllm/v1/worker/lora_model_runner_mixin.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,16 @@ def load_lora_model(self, model: nn.Module, model_config: ModelConfig,
2828
scheduler_config: SchedulerConfig,
2929
lora_config: LoRAConfig, device: str) -> nn.Module:
3030

31-
assert supports_lora(
32-
model), f"{model.__class__.__name__} does not support LoRA yet."
31+
if not supports_lora(model):
32+
raise ValueError(
33+
f"{model.__class__.__name__} does not support LoRA yet.")
3334

3435
if supports_multimodal(model):
3536
logger.warning("Regarding multimodal models, vLLM currently "
3637
"only supports adding LoRA to language model.")
3738

38-
# It's necessary to distinguish between the max_position_embeddings
39-
# of VLMs and LLMs.
40-
if hasattr(model.config, "max_position_embeddings"):
41-
max_pos_embeddings = model.config.max_position_embeddings
42-
else:
43-
max_pos_embeddings = (
44-
model.config.text_config.max_position_embeddings)
39+
# Use get_text_config() in case of multimodal models
40+
text_config = model_config.hf_config.get_text_config()
4541

4642
# Add LoRA Manager to the Model Runner
4743
self.lora_manager = LRUCacheWorkerLoRAManager(
@@ -52,7 +48,7 @@ def load_lora_model(self, model: nn.Module, model_config: ModelConfig,
5248
device,
5349
model.embedding_modules,
5450
model.embedding_padding_modules,
55-
max_position_embeddings=max_pos_embeddings,
51+
max_position_embeddings=text_config.max_position_embeddings,
5652
)
5753
return self.lora_manager.create_lora_manager(model)
5854

0 commit comments

Comments
 (0)