|
| 1 | +# |
| 2 | +# Copyright (c) 2025 Huawei Technologies Co., Ltd. All Rights Reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# This file is a part of the vllm-ascend project. |
| 16 | +# |
| 17 | + |
| 18 | +# CI-specific test image that pre-installs vllm + vllm-ascend on top of the |
| 19 | +# CANN base image. The source code is baked in at /vllm-workspace/vllm-ascend |
| 20 | +# so that the test job can skip checkout / install entirely. |
| 21 | +# |
| 22 | +# Build args: |
| 23 | +# CANN_TAG – CANN image tag (e.g. 9.0.0-910b-ubuntu22.04-py3.12) |
| 24 | +# VLLM_COMMIT – vLLM commit hash to checkout |
| 25 | +# SOC_VERSION – Ascend SOC version (e.g. ascend910b1) |
| 26 | +# INSTALL_MODE – "device" (compile kernels, install mooncake + triton-ascend) |
| 27 | +# or "nodevice" (COMPILE_CUSTOM_KERNELS=0, no mooncake/triton-ascend) |
| 28 | + |
| 29 | +ARG CANN_TAG=9.0.0-910b-ubuntu22.04-py3.12 |
| 30 | +FROM swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:${CANN_TAG} |
| 31 | + |
| 32 | +ARG VLLM_COMMIT |
| 33 | +ARG SOC_VERSION=ascend910b1 |
| 34 | +ARG INSTALL_MODE=device |
| 35 | +ARG VLLM_REPO=https://github.com/vllm-project/vllm.git |
| 36 | + |
| 37 | +ENV DEBIAN_FRONTEND=noninteractive |
| 38 | +ENV SOC_VERSION=${SOC_VERSION} \ |
| 39 | + UV_INDEX_URL=http://cache-service.nginx-pypi-cache.svc.cluster.local/pypi/simple \ |
| 40 | + UV_EXTRA_INDEX_URL="https://repo.huaweicloud.com/ascend/repos/pypi http://cache-service.nginx-pypi-cache.svc.cluster.local/whl/cpu/" \ |
| 41 | + UV_INDEX_STRATEGY=unsafe-best-match \ |
| 42 | + UV_INSECURE_HOST=cache-service.nginx-pypi-cache.svc.cluster.local \ |
| 43 | + UV_HTTP_TIMEOUT=120 \ |
| 44 | + UV_NO_CACHE=1 \ |
| 45 | + UV_SYSTEM_PYTHON=1 |
| 46 | + |
| 47 | +# --------------------------------------------------------------------------- |
| 48 | +# Install packages (mirrors _selected_tests.yaml "Install packages" step) |
| 49 | +# --------------------------------------------------------------------------- |
| 50 | +RUN sed -Ei 's@(ports|archive).ubuntu.com@cache-service.nginx-pypi-cache.svc.cluster.local:8081@g' /etc/apt/sources.list && \ |
| 51 | + pip config set global.index-url http://cache-service.nginx-pypi-cache.svc.cluster.local/pypi/simple && \ |
| 52 | + pip config set global.trusted-host cache-service.nginx-pypi-cache.svc.cluster.local && \ |
| 53 | + apt-get update -y && \ |
| 54 | + apt-get install -y python3-pip git vim wget net-tools gcc g++ cmake libnuma-dev curl gnupg2 zstd && \ |
| 55 | + pip install uv |
| 56 | + |
| 57 | +# --------------------------------------------------------------------------- |
| 58 | +# Checkout vllm and install (empty target, uninstall triton) |
| 59 | +# --------------------------------------------------------------------------- |
| 60 | +RUN git init /vllm-workspace/vllm && \ |
| 61 | + git -C /vllm-workspace/vllm fetch --depth 1 "$VLLM_REPO" "$VLLM_COMMIT" && \ |
| 62 | + git -C /vllm-workspace/vllm checkout FETCH_HEAD && \ |
| 63 | + cd /vllm-workspace/vllm && \ |
| 64 | + VLLM_TARGET_DEVICE=empty uv pip install . && \ |
| 65 | + pip uninstall -y triton |
| 66 | + |
| 67 | +# --------------------------------------------------------------------------- |
| 68 | +# Copy vllm-ascend source from build context (already rebased on latest main) |
| 69 | +# --------------------------------------------------------------------------- |
| 70 | +COPY . /vllm-workspace/vllm-ascend/ |
| 71 | +WORKDIR /vllm-workspace/vllm-ascend |
| 72 | + |
| 73 | +# --------------------------------------------------------------------------- |
| 74 | +# Install Mooncake wheel (device mode only — aarch64 wheel) |
| 75 | +# --------------------------------------------------------------------------- |
| 76 | +RUN if [ "$INSTALL_MODE" = "device" ]; then \ |
| 77 | + apt-get install -y --no-install-recommends \ |
| 78 | + libibverbs1 ibverbs-providers librdmacm1 libnuma1 libcurl4 && \ |
| 79 | + ldconfig && \ |
| 80 | + MOONCAKE_WHEEL="mooncake_transfer_engine_ascend-0.3.9-cp312-cp312-manylinux_2_35_aarch64.whl" && \ |
| 81 | + pip install --no-cache-dir --no-deps \ |
| 82 | + "https://vllm-ascend.obs.cn-north-4.myhuaweicloud.com/vllm-ascend/${MOONCAKE_WHEEL}" && \ |
| 83 | + pip show mooncake-transfer-engine-ascend || true; \ |
| 84 | + fi |
| 85 | + |
| 86 | +# --------------------------------------------------------------------------- |
| 87 | +# Install vllm-ascend (with csrc cache logic matching _selected_tests.yaml) |
| 88 | +# --------------------------------------------------------------------------- |
| 89 | +RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ |
| 90 | + source /usr/local/Ascend/nnal/atb/set_env.sh && \ |
| 91 | + arch=$(uname -i) && \ |
| 92 | + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/Ascend/ascend-toolkit/latest/${arch}-linux/devlib && \ |
| 93 | + if [ "$(uname -m)" = "x86_64" ]; then \ |
| 94 | + export UV_EXTRA_INDEX_URL="${UV_EXTRA_INDEX_URL} https://download.pytorch.org/whl/cpu/"; \ |
| 95 | + fi && \ |
| 96 | + export MAX_JOBS=16 && \ |
| 97 | + pip install uc-manager && \ |
| 98 | + uv pip install -r requirements-dev.txt && \ |
| 99 | + if [ "$INSTALL_MODE" = "device" ]; then \ |
| 100 | + uv pip install --force-reinstall --no-deps triton-ascend==3.2.1; \ |
| 101 | + fi && \ |
| 102 | + if [ "$INSTALL_MODE" = "nodevice" ] || find vllm_ascend -maxdepth 1 -name '*.so' -type f 2>/dev/null | grep -q .; then \ |
| 103 | + echo "CSRC cache hit or nodevice: skip kernel compilation" && \ |
| 104 | + COMPILE_CUSTOM_KERNELS=0 uv pip install -e .; \ |
| 105 | + else \ |
| 106 | + echo "CSRC cache miss: compile kernels" && \ |
| 107 | + uv pip install -e . --no-build-isolation; \ |
| 108 | + fi |
| 109 | + |
| 110 | +CMD ["/bin/bash"] |
0 commit comments