From 4142235c2bfa3b7ffd9945ae1b6a17bb92a9fe4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=AD=9D=E5=90=9B?= Date: Thu, 24 Sep 2026 21:35:31 +0800 Subject: [PATCH] [NPU] Update CANN version to 9.1.0 (#40524) --- .github/workflows/_npu-pr-test-stage.yml | 2 +- .../workflows/_npu-single-node-test-stage.yml | 4 +- .github/workflows/coverage-collection-npu.yml | 2 +- .github/workflows/diffusion-ci-gt-gen-npu.yml | 4 +- .github/workflows/full-test-npu.yml | 31 +--- .github/workflows/nightly-test-npu.yml | 155 +----------------- .github/workflows/pr-test-npu.yml | 86 +++++++--- .../workflows/release-docker-npu-nightly.yml | 87 +++++++--- .github/workflows/release-docker-npu.yml | 4 +- docker/npu.Dockerfile | 116 +++++++++---- python/pyproject_npu.toml | 2 - scripts/ci/npu/npu_ci_install_dependency.sh | 155 ++++++++++++++---- .../npu/attention/test_npu_ascend_backend.py | 2 +- .../attention/test_npu_ascend_dsv4_backend.py | 3 +- test/run_suite.py | 2 +- 15 files changed, 352 insertions(+), 303 deletions(-) diff --git a/.github/workflows/_npu-pr-test-stage.yml b/.github/workflows/_npu-pr-test-stage.yml index 0bf8a37c9c..ee08a54fe2 100644 --- a/.github/workflows/_npu-pr-test-stage.yml +++ b/.github/workflows/_npu-pr-test-stage.yml @@ -19,7 +19,7 @@ on: type: string required: true npu_device_type: - description: 'NPU device type, e.g. 910b, a3.' + description: 'NPU device type, e.g. a3, 950.' type: string default: 'a3' run_timeout_minutes: diff --git a/.github/workflows/_npu-single-node-test-stage.yml b/.github/workflows/_npu-single-node-test-stage.yml index 2a6b434e38..7fe82bd73f 100644 --- a/.github/workflows/_npu-single-node-test-stage.yml +++ b/.github/workflows/_npu-single-node-test-stage.yml @@ -21,7 +21,7 @@ on: required: true type: string description: image for pods - default: "swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-a3" + default: "swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.1.0-a3" install_sglang_deps: required: false type: boolean @@ -31,7 +31,7 @@ on: required: false type: string default: 'a3' - description: device type for dependency installation (a3 or 910b) + description: device type for dependency installation (a3 or 950) transformers_version: required: false type: string diff --git a/.github/workflows/coverage-collection-npu.yml b/.github/workflows/coverage-collection-npu.yml index 52ff15cd40..8493bf3037 100644 --- a/.github/workflows/coverage-collection-npu.yml +++ b/.github/workflows/coverage-collection-npu.yml @@ -2,7 +2,7 @@ # Delegates to pr-test-npu.yml with coverage_mode=true, which switches: # - Runners to the coverage pool (shared /root/.cache with setup-covstub) # - use_coverage_runner=true on all test jobs -# - Skips pr-gate, base-a (910b), multimodal-gen, recommend, analyze +# - Skips pr-gate, multimodal-gen, recommend, analyze # - Runs setup-covstub to assemble coverage data and publish it to the # shared disk at a fixed path (/root/.cache/tests/precise-test/coverage) # pr-test-npu-finish is the final gate in the called workflow. diff --git a/.github/workflows/diffusion-ci-gt-gen-npu.yml b/.github/workflows/diffusion-ci-gt-gen-npu.yml index 36e5697146..b4eed2f8db 100644 --- a/.github/workflows/diffusion-ci-gt-gen-npu.yml +++ b/.github/workflows/diffusion-ci-gt-gen-npu.yml @@ -94,7 +94,7 @@ jobs: matrix: ${{ fromJson(needs.compute-diffusion-partitions.outputs.matrix-1npu) }} timeout-minutes: 150 container: - image: swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.0.0-a3-ubuntu22.04-py3.11 + image: swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.1.0-a3-ubuntu22.04-py3.12 steps: - name: Checkout code uses: actions/checkout@v4 @@ -166,7 +166,7 @@ jobs: matrix: ${{ fromJson(needs.compute-diffusion-partitions.outputs.matrix-2npu) }} timeout-minutes: 150 container: - image: swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.0.0-a3-ubuntu22.04-py3.11 + image: swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.1.0-a3-ubuntu22.04-py3.12 steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/full-test-npu.yml b/.github/workflows/full-test-npu.yml index 9f38e57719..7722643404 100644 --- a/.github/workflows/full-test-npu.yml +++ b/.github/workflows/full-test-npu.yml @@ -18,16 +18,11 @@ on: required: false type: string default: 'all' - image_a2: - description: 'The a2 running docker image of the test task.' - required: false - type: string - default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-910b' image_a3: description: 'The a3 running docker image of the test task. Must be an image with sglang preinstalled (e.g. lmsysorg/sglang:*a3*).' required: false type: string - default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-a3' + default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.1.0-a3' concurrency: group: full-test-npu-${{ inputs.ref || github.ref }} @@ -39,7 +34,6 @@ jobs: outputs: ref: ${{ steps.set-vars.outputs.ref }} job_filter: ${{ steps.set-vars.outputs.job_filter }} - image_a2: ${{ steps.set-vars.outputs.image_a2 }} image_a3: ${{ steps.set-vars.outputs.image_a3 }} steps: # When triggered by PR, no inputs parameters are used. The latest community code is tested by default. @@ -58,14 +52,8 @@ jobs: echo "job_filter=${{ inputs.job_filter }}" >> $GITHUB_OUTPUT fi - if [ -z "${{ inputs.image_a2 }}" ]; then - echo "image_a2=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-910b" >> $GITHUB_OUTPUT - else - echo "image_a2=${{ inputs.image_a2 }}" >> $GITHUB_OUTPUT - fi - if [ -z "${{ inputs.image_a3 }}" ]; then - echo "image_a3=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-a3" >> $GITHUB_OUTPUT + echo "image_a3=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.1.0-a3" >> $GITHUB_OUTPUT else echo "image_a3=${{ inputs.image_a3 }}" >> $GITHUB_OUTPUT fi @@ -81,20 +69,6 @@ jobs: image_a3: ${{ needs.set-image-config.outputs.image_a3 }} secrets: inherit - full-4-npu-a2: - name: full-4-npu-a2 - if: ${{ (github.repository == 'sgl-project/sglang' || github.event_name == 'pull_request') }} - needs: [set-image-config] - uses: ./.github/workflows/_npu-single-node-test-stage.yml - with: - runner: linux-aarch64-a2-4 - test_type: 'perf' - test_suite: full-4-npu-a2 - is_nightly_pipeline_job: true - skip_pr_test_health_check: 'true' - image: ${{ needs.set-image-config.outputs.image_a2 }} - device_type_for_deps: '910b' - full-1-npu-a3: name: full-1-npu-a3 if: ${{ (github.repository == 'sgl-project/sglang' || github.event_name == 'pull_request') }} @@ -317,7 +291,6 @@ jobs: if: github.repository == 'sgl-project/sglang' && always() needs: - nighly-test-npu - - full-4-npu-a2 - full-1-npu-a3 - full-2-npu-a3 - full-4-npu-a3 diff --git a/.github/workflows/nightly-test-npu.yml b/.github/workflows/nightly-test-npu.yml index 72e01e46ba..7104e744bc 100644 --- a/.github/workflows/nightly-test-npu.yml +++ b/.github/workflows/nightly-test-npu.yml @@ -19,26 +19,16 @@ on: required: false type: string default: 'all' - image_a2: - description: 'The a2 running docker image of the test task.' - required: false - type: string - default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-910b' image_a3: description: 'The a3 running docker image of the test task.' required: false type: string - default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-a3' - image_a3_cann910: - description: 'The a3 running docker image of the test task with cann 9.1.0.' - required: false - type: string - default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:cann9.1.0-a3-nightly' + default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.1.0-a3' image_a5: description: 'The a5 running docker image of the test task.' required: false type: string - default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:cann9.1.0-950-nightly' + default: 'swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.1.0-950' skip_install_flag: description: 'Indicates whether to skip the installation of sglang, defaulting to false.' required: false @@ -56,21 +46,11 @@ on: required: false type: string default: 'all' - image_a2: - description: 'The a2 running docker image of the test task.' - required: false - type: string - default: '' image_a3: description: 'The a3 running docker image of the test task.' required: false type: string default: '' - image_a3_cann910: - description: 'The a3 running docker image of the test task with cann 9.1.0.' - required: false - type: string - default: '' image_a5: description: 'The a5 running docker image of the test task.' required: false @@ -90,9 +70,7 @@ jobs: outputs: ref: ${{ steps.set-vars.outputs.ref }} job_filter: ${{ steps.set-vars.outputs.job_filter }} - image_a2: ${{ steps.set-vars.outputs.image_a2 }} image_a3: ${{ steps.set-vars.outputs.image_a3 }} - image_a3_cann910: ${{ steps.set-vars.outputs.image_a3_cann910 }} image_a5: ${{ steps.set-vars.outputs.image_a5 }} skip_install_flag: ${{ steps.set-vars.outputs.skip_install_flag }} run_start_metadata: ${{ steps.set-vars.outputs.run_start_metadata }} @@ -115,23 +93,13 @@ jobs: else echo "job_filter=${{ inputs.job_filter }}" >> $GITHUB_OUTPUT fi - if [ -z "${{ inputs.image_a2 }}" ]; then - echo "image_a2=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-910b" >> $GITHUB_OUTPUT - else - echo "image_a2=${{ inputs.image_a2 }}" >> $GITHUB_OUTPUT - fi if [ -z "${{ inputs.image_a3 }}" ]; then - echo "image_a3=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.0.0-a3" >> $GITHUB_OUTPUT + echo "image_a3=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.1.0-a3" >> $GITHUB_OUTPUT else echo "image_a3=${{ inputs.image_a3 }}" >> $GITHUB_OUTPUT fi - if [ -z "${{ inputs.image_a3_cann910 }}" ]; then - echo "image_a3_cann910=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:cann9.1.0-a3-nightly" >> $GITHUB_OUTPUT - else - echo "image_a3_cann910=${{ inputs.image_a3_cann910 }}" >> $GITHUB_OUTPUT - fi if [ -z "${{ inputs.image_a5 }}" ]; then - echo "image_a5=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:cann9.1.0-950-nightly" >> $GITHUB_OUTPUT + echo "image_a5=swr.cn-southwest-2.myhuaweicloud.com/base_image/dockerhub/lmsysorg/sglang:main-cann9.1.0-950" >> $GITHUB_OUTPUT else echo "image_a5=${{ inputs.image_a5 }}" >> $GITHUB_OUTPUT fi @@ -329,41 +297,6 @@ jobs: install_sglang_deps: false device_type_for_deps: 'a5' run_start_metadata: ${{ needs.set-image-config.outputs.run_start_metadata }} - - # Suites suffixed with `-cann910` run against the CANN 9.1.0 image. - nightly-perf-16-npu-a3-cann910: - name: nightly-perf-16-npu-a3-cann910 - if: ${{ !cancelled() }} - needs: [set-image-config] - uses: ./.github/workflows/_npu-single-node-test-stage.yml - with: - runner: linux-aarch64-a3-800t-16 - test_type: 'perf' - test_suite: nightly-perf-16-npu-a3-cann910 - is_nightly_pipeline_job: true - skip_pr_test_health_check: 'true' - image: ${{ needs.set-image-config.outputs.image_a3_cann910 }} - install_sglang_deps: false - device_type_for_deps: 'a3' - run_start_metadata: ${{ needs.set-image-config.outputs.run_start_metadata }} - test_timeout_minutes: '180' - - nightly-acc-16-npu-a3-cann910: - name: nightly-acc-16-npu-a3-cann910 - if: ${{ !cancelled() }} - needs: [set-image-config] - uses: ./.github/workflows/_npu-single-node-test-stage.yml - with: - runner: linux-aarch64-a3-16- - test_type: 'accuracy' - test_suite: nightly-acc-16-npu-a3-cann910 - is_nightly_pipeline_job: true - skip_pr_test_health_check: 'true' - image: ${{ needs.set-image-config.outputs.image_a3_cann910 }} - install_sglang_deps: false - device_type_for_deps: 'a3' - run_start_metadata: ${{ needs.set-image-config.outputs.run_start_metadata }} - nightly-poc-multi-node-tests: name: multi-node-poc if: ${{ !cancelled() }} @@ -444,72 +377,6 @@ jobs: transformers_version: '' run_start_metadata: ${{ needs.set-image-config.outputs.run_start_metadata }} - nightly-poc-multi-node-tests-cann910: - name: multi-node-poc-cann910 - if: ${{ !cancelled() }} - # Multi-node jobs run strictly one at a time to avoid contending for the - # same A3 multi-node resources: 9.0.0 multi -> 9.0.0 mix -> cann910 multi -> cann910 mix. - needs: [set-image-config, nightly-perf-16-npu-a3-cann910, nightly-acc-16-npu-a3-cann910, nightly-poc-multi-node-tests, nightly-poc-multi-node-mix-tests] - strategy: - fail-fast: false - max-parallel: 1 - matrix: - test_config: - # deepseek_v4_flash performance tests - - name: deepseek_v4_flash_w8a8_1p1d_16p_in8k_out1k_50ms - prefill_size: 1 - decode_size: 1 - router_size: 1 - test_case: test/registered/npu/performance/deepseek_v4_flash/test_npu_deepseek_v4_flash_w8a8_1p1d_16p_in8k_out1k_50ms.py - test_type: 'perf' - prefill_decode_deployment: 'separation' - uses: ./.github/workflows/nightly-test-npu-e2e-multi-node.yml - with: - runner: linux-amd64-cpu-4 - test_type: ${{ matrix.test_config.test_type || 'perf' }} - test_config_name: ${{ matrix.test_config.name }} - prefill_size: ${{ matrix.test_config.prefill_size }} - decode_size: ${{ matrix.test_config.decode_size }} - router_size: ${{ matrix.test_config.router_size }} - test_case: ${{ matrix.test_config.test_case }} - image: ${{ needs.set-image-config.outputs.image_a3_cann910 }} - install_sglang_from_source: false - prefill_decode_deployment: ${{ matrix.test_config.prefill_decode_deployment }} - transformers_version: '' - run_start_metadata: ${{ needs.set-image-config.outputs.run_start_metadata }} - - nightly-poc-multi-node-mix-tests-cann910: - name: multi-node-mix-poc-cann910 - if: false - needs: [set-image-config, nightly-poc-multi-node-tests-cann910] - strategy: - fail-fast: false - max-parallel: 1 - matrix: - test_config: - # glm_5_2 accuracy tests - - name: glm_5_2_w8a8_16p_gpqa - node_size: 2 - test_case: test/registered/npu/accuracy/glm5_2/test_npu_glm_5_2_w8a8_16p_gpqa.py - test_type: 'accuracy' - # kimi_k3 accuracy tests - - name: kimi_k3_w4a8_32p_gpqa - node_size: 4 - test_case: test/registered/npu/accuracy/kimi_k3/test_npu_kimi_k3_w4a8_32p_gpqa.py - test_type: 'accuracy' - uses: ./.github/workflows/nightly-test-npu-e2e-multi-node.yml - with: - runner: linux-amd64-cpu-4 - test_type: ${{ matrix.test_config.test_type || 'perf' }} - test_config_name: ${{ matrix.test_config.name }} - node_size: ${{ matrix.test_config.node_size }} - test_case: ${{ matrix.test_config.test_case }} - image: ${{ needs.set-image-config.outputs.image_a3_cann910 }} - install_sglang_from_source: false - prefill_decode_deployment: 'mix' - transformers_version: '' - run_start_metadata: ${{ needs.set-image-config.outputs.run_start_metadata }} - check-all-jobs: if: ${{ !cancelled() }} needs: @@ -523,21 +390,15 @@ jobs: - nightly-perf-16-npu-a3 - nightly-acc-2-npu-a3 - nightly-acc-16-npu-a3 - - nightly-perf-16-npu-a3-cann910 - - nightly-acc-16-npu-a3-cann910 - nightly-acc-4-npu-a5 - nightly-poc-multi-node-tests - nightly-poc-multi-node-mix-tests - - nightly-poc-multi-node-tests-cann910 - - nightly-poc-multi-node-mix-tests-cann910 runs-on: ubuntu-latest steps: - name: Generate results table run: | multi_result="${{ needs.nightly-poc-multi-node-tests.result }}" mix_result="${{ needs.nightly-poc-multi-node-mix-tests.result }}" - multi_cann910_result="${{ needs.nightly-poc-multi-node-tests-cann910.result }}" - mix_cann910_result="${{ needs.nightly-poc-multi-node-mix-tests-cann910.result }}" # single-node suites are reported per suite; overall status is success if none failed single_result="success" @@ -552,8 +413,6 @@ jobs: "${{ needs.nightly-perf-16-npu-a3.result }}" \ "${{ needs.nightly-acc-2-npu-a3.result }}" \ "${{ needs.nightly-acc-16-npu-a3.result }}" \ - "${{ needs.nightly-perf-16-npu-a3-cann910.result }}" \ - "${{ needs.nightly-acc-16-npu-a3-cann910.result }}" \ "${{ needs.nightly-acc-4-npu-a5.result }}"; do if [ "${r}" != "success" ] && [ "${r}" != "skipped" ]; then single_result="failure" @@ -585,8 +444,6 @@ jobs: "nightly-perf-16-npu-a3:${{ needs.nightly-perf-16-npu-a3.result }}" \ "nightly-acc-2-npu-a3:${{ needs.nightly-acc-2-npu-a3.result }}" \ "nightly-acc-16-npu-a3:${{ needs.nightly-acc-16-npu-a3.result }}" \ - "nightly-perf-16-npu-a3-cann910:${{ needs.nightly-perf-16-npu-a3-cann910.result }}" \ - "nightly-acc-16-npu-a3-cann910:${{ needs.nightly-acc-16-npu-a3-cann910.result }}" \ "nightly-acc-4-npu-a5:${{ needs.nightly-acc-4-npu-a5.result }}"; do suite="${entry%%:*}" r="${entry##*:}" @@ -594,12 +451,10 @@ jobs: done echo "| multi-node-poc | $(group_icon ${multi_result}) ${multi_result} |" >> $GITHUB_STEP_SUMMARY echo "| multi-node-mix-poc | $(group_icon ${mix_result}) ${mix_result} |" >> $GITHUB_STEP_SUMMARY - echo "| multi-node-poc-cann910 | $(group_icon ${multi_cann910_result}) ${multi_cann910_result} |" >> $GITHUB_STEP_SUMMARY - echo "| multi-node-mix-poc-cann910 | $(group_icon ${mix_cann910_result}) ${mix_cann910_result} |" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY FAIL=0 - for r in "${single_result}" "${multi_result}" "${mix_result}" "${multi_cann910_result}" "${mix_cann910_result}"; do + for r in "${single_result}" "${multi_result}" "${mix_result}"; do if [ "${r}" != "success" ] && [ "${r}" != "skipped" ]; then FAIL=1; fi done exit $FAIL diff --git a/.github/workflows/pr-test-npu.yml b/.github/workflows/pr-test-npu.yml index 922d27412e..afb2e531ab 100644 --- a/.github/workflows/pr-test-npu.yml +++ b/.github/workflows/pr-test-npu.yml @@ -106,29 +106,71 @@ jobs: runs-on: ubuntu-latest outputs: CANN_image_a3: ${{ steps.set-vars.outputs.CANN_image_a3 }} - CANN_image_910b: ${{ steps.set-vars.outputs.CANN_image_910b }} steps: # When triggered by PR, no inputs parameters are used. The latest community code is tested by default. - name: Set image config id: set-vars run: | - echo "CANN_image_a3=swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.0.0-a3-ubuntu22.04-py3.11" >> $GITHUB_OUTPUT - echo "CANN_image_910b=swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.0.0-910b-ubuntu22.04-py3.11" >> $GITHUB_OUTPUT + echo "CANN_image_a3=swr.cn-southwest-2.myhuaweicloud.com/base_image/ascend-ci/cann:9.1.0-a3-ubuntu22.04-py3.12" >> $GITHUB_OUTPUT - base-a-test-1-npu-a2: - needs: [check-changes, pr-gate, set-image-config] + # Stage-A gate: CPU-only unit tests. The NPU attention-backend UTs stub out + # torch_npu / sgl_kernel_npu before importing, so a hosted runner suffices. + base-a-test-npu: + needs: [check-changes, pr-gate] if: ${{ !failure() && !cancelled() && inputs.coverage_mode != true && needs.check-changes.outputs.main_package == 'true' }} - uses: ./.github/workflows/_npu-pr-test-stage.yml - with: - self_name: base-a-test-1-npu-a2 - runner_config: linux-aarch64-a2-1 - image: ${{ needs.set-image-config.outputs.CANN_image_910b }} - npu_device_type: 910b - run_timeout_minutes: '15' - secrets: inherit + runs-on: ubuntu-latest + timeout-minutes: 45 + env: + SGLANG_IS_IN_CI: true + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Pin to the event SHA so this job tests the same commit as the rest of the run. + ref: ${{ inputs.ref || github.sha }} + + # Same gate the NPU stages run first: fail before the NPU jobs are scheduled. + - uses: ./.github/actions/check-pr-test-health + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + cache-dependency-glob: 'python/pyproject_npu.toml' + + - name: Install dependencies + timeout-minutes: 30 + env: + # uv pip targets a venv by default; setup-python has no venv. + UV_SYSTEM_PYTHON: "1" + run: | + # Resolve the same dependency set as the NPU stages, minus Ascend-only wheels. + rm -f python/pyproject.toml + mv python/pyproject_npu.toml python/pyproject.toml + # Versions mirror npu_ci_install_dependency.sh's defaults; keep them in sync. + # triton: sglang.srt.utils.common imports it unconditionally and the CPU + # wheel does not pull it in (the NPU image uses triton-ascend instead). + # unsafe-best-match: --index-url is the lowest-priority index, so the + # default strategy would resolve PyPI's CUDA torch, not the +cpu build. + uv pip install torch==2.10.0 torchvision==0.25.0 torchaudio==2.10.0 triton \ + --index-url https://download.pytorch.org/whl/cpu \ + --extra-index-url https://pypi.org/simple/ \ + --index-strategy unsafe-best-match + uv pip install -e "python[dev_npu]" --index-strategy unsafe-best-match + + - name: Run NPU unit tests + timeout-minutes: 10 + run: | + cd test + python3 run_suite.py --hw npu --suite base-a-test-npu base-b-test-1-npu-a3: - needs: [check-changes, pr-gate, set-image-config, base-a-test-1-npu-a2] + needs: [check-changes, pr-gate, set-image-config, base-a-test-npu] if: ${{ !failure() && !cancelled() && (inputs.coverage_mode == true || needs.check-changes.outputs.main_package == 'true') }} uses: ./.github/workflows/_npu-pr-test-stage.yml with: @@ -142,7 +184,7 @@ jobs: secrets: inherit base-b-test-2-npu-a3: - needs: [check-changes, pr-gate, set-image-config, base-a-test-1-npu-a2] + needs: [check-changes, pr-gate, set-image-config, base-a-test-npu] if: ${{ !failure() && !cancelled() && (inputs.coverage_mode == true || needs.check-changes.outputs.main_package == 'true') }} uses: ./.github/workflows/_npu-pr-test-stage.yml with: @@ -156,7 +198,7 @@ jobs: secrets: inherit base-b-test-4-npu-a3: - needs: [check-changes, pr-gate, set-image-config, base-a-test-1-npu-a2] + needs: [check-changes, pr-gate, set-image-config, base-a-test-npu] if: ${{ !failure() && !cancelled() && (inputs.coverage_mode == true || needs.check-changes.outputs.main_package == 'true') }} uses: ./.github/workflows/_npu-pr-test-stage.yml with: @@ -171,7 +213,7 @@ jobs: secrets: inherit base-b-test-8-npu-a3: - needs: [check-changes, pr-gate, set-image-config, base-a-test-1-npu-a2] + needs: [check-changes, pr-gate, set-image-config, base-a-test-npu] if: ${{ !failure() && !cancelled() && (inputs.coverage_mode == true || needs.check-changes.outputs.main_package == 'true') }} uses: ./.github/workflows/_npu-pr-test-stage.yml with: @@ -185,7 +227,7 @@ jobs: secrets: inherit base-b-test-16-npu-a3: - needs: [check-changes, pr-gate, set-image-config, base-a-test-1-npu-a2] + needs: [check-changes, pr-gate, set-image-config, base-a-test-npu] if: ${{ !failure() && !cancelled() && (inputs.coverage_mode == true || needs.check-changes.outputs.main_package == 'true') }} uses: ./.github/workflows/_npu-pr-test-stage.yml with: @@ -199,7 +241,7 @@ jobs: secrets: inherit multimodal-gen-test-1-npu-a3: - needs: [check-changes, pr-gate, set-image-config, base-a-test-1-npu-a2] + needs: [check-changes, pr-gate, set-image-config, base-a-test-npu] if: ${{ !failure() && !cancelled() && inputs.coverage_mode != true && needs.check-changes.outputs.multimodal_gen == 'true' }} runs-on: linux-aarch64-a3-800t-2 strategy: @@ -263,7 +305,7 @@ jobs: retention-days: 7 multimodal-gen-test-4-npu-a3: - needs: [check-changes, pr-gate, set-image-config, base-a-test-1-npu-a2] + needs: [check-changes, pr-gate, set-image-config, base-a-test-npu] if: ${{ !failure() && !cancelled() && inputs.coverage_mode != true && needs.check-changes.outputs.multimodal_gen == 'true' }} runs-on: linux-aarch64-a3-800t-4 strategy: @@ -483,7 +525,7 @@ jobs: name: Analyze failure report needs: [ - base-a-test-1-npu-a2, + base-a-test-npu, base-b-test-1-npu-a3, base-b-test-2-npu-a3, base-b-test-4-npu-a3, @@ -646,7 +688,7 @@ jobs: [ check-changes, - base-a-test-1-npu-a2, + base-a-test-npu, base-b-test-1-npu-a3, base-b-test-2-npu-a3, base-b-test-4-npu-a3, diff --git a/.github/workflows/release-docker-npu-nightly.yml b/.github/workflows/release-docker-npu-nightly.yml index c08ee3d41a..4dc129f197 100644 --- a/.github/workflows/release-docker-npu-nightly.yml +++ b/.github/workflows/release-docker-npu-nightly.yml @@ -1,4 +1,5 @@ name: Release Docker Images Nightly (NPU) + on: pull_request: branches: @@ -8,25 +9,41 @@ on: - 'docker/npu.Dockerfile' workflow_dispatch: schedule: - - cron: "0 14 * * *" # Execute at 10:00 p.m. Beijing Time every day - + - cron: "0 14 * * *" concurrency: group: ${{ github.workflow }}-${{ github.sha }} cancel-in-progress: true jobs: build: - runs-on: ubuntu-22.04-arm + name: build ${{ matrix.platform }}-${{ matrix.device_type }} + runs-on: ${{ matrix.runner }} strategy: + fail-fast: false matrix: - cann_version: ["9.0.0"] - device_type: ["910b", "a3"] + include: + - device_type: a3 + cann_version: "9.1.0" + platform: amd64 + runner: ubuntu-latest + - device_type: a3 + cann_version: "9.1.0" + platform: arm64 + runner: ubuntu-22.04-arm + - device_type: 950 + cann_version: "9.1.0" + platform: amd64 + runner: ubuntu-latest + - device_type: 950 + cann_version: "9.1.0" + platform: arm64 + runner: ubuntu-22.04-arm steps: - name: Checkout repository uses: actions/checkout@v4 - name: Free up disk space - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be with: tool-cache: true docker-images: false @@ -38,48 +55,64 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: | - lmsysorg/sglang - # push with schedule event - # push with workflow_dispatch event + images: lmsysorg/sglang tags: | type=ref,event=pr type=ref,event=branch type=schedule,pattern=main flavor: | latest=false - suffix=-cann${{ matrix.cann_version }}-${{ matrix.device_type }},onlatest=true - # Login against a Docker registry except on PR - # https://github.com/docker/login-action - - name: Log into docker hub + suffix=-cann${{ matrix.cann_version }}-${{ matrix.device_type }}-${{ matrix.platform }} + + - name: Log into Docker Hub uses: docker/login-action@v3 if: ${{ github.repository == 'sgl-project/sglang' && github.event_name != 'pull_request' }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - # Enable Docker multi-architecture build environment - # Emulate non-native architectures - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - # Required for building and pushing multi-arch Docker images - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - name: Build and push Docker image - id: build-and-push uses: docker/build-push-action@v6 with: context: docker file: docker/npu.Dockerfile - platforms: linux/arm64,linux/amd64 + platforms: linux/${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} tags: ${{ steps.meta.outputs.tags }} - push: ${{ github.repository == 'sgl-project/sglang' && github.event_name != 'pull_request' }} + outputs: ${{ github.repository == 'sgl-project/sglang' && github.event_name != 'pull_request' && 'type=registry,oci-mediatypes=false' || '' }} provenance: false + sbom: false build-args: | SGLANG_KERNEL_NPU_TAG=2026.9.0.post5 CANN_VERSION=${{ matrix.cann_version }} DEVICE_TYPE=${{ matrix.device_type }} + + merge: + name: merge multi-arch manifest + needs: build + if: ${{ github.repository == 'sgl-project/sglang' && github.event_name != 'pull_request' }} + runs-on: ubuntu-latest + strategy: + matrix: + cann_version: ["9.1.0"] + device_type: ["a3", "950"] + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Compute base image + run: | + echo "IMAGE=lmsysorg/sglang:${GITHUB_REF_NAME}-cann${{ matrix.cann_version }}-${{ matrix.device_type }}" >> "$GITHUB_ENV" + + - name: Create multi-arch manifest + run: | + docker buildx imagetools create \ + -t "${IMAGE}" \ + "${IMAGE}-amd64" \ + "${IMAGE}-arm64" diff --git a/.github/workflows/release-docker-npu.yml b/.github/workflows/release-docker-npu.yml index 73c51cf319..eb8a2fbb64 100644 --- a/.github/workflows/release-docker-npu.yml +++ b/.github/workflows/release-docker-npu.yml @@ -14,8 +14,8 @@ jobs: runs-on: ubuntu-22.04-arm strategy: matrix: - cann_version: ["9.0.0"] - device_type: ["910b", "a3"] + cann_version: ["9.1.0"] + device_type: ["a3", "950"] steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/docker/npu.Dockerfile b/docker/npu.Dockerfile index 1a2f597c5f..3a5f71fd3d 100644 --- a/docker/npu.Dockerfile +++ b/docker/npu.Dockerfile @@ -1,40 +1,46 @@ -ARG CANN_VERSION=9.0.0 -ARG DEVICE_TYPE=a3 +ARG CANN_VERSION=9.1.0 +ARG DEVICE_TYPE=950 ARG OS=ubuntu22.04 -ARG PYTHON_VERSION=py3.11 +ARG PYTHON_VERSION=py3.12 +ARG arch FROM quay.io/ascend/cann:$CANN_VERSION-$DEVICE_TYPE-$OS-$PYTHON_VERSION -# Update pip & apt sources ARG TARGETARCH ARG CANN_VERSION ARG DEVICE_TYPE +ARG arch ARG PIP_INDEX_URL="https://pypi.org/simple/" ARG APTMIRROR="" +# torch_npu 2.10.0.post6 requires torch==2.10.0, so PYTORCH_VERSION stays at 2.10.0 ARG PYTORCH_VERSION="2.10.0" ARG TORCHVISION_VERSION="0.25.0" ARG TORCHAUDIO_VERSION="2.10.0" -ARG PTA_URL_ARM64="https://gitcode.com/Ascend/pytorch/releases/download/v26.0.0-pytorch2.10.0/torch_npu-2.10.0-cp311-cp311-manylinux_2_28_aarch64.whl" -ARG PTA_URL_AMD64="https://gitcode.com/Ascend/pytorch/releases/download/v26.0.0-pytorch2.10.0/torch_npu-2.10.0-cp311-cp311-manylinux_2_28_x86_64.whl" +ARG TORCH_NPU_VERSION="2.10.0.post6" +ARG TORCH_NPU_INDEX_URL="https://ascend.devcloud.huaweicloud.com/pypi/simple/" ARG SGLANG_TAG=main ARG ASCEND_CANN_PATH=/usr/local/Ascend/ascend-toolkit -ARG SGLANG_KERNEL_NPU_TAG=main - +ARG SGLANG_KERNEL_NPU_TAG=2026.9.0.post5 ARG PIP_INSTALL="python3 -m pip install --no-cache-dir" ARG DEVICE_TYPE +ARG MODELSCOPE_VERSION="" +ARG EVALSCOPE_VERSION="" -RUN if [ "$TARGETARCH" = "amd64" ]; then \ - echo "Using x86_64 dependencies"; \ - echo "PTA_URL=$PTA_URL_AMD64" >> /etc/environment_new; \ - elif [ "$TARGETARCH" = "arm64" ]; then \ - echo "Using aarch64 dependencies"; \ - echo "PTA_URL=$PTA_URL_ARM64" >> /etc/environment_new; \ - else \ - echo "Unsupported TARGETARCH: $TARGETARCH"; exit 1; \ - fi +ARG MF_VERSION="1.2.1" +ARG MF_WHEEL_URL_AARCH64="https://obs-memfabric-hybrid.obs.cn-north-4.myhuaweicloud.com/mf/v1.2.1/20260923.4/memfabric_hybrid-1.2.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl" +ARG MF_WHEEL_URL_X86_64="https://obs-memfabric-hybrid.obs.cn-north-4.myhuaweicloud.com/mf/v1.2.1/20260923.4/memfabric_hybrid-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl" +ARG MC_WHEEL_URL_AARCH64="https://obs-memfabric-hybrid.obs.cn-north-4.myhuaweicloud.com/memcache/v1.2.1/20260923.4/memcache_hybrid-1.2.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl" +ARG MC_WHEEL_URL_X86_64="https://obs-memfabric-hybrid.obs.cn-north-4.myhuaweicloud.com/memcache/v1.2.1/20260923.4/memcache_hybrid-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl" -# Set workspace directory -WORKDIR /sgl-workspace/sglang +# memfabric-zbal: 950 与 a3 使用不同版本 +ARG ZBAL_VERSION_950="1.2.21004.post1" +ARG ZBAL_VERSION_A3="1.1.3" + + +# Later RUN steps source /etc/environment_new, so make sure it exists +RUN touch /etc/environment_new + +WORKDIR /workspace # Define environments ENV DEBIAN_FRONTEND=noninteractive @@ -56,7 +62,6 @@ RUN apt-get update -y && apt upgrade -y && apt-get install -y \ clang \ locales \ ccache \ - ffmpeg \ openssl \ libssl-dev \ pkg-config \ @@ -72,7 +77,30 @@ ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US:en ENV LC_ALL=en_US.UTF-8 +### Install MemFabric and MemCache (按 TARGETARCH 直接取对应架构的 OBS wheel) +RUN set -eux; \ + case "$TARGETARCH" in \ + arm64) \ + MF_URL="$MF_WHEEL_URL_AARCH64"; \ + MC_URL="$MC_WHEEL_URL_AARCH64"; \ + ;; \ + amd64) \ + MF_URL="$MF_WHEEL_URL_X86_64"; \ + MC_URL="$MC_WHEEL_URL_X86_64"; \ + ;; \ + *) \ + echo "Unsupported architecture: $TARGETARCH" >&2; \ + exit 1; \ + ;; \ + esac; \ + ${PIP_INSTALL} "$MF_URL" --force-reinstall; \ + mfcli kernel install; \ + ${PIP_INSTALL} "$MC_URL" --force-reinstall --no-deps +### Install memfabric-zbal +RUN if [ "$DEVICE_TYPE" = "950" ]; then ZBAL_PKG="memfabric-zbal==${ZBAL_VERSION_950}"; \ + else ZBAL_PKG="memfabric-zbal==${ZBAL_VERSION_A3}"; fi; \ + ${PIP_INSTALL} "$ZBAL_PKG" -i https://pypi.org/simple/ ### Install SGLang Model Gateway RUN ${PIP_INSTALL} sglang-router @@ -80,20 +108,46 @@ RUN ${PIP_INSTALL} sglang-router ### Install PyTorch and PTA RUN . /etc/environment_new && \ (${PIP_INSTALL} torch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} --index-url https://download.pytorch.org/whl/cpu) \ - && (${PIP_INSTALL} ${PTA_URL}) + && (${PIP_INSTALL} torch-npu==${TORCH_NPU_VERSION} --extra-index-url ${TORCH_NPU_INDEX_URL}) + + +### Install ModelScope & EvalScope +# Installed right after torch/torch-npu so their dependencies resolve against the pinned torch. +# MODELSCOPE_VERSION / EVALSCOPE_VERSION are empty by default -> latest release. +RUN . /etc/environment_new && \ + MS_PKG="modelscope" && \ + ES_PKG="evalscope" && \ + if [ -n "${MODELSCOPE_VERSION}" ]; then MS_PKG="modelscope==${MODELSCOPE_VERSION}"; fi && \ + if [ -n "${EVALSCOPE_VERSION}" ]; then ES_PKG="evalscope==${EVALSCOPE_VERSION}"; fi && \ + ${PIP_INSTALL} "${MS_PKG}" "${ES_PKG}" ## Install triton-ascend -RUN (${PIP_INSTALL} pybind11) && \ - (${PIP_INSTALL} triton-ascend==3.2.1.dev20260530 --extra-index-url=https://mirrors.huaweicloud.com/ascend/repos/pypi/nightly --trusted-host triton-ascend.osinfra.cn) +RUN . /etc/environment_new && \ + ${PIP_INSTALL} pybind11 && \ + if [ "$TARGETARCH" = "arm64" ]; then \ + ${PIP_INSTALL} https://sglang-ascend.obs.cn-east-3.myhuaweicloud.com/ta/triton_ascend-3.2.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl; \ + elif [ "$TARGETARCH" = "amd64" ]; then \ + ${PIP_INSTALL} https://github.com/triton-lang/triton-ascend/releases/download/v3.2.2/triton_ascend-3.2.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; \ + else \ + echo "Unsupported architecture: $TARGETARCH"; \ + exit 1; \ + fi -# Install SGLang (editable mode to preserve source and git history) -RUN git clone https://github.com/sgl-project/sglang --branch $SGLANG_TAG /sgl-workspace/sglang && \ +# Install SGLang +RUN git clone https://github.com/sgl-project/sglang --branch ${SGLANG_TAG} /sgl-workspace/sglang && \ cd /sgl-workspace/sglang/python && rm -rf pyproject.toml && mv pyproject_npu.toml pyproject.toml && \ + sed -i '/"memfabric-hybrid==1.1.4"/d; /"memfabric-zbal==1.1.2"/d' pyproject.toml && \ ${PIP_INSTALL} -v -e .[all_npu] +ENV ASCEND_HOME_PATH=/usr/local/Ascend/cann-${CANN_VERSION} + +ENV LD_LIBRARY_PATH=/usr/local/Ascend/cann-${CANN_VERSION}/lib64:/usr/local/Ascend/cann-${CANN_VERSION}/lib:/usr/local/Ascend/cann-${CANN_VERSION}/x86_64-linux/devlib/device:/usr/local/Ascend/driver/lib64:/usr/local/lib:${LD_LIBRARY_PATH} + + RUN mkdir cann-custom-ops && \ cd cann-custom-ops && \ + source /usr/local/Ascend/cann-${CANN_VERSION}/set_env.sh && \ wget https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/custom-ops-${SGLANG_KERNEL_NPU_TAG}-torch2.10.0-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip && \ wget https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/ops-transformer-${SGLANG_KERNEL_NPU_TAG}-torch2.10.0-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip && \ unzip custom-ops-${SGLANG_KERNEL_NPU_TAG}-torch2.10.0-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip && \ @@ -101,7 +155,11 @@ RUN mkdir cann-custom-ops && \ chmod +x *.run && \ ./CANN-custom_ops-none-linux.$(arch).run --install-path=/usr/local/Ascend/cann-${CANN_VERSION}/opp && \ ./cann-ops-transformer-custom_linux-$(arch).run --install-path=/usr/local/Ascend/cann-${CANN_VERSION}/opp && \ - ${PIP_INSTALL} custom_ops-1.0-cp311-cp311-linux_$(arch).whl && \ + source /usr/local/Ascend/cann-${CANN_VERSION}/opp/vendors/customize/bin/set_env.bash && \ + source /usr/local/Ascend/cann-${CANN_VERSION}/opp/vendors/custom_transformer/bin/set_env.bash && \ + source /usr/local/Ascend/ascend-toolkit/latest/set_env.sh && \ + source /usr/local/Ascend/nnal/atb/set_env.sh && \ + ${PIP_INSTALL} custom_ops-1.0-cp312-cp312-linux_$(arch).whl && \ cd .. && rm -rf cann-custom-ops # Install Deep-ep @@ -109,9 +167,9 @@ RUN mkdir cann-custom-ops && \ RUN ${PIP_INSTALL} wheel==0.45.1 pybind11 pyyaml decorator scipy attrs psutil \ && mkdir sgl-kernel-npu \ && cd sgl-kernel-npu \ - && wget https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch2.10.0-py311-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip \ - && unzip sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch2.10.0-py311-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip \ - && ${PIP_INSTALL} deep_ep*.whl sgl_kernel_npu*.whl attentions*.whl \ + && wget https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch2.10.0-py312-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip \ + && unzip sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch2.10.0-py312-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip \ + && ${PIP_INSTALL} deep_ep*.whl sgl_kernel_npu*.whl torch_memory_saver*.whl \ && cd .. && rm -rf sgl-kernel-npu \ && cd "$(python3 -m pip show deep-ep | awk '/^Location:/ {print $2}')" && ln -sf deep_ep/deep_ep_cpp*.so diff --git a/python/pyproject_npu.toml b/python/pyproject_npu.toml index 5e925d3b1c..ace6a6e0d4 100644 --- a/python/pyproject_npu.toml +++ b/python/pyproject_npu.toml @@ -33,8 +33,6 @@ dependencies = [ "interegular", "IPython", "llguidance>=1.7.6,<2.0.0", - "memfabric-hybrid==1.1.4", - "memfabric-zbal==1.1.2", "mistral_common>=1.11.5", "modelscope", "msgspec", diff --git a/scripts/ci/npu/npu_ci_install_dependency.sh b/scripts/ci/npu/npu_ci_install_dependency.sh index 13c6a15652..7c0d01753f 100755 --- a/scripts/ci/npu/npu_ci_install_dependency.sh +++ b/scripts/ci/npu/npu_ci_install_dependency.sh @@ -5,8 +5,44 @@ PIP_INSTALL="python3 -m pip install --no-cache-dir" UV_PIP_INSTALL="uv pip install " DEVICE_TYPE=$1 +CANN_VERSION="${CANN_VERSION:-9.1.0}" +PYTORCH_VERSION="${PYTORCH_VERSION:-2.10.0}" +TORCHVISION_VERSION="${TORCHVISION_VERSION:-0.25.0}" +TORCHAUDIO_VERSION="${TORCHAUDIO_VERSION:-2.10.0}" +TORCH_NPU_VERSION="${TORCH_NPU_VERSION:-2.10.0.post6}" +TORCH_NPU_INDEX_URL="${TORCH_NPU_INDEX_URL:-https://ascend.devcloud.huaweicloud.com/pypi/simple/}" +SGLANG_KERNEL_NPU_TAG="${SGLANG_KERNEL_NPU_TAG:-2026.9.0.post5}" + +MF_VERSION="${MF_VERSION:-1.2.1}" +MF_PYPI_VERSION="${MF_PYPI_VERSION:-1.1.5}" +ZBAL_VERSION_950="${ZBAL_VERSION_950:-1.2.21004.post1}" +ZBAL_VERSION_A3="${ZBAL_VERSION_A3:-1.1.3}" + +MF_WHEEL_URL_AARCH64="${MF_WHEEL_URL_AARCH64:-https://sglang-npu.obs.cn-southwest-2.myhuaweicloud.com:443/memfabric/1.2.1/memfabric_hybrid-1.2.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl?AccessKeyId=HPUAAPJN7IAXFCS2GDSQ&Expires=1820732522&Signature=/vRnADjM4r7v392pAygfpiowOMo%3D}" +MF_WHEEL_URL_X86_64="${MF_WHEEL_URL_X86_64:-https://sglang-npu.obs.cn-southwest-2.myhuaweicloud.com:443/memfabric/1.2.1/memfabric_hybrid-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl?AccessKeyId=HPUAAPJN7IAXFCS2GDSQ&Expires=1820732540&Signature=8TKnsDBAihKWkEGcV5/SLkCXVeM%3D}" +MC_WHEEL_URL_AARCH64="${MC_WHEEL_URL_AARCH64:-https://sglang-npu.obs.cn-southwest-2.myhuaweicloud.com:443/memfabric/1.2.1/memcache_hybrid-1.2.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl?AccessKeyId=HPUAAPJN7IAXFCS2GDSQ&Expires=1820732457&Signature=xyC5pL2ztyoeIBgsmZ/cB0CFDBU%3D}" +MC_WHEEL_URL_X86_64="${MC_WHEEL_URL_X86_64:-https://sglang-npu.obs.cn-southwest-2.myhuaweicloud.com:443/memfabric/1.2.1/memcache_hybrid-1.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl?AccessKeyId=HPUAAPJN7IAXFCS2GDSQ&Expires=1820732498&Signature=0pxMuRqZjSyFaAfTtRBEbKHYmmY%3D}" + +ASCEND_HOME_PATH="${ASCEND_HOME_PATH:-/usr/local/Ascend/cann-${CANN_VERSION}}" +export ASCEND_HOME_PATH +export LD_LIBRARY_PATH="${ASCEND_HOME_PATH}/lib64:${ASCEND_HOME_PATH}/lib:${ASCEND_HOME_PATH}/$(arch)-linux/devlib/device:/usr/local/Ascend/driver/lib64:/usr/local/lib:${LD_LIBRARY_PATH:-}" + +GITHUB_PROXY_URL="${GITHUB_PROXY_URL:-}" + +source_env() { + if [ -f "$1" ]; then + # Vendor set_env scripts (e.g. opp/vendors/*/bin/set_env.bash) append to + # variables like ASCEND_CUSTOM_OPP_PATH via ${VAR} without a default, which + # aborts under `set -u`. Relax nounset only while sourcing them. + set +u + # shellcheck disable=SC1090 + source "$1" + set -u + else + echo "[skip] set_env not found: $1" + fi +} -# Install the required dependencies in CI. apt update -y && apt install -y \ unzip \ build-essential \ @@ -32,50 +68,103 @@ export UV_NO_CACHE=true export UV_SYSTEM_PYTHON=true export UV_INDEX_STRATEGY=unsafe-best-match -# Install Rust toolchain (needed by crates built via setuptools-rust, e.g. the -# native gRPC extension bundled into the sglang wheel). SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" bash "${SCRIPT_DIR}/../utils/install_rustup.sh" export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:${PATH}" ${UV_PIP_INSTALL} pybind11 pyyaml decorator scipy attrs psutil +if [ "${DEVICE_TYPE}" = "950" ]; then + case "$(arch)" in + aarch64) + WHEEL_TAG="cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64" + MF_URL="${MF_WHEEL_URL_AARCH64}" + MF_SHA256="27b9c0f18db6260e632f00a2302176bbbd781858d12f3a51d8af6169ac5337c1" + MC_URL="${MC_WHEEL_URL_AARCH64}" + MC_SHA256="c578dfa102e1266755c910e701ed557d50d152376799ae84968d07fbb5fa359e" + ;; + x86_64) + WHEEL_TAG="cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64" + MF_URL="${MF_WHEEL_URL_X86_64}" + MF_SHA256="b754ee9a511f2a495963eec816001ba34924330441f3d6409e7e5d195c0515a0" + MC_URL="${MC_WHEEL_URL_X86_64}" + MC_SHA256="4a684656978880d1cc7b58663036ad13bd966a240067224a93f23ba327bc7370" + ;; + *) + echo "Unsupported architecture: $(arch)" >&2 + exit 1 + ;; + esac + MF_WHEEL="/tmp/memfabric_hybrid-${MF_VERSION}-${WHEEL_TAG}.whl" + MC_WHEEL="/tmp/memcache_hybrid-${MF_VERSION}-${WHEEL_TAG}.whl" + curl -fL --retry 3 --retry-delay 2 -o "${MF_WHEEL}" "${MF_URL}" + curl -fL --retry 3 --retry-delay 2 -o "${MC_WHEEL}" "${MC_URL}" + echo "${MF_SHA256} ${MF_WHEEL}" | sha256sum -c - + echo "${MC_SHA256} ${MC_WHEEL}" | sha256sum -c - + ${PIP_INSTALL} "${MF_WHEEL}" --force-reinstall + mfcli kernel install + ${PIP_INSTALL} "${MC_WHEEL}" --force-reinstall --no-deps + rm -f "${MF_WHEEL}" "${MC_WHEEL}" +else + ${PIP_INSTALL} memfabric-hybrid==${MF_PYPI_VERSION} + ${PIP_INSTALL} memcache-hybrid==${MF_PYPI_VERSION} +fi + +### Install memfabric-zbal +if [ "${DEVICE_TYPE}" = "950" ]; then + ${PIP_INSTALL} memfabric-zbal==${ZBAL_VERSION_950} -i https://pypi.org/simple/ +else + ${PIP_INSTALL} memfabric-zbal==${ZBAL_VERSION_A3} -i https://pypi.org/simple/ +fi + +### Install SGLang Model Gateway +${PIP_INSTALL} sglang-router -### Install PyTorch and PTA -PYTORCH_VERSION="2.10.0" -TORCHVISION_VERSION="0.25.0" -TORCHAUDIO_VERSION="2.10.0" ${UV_PIP_INSTALL} torch==${PYTORCH_VERSION} torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} --index-url ${TORCH_CACHE_URL:="https://download.pytorch.org/whl/cpu"} --extra-index-url ${PYPI_CACHE_URL:="https://pypi.org/simple/"} -PTA_URL="https://gitcode.com/Ascend/pytorch/releases/download/v26.0.0-pytorch2.10.0/torch_npu-2.10.0-cp311-cp311-manylinux_2_28_aarch64.whl" -# GitCode does not allow UV downloads. -${PIP_INSTALL} ${PTA_URL} +${PIP_INSTALL} torch-npu==${TORCH_NPU_VERSION} --extra-index-url ${TORCH_NPU_INDEX_URL} -### Install Triton-Ascend -${PIP_INSTALL} triton-ascend==3.2.1.dev20260530 --extra-index-url=https://mirrors.huaweicloud.com/ascend/repos/pypi/nightly --trusted-host triton-ascend.osinfra.cn +case "$(arch)" in +aarch64) + ${PIP_INSTALL} https://sglang-ascend.obs.cn-east-3.myhuaweicloud.com/ta/triton_ascend-3.2.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl + ;; +x86_64) + ${PIP_INSTALL} "${GITHUB_PROXY_URL}https://github.com/triton-lang/triton-ascend/releases/download/v3.2.2/triton_ascend-3.2.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl" + ;; +*) + echo "Unsupported architecture: $(arch)" >&2 + exit 1 + ;; +esac +mkdir -p sgl-kernel-npu +(cd sgl-kernel-npu && + wget "${GITHUB_PROXY_URL}https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-py312-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip" && + unzip ./sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-py312-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip && + ${UV_PIP_INSTALL} ./deep_ep*.whl ./sgl_kernel_npu*.whl ./attentions*.whl ./torch_memory_saver*.whl && + (cd "$(python3 -m pip show deep-ep | grep -E '^Location:' | awk '{print $2}')" && ln -sf deep_ep/deep_ep_cpp*.so)) +rm -rf sgl-kernel-npu -### Install sgl-kernel-npu -SGLANG_KERNEL_NPU_TAG="2026.9.0.post5" -mkdir sgl-kernel-npu -(cd sgl-kernel-npu && wget "${GITHUB_PROXY_URL:=""}https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-py311-cann9.0.0-${DEVICE_TYPE}-$(arch).zip" \ -&& unzip ./sgl-kernel-npu-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-py311-cann9.0.0-${DEVICE_TYPE}-$(arch).zip \ -&& ${UV_PIP_INSTALL} ./deep_ep*.whl ./sgl_kernel_npu*.whl ./attentions*.whl \ -&& (cd "$(python3 -m pip show deep-ep | grep -E '^Location:' | awk '{print $2}')" && ln -s deep_ep/deep_ep_cpp*.so)) - -### Install custom-ops -mkdir cann-custom-ops -(cd cann-custom-ops && \ -wget "${GITHUB_PROXY_URL:=""}https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/custom-ops-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann9.0.0-${DEVICE_TYPE}-$(arch).zip" && \ -wget "${GITHUB_PROXY_URL:=""}https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/ops-transformer-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann9.0.0-${DEVICE_TYPE}-$(arch).zip" && \ -unzip custom-ops-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann9.0.0-${DEVICE_TYPE}-$(arch).zip && \ -unzip ops-transformer-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann9.0.0-${DEVICE_TYPE}-$(arch).zip && \ -chmod +x *.run && \ -./CANN-custom_ops-none-linux.$(arch).run --install-path=/usr/local/Ascend/cann-9.0.0/opp && \ -./cann-ops-transformer-custom_linux-$(arch).run --install-path=/usr/local/Ascend/cann-9.0.0/opp && \ -${PIP_INSTALL} custom_ops-1.0-cp311-cp311-linux_$(arch).whl) +mkdir -p cann-custom-ops +(cd cann-custom-ops && + source_env "${ASCEND_HOME_PATH}/set_env.sh" && + wget "${GITHUB_PROXY_URL}https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/custom-ops-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip" && + wget "${GITHUB_PROXY_URL}https://github.com/sgl-project/sgl-kernel-npu/releases/download/${SGLANG_KERNEL_NPU_TAG}/ops-transformer-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip" && + unzip custom-ops-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip && + unzip ops-transformer-${SGLANG_KERNEL_NPU_TAG}-torch${PYTORCH_VERSION}-cann${CANN_VERSION}-${DEVICE_TYPE}-$(arch).zip && + chmod +x *.run && + ./CANN-custom_ops-none-linux.$(arch).run --install-path=${ASCEND_HOME_PATH}/opp && + ./cann-ops-transformer-custom_linux-$(arch).run --install-path=${ASCEND_HOME_PATH}/opp && + source_env "${ASCEND_HOME_PATH}/opp/vendors/customize/bin/set_env.bash" && + source_env "${ASCEND_HOME_PATH}/opp/vendors/custom_transformer/bin/set_env.bash" && + source_env /usr/local/Ascend/ascend-toolkit/latest/set_env.sh && + source_env /usr/local/Ascend/nnal/atb/set_env.sh && + ${PIP_INSTALL} custom_ops-1.0-cp312-cp312-linux_$(arch).whl) rm -rf cann-custom-ops - -### Install SGLang rm -rf python/pyproject.toml && mv python/pyproject_npu.toml python/pyproject.toml +# The upstream metadata pins memfabric to single versions (memfabric-hybrid==1.1.4 and +# memfabric-zbal==1.1.2; the latter publishes no cp312 wheel), while this script installs the +# per-device versions above. Strip any memfabric pin so pip neither pulls a different build nor +# fails on a version without a wheel for this Python. No-op once the pins are gone from the file. +sed -i '/"memfabric-/d' python/pyproject.toml ${UV_PIP_INSTALL} -v -e "python[dev_npu]" diff --git a/test/registered/unit/npu/attention/test_npu_ascend_backend.py b/test/registered/unit/npu/attention/test_npu_ascend_backend.py index c110ea9197..06189ef8d2 100644 --- a/test/registered/unit/npu/attention/test_npu_ascend_backend.py +++ b/test/registered/unit/npu/attention/test_npu_ascend_backend.py @@ -12,7 +12,7 @@ import torch from sglang.test.ci.ci_register import register_npu_ci -register_npu_ci(est_time=5, suite="base-a-test-1-npu-a2") +register_npu_ci(est_time=5, suite="base-a-test-npu") # Mock NPU-only modules before importing the source module. for _ in ( diff --git a/test/registered/unit/npu/attention/test_npu_ascend_dsv4_backend.py b/test/registered/unit/npu/attention/test_npu_ascend_dsv4_backend.py index e18a08ae9d..3fc7e24359 100644 --- a/test/registered/unit/npu/attention/test_npu_ascend_dsv4_backend.py +++ b/test/registered/unit/npu/attention/test_npu_ascend_dsv4_backend.py @@ -12,7 +12,7 @@ import torch from sglang.test.ci.ci_register import register_npu_ci -register_npu_ci(est_time=4, suite="base-a-test-1-npu-a2") +register_npu_ci(est_time=4, suite="base-a-test-npu") for mod in ( "torch_npu", @@ -26,6 +26,7 @@ for mod in ( "sglang.srt.speculative.decoupled_spec_io", "sglang.srt.speculative.spec_info", "sglang.srt.speculative.eagle_info", + "sglang.srt.speculative.base_spec_worker", ): sys.modules.setdefault(mod, MagicMock()) diff --git a/test/run_suite.py b/test/run_suite.py index b57eaa69d9..603680bdb0 100644 --- a/test/run_suite.py +++ b/test/run_suite.py @@ -105,7 +105,7 @@ PER_COMMIT_SUITES = { "extra-b-test-8-gpu-b300", ], HWBackend.NPU: [ - "base-a-test-1-npu-a2", + "base-a-test-npu", "base-b-test-1-npu-a3", "base-b-test-2-npu-a3", "base-b-test-4-npu-a3",