mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-13 13:55:01 +08:00
- **Add SPDX license headers to python source files**
- **Check for SPDX headers using pre-commit**
commit 9d7ef44c3cfb72ca4c32e1c677d99259d10d4745
Author: Russell Bryant <rbryant@redhat.com>
Date: Fri Jan 31 14:18:24 2025 -0500
Add SPDX license headers to python source files
This commit adds SPDX license headers to python source files as
recommended to
the project by the Linux Foundation. These headers provide a concise way
that is
both human and machine readable for communicating license information
for each
source file. It helps avoid any ambiguity about the license of the code
and can
also be easily used by tools to help manage license compliance.
The Linux Foundation runs license scans against the codebase to help
ensure
we are in compliance with the licenses of the code we use, including
dependencies. Having these headers in place helps that tool do its job.
More information can be found on the SPDX site:
- https://spdx.dev/learn/handling-license-info/
Signed-off-by: Russell Bryant <rbryant@redhat.com>
commit 5a1cf1cb3b80759131c73f6a9dddebccac039dea
Author: Russell Bryant <rbryant@redhat.com>
Date: Fri Jan 31 14:36:32 2025 -0500
Check for SPDX headers using pre-commit
Signed-off-by: Russell Bryant <rbryant@redhat.com>
---------
Signed-off-by: Russell Bryant <rbryant@redhat.com>
57 lines
1.9 KiB
Python
57 lines
1.9 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
"""Tests for phi3v's multimodal preprocessing kwargs."""
|
|
import pytest
|
|
|
|
from vllm.multimodal import MULTIMODAL_REGISTRY
|
|
from vllm.multimodal.utils import cached_get_tokenizer
|
|
|
|
from ....conftest import _ImageAssets
|
|
from ...utils import build_model_context
|
|
|
|
|
|
@pytest.mark.parametrize("model_id", ["microsoft/Phi-3.5-vision-instruct"])
|
|
# yapf: disable
|
|
@pytest.mark.parametrize(
|
|
("mm_processor_kwargs", "expected_toks_per_img"),
|
|
[
|
|
({"num_crops": 4}, 757),
|
|
({"num_crops": 16}, 1921),
|
|
# the default num_crops of phi-3.5-vision is 4
|
|
({}, 757),
|
|
])
|
|
# yapf: enable
|
|
@pytest.mark.parametrize("num_imgs", [1, 2])
|
|
def test_processor_override(
|
|
image_assets: _ImageAssets,
|
|
model_id: str,
|
|
mm_processor_kwargs: dict[str, int],
|
|
expected_toks_per_img: int,
|
|
num_imgs: int,
|
|
):
|
|
"""Ensure input_processor_for_phi3v handles num_crops properly."""
|
|
# Avoid initializing CUDA early
|
|
from vllm.model_executor.models.phi3v import _IMAGE_TOKEN_ID
|
|
|
|
ctx = build_model_context(
|
|
model_name=model_id,
|
|
tokenizer_name=model_id,
|
|
trust_remote_code=True,
|
|
limit_mm_per_prompt={"image": num_imgs},
|
|
)
|
|
tokenizer = cached_get_tokenizer(ctx.model_config.tokenizer)
|
|
processor = MULTIMODAL_REGISTRY.create_processor(
|
|
ctx.model_config,
|
|
tokenizer=tokenizer,
|
|
)
|
|
|
|
# Build the image str / prompt based on the number of images we pass
|
|
img_str = "".join([f"<|image_{idx}|>\n" for idx in range(1, num_imgs + 1)])
|
|
prompt = f"<|user|>\n{img_str}<|end|>\n<|assistant|>\n"
|
|
mm_data = {"image": [image_assets[0].pil_image] * num_imgs}
|
|
|
|
processed_inputs = processor.apply(prompt, mm_data, mm_processor_kwargs)
|
|
|
|
# Ensure we have the right number of placeholders per num_crops size
|
|
img_tok_count = processed_inputs["prompt_token_ids"].count(_IMAGE_TOKEN_ID)
|
|
assert img_tok_count == expected_toks_per_img * num_imgs
|