[Bugfix][Frontend] Reject LoRA adapters named after a served model (#59286)
Signed-off-by: Nick Hill <nickhill123@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
765872e7ed
commit
105a4e097b
@@ -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()
|
||||
|
||||
@@ -245,6 +245,14 @@ class OpenAIServingModels:
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user