- **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>
83 lines
2.6 KiB
Python
83 lines
2.6 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from vllm import LLM, SamplingParams
|
|
from vllm.assets.image import ImageAsset
|
|
|
|
from ..utils import fork_new_process_for_each_test
|
|
|
|
|
|
@fork_new_process_for_each_test
|
|
def test_plugin(dummy_opt_path):
|
|
os.environ["VLLM_PLUGINS"] = ""
|
|
with pytest.raises(Exception) as excinfo:
|
|
LLM(model=dummy_opt_path, load_format="dummy")
|
|
assert "are not supported for now" in str(excinfo.value)
|
|
|
|
|
|
@fork_new_process_for_each_test
|
|
def test_oot_registration_text_generation(dummy_opt_path):
|
|
os.environ["VLLM_PLUGINS"] = "register_dummy_model"
|
|
prompts = ["Hello, my name is", "The text does not matter"]
|
|
sampling_params = SamplingParams(temperature=0)
|
|
llm = LLM(model=dummy_opt_path, load_format="dummy")
|
|
first_token = llm.get_tokenizer().decode(0)
|
|
outputs = llm.generate(prompts, sampling_params)
|
|
|
|
for output in outputs:
|
|
generated_text = output.outputs[0].text
|
|
# make sure only the first token is generated
|
|
rest = generated_text.replace(first_token, "")
|
|
assert rest == ""
|
|
|
|
|
|
@fork_new_process_for_each_test
|
|
def test_oot_registration_embedding(dummy_gemma2_embedding_path):
|
|
os.environ["VLLM_PLUGINS"] = "register_dummy_model"
|
|
prompts = ["Hello, my name is", "The text does not matter"]
|
|
llm = LLM(model=dummy_gemma2_embedding_path, load_format="dummy")
|
|
outputs = llm.embed(prompts)
|
|
|
|
for output in outputs:
|
|
assert all(v == 0 for v in output.outputs.embedding)
|
|
|
|
|
|
image = ImageAsset("cherry_blossom").pil_image.convert("RGB")
|
|
|
|
|
|
@fork_new_process_for_each_test
|
|
def test_oot_registration_multimodal(dummy_llava_path):
|
|
os.environ["VLLM_PLUGINS"] = "register_dummy_model"
|
|
prompts = [{
|
|
"prompt": "What's in the image?<image>",
|
|
"multi_modal_data": {
|
|
"image": image
|
|
},
|
|
}, {
|
|
"prompt": "Describe the image<image>",
|
|
"multi_modal_data": {
|
|
"image": image
|
|
},
|
|
}]
|
|
|
|
sampling_params = SamplingParams(temperature=0)
|
|
llm = LLM(model=dummy_llava_path,
|
|
load_format="dummy",
|
|
max_num_seqs=1,
|
|
trust_remote_code=True,
|
|
gpu_memory_utilization=0.98,
|
|
max_model_len=4096,
|
|
enforce_eager=True,
|
|
limit_mm_per_prompt={"image": 1})
|
|
first_token = llm.get_tokenizer().decode(0)
|
|
outputs = llm.generate(prompts, sampling_params)
|
|
|
|
for output in outputs:
|
|
generated_text = output.outputs[0].text
|
|
# make sure only the first token is generated
|
|
rest = generated_text.replace(first_token, "")
|
|
assert rest == ""
|