[Core][Frontend] Add Support for Inference Time mm_processor_kwargs (#9131)
Signed-off-by: Alex-Brooks <Alex.Brooks@ibm.com>
This commit is contained in:
@@ -2,6 +2,7 @@ from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm.inputs import zip_enc_dec_prompts
|
||||
from vllm.inputs.parse import parse_and_batch_prompt
|
||||
|
||||
STRING_INPUTS = [
|
||||
@@ -51,3 +52,28 @@ def test_parse_single_batch_token_consistent(token_input: List[int]):
|
||||
def test_parse_single_batch_string_slice(inputs_slice: slice):
|
||||
assert parse_and_batch_prompt(STRING_INPUTS)[inputs_slice] \
|
||||
== parse_and_batch_prompt(STRING_INPUTS[inputs_slice])
|
||||
|
||||
|
||||
# yapf: disable
|
||||
@pytest.mark.parametrize('mm_processor_kwargs,expected_mm_kwargs', [
|
||||
(None, [{}, {}]),
|
||||
({}, [{}, {}]),
|
||||
({"foo": 100}, [{"foo": 100}, {"foo": 100}]),
|
||||
([{"foo": 100}, {"bar": 200}], [{"foo": 100}, {"bar": 200}]),
|
||||
])
|
||||
# yapf: enable
|
||||
def test_zip_enc_dec_prompts(mm_processor_kwargs, expected_mm_kwargs):
|
||||
"""Test mm_processor_kwargs init for zipping enc/dec prompts."""
|
||||
encoder_prompts = ['An encoder prompt', 'Another encoder prompt']
|
||||
decoder_prompts = ['A decoder prompt', 'Another decoder prompt']
|
||||
zipped_prompts = zip_enc_dec_prompts(encoder_prompts, decoder_prompts,
|
||||
mm_processor_kwargs)
|
||||
assert len(zipped_prompts) == len(encoder_prompts) == len(decoder_prompts)
|
||||
for enc, dec, exp_kwargs, zipped in zip(encoder_prompts, decoder_prompts,
|
||||
expected_mm_kwargs,
|
||||
zipped_prompts):
|
||||
assert isinstance(zipped, dict)
|
||||
assert len(zipped.keys()) == 3
|
||||
assert zipped['encoder_prompt'] == enc
|
||||
assert zipped['decoder_prompt'] == dec
|
||||
assert zipped['mm_processor_kwargs'] == exp_kwargs
|
||||
|
||||
Reference in New Issue
Block a user