Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/build-rocm-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/macos-cpu-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,17 @@ jobs:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v5
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: |
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ubuntu-arm64-cpu-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ubuntu-cpu-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/ubuntu-cuda-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-x64-cpu-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
12 changes: 5 additions & 7 deletions k2/csrc/ragged_ops_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@ struct PairInputIterator {
K2_CUDA_HOSTDEV Pair<T> operator[](int32_t idx) const {
return Pair<T>{t_[idx + offset_], idx + offset_};
}
K2_CUDA_HOSTDEV PairInputIterator operator+(int32_t offset) {
return PairInputIterator{t_, offset + offset_};
template <typename U>
K2_CUDA_HOSTDEV PairInputIterator operator+(U offset) {
return PairInputIterator{t_, static_cast<int32_t>(offset + offset_)};
}
K2_CUDA_HOSTDEV PairInputIterator &operator+=(int32_t offset) {
offset_ += offset;
Expand Down Expand Up @@ -592,12 +593,9 @@ struct PairOutputIterator { // outputs just the index of the pair.
const {
return PairOutputIteratorDeref<T>(i_);
}
template <typename U>
__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
Expand Down
18 changes: 6 additions & 12 deletions scripts/github_actions/build-ubuntu-cpu-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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

Expand All @@ -68,20 +69,13 @@ 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
plat=manylinux_2_28_aarch64
else
plat=manylinux_2_17_aarch64
fi
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
python3 --version
which python3

auditwheel --verbose repair \
--exclude libc10.so \
Expand Down
17 changes: 9 additions & 8 deletions scripts/github_actions/build-ubuntu-cpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
64 changes: 15 additions & 49 deletions scripts/github_actions/build-ubuntu-cuda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 "
Expand All @@ -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 \
Expand Down
14 changes: 13 additions & 1 deletion scripts/github_actions/generate_build_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Python 3.15 is not yet released, and there are no official stable releases, docker images, or PyTorch wheels available for it. Including "3.15" in the build matrix will cause the CI workflow to fail when attempting to set up the environment or install PyTorch for Python 3.15.

Please remove "3.15" from the list of supported Python versions.

Suggested change
"python-version": ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"],
"python-version": ["3.10", "3.11", "3.12", "3.13", "3.14"],

"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:
Expand All @@ -405,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")
Comment on lines +416 to +417

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Since "3.15" should be removed from the supported Python versions for "2.13.0" (as it is not yet released), this block is no longer needed and would actually cause a ValueError: list.remove(x): x not in list if "3.15" is not present in the list.

Please remove this block.


excluded_python_versions = ["3.6", "3.7"]

enabled_torch_versions = ["1.10.0"]
Expand Down Expand Up @@ -484,6 +495,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]
Expand Down
19 changes: 19 additions & 0 deletions scripts/github_actions/install_torch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The condition major > 2 in the elif statement is redundant because any case where major > 2 is true will already be handled by the preceding if statement on line 156.

You can simplify this to only check for major == 2 and minor >= 1.

Suggested change
elif major > 2 or (major == 2 and minor >= 1):
elif major == 2 and minor >= 1:

extra_cmake_args += f" -DCMAKE_CXX_STANDARD=17 "

if cmake_args == "":
Expand Down
Loading