|
| 1 | +# |
| 2 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved. |
| 3 | +# This file is a part of the vllm-ascend project. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +import os |
| 18 | + |
| 19 | +import pytest |
| 20 | + |
| 21 | +from tests.conftest import VllmRunner |
| 22 | + |
| 23 | + |
| 24 | +@pytest.mark.skip(reason="Due to OOM,waiting for 1311pr to merge in") |
| 25 | +@pytest.mark.skipif(os.getenv("VLLM_USE_V1") == "0", |
| 26 | + reason="w4a8_dynamic is not supported on v0") |
| 27 | +def test_deepseek_W4A8(monkeypatch: pytest.MonkeyPatch): |
| 28 | + with monkeypatch.context() as m: |
| 29 | + m.setenv("VLLM_USE_V1", "1") |
| 30 | + |
| 31 | + prompts = [ |
| 32 | + "Hello, my name is", |
| 33 | + "The president of the United States is", |
| 34 | + "The capital of France is", |
| 35 | + "The future of AI is", |
| 36 | + ] |
| 37 | + dtype = "bfloat16" |
| 38 | + max_tokens = 5 |
| 39 | + with VllmRunner( |
| 40 | + "vllm-ascend/DeepSeek-R1-w4a8-pruning", |
| 41 | + dtype=dtype, |
| 42 | + tensor_parallel_size=2, |
| 43 | + enforce_eager=True, |
| 44 | + quantization="ascend", |
| 45 | + enable_expert_parallel=True, |
| 46 | + additional_config={ |
| 47 | + "torchair_graph_config": { |
| 48 | + "enabled": False, |
| 49 | + }, |
| 50 | + "ascend_scheduler_config": { |
| 51 | + "enabled": True, |
| 52 | + } |
| 53 | + }, |
| 54 | + ) as vllm_model: |
| 55 | + # use greedy sampler to make sure the generated results are fix |
| 56 | + vllm_output = vllm_model.generate_greedy(prompts, max_tokens) |
| 57 | + |
| 58 | + golden_results = [ |
| 59 | + 'Hello, my name is逸研究发现IPPudsimentary', |
| 60 | + 'The president of the United States is逸 Ban Corporealistically', |
| 61 | + 'The capital of France is逸 Ban Corporealistically', |
| 62 | + 'The future of AI is逸 Ban Corporealistically', |
| 63 | + ] |
| 64 | + assert len(golden_results) == len(vllm_output) |
| 65 | + for i in range(len(vllm_output)): |
| 66 | + assert golden_results[i] == vllm_output[i][1] |
| 67 | + print(f"Generated text: {vllm_output[i][1]!r}") |
0 commit comments