mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-20 10:25:34 +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>
141 lines
5.4 KiB
Python
141 lines
5.4 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
"""Entrypoints for wrapping the core run_test implementation for specific test
|
|
types / modalities.
|
|
"""
|
|
from pathlib import PosixPath
|
|
from typing import Type
|
|
|
|
from .....conftest import HfRunner, VllmRunner, _ImageAssets, _VideoAssets
|
|
from . import builders, core
|
|
from .types import ExpandableVLMTestArgs, VLMTestInfo
|
|
|
|
|
|
####### Entrypoints for running different test types
|
|
def run_single_image_test(*, tmp_path: PosixPath, model_test_info: VLMTestInfo,
|
|
test_case: ExpandableVLMTestArgs,
|
|
hf_runner: Type[HfRunner],
|
|
vllm_runner: Type[VllmRunner],
|
|
image_assets: _ImageAssets):
|
|
assert test_case.size_wrapper is not None
|
|
inputs = builders.build_single_image_inputs_from_test_info(
|
|
model_test_info, image_assets, test_case.size_wrapper, tmp_path)
|
|
|
|
core.run_test(
|
|
hf_runner=hf_runner,
|
|
vllm_runner=vllm_runner,
|
|
inputs=inputs,
|
|
model=test_case.model,
|
|
dtype=test_case.dtype,
|
|
max_tokens=test_case.max_tokens,
|
|
num_logprobs=test_case.num_logprobs,
|
|
limit_mm_per_prompt={"image": 1},
|
|
distributed_executor_backend=test_case.distributed_executor_backend,
|
|
runner_mm_key="images",
|
|
**model_test_info.get_non_parametrized_runner_kwargs())
|
|
|
|
|
|
def run_multi_image_test(*, tmp_path: PosixPath, model_test_info: VLMTestInfo,
|
|
test_case: ExpandableVLMTestArgs,
|
|
hf_runner: Type[HfRunner],
|
|
vllm_runner: Type[VllmRunner],
|
|
image_assets: _ImageAssets):
|
|
assert test_case.size_wrapper is not None
|
|
inputs = builders.build_multi_image_inputs_from_test_info(
|
|
model_test_info, image_assets, test_case.size_wrapper, tmp_path)
|
|
|
|
core.run_test(
|
|
hf_runner=hf_runner,
|
|
vllm_runner=vllm_runner,
|
|
inputs=inputs,
|
|
model=test_case.model,
|
|
dtype=test_case.dtype,
|
|
max_tokens=test_case.max_tokens,
|
|
num_logprobs=test_case.num_logprobs,
|
|
limit_mm_per_prompt={"image": len(image_assets)},
|
|
distributed_executor_backend=test_case.distributed_executor_backend,
|
|
runner_mm_key="images",
|
|
**model_test_info.get_non_parametrized_runner_kwargs())
|
|
|
|
|
|
def run_embedding_test(*, model_test_info: VLMTestInfo,
|
|
test_case: ExpandableVLMTestArgs,
|
|
hf_runner: Type[HfRunner],
|
|
vllm_runner: Type[VllmRunner],
|
|
image_assets: _ImageAssets):
|
|
assert test_case.size_wrapper is not None
|
|
inputs, vllm_embeddings = builders.build_embedding_inputs_from_test_info(
|
|
model_test_info, image_assets, test_case.size_wrapper)
|
|
|
|
core.run_test(
|
|
hf_runner=hf_runner,
|
|
vllm_runner=vllm_runner,
|
|
inputs=inputs,
|
|
model=test_case.model,
|
|
dtype=test_case.dtype,
|
|
max_tokens=test_case.max_tokens,
|
|
num_logprobs=test_case.num_logprobs,
|
|
limit_mm_per_prompt={"image": 1},
|
|
vllm_embeddings=vllm_embeddings,
|
|
distributed_executor_backend=test_case.distributed_executor_backend,
|
|
runner_mm_key="images",
|
|
**model_test_info.get_non_parametrized_runner_kwargs())
|
|
|
|
|
|
def run_video_test(
|
|
*,
|
|
model_test_info: VLMTestInfo,
|
|
test_case: ExpandableVLMTestArgs,
|
|
hf_runner: Type[HfRunner],
|
|
vllm_runner: Type[VllmRunner],
|
|
video_assets: _VideoAssets,
|
|
):
|
|
assert test_case.size_wrapper is not None
|
|
assert test_case.num_video_frames is not None
|
|
inputs = builders.build_video_inputs_from_test_info(
|
|
model_test_info, video_assets, test_case.size_wrapper,
|
|
test_case.num_video_frames)
|
|
|
|
core.run_test(
|
|
hf_runner=hf_runner,
|
|
vllm_runner=vllm_runner,
|
|
inputs=inputs,
|
|
model=test_case.model,
|
|
dtype=test_case.dtype,
|
|
max_tokens=test_case.max_tokens,
|
|
num_logprobs=test_case.num_logprobs,
|
|
limit_mm_per_prompt={"video": len(video_assets)},
|
|
distributed_executor_backend=test_case.distributed_executor_backend,
|
|
runner_mm_key="videos",
|
|
**model_test_info.get_non_parametrized_runner_kwargs())
|
|
|
|
|
|
def run_custom_inputs_test(*, model_test_info: VLMTestInfo,
|
|
test_case: ExpandableVLMTestArgs,
|
|
hf_runner: Type[HfRunner],
|
|
vllm_runner: Type[VllmRunner]):
|
|
# Custom test cases can provide inputs directly, but they need to
|
|
# explicitly provided a CustomTestConfig, which wraps the inputs and
|
|
# the limit_mm_per_prompt
|
|
assert test_case.custom_test_opts is not None
|
|
|
|
inputs = test_case.custom_test_opts.inputs
|
|
limit_mm_per_prompt = test_case.custom_test_opts.limit_mm_per_prompt
|
|
runner_mm_key = test_case.custom_test_opts.runner_mm_key
|
|
# Inputs, limit_mm_per_prompt, and runner_mm_key should all be set
|
|
assert inputs is not None
|
|
assert limit_mm_per_prompt is not None
|
|
assert runner_mm_key is not None
|
|
|
|
core.run_test(
|
|
hf_runner=hf_runner,
|
|
vllm_runner=vllm_runner,
|
|
inputs=inputs,
|
|
model=test_case.model,
|
|
dtype=test_case.dtype,
|
|
max_tokens=test_case.max_tokens,
|
|
num_logprobs=test_case.num_logprobs,
|
|
limit_mm_per_prompt=limit_mm_per_prompt,
|
|
distributed_executor_backend=test_case.distributed_executor_backend,
|
|
runner_mm_key=runner_mm_key,
|
|
**model_test_info.get_non_parametrized_runner_kwargs())
|