From 10772d94e3d51f75eec6093f00ce6c04ea2a799b Mon Sep 17 00:00:00 2001 From: wangxiyuan Date: Thu, 30 Oct 2025 15:53:15 +0800 Subject: [PATCH] [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: https://github.com/vllm-project/vllm/commit/c9461e05a4ed3557cfbf4b15ded1e26761cc39ca Signed-off-by: wangxiyuan --- CMakeLists.txt | 7 +++++++ README.md | 2 +- README.zh.md | 2 +- docs/source/installation.md | 4 ++-- .../mooncake_connector_deployment_guide.md | 2 +- .../mooncake_connector_store_deployment_guide.md | 2 +- pyproject.toml | 2 +- requirements.txt | 2 +- 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b64611df..272bdb13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,13 @@ set(VLLM_ASCEND_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}") find_package(Torch REQUIRED) +run_python(TORCH_VERSION + "import torch; print(torch.__version__)" "Failed to locate torch path") +# check torch version is 2.7.1 +if(NOT ${TORCH_VERSION} VERSION_EQUAL "2.7.1") + message(FATAL_ERROR "Expected PyTorch version 2.7.1, but found ${TORCH_VERSION}") +endif() + set(RUN_MODE "npu" CACHE STRING "cpu/sim/npu") set(SOC_VERSION ${SOC_VERSION}) message(STATUS "Detected SOC version: ${SOC_VERSION}") diff --git a/README.md b/README.md index ec38a757..70c4c150 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ By using vLLM Ascend plugin, popular open-source models, including Transformer-l - Software: * Python >= 3.9, < 3.12 * CANN >= 8.2.rc1 (Ascend HDK version refers to [here](https://www.hiascend.com/document/detail/zh/canncommercial/82RC1/releasenote/releasenote_0000.html)) - * PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724 + * PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724 * vLLM (the same version as vllm-ascend) ## Getting Started diff --git a/README.zh.md b/README.zh.md index b495c8d4..b08d5c29 100644 --- a/README.zh.md +++ b/README.zh.md @@ -44,7 +44,7 @@ vLLM 昇腾插件 (`vllm-ascend`) 是一个由社区维护的让vLLM在Ascend NP - 软件: * Python >= 3.9, < 3.12 * CANN >= 8.2.rc1 (Ascend HDK 版本参考[这里](https://www.hiascend.com/document/detail/zh/canncommercial/82RC1/releasenote/releasenote_0000.html)) - * PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724 + * PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724 * vLLM (与vllm-ascend版本一致) ## 开始使用 diff --git a/docs/source/installation.md b/docs/source/installation.md index c4456153..ba82eac7 100644 --- a/docs/source/installation.md +++ b/docs/source/installation.md @@ -13,8 +13,8 @@ This document describes how to install vllm-ascend manually. |---------------|----------------------------------|-------------------------------------------| | Ascend HDK | Refer to [here](https://www.hiascend.com/document/detail/zh/canncommercial/82RC1/releasenote/releasenote_0000.html) | Required for CANN | | CANN | >= 8.2.RC1 | Required for vllm-ascend and torch-npu | - | torch-npu | >= 2.7.1.dev20250724 | Required for vllm-ascend, No need to install manually, it will be auto installed in below steps | - | torch | >= 2.7.1 | Required for torch-npu and vllm | + | torch-npu | == 2.7.1.dev20250724 | Required for vllm-ascend, No need to install manually, it will be auto installed in below steps | + | torch | == 2.7.1 | Required for torch-npu and vllm | There are two installation methods: - **Using pip**: first prepare env manually or via CANN image, then install `vllm-ascend` using pip. diff --git a/examples/disaggregated_prefill_v1/mooncake_connector_deployment_guide.md b/examples/disaggregated_prefill_v1/mooncake_connector_deployment_guide.md index 3e916ccf..2ccac6a5 100644 --- a/examples/disaggregated_prefill_v1/mooncake_connector_deployment_guide.md +++ b/examples/disaggregated_prefill_v1/mooncake_connector_deployment_guide.md @@ -5,7 +5,7 @@ * Software: * Python >= 3.9, < 3.12 * CANN >= 8.2.rc1 - * PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724 + * PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724 * vLLM (same version as vllm-ascend) * mooncake-transfer-engine reference documentation: https://github.com/kvcache-ai/Mooncake/blob/main/doc/zh/ascend_transport.md diff --git a/examples/disaggregated_prefill_v1/mooncake_connector_store_deployment_guide.md b/examples/disaggregated_prefill_v1/mooncake_connector_store_deployment_guide.md index d33c7811..7c4672d0 100644 --- a/examples/disaggregated_prefill_v1/mooncake_connector_store_deployment_guide.md +++ b/examples/disaggregated_prefill_v1/mooncake_connector_store_deployment_guide.md @@ -5,7 +5,7 @@ * Software: * Python >= 3.9, < 3.12 * CANN >= 8.2.rc1 - * PyTorch >= 2.7.1, torch-npu >= 2.7.1.dev20250724 + * PyTorch == 2.7.1, torch-npu == 2.7.1.dev20250724 * vLLM:main branch * vLLM-Ascend:main branch * Mooncake:[AscendTransport/Mooncake at pooling-async-memcpy](https://github.com/AscendTransport/Mooncake/tree/pooling-async-memcpy)(Currently available branch code, continuously updated.) diff --git a/pyproject.toml b/pyproject.toml index e1aac71f..fbb5d5ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ requires = [ "setuptools>=64", "setuptools-scm>=8", "torch-npu==2.7.1.dev20250724", - "torch>=2.7.1", + "torch==2.7.1", "torchvision", "wheel", "msgpack", diff --git a/requirements.txt b/requirements.txt index 0cb38311..3c3e83a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ scipy pandas setuptools>=64 setuptools-scm>=8 -torch>=2.7.1 +torch==2.7.1 torchvision wheel pandas-stubs