mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2025-12-10 16:15:40 +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>
52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
"""Tests whether gptq models with quantized lm_head can be loaded.
|
|
|
|
Run `pytest tests/quantization/test_quant_lm_head_true.py --forked`.
|
|
"""
|
|
from typing import Tuple
|
|
|
|
import pytest
|
|
import torch
|
|
|
|
from vllm.model_executor.layers.quantization.gptq import GPTQLinearMethod
|
|
from vllm.model_executor.layers.quantization.gptq_marlin import (
|
|
GPTQMarlinLinearMethod)
|
|
from vllm.model_executor.layers.quantization.marlin import MarlinLinearMethod
|
|
from vllm.model_executor.layers.vocab_parallel_embedding import (
|
|
UnquantizedEmbeddingMethod)
|
|
|
|
PROMPT = "On the surface of Mars, we found"
|
|
|
|
MODELS_QUANT = [(
|
|
"LnL-AI/TinyLlama-1.1B-intermediate-step-1341k-3T-autoround-lm_head-symFalse",
|
|
True), ("TheBloke/TinyLlama-1.1B-Chat-v1.0-GPTQ", False),
|
|
("neuralmagic/Meta-Llama-3-8B-Instruct-FP8", False)]
|
|
|
|
|
|
@pytest.mark.parametrize("model_lm_head_quant", MODELS_QUANT)
|
|
def test_lm_head(
|
|
vllm_runner,
|
|
model_lm_head_quant: Tuple[str, bool],
|
|
) -> None:
|
|
model, lm_head_quantized = model_lm_head_quant
|
|
|
|
with vllm_runner(model, dtype=torch.float16,
|
|
max_model_len=2048) as vllm_model:
|
|
|
|
def check_model(model):
|
|
lm_head_layer = model.lm_head
|
|
|
|
if lm_head_quantized:
|
|
assert isinstance(lm_head_layer.linear_method,
|
|
(GPTQLinearMethod, GPTQMarlinLinearMethod,
|
|
MarlinLinearMethod))
|
|
else:
|
|
assert isinstance(lm_head_layer.linear_method,
|
|
UnquantizedEmbeddingMethod)
|
|
|
|
vllm_model.apply_model(check_model)
|
|
|
|
print(
|
|
vllm_model.generate_greedy(prompts=["Hello my name is"],
|
|
max_tokens=10)[0][1])
|