2025-02-02 14:58:18 -05:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2025-06-03 11:20:17 -07:00
|
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
2025-02-02 14:58:18 -05:00
|
|
|
|
2024-05-29 04:29:31 +08:00
|
|
|
import pytest
|
|
|
|
|
|
2026-02-13 14:48:38 +08:00
|
|
|
from vllm.config import ModelConfig, VllmConfig
|
2025-10-05 18:10:20 +08:00
|
|
|
from vllm.inputs.preprocess import InputPreprocessor
|
2024-05-29 04:29:31 +08:00
|
|
|
|
2025-09-30 09:45:20 -04:00
|
|
|
pytestmark = pytest.mark.cpu_test
|
|
|
|
|
|
2024-10-08 08:12:56 -06:00
|
|
|
|
2026-02-06 23:43:47 +08:00
|
|
|
@pytest.mark.parametrize("model_id", ["facebook/chameleon-7b"])
|
|
|
|
|
@pytest.mark.parametrize("prompt", ["", {"prompt_token_ids": []}])
|
2025-11-17 06:49:25 -08:00
|
|
|
@pytest.mark.skip(
|
|
|
|
|
reason=(
|
|
|
|
|
"Applying huggingface processor on text inputs results in "
|
|
|
|
|
"significant performance regression for multimodal models. "
|
|
|
|
|
"See https://github.com/vllm-project/vllm/issues/26320"
|
|
|
|
|
)
|
|
|
|
|
)
|
2025-10-05 18:10:20 +08:00
|
|
|
def test_preprocessor_always_mm_code_path(model_id, prompt):
|
|
|
|
|
model_config = ModelConfig(model=model_id)
|
2026-02-13 14:48:38 +08:00
|
|
|
vllm_config = VllmConfig(model_config=model_config)
|
|
|
|
|
input_preprocessor = InputPreprocessor(vllm_config)
|
2025-10-05 18:10:20 +08:00
|
|
|
|
|
|
|
|
# HF processor adds sep token
|
2026-01-22 20:44:22 +08:00
|
|
|
tokenizer = input_preprocessor.get_tokenizer()
|
2025-10-05 18:10:20 +08:00
|
|
|
sep_token_id = tokenizer.vocab[tokenizer.sep_token]
|
|
|
|
|
|
|
|
|
|
processed_inputs = input_preprocessor.preprocess(prompt)
|
|
|
|
|
assert sep_token_id in processed_inputs["prompt_token_ids"]
|