[CI] Add cibw-based wheel publishing to PyPI#19656
Conversation
Add a workflow_dispatch pipeline that builds, tests, and publishes manylinux/ macOS/Windows wheels via cibuildwheel with OIDC trusted publishing. - publish_wheel.yml + build-wheel-for-publish action: per-OS/arch matrix, static-LLVM host builds, a separate build_cuda_runtime stage that compiles the libtvm_runtime_cuda sidecar and injects it via -DTVM_PACKAGE_EXTRA_LIBS, auditwheel/delocate/delvewheel repair, and post-upload install+import verify. - pyproject.toml [tool.cibuildwheel]: manylinux_2_28 image pins, skips, test-command, per-platform repair commands. - cmake: FindLLVM prefers static zstd; tvm_compiler links --no-relax + --as-needed on Linux; Library.cmake rpath/install helper reused by backends. - tests/python/wheel: assert LLVM enabled and CUDA runtime bundled.
There was a problem hiding this comment.
Code Review
This pull request refactors the TVM wheel packaging and build process by introducing a standard cibuildwheel flow, adding helper scripts to build CUDA runtime sidecar libraries on Linux and Windows, and consolidating target library configurations with a new CMake helper. Key feedback includes moving pytest from core runtime dependencies to test dependencies in pyproject.toml, ensuring the fallback conda create command in the Windows build script cleans up partially populated directories, avoiding fragile ^ line continuations in the generated Windows batch file, and quoting ${USE_LLVM} in CMakeLists.txt to prevent syntax errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| "psutil", | ||
| "scipy", | ||
| "tornado", | ||
| "pytest", | ||
| "typing_extensions", |
There was a problem hiding this comment.
The testing framework pytest is listed as a core runtime dependency in dependencies. Production users installing TVM do not need pytest to run inference or compile models. It should be moved to [dependency-groups] or [project.optional-dependencies] (e.g., under test or dev) to keep the production dependency graph minimal.
| "psutil", | |
| "scipy", | |
| "tornado", | |
| "pytest", | |
| "typing_extensions", | |
| "psutil", | |
| "typing_extensions", |
| "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit -y \ | ||
| || "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit --use-only-tar-bz2 -y |
There was a problem hiding this comment.
If the first conda create command fails halfway, the target directory ${cuda_prefix} may be left partially populated. The fallback command will then fail because the directory is not empty. Cleaning up the directory before retrying ensures the fallback command can run successfully.
| "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit -y \ | |
| || "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit --use-only-tar-bz2 -y | |
| "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit -y \ | |
| || { rm -rf "${cuda_prefix_unix}" && "${conda_exe}" create -q -p "${cuda_prefix}" -c nvidia/label/cuda-13.0.2 cuda-toolkit --use-only-tar-bz2 -y; } |
| cmake -S "${repo_root}" -B "${build_dir}" -G Ninja ^ | ||
| -DCMAKE_BUILD_TYPE=Release ^ | ||
| -DBUILD_TESTING=OFF ^ | ||
| -DTVM_BUILD_PYTHON_MODULE=ON ^ | ||
| -DUSE_CUDA="${cuda_root}" ^ | ||
| -DUSE_LLVM=OFF ^ | ||
| -DUSE_CUBLAS=OFF -DUSE_CUDNN=OFF -DUSE_CUTLASS=OFF -DUSE_NCCL=OFF -DUSE_NVTX=OFF ^ | ||
| -DCMAKE_CUDA_COMPILER="${nvcc_exe}" ^ | ||
| -DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler" || exit /b 1 |
There was a problem hiding this comment.
Using line continuations with ^ in a generated Windows batch file is fragile because any trailing whitespace after the ^ character will break the command. It is safer to write the entire cmake command on a single line to prevent accidental syntax errors during execution.
| cmake -S "${repo_root}" -B "${build_dir}" -G Ninja ^ | |
| -DCMAKE_BUILD_TYPE=Release ^ | |
| -DBUILD_TESTING=OFF ^ | |
| -DTVM_BUILD_PYTHON_MODULE=ON ^ | |
| -DUSE_CUDA="${cuda_root}" ^ | |
| -DUSE_LLVM=OFF ^ | |
| -DUSE_CUBLAS=OFF -DUSE_CUDNN=OFF -DUSE_CUTLASS=OFF -DUSE_NCCL=OFF -DUSE_NVTX=OFF ^ | |
| -DCMAKE_CUDA_COMPILER="${nvcc_exe}" ^ | |
| -DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler" || exit /b 1 | |
| cmake -S "${repo_root}" -B "${build_dir}" -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DTVM_BUILD_PYTHON_MODULE=ON -DUSE_CUDA="${cuda_root}" -DUSE_LLVM=OFF -DUSE_CUBLAS=OFF -DUSE_CUDNN=OFF -DUSE_CUTLASS=OFF -DUSE_NCCL=OFF -DUSE_NVTX=OFF -DCMAKE_CUDA_COMPILER="${nvcc_exe}" -DCMAKE_CUDA_FLAGS="-allow-unsupported-compiler" || exit /b 1 |
| # generation. Disabling linker relaxation keeps the GOT-indirect sequences and | ||
| # avoids the miscompilation; it is harmless when LLVM is linked dynamically. | ||
| # See binutils bug ld/25754. | ||
| if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ${USE_LLVM} MATCHES ${IS_FALSE_PATTERN}) |
There was a problem hiding this comment.
In CMake, if ${USE_LLVM} is set to a path (e.g., to a specific llvm-config), expanding it unquoted in the if condition can cause syntax errors if the path contains spaces or special characters. Quoting the variable as "${USE_LLVM}" is safer and prevents potential configuration failures.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT "${USE_LLVM}" MATCHES ${IS_FALSE_PATTERN})
Add a workflow_dispatch pipeline that builds, tests, and publishes manylinux/ macOS/Windows wheels via cibuildwheel with OIDC trusted publishing.