2025-12-08 08:27:46 +08:00
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
#
|
|
|
|
|
"""
|
2026-03-23 09:08:21 +08:00
|
|
|
Compare the outputs of vLLM with and without xlite via logprob-based accuracy
|
|
|
|
|
check (3 tokens: 1 prefill + 2 decode).
|
2025-12-08 08:27:46 +08:00
|
|
|
|
|
|
|
|
Run `pytest tests/e2e/singlecard/test_xlite.py`.
|
|
|
|
|
"""
|
|
|
|
|
|
2026-02-24 15:50:00 +08:00
|
|
|
# ruff: noqa: E501
|
|
|
|
|
|
2025-12-25 09:17:06 +08:00
|
|
|
import os
|
|
|
|
|
|
2025-12-08 08:27:46 +08:00
|
|
|
import pytest
|
|
|
|
|
|
2026-03-23 09:08:21 +08:00
|
|
|
from tests.e2e.singlecard.utils import PROMPTS_SHORT, LLMTestCase, compare_logprobs
|
2025-12-08 08:27:46 +08:00
|
|
|
|
2025-12-25 09:17:06 +08:00
|
|
|
os.environ["VLLM_ASCEND_ENABLE_NZ"] = "2"
|
|
|
|
|
|
2026-01-07 20:58:15 +08:00
|
|
|
CASE_DECODE_ONLY = LLMTestCase(
|
|
|
|
|
model="Qwen/Qwen3-0.6B",
|
|
|
|
|
prompts=PROMPTS_SHORT,
|
2026-02-24 15:50:00 +08:00
|
|
|
)
|
2026-01-07 20:58:15 +08:00
|
|
|
|
2026-01-21 09:26:03 +08:00
|
|
|
CASE_FULL = LLMTestCase(
|
2026-01-07 20:58:15 +08:00
|
|
|
model="Qwen/Qwen3-0.6B",
|
2026-03-23 09:08:21 +08:00
|
|
|
prompts=PROMPTS_SHORT,
|
2026-02-24 15:50:00 +08:00
|
|
|
)
|
2025-12-25 09:17:06 +08:00
|
|
|
|
2025-12-08 08:27:46 +08:00
|
|
|
|
2026-02-24 15:50:00 +08:00
|
|
|
@pytest.mark.skip(reason="TODO: Re-enable xlite_decode_only e2e test when stable.")
|
2026-01-07 20:58:15 +08:00
|
|
|
@pytest.mark.parametrize("cur_case", [CASE_DECODE_ONLY])
|
|
|
|
|
def test_models_with_xlite_decode_only(cur_case: LLMTestCase):
|
|
|
|
|
runner_kwargs = {
|
|
|
|
|
"model_name": cur_case.model,
|
|
|
|
|
"max_model_len": 1024,
|
|
|
|
|
"block_size": 128,
|
2026-02-24 15:50:00 +08:00
|
|
|
"additional_config": {"xlite_graph_config": {"enabled": True}},
|
2026-01-07 20:58:15 +08:00
|
|
|
}
|
2026-03-23 09:08:21 +08:00
|
|
|
compare_logprobs(runner_kwargs=runner_kwargs, prompts=cur_case.prompts)
|
2026-01-07 20:58:15 +08:00
|
|
|
|
|
|
|
|
|
2026-01-21 09:26:03 +08:00
|
|
|
@pytest.mark.parametrize("cur_case", [CASE_FULL])
|
2026-01-07 20:58:15 +08:00
|
|
|
def test_models_with_xlite_full_mode(cur_case: LLMTestCase):
|
|
|
|
|
runner_kwargs = {
|
|
|
|
|
"model_name": cur_case.model,
|
|
|
|
|
"max_model_len": 1024,
|
|
|
|
|
"block_size": 128,
|
2026-02-24 15:50:00 +08:00
|
|
|
"additional_config": {"xlite_graph_config": {"enabled": True, "full_mode": True}},
|
2026-01-07 20:58:15 +08:00
|
|
|
}
|
2026-03-23 09:08:21 +08:00
|
|
|
compare_logprobs(runner_kwargs=runner_kwargs, prompts=cur_case.prompts)
|