Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/entrypoints/serve/lora/test_serving_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,22 @@ async def test_load_lora_adapter_duplicate():
assert len(serving_models.lora_requests) == 1


@pytest.mark.asyncio
@pytest.mark.parametrize("load_inplace", [False, True])
async def test_load_lora_adapter_base_model_name(load_inplace: bool):
"""A LoRA named after a served model would shadow it for all requests."""
serving_models = await _async_serving_models_init()
request = LoadLoRAAdapterRequest(
lora_name=MODEL_NAME, lora_path="/path/to/adapter", load_inplace=load_inplace
)
response = await serving_models.load_lora_adapter(request)
assert isinstance(response, ErrorResponse)
assert response.error.type == "InvalidUserInput"
assert response.error.code == HTTPStatus.BAD_REQUEST
assert len(serving_models.lora_requests) == 0
serving_models.engine_client.add_lora.assert_not_called()


@pytest.mark.asyncio
async def test_unload_lora_adapter_success():
serving_models = await _async_serving_models_init()
Expand Down
8 changes: 8 additions & 0 deletions vllm/entrypoints/openai/models/serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ async def _check_load_lora_adapter_request(
status_code=HTTPStatus.BAD_REQUEST,
)

if self.is_base_model(request.lora_name):
return create_error_response(
message=f"The lora adapter '{request.lora_name}' conflicts with a "
"served base model.",
err_type="InvalidUserInput",
status_code=HTTPStatus.BAD_REQUEST,
)

# If not loading inplace
# Check if the lora adapter with the given name already exists
if not request.load_inplace and request.lora_name in self.lora_requests:
Expand Down
Loading