From a2906b5403f3d0dc8959f99fcf0f2b3cdb674e6a Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 10 Jul 2026 11:51:48 +0800 Subject: [PATCH 1/7] Build wheels for PyTorch 2.13.0 --- .github/workflows/build-rocm-ubuntu.yml | 3 +++ .github/workflows/ubuntu-arm64-cpu-wheels.yml | 4 ++++ .github/workflows/ubuntu-cpu-wheels.yml | 5 +++++ .github/workflows/ubuntu-cuda-wheels.yml | 5 +++++ .../github_actions/generate_build_matrix.py | 11 ++++++++++- scripts/github_actions/install_torch.sh | 19 +++++++++++++++++++ 6 files changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-rocm-ubuntu.yml b/.github/workflows/build-rocm-ubuntu.yml index 873cfcb9f..b3afa62b5 100644 --- a/.github/workflows/build-rocm-ubuntu.yml +++ b/.github/workflows/build-rocm-ubuntu.yml @@ -114,6 +114,9 @@ jobs: elif [[ $PYTHON_VERSION == "3.14" ]]; then python_dir=/opt/python/cp314-cp314 export PYTHONPATH=/opt/python/cp314-cp314/lib/python3.14/site-packages:$PYTHONPATH + elif [[ $PYTHON_VERSION == "3.15" ]]; then + python_dir=/opt/python/cp315-cp315 + export PYTHONPATH=/opt/python/cp315-cp315/lib/python3.15/site-packages:$PYTHONPATH else echo "Unsupported Python version $PYTHON_VERSION" exit 1 diff --git a/.github/workflows/ubuntu-arm64-cpu-wheels.yml b/.github/workflows/ubuntu-arm64-cpu-wheels.yml index 830736f0d..95b8e8c67 100644 --- a/.github/workflows/ubuntu-arm64-cpu-wheels.yml +++ b/.github/workflows/ubuntu-arm64-cpu-wheels.yml @@ -94,6 +94,7 @@ jobs: # cp313-cp313 # cp313-cp313t (no gil) # cp314-cp314 + # cp315-cp315 if [[ $PYTHON_VERSION == "3.6" ]]; then python_dir=/opt/python/cp36-cp36m export PYTHONPATH=/opt/python/cp36-cp36m/lib/python3.6/site-packages:$PYTHONPATH @@ -121,6 +122,9 @@ jobs: elif [[ $PYTHON_VERSION == "3.14" ]]; then python_dir=/opt/python/cp314-cp314 export PYTHONPATH=/opt/python/cp314-cp314/lib/python3.14/site-packages:$PYTHONPATH + elif [[ $PYTHON_VERSION == "3.15" ]]; then + python_dir=/opt/python/cp315-cp315 + export PYTHONPATH=/opt/python/cp315-cp315/lib/python3.15/site-packages:$PYTHONPATH else echo "Unsupported Python version $PYTHON_VERSION" exit 1 diff --git a/.github/workflows/ubuntu-cpu-wheels.yml b/.github/workflows/ubuntu-cpu-wheels.yml index 9bb48d754..f67fe83f4 100644 --- a/.github/workflows/ubuntu-cpu-wheels.yml +++ b/.github/workflows/ubuntu-cpu-wheels.yml @@ -93,6 +93,8 @@ jobs: # cp312-cp312 # cp313-cp313 # cp313-cp313t (no gil) + # cp314-cp314 + # cp315-cp315 if [[ $PYTHON_VERSION == "3.6" ]]; then python_dir=/opt/python/cp36-cp36m export PYTHONPATH=/opt/python/cp36-cp36m/lib/python3.6/site-packages:$PYTHONPATH @@ -120,6 +122,9 @@ jobs: elif [[ $PYTHON_VERSION == "3.14" ]]; then python_dir=/opt/python/cp314-cp314 export PYTHONPATH=/opt/python/cp314-cp314/lib/python3.14/site-packages:$PYTHONPATH + elif [[ $PYTHON_VERSION == "3.15" ]]; then + python_dir=/opt/python/cp315-cp315 + export PYTHONPATH=/opt/python/cp315-cp315/lib/python3.15/site-packages:$PYTHONPATH else echo "Unsupported Python version $PYTHON_VERSION" exit 1 diff --git a/.github/workflows/ubuntu-cuda-wheels.yml b/.github/workflows/ubuntu-cuda-wheels.yml index 5d8168fb0..c6f1bfa86 100644 --- a/.github/workflows/ubuntu-cuda-wheels.yml +++ b/.github/workflows/ubuntu-cuda-wheels.yml @@ -107,6 +107,8 @@ jobs: # cp312-cp312 # cp313-cp313 # cp313-cp313t (no gil) + # cp314-cp314 + # cp315-cp315 if [[ $PYTHON_VERSION == "3.6" ]]; then python_dir=/opt/python/cp36-cp36m export PYTHONPATH=/opt/python/cp36-cp36m/lib/python3.6/site-packages:$PYTHONPATH @@ -134,6 +136,9 @@ jobs: elif [[ $PYTHON_VERSION == "3.14" ]]; then python_dir=/opt/python/cp314-cp314 export PYTHONPATH=/opt/python/cp314-cp314/lib/python3.14/site-packages:$PYTHONPATH + elif [[ $PYTHON_VERSION == "3.15" ]]; then + python_dir=/opt/python/cp315-cp315 + export PYTHONPATH=/opt/python/cp315-cp315/lib/python3.15/site-packages:$PYTHONPATH else echo "Unsupported Python version $PYTHON_VERSION" exit 1 diff --git a/scripts/github_actions/generate_build_matrix.py b/scripts/github_actions/generate_build_matrix.py index fc8929ce5..209959e43 100755 --- a/scripts/github_actions/generate_build_matrix.py +++ b/scripts/github_actions/generate_build_matrix.py @@ -386,10 +386,18 @@ def generate_build_matrix( else ["12.6.2", "13.0.1", "13.2.0"] ), }, + "2.13.0": { + "python-version": ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"], + "cuda": ( + ["12.6", "13.0", "13.2"] # default 13.0 + if not for_windows + else ["12.6.2", "13.0.1", "13.2.0"] + ), + }, # https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts } if test_only_latest_torch: - latest = "2.12.1" + latest = "2.13.0" matrix = {latest: matrix[latest]} if for_windows or for_macos: @@ -484,6 +492,7 @@ def generate_build_matrix( "2.11.0": ["7.1", "7.2"], "2.12.0": ["7.1", "7.2"], "2.12.1": ["7.1", "7.2"], + "2.13.0": ["7.1", "7.2"], } if torch in rocm_versions_map: rocm_list = rocm_versions_map[torch] diff --git a/scripts/github_actions/install_torch.sh b/scripts/github_actions/install_torch.sh index fdd91fb92..22e073805 100755 --- a/scripts/github_actions/install_torch.sh +++ b/scripts/github_actions/install_torch.sh @@ -404,6 +404,25 @@ case ${torch} in ;; esac ;; + 2.13.*) + case ${cuda} in + 12.6) + package="torch==${torch}+cu126" + # https://download.pytorch.org/whl/nightly/torch/ + url=https://download.pytorch.org/whl/torch/ + ;; + 13.0) + # default 13.0 + package="torch==${torch}+cu130" + url=https://download.pytorch.org/whl/torch/ + ;; + 13.2) + # default 13.0 + package="torch==${torch}+cu132" + url=https://download.pytorch.org/whl/torch/ + ;; + esac + ;; # 2.8.*) # case ${cuda} in # 12.6) From 9a59de0c0cb17c17168a47722e4516b3386881e3 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 10 Jul 2026 12:05:43 +0800 Subject: [PATCH 2/7] Small fixes --- .github/workflows/macos-cpu-wheels.yml | 2 +- .github/workflows/windows-x64-cpu-wheels.yml | 2 +- .../github_actions/build-ubuntu-cpu-arm64.sh | 18 ++---- scripts/github_actions/build-ubuntu-cpu.sh | 17 ++--- scripts/github_actions/build-ubuntu-cuda.sh | 64 +++++-------------- 5 files changed, 32 insertions(+), 71 deletions(-) diff --git a/.github/workflows/macos-cpu-wheels.yml b/.github/workflows/macos-cpu-wheels.yml index 323e7dc85..a8323f780 100644 --- a/.github/workflows/macos-cpu-wheels.yml +++ b/.github/workflows/macos-cpu-wheels.yml @@ -50,7 +50,7 @@ jobs: fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/windows-x64-cpu-wheels.yml b/.github/workflows/windows-x64-cpu-wheels.yml index 5cb157bbb..f2d630853 100644 --- a/.github/workflows/windows-x64-cpu-wheels.yml +++ b/.github/workflows/windows-x64-cpu-wheels.yml @@ -50,7 +50,7 @@ jobs: fetch-depth: 0 - name: Setup Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} diff --git a/scripts/github_actions/build-ubuntu-cpu-arm64.sh b/scripts/github_actions/build-ubuntu-cpu-arm64.sh index d8804d24c..0a8c201c3 100755 --- a/scripts/github_actions/build-ubuntu-cpu-arm64.sh +++ b/scripts/github_actions/build-ubuntu-cpu-arm64.sh @@ -15,6 +15,12 @@ if [ -z $TORCH_VERSION ]; then exit 1 fi +if [ -z "$PYTHON_INSTALL_DIR" ]; then + echo "Please set the environment variable PYTHON_INSTALL_DIR" + echo "Example: export PYTHON_INSTALL_DIR=/opt/python/cp310-cp310" + exit 1 +fi + export PATH=$PYTHON_INSTALL_DIR/bin:$PATH export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH ls -lh $PYTHON_INSTALL_DIR/lib/ @@ -50,11 +56,6 @@ python3 -m pip install -qq torch==$TORCH_VERSION python3 -c "import torch; print(torch.__file__)" python3 -m torch.utils.collect_env -export PATH=$PYTHON_INSTALL_DIR/bin:$PATH - -python3 --version -which python3 - rm -rf ~/.cache/pip >/dev/null 2>&1 yum clean all >/dev/null 2>&1 @@ -68,10 +69,6 @@ export CMAKE_CUDA_COMPILER_LAUNCHER= export K2_CMAKE_ARGS=" -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 " export K2_MAKE_ARGS=" -j2 " -nvcc --version || true -rm -rf /usr/local/cuda* -nvcc --version || true - python3 setup.py bdist_wheel if [[ x"$IS_2_28" == x"1" ]]; then @@ -79,9 +76,6 @@ if [[ x"$IS_2_28" == x"1" ]]; then else plat=manylinux_2_17_aarch64 fi -export PATH=$PYTHON_INSTALL_DIR/bin:$PATH -python3 --version -which python3 auditwheel --verbose repair \ --exclude libc10.so \ diff --git a/scripts/github_actions/build-ubuntu-cpu.sh b/scripts/github_actions/build-ubuntu-cpu.sh index 3aa2f753c..7cb4e13a8 100755 --- a/scripts/github_actions/build-ubuntu-cpu.sh +++ b/scripts/github_actions/build-ubuntu-cpu.sh @@ -15,6 +15,15 @@ if [ -z $TORCH_VERSION ]; then exit 1 fi +if [ -z "$PYTHON_INSTALL_DIR" ]; then + echo "Please set the environment variable PYTHON_INSTALL_DIR" + echo "Example: export PYTHON_INSTALL_DIR=/opt/python/cp310-cp310" + exit 1 +fi + +export PATH=$PYTHON_INSTALL_DIR/bin:$PATH +export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH + python3 -m pip install -U pip cmake "numpy<=1.26.4" python3 -m pip install -U wheel twine typing_extensions python3 -m pip install -U bs4 requests tqdm auditwheel patchelf @@ -41,11 +50,6 @@ python3 -m pip install -qq torch==$TORCH_VERSION+cpu -f https://download.pytorch python3 -c "import torch; print(torch.__file__)" python3 -m torch.utils.collect_env -export PATH=$PYTHON_INSTALL_DIR/bin:$PATH - -python3 --version -which python3 - rm -rf ~/.cache/pip >/dev/null 2>&1 yum clean all >/dev/null 2>&1 @@ -73,9 +77,6 @@ if [[ x"$IS_2_28" == x"1" ]]; then else plat=manylinux_2_17_x86_64 fi -export PATH=$PYTHON_INSTALL_DIR/bin:$PATH -python3 --version -which python3 pushd dist unzip *.whl diff --git a/scripts/github_actions/build-ubuntu-cuda.sh b/scripts/github_actions/build-ubuntu-cuda.sh index a8d9af4d9..0381547c0 100755 --- a/scripts/github_actions/build-ubuntu-cuda.sh +++ b/scripts/github_actions/build-ubuntu-cuda.sh @@ -2,23 +2,27 @@ # set -ex -if [ -z $PYTHON_VERSION ]; then +if [ -z "$PYTHON_VERSION" ]; then echo "Please set the environment variable PYTHON_VERSION" - echo "Example: export PYTHON_VERSION=3.8" - # Valid values: 3.6, 3.7, 3.8, 3.9, 3.10, 3.11 + echo "Example: export PYTHON_VERSION=3.10" exit 1 fi -if [ -z $TORCH_VERSION ]; then +if [ -z "$TORCH_VERSION" ]; then echo "Please set the environment variable TORCH_VERSION" - echo "Example: export TORCH_VERSION=1.10.0" + echo "Example: export TORCH_VERSION=2.12.1" exit 1 fi -if [ -z $CUDA_VERSION ]; then +if [ -z "$CUDA_VERSION" ]; then echo "Please set the environment variable CUDA_VERSION" - echo "Example: export CUDA_VERSION=10.2" - # valid values: 10.2, 11.1, 11.3, 11.6, 11.7, 11.8, 12.1 + echo "Example: export CUDA_VERSION=12.1" + exit 1 +fi + +if [ -z "$PYTHON_INSTALL_DIR" ]; then + echo "Please set the environment variable PYTHON_INSTALL_DIR" + echo "Example: export PYTHON_INSTALL_DIR=/opt/python/cp310-cp310" exit 1 fi @@ -27,7 +31,9 @@ if [[ $TORCH_VERSION =~ 2.2.* && $CUDA_VERSION =~ 12.* ]]; then export TORCH_CUDA_ARCH_LIST="8.0 8.6 8.9 9.0" fi -# python3 -m pip install scikit-build +export PATH=$PYTHON_INSTALL_DIR/bin:$PATH +export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH + python3 -m pip install --no-cache-dir -U pip cmake "numpy<=1.26.4" python3 -m pip install --no-cache-dir wheel twine typing_extensions python3 -m pip install --no-cache-dir bs4 requests tqdm auditwheel patchelf @@ -40,48 +46,11 @@ python3 -c "import torch; print(torch.__file__)" sed -i.bak /9.0a/d /Python-*/py-3.*/lib/python3.*/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake || true -if [[ x"$IS_2_28" != x"1" ]]; then - yum -y install openssl-devel -fi - -yum -y install zlib-devel bzip2-devel libffi-devel xz-devel wget redhat-lsb-core - -INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.2 -if [[ $PYTHON_VERSION == "3.13" || $PYTHON_VERSION == "3.14" ]]; then - INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.0 -fi -echo "Installing $INSTALLED_PYTHON_VERSION" - -curl -O https://www.python.org/ftp/python/$INSTALLED_PYTHON_VERSION/Python-$INSTALLED_PYTHON_VERSION.tgz -tar xf Python-$INSTALLED_PYTHON_VERSION.tgz -pushd Python-$INSTALLED_PYTHON_VERSION - -PYTHON_INSTALL_DIR=$PWD/py-${PYTHON_VERSION} - -if [[ $PYTHON_VERSION =~ 3.1. && x"$IS_2_28" != x"1" ]]; then - yum install -y openssl11-devel - sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure -fi - -./configure --enable-shared --prefix=$PYTHON_INSTALL_DIR >/dev/null -make install >/dev/null - -popd - -export PATH=$PYTHON_INSTALL_DIR/bin:$PATH -export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH -ls -lh $PYTHON_INSTALL_DIR/lib/ - -python3 --version -which python3 - rm -rf ~/.cache/pip >/dev/null 2>&1 yum clean all >/dev/null 2>&1 cd /var/www -export CMAKE_CUDA_COMPILER_LAUNCHER= - export CMAKE_CUDA_COMPILER_LAUNCHER= # export K2_CMAKE_ARGS="-DCUDAToolkit_TARGET_DIR=/usr/local/cuda/targets/x86_64-linux -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 " export K2_CMAKE_ARGS="-DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 " @@ -93,9 +62,6 @@ if [[ x"$IS_2_28" == x"1" ]]; then else plat=manylinux_2_17_x86_64 fi -export PATH=$PYTHON_INSTALL_DIR/bin:$PATH -python3 --version -which python3 auditwheel --verbose repair \ --exclude libc10.so \ From e3ed5867cb74cd83d154677d7c42aea3f43187e9 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 10 Jul 2026 12:10:43 +0800 Subject: [PATCH 3/7] Fix macos --- .github/workflows/macos-cpu-wheels.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/macos-cpu-wheels.yml b/.github/workflows/macos-cpu-wheels.yml index a8323f780..1a1bf7763 100644 --- a/.github/workflows/macos-cpu-wheels.yml +++ b/.github/workflows/macos-cpu-wheels.yml @@ -50,10 +50,17 @@ jobs: fetch-depth: 0 - name: Setup Python + if: matrix.python-version != '3.15' uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Setup Python + if: matrix.python-version == '3.15' + uses: actions/setup-python@v6 + with: + python-version: '3.15.0-beta.3' + - name: Install dependencies shell: bash run: | From 5abe7373ddc27b682cc2cbc5ca3299e8df8bd742 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 10 Jul 2026 12:19:54 +0800 Subject: [PATCH 4/7] Fix rocm --- .github/workflows/build-rocm-ubuntu.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-rocm-ubuntu.yml b/.github/workflows/build-rocm-ubuntu.yml index b3afa62b5..af3e7194d 100644 --- a/.github/workflows/build-rocm-ubuntu.yml +++ b/.github/workflows/build-rocm-ubuntu.yml @@ -96,7 +96,7 @@ jobs: if [[ $PYTHON_VERSION == "3.8" ]]; then python_dir=/opt/python/cp38-cp38 export PYTHONPATH=/opt/python/cp310-cp310/lib/python3.10/site-packages:$PYTHONPATH - if [[ $PYTHON_VERSION == "3.9" ]]; then + elif [[ $PYTHON_VERSION == "3.9" ]]; then python_dir=/opt/python/cp39-cp39 export PYTHONPATH=/opt/python/cp310-cp310/lib/python3.10/site-packages:$PYTHONPATH elif [[ $PYTHON_VERSION == "3.10" ]]; then From 2c665f5ceb69afa69a4306fbdc9c5f287a153cf2 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 10 Jul 2026 12:24:03 +0800 Subject: [PATCH 5/7] Fix building with CUDA --- k2/csrc/ragged_ops_inl.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/k2/csrc/ragged_ops_inl.h b/k2/csrc/ragged_ops_inl.h index f211f5941..998a1123d 100644 --- a/k2/csrc/ragged_ops_inl.h +++ b/k2/csrc/ragged_ops_inl.h @@ -554,8 +554,9 @@ struct PairInputIterator { K2_CUDA_HOSTDEV Pair operator[](int32_t idx) const { return Pair{t_[idx + offset_], idx + offset_}; } - K2_CUDA_HOSTDEV PairInputIterator operator+(int32_t offset) { - return PairInputIterator{t_, offset + offset_}; + template + K2_CUDA_HOSTDEV PairInputIterator operator+(U offset) { + return PairInputIterator{t_, static_cast(offset + offset_)}; } K2_CUDA_HOSTDEV PairInputIterator &operator+=(int32_t offset) { offset_ += offset; @@ -592,12 +593,9 @@ struct PairOutputIterator { // outputs just the index of the pair. const { return PairOutputIteratorDeref(i_); } + template __host__ __device__ __forceinline__ PairOutputIterator - operator+(int32_t offset) const { - return PairOutputIterator{i_ + offset}; - } - __host__ __device__ __forceinline__ PairOutputIterator - operator+(size_t offset) const { + operator+(U offset) const { return PairOutputIterator{i_ + offset}; } __host__ __device__ __forceinline__ PairOutputIterator From 7217fe733e9eb3fa02371f025ceb8ca53608a77b Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 10 Jul 2026 12:33:23 +0800 Subject: [PATCH 6/7] Fix for windows --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 32e63c2eb..7eec2293e 100644 --- a/setup.py +++ b/setup.py @@ -153,7 +153,9 @@ def build_extension(self, ext: setuptools.extension.Extension): major, minor = get_pytorch_version().split(".")[:2] major = int(major) minor = int(minor) - if major > 2 or (major == 2 and minor >= 1): + if major > 2 or (major == 2 and minor >= 13): + extra_cmake_args += f" -DCMAKE_CXX_STANDARD=20 " + elif major > 2 or (major == 2 and minor >= 1): extra_cmake_args += f" -DCMAKE_CXX_STANDARD=17 " if cmake_args == "": From c5d04cb10b24b9cfedf568ae7c9d791556f190c6 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Fri, 10 Jul 2026 14:05:12 +0800 Subject: [PATCH 7/7] Small fixes --- scripts/github_actions/generate_build_matrix.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/github_actions/generate_build_matrix.py b/scripts/github_actions/generate_build_matrix.py index 209959e43..11cb1a11e 100755 --- a/scripts/github_actions/generate_build_matrix.py +++ b/scripts/github_actions/generate_build_matrix.py @@ -413,6 +413,9 @@ def generate_build_matrix( if "1.13.1" in matrix: matrix["1.13.1"]["python-version"].remove("3.11") + if "2.13.0" in matrix: + matrix["2.13.0"]["python-version"].remove("3.15") + excluded_python_versions = ["3.6", "3.7"] enabled_torch_versions = ["1.10.0"]