MasterJH5574 commented on code in PR #19641:
URL: https://github.com/apache/tvm/pull/19641#discussion_r3326652479


##########
.github/workflows/publish_wheel.yml:
##########
@@ -0,0 +1,286 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Publish TVM wheels
+
+on:
+  workflow_dispatch:
+    inputs:
+      tag:
+        description: "Tag, branch, or SHA to build; PyPI publishes require 
refs/tags/<tag>"
+        required: true
+        type: string
+      publish_repository:
+        description: "Where to publish after the wheel build succeeds"
+        required: true
+        default: "none"
+        type: choice
+        options:
+          - none
+          - testpypi
+          - pypi
+      distribution_name:
+        description: "Optional package name override, e.g. tvm-yourname-test 
for TestPyPI"
+        required: false
+        default: ""
+        type: string
+      distribution_version:
+        description: "Optional package version override for TestPyPI 
validation builds"
+        required: false
+        default: ""
+        type: string
+      cuda_architectures:
+        description: "CMake CUDA architectures for libtvm_runtime_cuda.so"
+        required: false
+        default: "75"
+        type: string
+      verify_from_repository:
+        description: "Install the uploaded package from the selected 
repository and import-test it"
+        required: true
+        default: true
+        type: boolean
+
+permissions:
+  contents: read
+
+jobs:
+  build_wheels:
+    name: ${{ matrix.name }}
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - name: "Linux x86_64 wheel with CUDA runtime (manylinux_2_28)"
+            os: ubuntu-latest
+            arch: x86_64
+            build: cp310-manylinux_x86_64
+            linux_image: manylinux_2_28
+            linux_image_tag: "2026.01.04-1"
+            include_cuda_runtime: "true"
+            artifact_suffix: linux-x86_64-manylinux_2_28
+          - name: "Linux aarch64 wheel with CUDA runtime (manylinux_2_28)"
+            os: ubuntu-24.04-arm
+            arch: aarch64
+            build: cp310-manylinux_aarch64
+            linux_image: manylinux_2_28
+            linux_image_tag: "2026.01.04-1"
+            include_cuda_runtime: "true"
+            artifact_suffix: linux-aarch64-manylinux_2_28
+          - name: "macOS arm64 CPU wheel"
+            os: macos-14
+            arch: arm64
+            build: cp310-macosx_arm64
+            linux_image: ""
+            linux_image_tag: ""
+            include_cuda_runtime: "false"
+            artifact_suffix: macos-arm64
+          - name: "Windows AMD64 CPU wheel"
+            os: windows-latest
+            arch: AMD64
+            build: cp310-win_amd64
+            linux_image: ""
+            linux_image_tag: ""
+            include_cuda_runtime: "false"
+            artifact_suffix: windows-amd64
+    steps:
+      - name: Validate publish inputs
+        shell: bash
+        env:
+          TVM_PUBLISH_REPOSITORY: ${{ inputs.publish_repository }}
+          TVM_PUBLISH_REF: ${{ inputs.tag }}
+          TVM_VERIFY_FROM_REPOSITORY: ${{ inputs.verify_from_repository }}
+          TVM_WHEEL_DIST_NAME: ${{ inputs.distribution_name }}
+          TVM_WHEEL_DIST_VERSION: ${{ inputs.distribution_version }}
+        run: |
+          set -eux
+          if [[ -n "${TVM_WHEEL_DIST_NAME}" && ! "${TVM_WHEEL_DIST_NAME}" =~ 
^[A-Za-z0-9]([A-Za-z0-9._-]*[A-Za-z0-9])?$ ]]; then
+            echo "distribution_name must be a valid Python package name 
override" >&2
+            exit 1
+          fi
+          if [[ -n "${TVM_WHEEL_DIST_VERSION}" && ! 
"${TVM_WHEEL_DIST_VERSION}" =~ ^[A-Za-z0-9][A-Za-z0-9._!+-]*$ ]]; then
+            echo "distribution_version must be a valid Python package version 
override" >&2
+            exit 1
+          fi
+          if [[ "${TVM_PUBLISH_REPOSITORY}" == "pypi" && -n 
"${TVM_WHEEL_DIST_NAME}" ]]; then
+            echo "distribution_name must be empty when publishing to PyPI" >&2
+            exit 1
+          fi
+          if [[ "${TVM_PUBLISH_REPOSITORY}" == "pypi" && -n 
"${TVM_WHEEL_DIST_VERSION}" ]]; then
+            echo "distribution_version must be empty when publishing to PyPI" 
>&2
+            exit 1
+          fi
+          if [[ "${TVM_PUBLISH_REPOSITORY}" == "pypi" && "${TVM_PUBLISH_REF}" 
!= refs/tags/* ]]; then
+            echo "PyPI publishes must use an immutable refs/tags/<tag> ref" >&2
+            exit 1
+          fi
+          if [[ "${TVM_PUBLISH_REPOSITORY}" == "pypi" && 
"${TVM_VERIFY_FROM_REPOSITORY}" != "true" ]]; then
+            echo "verify_from_repository must be enabled when publishing to 
PyPI" >&2
+            exit 1
+          fi
+
+      - name: Checkout source
+        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 
v6.0.2
+        with:
+          ref: ${{ inputs.tag }}
+          submodules: recursive
+          fetch-depth: 1
+          fetch-tags: true
+
+      - name: Build CUDA runtime
+        id: build_cuda
+        uses: ./.github/actions/build-cuda
+        with:
+          arch: ${{ matrix.arch }}
+          linux_image: ${{ matrix.linux_image }}
+          linux_image_tag: ${{ matrix.linux_image_tag }}
+          cuda_architectures: ${{ inputs.cuda_architectures }}
+          include_cuda_runtime: ${{ matrix.include_cuda_runtime }}

Review Comment:
   Skip when cuda is not needed.



##########
.github/actions/build-cuda/action.yml:
##########
@@ -0,0 +1,117 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Build CUDA Runtime
+description: Build libtvm_runtime_cuda for the TVM wheel packaging flow.
+
+inputs:
+  arch:
+    description: "Target Linux architecture for CUDA builds (x86_64 or 
aarch64)"
+    required: true
+  linux_image:
+    description: "Manylinux image tag to use on Linux runners"
+    required: false
+    default: ""
+  linux_image_tag:
+    description: "Pinned manylinux container tag shared with cibuildwheel"
+    required: false
+    default: ""
+  cuda_architectures:
+    description: "CMake CUDA architectures for libtvm_runtime_cuda.so"
+    required: false
+    default: "75"
+  include_cuda_runtime:
+    description: "Set to true to build the CUDA runtime library"
+    required: false
+    default: "false"

Review Comment:
   It should always be true? If that's the case, we can remove this param?



##########
.github/actions/build-cuda/action.yml:
##########
@@ -0,0 +1,117 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Build CUDA Runtime
+description: Build libtvm_runtime_cuda for the TVM wheel packaging flow.
+
+inputs:
+  arch:
+    description: "Target Linux architecture for CUDA builds (x86_64 or 
aarch64)"
+    required: true
+  linux_image:
+    description: "Manylinux image tag to use on Linux runners"
+    required: false
+    default: ""
+  linux_image_tag:
+    description: "Pinned manylinux container tag shared with cibuildwheel"
+    required: false
+    default: ""
+  cuda_architectures:
+    description: "CMake CUDA architectures for libtvm_runtime_cuda.so"
+    required: false
+    default: "75"
+  include_cuda_runtime:
+    description: "Set to true to build the CUDA runtime library"
+    required: false
+    default: "false"
+
+outputs:
+  cuda_runtime_path:
+    description: "Absolute path to the built libtvm_runtime_cuda.so, or empty 
for CPU-only wheels"
+    value: ${{ steps.cuda_runtime.outputs.path }}
+
+runs:
+  using: "composite"
+  steps:
+    - uses: ./.github/actions/detect-env-vars
+      id: env_vars
+
+    - name: Detect CUDA inputs
+      id: cuda_inputs
+      shell: bash -l {0}
+      env:
+        INPUT_INCLUDE_CUDA_RUNTIME: ${{ inputs.include_cuda_runtime }}
+      run: |
+        set -eux
+        include_cuda_runtime="$(printf '%s' "${INPUT_INCLUDE_CUDA_RUNTIME}" | 
tr '[:upper:]' '[:lower:]')"
+        case "${include_cuda_runtime}" in
+          1|true|yes|on) include_cuda_runtime=1 ;;
+          0|false|no|off) include_cuda_runtime=0 ;;
+          *)
+            echo "include_cuda_runtime must be a boolean value" >&2
+            exit 1
+            ;;
+        esac
+        echo "include_cuda_runtime=${include_cuda_runtime}" >> 
"${GITHUB_OUTPUT}"
+
+    - name: Build CUDA runtime in manylinux
+      if: runner.os == 'Linux' && 
steps.cuda_inputs.outputs.include_cuda_runtime == '1'
+      shell: bash -l {0}
+      env:
+        TVM_MANYLINUX_IMAGE: ${{ inputs.linux_image }}
+        TVM_MANYLINUX_IMAGE_TAG: ${{ inputs.linux_image_tag }}
+        TVM_ARCH: ${{ inputs.arch }}
+        TVM_CUDA_ARCHITECTURES: ${{ inputs.cuda_architectures }}
+        TVM_CUDA_BUILD_DIR: ${{ runner.temp }}/tvm-wheel-cuda
+        TVM_INCLUDE_CUDA_RUNTIME: "1"
+        TVM_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
+        CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
+      run: ci/scripts/package/tvm_wheel_helper.sh manylinux-cuda
+
+    - name: Reject non-Linux CUDA runtime builds
+      if: runner.os != 'Linux' && 
steps.cuda_inputs.outputs.include_cuda_runtime == '1'
+      shell: bash -l {0}
+      run: |
+        echo "CUDA runtime wheels are only enabled on Linux in this workflow" 
>&2
+        exit 1

Review Comment:
   Can be dropped?



##########
.github/actions/build-cuda/action.yml:
##########
@@ -0,0 +1,117 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Build CUDA Runtime
+description: Build libtvm_runtime_cuda for the TVM wheel packaging flow.
+
+inputs:
+  arch:
+    description: "Target Linux architecture for CUDA builds (x86_64 or 
aarch64)"
+    required: true
+  linux_image:
+    description: "Manylinux image tag to use on Linux runners"
+    required: false
+    default: ""
+  linux_image_tag:
+    description: "Pinned manylinux container tag shared with cibuildwheel"
+    required: false
+    default: ""
+  cuda_architectures:
+    description: "CMake CUDA architectures for libtvm_runtime_cuda.so"
+    required: false
+    default: "75"
+  include_cuda_runtime:
+    description: "Set to true to build the CUDA runtime library"
+    required: false
+    default: "false"
+
+outputs:
+  cuda_runtime_path:
+    description: "Absolute path to the built libtvm_runtime_cuda.so, or empty 
for CPU-only wheels"
+    value: ${{ steps.cuda_runtime.outputs.path }}
+
+runs:
+  using: "composite"
+  steps:
+    - uses: ./.github/actions/detect-env-vars
+      id: env_vars
+
+    - name: Detect CUDA inputs
+      id: cuda_inputs
+      shell: bash -l {0}
+      env:
+        INPUT_INCLUDE_CUDA_RUNTIME: ${{ inputs.include_cuda_runtime }}
+      run: |
+        set -eux
+        include_cuda_runtime="$(printf '%s' "${INPUT_INCLUDE_CUDA_RUNTIME}" | 
tr '[:upper:]' '[:lower:]')"
+        case "${include_cuda_runtime}" in
+          1|true|yes|on) include_cuda_runtime=1 ;;
+          0|false|no|off) include_cuda_runtime=0 ;;
+          *)
+            echo "include_cuda_runtime must be a boolean value" >&2
+            exit 1
+            ;;
+        esac
+        echo "include_cuda_runtime=${include_cuda_runtime}" >> 
"${GITHUB_OUTPUT}"

Review Comment:
   Is this check unnecessary?



##########
.github/actions/build-cuda/action.yml:
##########
@@ -0,0 +1,117 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Build CUDA Runtime
+description: Build libtvm_runtime_cuda for the TVM wheel packaging flow.
+
+inputs:
+  arch:
+    description: "Target Linux architecture for CUDA builds (x86_64 or 
aarch64)"
+    required: true
+  linux_image:
+    description: "Manylinux image tag to use on Linux runners"
+    required: false
+    default: ""
+  linux_image_tag:
+    description: "Pinned manylinux container tag shared with cibuildwheel"
+    required: false
+    default: ""
+  cuda_architectures:
+    description: "CMake CUDA architectures for libtvm_runtime_cuda.so"
+    required: false
+    default: "75"
+  include_cuda_runtime:
+    description: "Set to true to build the CUDA runtime library"
+    required: false
+    default: "false"
+
+outputs:
+  cuda_runtime_path:
+    description: "Absolute path to the built libtvm_runtime_cuda.so, or empty 
for CPU-only wheels"
+    value: ${{ steps.cuda_runtime.outputs.path }}
+
+runs:
+  using: "composite"
+  steps:
+    - uses: ./.github/actions/detect-env-vars
+      id: env_vars
+
+    - name: Detect CUDA inputs
+      id: cuda_inputs
+      shell: bash -l {0}
+      env:
+        INPUT_INCLUDE_CUDA_RUNTIME: ${{ inputs.include_cuda_runtime }}
+      run: |
+        set -eux
+        include_cuda_runtime="$(printf '%s' "${INPUT_INCLUDE_CUDA_RUNTIME}" | 
tr '[:upper:]' '[:lower:]')"
+        case "${include_cuda_runtime}" in
+          1|true|yes|on) include_cuda_runtime=1 ;;
+          0|false|no|off) include_cuda_runtime=0 ;;
+          *)
+            echo "include_cuda_runtime must be a boolean value" >&2
+            exit 1
+            ;;
+        esac
+        echo "include_cuda_runtime=${include_cuda_runtime}" >> 
"${GITHUB_OUTPUT}"
+
+    - name: Build CUDA runtime in manylinux
+      if: runner.os == 'Linux' && 
steps.cuda_inputs.outputs.include_cuda_runtime == '1'
+      shell: bash -l {0}
+      env:
+        TVM_MANYLINUX_IMAGE: ${{ inputs.linux_image }}
+        TVM_MANYLINUX_IMAGE_TAG: ${{ inputs.linux_image_tag }}
+        TVM_ARCH: ${{ inputs.arch }}
+        TVM_CUDA_ARCHITECTURES: ${{ inputs.cuda_architectures }}
+        TVM_CUDA_BUILD_DIR: ${{ runner.temp }}/tvm-wheel-cuda
+        TVM_INCLUDE_CUDA_RUNTIME: "1"
+        TVM_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
+        CMAKE_BUILD_PARALLEL_LEVEL: ${{ steps.env_vars.outputs.cpu_count }}
+      run: ci/scripts/package/tvm_wheel_helper.sh manylinux-cuda
+
+    - name: Reject non-Linux CUDA runtime builds
+      if: runner.os != 'Linux' && 
steps.cuda_inputs.outputs.include_cuda_runtime == '1'
+      shell: bash -l {0}
+      run: |
+        echo "CUDA runtime wheels are only enabled on Linux in this workflow" 
>&2
+        exit 1
+
+    - name: Report CUDA runtime output
+      id: cuda_runtime
+      shell: bash -l {0}
+      env:
+        INCLUDE_CUDA_RUNTIME: ${{ 
steps.cuda_inputs.outputs.include_cuda_runtime }}
+        TVM_CUDA_BUILD_DIR: ${{ runner.temp }}/tvm-wheel-cuda
+        TVM_CUDA_RUNTIME_PATH: ""
+      run: |
+        set -eux
+        if [[ "${INCLUDE_CUDA_RUNTIME}" != "1" ]]; then
+          echo "path=" >> "${GITHUB_OUTPUT}"
+          exit 0
+        fi
+        cuda_runtime="$(ci/scripts/package/tvm_wheel_helper.sh cuda-path)"
+        if [[ -z "${cuda_runtime}" ]]; then
+          echo "CUDA runtime build did not produce libtvm_runtime_cuda.so" >&2
+          exit 1
+        fi
+        case "${cuda_runtime}" in
+          "${TVM_CUDA_BUILD_DIR}"/*) ;;
+          *)
+            echo "CUDA runtime path is outside the expected build directory: 
${cuda_runtime}" >&2
+            exit 1
+            ;;
+        esac
+        echo "path=${cuda_runtime}" >> "${GITHUB_OUTPUT}"

Review Comment:
   Do we need this report step? Or the "Build CUDA runtime in manylinux" step 
above already reports necessary info (e.g., success, failure, or failure reason)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to