### What this PR does / why we need it?
While using the LLM Compressor quantization tool from the VLLM community
to generate quantized weights, the VLLM Ascend engine needs to be
adapted to support the compressed tensors quantization format.
1. Support Moe model W8A8 Int8 dynamic weight.
2. Specify W4A16 quantization configuration.
Co-authored-by: menogrey 1299267905@qq.com
Co-authored-by: kunpengW-code 1289706727@qq.com
### Does this PR introduce _any_ user-facing change?
No
- vLLM version: v0.13.0
- vLLM main:
2f4e6548ef
---------
Signed-off-by: LHXuuu <scut_xlh@163.com>
Signed-off-by: menogrey <1299267905@qq.com>
Signed-off-by: Wang Kunpeng <1289706727@qq.com>
Co-authored-by: menogrey <1299267905@qq.com>
Co-authored-by: Wang Kunpeng <1289706727@qq.com>
68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
#
|
|
# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved.
|
|
# Copyright 2023 The vLLM team.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# This file is a part of the vllm-ascend project.
|
|
# Adapted from vllm/tests/basic_correctness/test_basic_correctness.py
|
|
#
|
|
from modelscope import snapshot_download # type: ignore
|
|
|
|
from tests.e2e.conftest import VllmRunner
|
|
|
|
|
|
def test_qwen2_5_w8a8_external_quantized_tp2():
|
|
example_prompts = [
|
|
"The president of the United States is",
|
|
]
|
|
max_tokens = 5
|
|
with VllmRunner(
|
|
snapshot_download("neuralmagic/Qwen2.5-3B-quantized.w8a8"),
|
|
tensor_parallel_size=2,
|
|
cudagraph_capture_sizes=[1, 2, 4, 8],
|
|
max_model_len=4096,
|
|
gpu_memory_utilization=0.8,
|
|
) as vllm_model:
|
|
vllm_output = vllm_model.generate_greedy(example_prompts, max_tokens)
|
|
|
|
golden_results = [
|
|
'The president of the United States is the head of state and',
|
|
]
|
|
|
|
for i in range(len(vllm_output)):
|
|
assert golden_results[i] == vllm_output[i][1]
|
|
print(f"Generated text: {vllm_output[i][1]!r}")
|
|
|
|
|
|
def test_qwen3_moe_w8a8_dynamic_llm_compressor():
|
|
example_prompts = [
|
|
"The president of the United States is",
|
|
]
|
|
max_tokens = 5
|
|
with VllmRunner(
|
|
snapshot_download(
|
|
"vllm-ascend/Qwen3-30B-A3B-Instruct-2507-quantized.w8a8"),
|
|
tensor_parallel_size=2,
|
|
max_model_len=4096,
|
|
gpu_memory_utilization=0.8,
|
|
) as vllm_model:
|
|
vllm_output = vllm_model.generate_greedy(example_prompts, max_tokens)
|
|
|
|
golden_results = [
|
|
'The president of the United States is the head of state and',
|
|
]
|
|
|
|
for i in range(len(vllm_output)):
|
|
assert golden_results[i] == vllm_output[i][1]
|
|
print(f"Generated text: {vllm_output[i][1]!r}")
|