[Bugfix] Reject removed pooling parameters (#48984)
Signed-off-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from pydantic import TypeAdapter, ValidationError
|
||||
|
||||
from tests.models.utils import EmbedModelInfo
|
||||
from vllm import PoolingParams
|
||||
from vllm.config import ModelConfig, PoolerConfig
|
||||
from vllm.entrypoints.pooling.classify.protocol import ClassificationRequest
|
||||
from vllm.entrypoints.pooling.embed.protocol import EmbeddingRequest
|
||||
from vllm.entrypoints.pooling.pooling.protocol import PoolingRequest
|
||||
from vllm.exceptions import VLLMValidationError
|
||||
|
||||
EMBEDDING_MODELS = [
|
||||
EmbedModelInfo("intfloat/multilingual-e5-small", is_matryoshka=False),
|
||||
@@ -27,6 +33,38 @@ class MockModelConfig:
|
||||
pooler_config: PoolerConfig
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("parameter", "value", "message"),
|
||||
[
|
||||
(
|
||||
"normalize",
|
||||
False,
|
||||
"Parameter `normalize` was removed; use `use_activation` instead.",
|
||||
),
|
||||
("task", "score", "`score` task was removed; use `classify` instead."),
|
||||
(
|
||||
"task",
|
||||
"encode",
|
||||
"`encode` task was removed; use `token_embed` or `token_classify` instead.",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_removed_pooling_parameters(parameter: str, value: Any, message: str):
|
||||
data = {"input": "hello", parameter: value}
|
||||
for request_type in (EmbeddingRequest, ClassificationRequest, PoolingRequest):
|
||||
with pytest.raises(ValidationError, match=message) as exc_info:
|
||||
TypeAdapter(request_type).validate_python(data)
|
||||
assert len(exc_info.value.errors()) == 1
|
||||
|
||||
with pytest.raises(ValidationError, match=message) as exc_info:
|
||||
TypeAdapter(PoolerConfig).validate_python({parameter: value})
|
||||
assert len(exc_info.value.errors()) == 1
|
||||
|
||||
if parameter == "task":
|
||||
with pytest.raises(VLLMValidationError, match=message):
|
||||
PoolingParams(task=value)
|
||||
|
||||
|
||||
def test_embed():
|
||||
task = "embed"
|
||||
model_config = MockModelConfig(pooler_config=PoolerConfig(seq_pooling_type="CLS"))
|
||||
|
||||
Reference in New Issue
Block a user