
- **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>
69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import weakref
|
|
|
|
import pytest
|
|
# downloading lora to test lora requests
|
|
from huggingface_hub import snapshot_download
|
|
|
|
from vllm import LLM
|
|
from vllm.distributed import cleanup_dist_env_and_memory
|
|
from vllm.lora.request import LoRARequest
|
|
|
|
MODEL_NAME = "HuggingFaceH4/zephyr-7b-beta"
|
|
|
|
PROMPTS = [
|
|
"Hello, my name is",
|
|
"The president of the United States is",
|
|
"The capital of France is",
|
|
"The future of AI is",
|
|
]
|
|
|
|
LORA_NAME = "typeof/zephyr-7b-beta-lora"
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def llm():
|
|
# pytest caches the fixture so we use weakref.proxy to
|
|
# enable garbage collection
|
|
llm = LLM(model=MODEL_NAME,
|
|
tensor_parallel_size=1,
|
|
max_model_len=8192,
|
|
enable_lora=True,
|
|
max_loras=4,
|
|
max_lora_rank=64,
|
|
max_num_seqs=128,
|
|
enforce_eager=True)
|
|
|
|
with llm.deprecate_legacy_api():
|
|
yield weakref.proxy(llm)
|
|
|
|
del llm
|
|
|
|
cleanup_dist_env_and_memory()
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def zephyr_lora_files():
|
|
return snapshot_download(repo_id=LORA_NAME)
|
|
|
|
|
|
@pytest.mark.skip_global_cleanup
|
|
def test_multiple_lora_requests(llm: LLM, zephyr_lora_files):
|
|
lora_request = [
|
|
LoRARequest(LORA_NAME + str(idx), idx + 1, zephyr_lora_files)
|
|
for idx in range(len(PROMPTS))
|
|
]
|
|
# Multiple SamplingParams should be matched with each prompt
|
|
outputs = llm.generate(PROMPTS, lora_request=lora_request)
|
|
assert len(PROMPTS) == len(outputs)
|
|
|
|
# Exception raised, if the size of params does not match the size of prompts
|
|
with pytest.raises(ValueError):
|
|
outputs = llm.generate(PROMPTS, lora_request=lora_request[:1])
|
|
|
|
# Single LoRARequest should be applied to every prompt
|
|
single_lora_request = lora_request[0]
|
|
outputs = llm.generate(PROMPTS, lora_request=single_lora_request)
|
|
assert len(PROMPTS) == len(outputs)
|