Skip to content

Commit 10772d9

Browse files
authored
[Build] Force torch version (#3791)
We notice that sometimes user build vllm-ascend with incorrect torch version. In this case, the build is passed, but when running the code, the error `AttributeError: '_OpNamespace' '_C_ascend' object has no attribute 'weak_ref_tensor'` is raised. Let's force the torch version to 2.7.1 and check the torch version when build from source to fix the issue. closes: #3342 - vLLM version: v0.11.0rc3 - vLLM main: vllm-project/vllm@c9461e0 Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
1 parent ff47524 commit 10772d9

File tree

8 files changed

+15
-8
lines changed

8 files changed

+15
-8
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ set(VLLM_ASCEND_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}")
2020

2121
find_package(Torch REQUIRED)
2222

23+
run_python(TORCH_VERSION
24+
"import torch; print(torch.__version__)" "Failed to locate torch path")
25+
# check torch version is 2.7.1
26+
if(NOT ${TORCH_VERSION} VERSION_EQUAL "2.7.1")
27+
message(FATAL_ERROR "Expected PyTorch version 2.7.1, but found ${TORCH_VERSION}")
28+
endif()
29+
2330
set(RUN_MODE "npu" CACHE STRING "cpu/sim/npu")
2431
set(SOC_VERSION ${SOC_VERSION})
2532
message(STATUS "Detected SOC version: ${SOC_VERSION}")

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ By using vLLM Ascend plugin, popular open-source models, including Transformer-l
4343
- Software:
4444
* Python >= 3.9, < 3.12
4545
* CANN >= 8.2.rc1 (Ascend HDK version refers to [here](https://www.hiascend.com/document/detail/zh/canncommercial/82RC1/releasenote/releasenote_0000.html))
46-
* PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724
46+
* PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724
4747
* vLLM (the same version as vllm-ascend)
4848

4949
## Getting Started

README.zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ vLLM 昇腾插件 (`vllm-ascend`) 是一个由社区维护的让vLLM在Ascend NP
4444
- 软件:
4545
* Python >= 3.9, < 3.12
4646
* CANN >= 8.2.rc1 (Ascend HDK 版本参考[这里](https://www.hiascend.com/document/detail/zh/canncommercial/82RC1/releasenote/releasenote_0000.html))
47-
* PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724
47+
* PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724
4848
* vLLM (与vllm-ascend版本一致)
4949

5050
## 开始使用

docs/source/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ This document describes how to install vllm-ascend manually.
1313
|---------------|----------------------------------|-------------------------------------------|
1414
| Ascend HDK | Refer to [here](https://www.hiascend.com/document/detail/zh/canncommercial/82RC1/releasenote/releasenote_0000.html) | Required for CANN |
1515
| CANN | >= 8.2.RC1 | Required for vllm-ascend and torch-npu |
16-
| torch-npu | >= 2.7.1.dev20250724 | Required for vllm-ascend, No need to install manually, it will be auto installed in below steps |
17-
| torch | >= 2.7.1 | Required for torch-npu and vllm |
16+
| torch-npu | == 2.7.1.dev20250724 | Required for vllm-ascend, No need to install manually, it will be auto installed in below steps |
17+
| torch | == 2.7.1 | Required for torch-npu and vllm |
1818

1919
There are two installation methods:
2020
- **Using pip**: first prepare env manually or via CANN image, then install `vllm-ascend` using pip.

examples/disaggregated_prefill_v1/mooncake_connector_deployment_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Software:
66
* Python >= 3.9, < 3.12
77
* CANN >= 8.2.rc1
8-
* PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724
8+
* PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724
99
* vLLM (same version as vllm-ascend)
1010
* mooncake-transfer-engine reference documentation: https://github.com/kvcache-ai/Mooncake/blob/main/doc/zh/ascend_transport.md
1111

examples/disaggregated_prefill_v1/mooncake_connector_store_deployment_guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Software:
66
* Python >= 3.9, < 3.12
77
* CANN >= 8.2.rc1
8-
* PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724
8+
* PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724
99
* vLLM:main branch
1010
* vLLM-Ascend:main branch
1111
* Mooncake:[AscendTransport/Mooncake at pooling-async-memcpy](https://github.com/AscendTransport/Mooncake/tree/pooling-async-memcpy)(Currently available branch code, continuously updated.)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ requires = [
1515
"setuptools>=64",
1616
"setuptools-scm>=8",
1717
"torch-npu==2.7.1.dev20250724",
18-
"torch>=2.7.1",
18+
"torch==2.7.1",
1919
"torchvision",
2020
"wheel",
2121
"msgpack",

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ scipy
1111
pandas
1212
setuptools>=64
1313
setuptools-scm>=8
14-
torch>=2.7.1
14+
torch==2.7.1
1515
torchvision
1616
wheel
1717
pandas-stubs

0 commit comments

Comments
 (0)