mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-16 16:36:02 +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>
96 lines
3.2 KiB
Python
96 lines
3.2 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
# flake8: noqa
|
|
"""Tests fp8 models against ground truth generation
|
|
Note: these tests will only pass on L4 GPU.
|
|
"""
|
|
import os
|
|
from typing import Optional
|
|
|
|
import pytest
|
|
|
|
from tests.kernels.utils import override_backend_env_variable
|
|
from tests.quantization.utils import is_quant_method_supported
|
|
|
|
from ...utils import check_logprobs_close
|
|
|
|
os.environ["TOKENIZERS_PARALLELISM"] = "true"
|
|
|
|
|
|
@pytest.mark.quant_model
|
|
@pytest.mark.skipif(not is_quant_method_supported("fp8"),
|
|
reason="fp8 is not supported on this GPU type.")
|
|
@pytest.mark.parametrize(
|
|
"kv_cache_dtype,base_model,test_model",
|
|
[
|
|
# Test FP8 checkpoint w. fp8_e4m3 kv-cache scaling factors.
|
|
("fp8_e4m3", "meta-llama/Llama-3.2-1B-Instruct",
|
|
"nm-testing/Llama-3.2-1B-Instruct-FP8-KV"),
|
|
# Test FP16 checkpoint w. fp8_e5m2 kv-cache.
|
|
("fp8_e5m2", "meta-llama/Llama-3.2-1B-Instruct",
|
|
"meta-llama/Llama-3.2-1B-Instruct"),
|
|
# Test FP16 checkpoint w. fp8_e4m3 kv-cache scaling factors in json.
|
|
("fp8_e4m3", "meta-llama/Llama-2-7b-chat-hf",
|
|
"meta-llama/Llama-2-7b-chat-hf")
|
|
])
|
|
# Due to low-precision numerical divergence, we only test logprob of 4 tokens
|
|
@pytest.mark.parametrize("max_tokens", [4])
|
|
@pytest.mark.parametrize("enforce_eager", [True])
|
|
@pytest.mark.parametrize("backend", ["FLASH_ATTN", "XFORMERS", "FLASHINFER"])
|
|
# NOTE: Increasing this in this suite will fail CI because we currently cannot
|
|
# reset distributed env properly. Use a value > 1 just when you test.
|
|
@pytest.mark.parametrize("tensor_parallel_size", [1])
|
|
# Due to low-precision numerical divergence, this test is too sensitive for
|
|
# the async postprocessor
|
|
@pytest.mark.parametrize("disable_async_output_proc", [True])
|
|
def test_models(
|
|
vllm_runner,
|
|
example_prompts,
|
|
kv_cache_dtype: str,
|
|
base_model: str,
|
|
test_model: str,
|
|
max_tokens: int,
|
|
enforce_eager: bool,
|
|
backend: str,
|
|
tensor_parallel_size: int,
|
|
disable_async_output_proc: bool,
|
|
monkeypatch,
|
|
) -> None:
|
|
"""
|
|
Only checks log probs match to cover the discrepancy in
|
|
numerical sensitive kernels.
|
|
"""
|
|
override_backend_env_variable(monkeypatch, backend)
|
|
|
|
MAX_MODEL_LEN = 1024
|
|
NUM_LOG_PROBS = 8
|
|
|
|
with vllm_runner(
|
|
base_model,
|
|
max_model_len=MAX_MODEL_LEN,
|
|
tensor_parallel_size=tensor_parallel_size,
|
|
enforce_eager=enforce_eager,
|
|
kv_cache_dtype="auto",
|
|
disable_async_output_proc=disable_async_output_proc,
|
|
) as vllm_model:
|
|
baseline_outputs = vllm_model.generate_greedy_logprobs(
|
|
example_prompts, max_tokens, NUM_LOG_PROBS)
|
|
|
|
with vllm_runner(
|
|
test_model,
|
|
max_model_len=MAX_MODEL_LEN,
|
|
tensor_parallel_size=tensor_parallel_size,
|
|
enforce_eager=enforce_eager,
|
|
kv_cache_dtype=kv_cache_dtype,
|
|
disable_async_output_proc=disable_async_output_proc,
|
|
) as vllm_model:
|
|
test_outputs = vllm_model.generate_greedy_logprobs(
|
|
example_prompts, max_tokens, NUM_LOG_PROBS)
|
|
|
|
check_logprobs_close(
|
|
outputs_0_lst=baseline_outputs,
|
|
outputs_1_lst=test_outputs,
|
|
name_0="fp16_kv_cache",
|
|
name_1="fp8_kv_cache",
|
|
)
|