0
tests/e2e/pull_request/one_card/_310p/__init__.py
Normal file
0
tests/e2e/pull_request/one_card/_310p/__init__.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import pytest
|
||||
import torch
|
||||
from modelscope import snapshot_download # type: ignore[import-untyped]
|
||||
from transformers import AutoModelForSequenceClassification
|
||||
|
||||
from tests.e2e.conftest import HfRunner, VllmRunner
|
||||
|
||||
|
||||
@pytest.mark.skip("Probabilistic failure, need fix")
|
||||
def test_qwen_pooling_classify_correctness() -> None:
|
||||
model_name = snapshot_download("Howeee/Qwen2.5-1.5B-apeach")
|
||||
|
||||
prompts = [
|
||||
"Hello, my name is",
|
||||
"The president of the United States is",
|
||||
"The capital of France is",
|
||||
"The future of AI is what",
|
||||
]
|
||||
|
||||
with VllmRunner(
|
||||
model_name,
|
||||
runner="pooling",
|
||||
max_model_len=1024,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
gpu_memory_utilization=0.6,
|
||||
) as vllm_runner:
|
||||
vllm_outputs = vllm_runner.classify(prompts)
|
||||
|
||||
with HfRunner(
|
||||
model_name,
|
||||
dtype="float16",
|
||||
model_kwargs={"attn_implementation": "eager"},
|
||||
auto_cls=AutoModelForSequenceClassification,
|
||||
) as hf_runner:
|
||||
hf_outputs = hf_runner.classify(prompts)
|
||||
|
||||
for hf_output, vllm_output in zip(hf_outputs, vllm_outputs):
|
||||
hf_output = torch.tensor(hf_output)
|
||||
vllm_output = torch.tensor(vllm_output)
|
||||
assert torch.allclose(hf_output, vllm_output, 1e-2)
|
||||
173
tests/e2e/pull_request/one_card/_310p/test_dense_model_310p.py
Normal file
173
tests/e2e/pull_request/one_card/_310p/test_dense_model_310p.py
Normal file
@@ -0,0 +1,173 @@
|
||||
#
|
||||
# Copyright (c) 2026 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.
|
||||
|
||||
|
||||
from tests.e2e.conftest import VllmRunner, wait_until_npu_memory_free
|
||||
from tests.e2e.model_utils import check_outputs_equal
|
||||
|
||||
QWEN3_5_PREFIX_MAMBA_PROMPT = (
|
||||
"You are reading a compact synthetic operations ledger. "
|
||||
"Use only the rows below when answering the final question.\n"
|
||||
+ "\n".join(
|
||||
f"Row {i}: route R{i:03d} moves cargo from zone {i % 11} to zone {(i * 7) % 13}; priority is {i % 5}."
|
||||
for i in range(64)
|
||||
)
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
QWEN3_5_PREFIX_MAMBA_PROMPTS = [
|
||||
QWEN3_5_PREFIX_MAMBA_PROMPT + "Question: What route is listed in row 17? Answer briefly.",
|
||||
QWEN3_5_PREFIX_MAMBA_PROMPT + "Question: What priority is listed in row 42? Answer briefly.",
|
||||
]
|
||||
|
||||
|
||||
def _generate_qwen3_5_prefix_mamba_outputs(enable_prefix_caching: bool) -> list[tuple[list[int], str]]:
|
||||
outputs: list[tuple[list[int], str]] = []
|
||||
|
||||
if enable_prefix_caching:
|
||||
with VllmRunner(
|
||||
"Qwen/Qwen3.5-4B",
|
||||
tensor_parallel_size=1,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
max_model_len=2048,
|
||||
max_num_batched_tokens=2048,
|
||||
enable_prefix_caching=True,
|
||||
mamba_cache_mode="align",
|
||||
mamba_ssm_cache_dtype="float16",
|
||||
) as vllm_model:
|
||||
for prompt in QWEN3_5_PREFIX_MAMBA_PROMPTS:
|
||||
outputs.extend(vllm_model.generate_greedy([prompt], max_tokens=8))
|
||||
else:
|
||||
with VllmRunner(
|
||||
"Qwen/Qwen3.5-4B",
|
||||
tensor_parallel_size=1,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
max_model_len=2048,
|
||||
max_num_batched_tokens=2048,
|
||||
enable_prefix_caching=False,
|
||||
mamba_ssm_cache_dtype="float16",
|
||||
) as vllm_model:
|
||||
for prompt in QWEN3_5_PREFIX_MAMBA_PROMPTS:
|
||||
outputs.extend(vllm_model.generate_greedy([prompt], max_tokens=8))
|
||||
return outputs
|
||||
|
||||
|
||||
def test_qwen3_dense_tp1_fp16():
|
||||
example_prompts = [
|
||||
"Hello, my name is",
|
||||
]
|
||||
max_tokens = 5
|
||||
with VllmRunner(
|
||||
"Qwen/Qwen3-8B",
|
||||
tensor_parallel_size=1,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
max_model_len=16384,
|
||||
) as vllm_model:
|
||||
vllm_model.generate_greedy(example_prompts, max_tokens)
|
||||
|
||||
|
||||
@wait_until_npu_memory_free(0.7)
|
||||
def test_qwen3_dense_tp1_fp16_aclgraph():
|
||||
example_prompts = [
|
||||
"Hello, my name is",
|
||||
] * 8
|
||||
max_tokens = 2
|
||||
with VllmRunner(
|
||||
"Qwen/Qwen3-8B",
|
||||
tensor_parallel_size=1,
|
||||
dtype="float16",
|
||||
max_num_seqs=16,
|
||||
max_model_len=16384,
|
||||
gpu_memory_utilization=0.80,
|
||||
additional_config={"ascend_compilation_config": {"fuse_norm_quant": False}},
|
||||
compilation_config={
|
||||
"cudagraph_mode": "FULL_DECODE_ONLY",
|
||||
"cudagraph_capture_sizes": [1, 2, 4, 8, 16],
|
||||
},
|
||||
) as vllm_model:
|
||||
vllm_model.generate_greedy(example_prompts, max_tokens)
|
||||
|
||||
|
||||
def test_qwen3_dense_tp1_w8a8():
|
||||
example_prompts = [
|
||||
"Hello, my name is",
|
||||
]
|
||||
max_tokens = 5
|
||||
with VllmRunner(
|
||||
"vllm-ascend/Qwen3-8B-W8A8",
|
||||
tensor_parallel_size=1,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
quantization="ascend",
|
||||
max_model_len=16384,
|
||||
) as vllm_model:
|
||||
vllm_model.generate_greedy(example_prompts, max_tokens)
|
||||
|
||||
|
||||
def test_qwen3_5_dense_tp1_fp16():
|
||||
example_prompts = [
|
||||
"Hello, my name is",
|
||||
]
|
||||
max_tokens = 5
|
||||
with VllmRunner(
|
||||
"Qwen/Qwen3.5-4B",
|
||||
tensor_parallel_size=1,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
max_model_len=16384,
|
||||
) as vllm_model:
|
||||
vllm_model.generate_greedy(example_prompts, max_tokens)
|
||||
|
||||
|
||||
@wait_until_npu_memory_free(0.7)
|
||||
def test_qwen3_5_dense_prefix_mamba_cache_tp1_fp16():
|
||||
prefix_cache_outputs = _generate_qwen3_5_prefix_mamba_outputs(enable_prefix_caching=True)
|
||||
no_prefix_cache_outputs = _generate_qwen3_5_prefix_mamba_outputs(enable_prefix_caching=False)
|
||||
|
||||
assert len(prefix_cache_outputs) == len(no_prefix_cache_outputs) == len(QWEN3_5_PREFIX_MAMBA_PROMPTS)
|
||||
check_outputs_equal(
|
||||
outputs_0_lst=no_prefix_cache_outputs,
|
||||
outputs_1_lst=prefix_cache_outputs,
|
||||
name_0="no_prefix_cache_outputs",
|
||||
name_1="prefix_cache_outputs",
|
||||
)
|
||||
|
||||
|
||||
@wait_until_npu_memory_free(0.7)
|
||||
def test_qwen3_5_dense_tp1_fp16_aclgraph():
|
||||
example_prompts = [
|
||||
"Hello, my name is",
|
||||
] * 8
|
||||
max_tokens = 2
|
||||
with VllmRunner(
|
||||
"Qwen/Qwen3.5-4B",
|
||||
tensor_parallel_size=1,
|
||||
dtype="float16",
|
||||
max_num_seqs=16,
|
||||
max_model_len=16384,
|
||||
gpu_memory_utilization=0.80,
|
||||
additional_config={"ascend_compilation_config": {"fuse_norm_quant": False}},
|
||||
compilation_config={
|
||||
"cudagraph_mode": "FULL_DECODE_ONLY",
|
||||
"cudagraph_capture_sizes": [1, 2, 4, 8, 16],
|
||||
},
|
||||
mamba_ssm_cache_dtype="float16",
|
||||
) as vllm_model:
|
||||
vllm_model.generate_greedy(example_prompts, max_tokens)
|
||||
106
tests/e2e/pull_request/one_card/_310p/test_embedding_310p.py
Normal file
106
tests/e2e/pull_request/one_card/_310p/test_embedding_310p.py
Normal file
@@ -0,0 +1,106 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
import pytest
|
||||
from modelscope import snapshot_download # type: ignore[import-untyped]
|
||||
|
||||
from tests.e2e.conftest import HfRunner, VllmRunner
|
||||
from tests.e2e.utils import check_embeddings_close
|
||||
|
||||
MODELS = [
|
||||
"Qwen/Qwen3-Embedding-0.6B", # lasttoken
|
||||
"intfloat/multilingual-e5-small", # mean_tokens
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("model", MODELS)
|
||||
def test_embed_models_correctness(model: str):
|
||||
queries = ["What is the capital of China?", "Explain gravity"]
|
||||
|
||||
model_name = snapshot_download(model)
|
||||
with VllmRunner(
|
||||
model_name,
|
||||
runner="pooling",
|
||||
max_model_len=512,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
gpu_memory_utilization=0.6,
|
||||
) as vllm_runner:
|
||||
vllm_outputs = vllm_runner.embed(queries)
|
||||
|
||||
with HfRunner(
|
||||
model_name,
|
||||
dtype="float16",
|
||||
is_sentence_transformer=True,
|
||||
) as hf_runner:
|
||||
hf_outputs = hf_runner.encode(queries)
|
||||
|
||||
check_embeddings_close(
|
||||
embeddings_0_lst=hf_outputs,
|
||||
embeddings_1_lst=vllm_outputs,
|
||||
name_0="hf",
|
||||
name_1="vllm",
|
||||
tol=1e-2,
|
||||
)
|
||||
|
||||
|
||||
def test_bge_m3_correctness():
|
||||
queries = ["What is the capital of China?", "Explain gravity"]
|
||||
|
||||
model_name = snapshot_download("BAAI/bge-m3")
|
||||
with VllmRunner(
|
||||
model_name,
|
||||
runner="pooling",
|
||||
max_model_len=1024,
|
||||
dtype="float16",
|
||||
cudagraph_capture_sizes=[512, 1024],
|
||||
additional_config={"ascend_compilation_config": {"fuse_norm_quant": False}},
|
||||
) as vllm_aclgraph_runner:
|
||||
vllm_aclgraph_outputs = vllm_aclgraph_runner.embed(queries)
|
||||
|
||||
with VllmRunner(
|
||||
model_name,
|
||||
runner="pooling",
|
||||
max_model_len=1024,
|
||||
dtype="float16",
|
||||
enforce_eager=True,
|
||||
) as vllm_runner:
|
||||
vllm_eager_outputs = vllm_runner.embed(queries)
|
||||
|
||||
with HfRunner(
|
||||
model_name,
|
||||
dtype="float16",
|
||||
is_sentence_transformer=True,
|
||||
) as hf_runner:
|
||||
hf_outputs = hf_runner.encode(queries)
|
||||
|
||||
check_embeddings_close(
|
||||
embeddings_0_lst=hf_outputs,
|
||||
embeddings_1_lst=vllm_eager_outputs,
|
||||
name_0="hf",
|
||||
name_1="vllm",
|
||||
tol=1e-2,
|
||||
)
|
||||
|
||||
check_embeddings_close(
|
||||
embeddings_0_lst=vllm_eager_outputs,
|
||||
embeddings_1_lst=vllm_aclgraph_outputs,
|
||||
name_0="eager",
|
||||
name_1="aclgraph",
|
||||
tol=1e-2,
|
||||
)
|
||||
87
tests/e2e/pull_request/one_card/_310p/test_scoring_310p.py
Normal file
87
tests/e2e/pull_request/one_card/_310p/test_scoring_310p.py
Normal file
@@ -0,0 +1,87 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
import pytest
|
||||
from modelscope import snapshot_download # type: ignore[import-untyped]
|
||||
|
||||
from tests.e2e.conftest import HfRunner, VllmRunner
|
||||
|
||||
CROSS_ENCODER_MODELS = [
|
||||
"BAAI/bge-reranker-v2-m3", # Roberta
|
||||
]
|
||||
|
||||
|
||||
TEXTS_1 = [
|
||||
"What is the capital of France?",
|
||||
"What is the capital of Germany?",
|
||||
]
|
||||
|
||||
TEXTS_2 = [
|
||||
"The capital of France is Paris.",
|
||||
"The capital of Germany is Berlin.",
|
||||
]
|
||||
|
||||
DTYPE = "float16"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module", params=CROSS_ENCODER_MODELS)
|
||||
def model_name(request):
|
||||
yield snapshot_download(request.param)
|
||||
|
||||
|
||||
def test_cross_encoder_score_1_to_1(model_name):
|
||||
text_pair = [TEXTS_1[0], TEXTS_2[0]]
|
||||
|
||||
with HfRunner(model_name, dtype=DTYPE, is_cross_encoder=True) as hf_model:
|
||||
hf_outputs = hf_model.predict([text_pair]).tolist()
|
||||
|
||||
with VllmRunner(
|
||||
model_name, runner="pooling", dtype=DTYPE, max_model_len=1024, enforce_eager=True, gpu_memory_utilization=0.6
|
||||
) as vllm_model:
|
||||
vllm_outputs = vllm_model.score(text_pair[0], text_pair[1])
|
||||
|
||||
assert len(vllm_outputs) == 1
|
||||
assert len(hf_outputs) == 1
|
||||
|
||||
assert hf_outputs[0] == pytest.approx(vllm_outputs[0], rel=0.01)
|
||||
|
||||
|
||||
def test_cross_encoder_score_1_to_N(model_name):
|
||||
text_pairs = [
|
||||
[TEXTS_1[0], TEXTS_2[0]],
|
||||
[TEXTS_1[0], TEXTS_2[1]],
|
||||
]
|
||||
|
||||
with HfRunner(model_name, dtype=DTYPE, is_cross_encoder=True) as hf_model:
|
||||
hf_outputs = hf_model.predict(text_pairs).tolist()
|
||||
|
||||
with VllmRunner(
|
||||
model_name, runner="pooling", dtype=DTYPE, max_model_len=1024, enforce_eager=True, gpu_memory_utilization=0.6
|
||||
) as vllm_model:
|
||||
vllm_outputs = vllm_model.score(TEXTS_1[0], TEXTS_2)
|
||||
|
||||
assert len(vllm_outputs) == 2
|
||||
assert len(hf_outputs) == 2
|
||||
|
||||
assert hf_outputs[0] == pytest.approx(vllm_outputs[0], rel=0.01)
|
||||
assert hf_outputs[1] == pytest.approx(vllm_outputs[1], rel=0.01)
|
||||
|
||||
|
||||
def test_cross_encoder_score_N_to_N(model_name):
|
||||
text_pairs = [
|
||||
[TEXTS_1[0], TEXTS_2[0]],
|
||||
[TEXTS_1[1], TEXTS_2[1]],
|
||||
]
|
||||
|
||||
with HfRunner(model_name, dtype=DTYPE, is_cross_encoder=True) as hf_model:
|
||||
hf_outputs = hf_model.predict(text_pairs).tolist()
|
||||
|
||||
with VllmRunner(
|
||||
model_name, runner="pooling", dtype=DTYPE, max_model_len=1024, enforce_eager=True, gpu_memory_utilization=0.6
|
||||
) as vllm_model:
|
||||
vllm_outputs = vllm_model.score(TEXTS_1, TEXTS_2)
|
||||
|
||||
assert len(vllm_outputs) == 2
|
||||
assert len(hf_outputs) == 2
|
||||
|
||||
assert hf_outputs[0] == pytest.approx(vllm_outputs[0], rel=0.01)
|
||||
assert hf_outputs[1] == pytest.approx(vllm_outputs[1], rel=0.01)
|
||||
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# Copyright (c) 2026 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.
|
||||
|
||||
from tests.e2e.conftest import VllmRunner
|
||||
|
||||
|
||||
def test_qwen3_5_mtp_tp1_eager():
|
||||
example_prompts = ["Hello, my name is"]
|
||||
with VllmRunner(
|
||||
"Qwen/Qwen3.5-4B",
|
||||
tensor_parallel_size=1,
|
||||
enforce_eager=True,
|
||||
dtype="float16",
|
||||
max_model_len=2048,
|
||||
mamba_ssm_cache_dtype="float16",
|
||||
speculative_config={
|
||||
"method": "qwen3_5_mtp",
|
||||
"num_speculative_tokens": 1,
|
||||
},
|
||||
) as vllm_model:
|
||||
vllm_model.generate_greedy(example_prompts, max_tokens=8)
|
||||
34
tests/e2e/pull_request/one_card/_310p/test_vl_model_310p.py
Normal file
34
tests/e2e/pull_request/one_card/_310p/test_vl_model_310p.py
Normal file
@@ -0,0 +1,34 @@
|
||||
#
|
||||
# Copyright (c) 2026 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.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from tests.e2e.conftest import wait_until_npu_memory_free
|
||||
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
full_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
sys.path.insert(0, full_dir)
|
||||
|
||||
# ruff: noqa: E402
|
||||
from tests.e2e.pull_request.utils_310p import run_vl_model_test
|
||||
|
||||
|
||||
@wait_until_npu_memory_free(target_free_percentage=0.7)
|
||||
def test_qwen3_vl_8b_tp1_fp16():
|
||||
"""Qwen3-VL-8B single-card FP16 test"""
|
||||
run_vl_model_test(model_name="Qwen/Qwen3-VL-8B-Instruct", tensor_parallel_size=1, max_tokens=5)
|
||||
Reference in New Issue
Block a user