diff --git a/.jenkins/test/config/dependent_packages.yaml b/.jenkins/test/config/dependent_packages.yaml index 144028f04b1ca379b6b0f7d620545f7f12409650..b3351caf76cf8ed33ed276e1d2d4e5dbc81a9a43 100644 --- a/.jenkins/test/config/dependent_packages.yaml +++ b/.jenkins/test/config/dependent_packages.yaml @@ -4,6 +4,9 @@ mindspore: mindspore_gs: 'https://repo.mindspore.cn/mindspore/golden-stick/version/202510/20251013/r1.3.0_20251013120007_58642969c8d2afbdbcb0d725a27117cd687bf936_newest/' +mindformers: + 'https://repo.mindspore.cn/mindspore/mindformers/version/202510/20251024/r1.7.0_20251024031508_69dc4a5cde5e4f7c3f8247f2d4574116661b0279_newest/' + msadapter: 'https://repo.mindspore.cn/mindspore/msadapter/version/202510/20251011/r0.3.0_20251011095813_951a8218d4c29785e48f304e720212b57056573e_newest/' diff --git a/build_image.sh b/build_image.sh index b596505c4465df1afff581554846fe43c6a84cd8..1e9eff6c931b480566b4eb05ac855c37f414aeb1 100644 --- a/build_image.sh +++ b/build_image.sh @@ -20,11 +20,48 @@ TARGET="910b" ARCH=$(uname -m) build_usage() { - echo "Usage: $0 [-a 910b|310p]" - exit 1 + echo "Usage: $0 [OPTIONS]" + echo "" + echo "Build docker images for vLLM-MindSpore Plugin" + echo "" + echo "OPTIONS:" + echo " [-a 910b|310p] Select platform for vLLM-MindSpore Plugin. Default: 910b." + echo " [-h] Show this help message and exit." + echo " [-v] Print docker build logs in details." + echo "" + echo "Examples:" + echo " $0 Normal installation." + echo " $0 -a 310p Installation on 310p." + echo " $0 -h Show helps for installation." + exit 0; } -while getopts "a:h" opt; do +add_verbose() { + if docker build -h 2>&1 | grep -q "\-\-progress"; then + build_args="--no-cache --progress=plain" + else + build_args="--no-cache" + fi +} + +build_args="" + +get_run_opts() { + while getopts ":vh" opt; do + case $opt in + v) + add_verbose + ;; + h) + echo "Usage: bash build_image.sh [-v]" + echo " verbose: print docker build logs in details" + exit 0 + ;; + esac + done +} + +while getopts "a:hv" opt; do case $opt in a) if [[ "$OPTARG" == "910b" || "$OPTARG" == "310p" ]]; then @@ -37,6 +74,9 @@ while getopts "a:h" opt; do h) build_usage ;; + v) + add_verbose + ;; \?|:) build_usage ;; @@ -50,39 +90,17 @@ if [ $# -gt 0 ]; then fi readonly IMAGE_TAG="vllm_ms_$(date +%Y%m%d)" +readonly CANN_VERSION="8.3.RC1" log() { echo "===== Build image for ${TARGET} ==== $*" } -CANN_TOOLKIT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-toolkit_8.1.RC1_linux-${ARCH}.run -CANN_KERNELS_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-kernels-${TARGET}_8.1.RC1_linux-${ARCH}.run -CANN_NNRT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%208.1.RC1/Ascend-cann-nnrt_8.1.RC1_linux-${ARCH}.run - -add_verbose() { - if docker build -h 2>&1 | grep -q "\-\-progress"; then - build_args="--no-cache --progress=plain" - else - build_args="--no-cache" - fi -} +CANN_TOOLKIT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%20${CANN_VERSION}/Ascend-cann-toolkit_${CANN_VERSION}_linux-${ARCH}.run +CANN_KERNELS_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%20${CANN_VERSION}/Ascend-cann-kernels-${TARGET}_${CANN_VERSION}_linux-${ARCH}.run +CANN_NNRT_URL=https://ascend-repo.obs.cn-east-2.myhuaweicloud.com/CANN/CANN%20${CANN_VERSION}/Ascend-cann-nnrt_${CANN_VERSION}_linux-${ARCH}.run -build_args="" -get_run_opts() { - while getopts ":vh" opt; do - case $opt in - v) - add_verbose - ;; - h) - echo "Usage: bash build_image.sh [-v]" - echo " verbose: print docker build logs in details" - exit 0 - ;; - esac - done -} main() { log "Starting Docker image build process" @@ -93,10 +111,6 @@ main() { log "Step 2: Building final image with install script" - # Get mindformers commit ID from submodule - local mindformers_commit=$(git submodule status tests/mindformers | awk '{print $1}' | sed 's/^-//') - log "Using mindformers commit: $mindformers_commit" - cat > Dockerfile.tmp << EOF FROM base_env @@ -111,22 +125,35 @@ RUN set -ex && \\ chmod a+x *.run && \\ bash /root/Ascend-cann-toolkit.run --install -q && \\ bash /root/Ascend-cann-kernels-${TARGET}.run --install -q && \\ - bash Ascend-cann-nnrt.run --install -q && \\ + bash /root/Ascend-cann-nnrt.run --install -q + +RUN set -ex && \\ + bash /root/Ascend-cann-nnrt.run --noexec --extract=./ && \ + mkdir -p /root/run_package/pyACL_package && \ + bash /root/run_package/Ascend-pyACL_${CANN_VERSION}_linux-${ARCH}.run --full --install-path=/root/run_package/pyACL_package && \ + echo "PYTHONPATH=/root/run_package/pyACL_package/${CANN_VERSION}/python/site-packages/:\$PYTHONPATH" >> ~/.bashrc + +RUN set -ex && \\ rm /root/*.run +RUN set -ex && \\ + pip3 install sympy && \\ + pip3 install /usr/local/Ascend/ascend-toolkit/latest/lib64/te-*.whl && \\ + pip3 install /usr/local/Ascend/ascend-toolkit/latest/lib64/hccl-*.whl + COPY install_depend_pkgs.sh /workspace/ COPY .jenkins/test/config/dependent_packages.yaml /workspace/.jenkins/test/config/ ADD ./ /workspace/vllm_mindspore -ARG MINDFORMERS_COMMIT=$mindformers_commit RUN chmod +x /workspace/vllm_mindspore/install_depend_pkgs.sh && \\ cd /workspace/vllm_mindspore && \\ - MINDFORMERS_COMMIT=\$MINDFORMERS_COMMIT AUTO_BUILD=1 ./install_depend_pkgs.sh + ./install_depend_pkgs.sh RUN cd /workspace/vllm_mindspore && \\ - pip install . + git config --global http.sslVerify false && \\ + pip install . && \\ + git config --global http.sslVerify true -ENV PYTHONPATH="/workspace/mindformers/:\$PYTHONPATH" WORKDIR /workspace CMD ["bash"] diff --git a/install_depend_pkgs.sh b/install_depend_pkgs.sh index 55bf53fbb354f5c79880e18bc6c6899b14a7daaa..dbdd6b27d041768ce4a40af5d7286b84197f02f2 100644 --- a/install_depend_pkgs.sh +++ b/install_depend_pkgs.sh @@ -19,11 +19,14 @@ set -euo pipefail readonly SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd) readonly CONFIG_FILE="$SCRIPT_DIR/.jenkins/test/config/dependent_packages.yaml" +readonly RELEASE_CONFIG_FILE="$SCRIPT_DIR/release_packages.yaml" readonly MF_DIR="$SCRIPT_DIR/mindformers" -readonly PIP_TRUSTED_HOSTS="--trusted-host repo.mindspore.cn --trusted-host mirrors.aliyun.com" +readonly PIP_TRUSTED_HOSTS="--trusted-host repo.mindspore.cn --trusted-host mirrors.aliyun.com --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com" readonly PIP_INDEX="-i https://mirrors.aliyun.com/pypi/simple" +export UV_HTTP_TIMEOUT=600 + FORCE_REINSTALL=false # Detect architecture @@ -57,6 +60,7 @@ log_package_url() { } pip_install() { + log "Installing $*" if [ "$FORCE_REINSTALL" = true ]; then uv pip install --system --no-cache-dir --force-reinstall $PIP_TRUSTED_HOSTS $PIP_INDEX "$@" else @@ -66,27 +70,6 @@ pip_install() { get_config() { python3 -c "import yaml; print(yaml.safe_load(open('$CONFIG_FILE'))['$1'])" 2>/dev/null; } -get_mindformers_commit() { - local mindformers_commit - - if [ -d ".git" ] && git submodule status tests/mindformers >/dev/null 2>&1; then - mindformers_commit=$(git submodule status tests/mindformers | awk '{print $1}' | sed 's/^-//') - else - if [ -z "${MINDFORMERS_COMMIT:-}" ]; then - log "Error: Script requires MINDFORMERS_COMMIT environment variable when running independently" - exit 1 - fi - mindformers_commit="$MINDFORMERS_COMMIT" - fi - - if [ -z "$mindformers_commit" ]; then - log "Failed to get mindformers commit" - exit 1 - fi - - echo "$mindformers_commit" -} - get_package_url() { local package="$1" local arch="${2:-any}" @@ -103,24 +86,30 @@ get_package_url() { echo "${base_url}${wheel_url}" } -install_mindformers() { - log "Installing mindformers" - local commit_id=$(get_mindformers_commit) - - if [ "$FORCE_REINSTALL" = true ] && [ -d "$MF_DIR" ]; then - log "Force reinstall: removing existing mindformers directory" - rm -rf "$MF_DIR" - fi - - if [ ! -d "$MF_DIR" ]; then - git clone https://gitee.com/mindspore/mindformers.git "$MF_DIR" +get_obs_package_url() { + local package="$1" + local version="$2" + local arch="${3:-any}" + local base_url=$(grep -A 1 -w "${package}:" "$RELEASE_CONFIG_FILE" | tail -n 1 | xargs) + + if [ -z "${base_url:-}" ]; then + local wheel_url="" + else + if [[ "$package" == "mindspore" ]]; then + local python_v="cp$(python3 --version 2>&1 | grep -oP 'Python \K\d+\.\d+' | tr -d .)" + local wheel_url="${base_url}/unified/${arch}/mindspore-${version}-${python_v}-${python_v}-linux_${arch}.whl" + elif [[ "$package" == "mindformers" ]]; then + local wheel_url="${base_url}/${arch}/mindformers-${version}-py3-none-${arch}.whl" + elif [[ "$package" == "msadapter" ]]; then + local wheel_url="${base_url}/${arch}/msadapter-${version}-py3-none-${arch}.whl" + elif [[ "$package" == "vllm" ]]; then + local wheel_url="${base_url}/${arch}/vllm-${version}.empty-py3-none-${arch}.whl" + else + local wheel_url=$(curl -k -s "$base_url" | sed -n 's/.*href="\([^"]*\.whl\)".*/\1/p' | grep -v sha256 | head -n 1) + fi fi - cd "$MF_DIR" - git checkout "$commit_id" - cd "$SCRIPT_DIR" - pip install $PIP_TRUSTED_HOSTS $PIP_INDEX -r mindformers/requirements.txt - log "Using mindformers commit: $commit_id" + echo "${wheel_url}" } cleanup_package() { @@ -172,6 +161,8 @@ main() { esac done + git config --global http.sslVerify false + if [ "$FORCE_REINSTALL" = true ]; then log "WARNING: Force reinstall mode enabled - all packages will be reinstalled" log "This will remove existing mindformers directory and reinstall all dependencies" @@ -179,35 +170,47 @@ main() { command -v uv &> /dev/null || pip install $PIP_TRUSTED_HOSTS $PIP_INDEX uv - [ ! -f "$CONFIG_FILE" ] && { echo "Config file not found: $CONFIG_FILE"; exit 1; } + [ ! -f "$RELEASE_CONFIG_FILE" ] && { echo "Config file not found: $RELEASE_CONFIG_FILE"; exit 1; } log "Starting dependency installation" local vllm_url=$(get_package_url "vllm" "any") - local mindspore_url=$(get_package_url "mindspore" "unified/${ARCH}") + local mindspore_url=$(get_obs_package_url "mindspore" "2.7.1" "${ARCH}") local msadapter_url=$(get_package_url "msadapter" "any") - local mindspore_gs_url=$(get_package_url "mindspore_gs" "any") + local mindformers_url=$(get_obs_package_url "mindformers" "1.7.0" "any") + if [ -z "${vllm_url:-}" ]; then + local vllm_url=$(get_package_url "vllm" "any") + fi + if [ -z "${mindspore_url:-}" ]; then + local mindspore_url=$(get_package_url "mindspore" "unified/${ARCH}") + fi + if [ -z "${msadapter_url:-}" ]; then + local msadapter_url=$(get_package_url "msadapter" "any") + fi + if [ -z "${mindformers_url:-}" ]; then + local mindformers_url=$(get_package_url "mindformers" "any") + fi + log "Package URLs:" log_package_url "vLLM" "$vllm_url" log_package_url "MindSpore" "$mindspore_url" + log_package_url "mindformers" "$mindformers_url" log_package_url "msadapter" "$msadapter_url" - log_package_url "mindspore-gs" "$mindspore_gs_url" # WARNING: do not adjust sequence of installation steps cleanup_package msadapter cleanup_package vllm pip_install "$vllm_url" pip_install "$mindspore_url" - install_mindformers - pip_install "$mindspore_gs_url" + pip_install "$mindformers_url" pip_install "$msadapter_url" cleanup_cache + + git config --global http.sslVerify true log "All dependencies installed successfully!" log "" - log "When using MindFormers backend, please configure environment variables manually:" - echo " export PYTHONPATH=\"$MF_DIR/:\$PYTHONPATH\"" } main "$@" diff --git a/release_packages.yaml b/release_packages.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6a53afdf2d2e37f8e7d947d3875beca82d31f5e9 --- /dev/null +++ b/release_packages.yaml @@ -0,0 +1,11 @@ +mindspore: + 'https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.7.1/MindSpore' + +mindformers: + 'https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.7.1/MindFormers' + +vllm: + 'https://repo.mindspore.cn/mirrors/vllm/version/202507/20250715/v0.9.1/' + +msadapter: + 'https://repo.mindspore.cn/mindspore/msadapter/version/202510/20251011/r0.3.0_20251011095813_951a8218d4c29785e48f304e720212b57056573e_newest/' \ No newline at end of file