Skip to content

Commit 1cfc277

Browse files
Build: Expand CUDA Toolkit Matrix (#1111)
* (ci) build with wider CUDA version matrix * (ci) build with wider CUDA version matrix * (ci) skip sm_89 target on CUDA 11.7 * (ci) skip sm_90 target on CUDA 11.8 * modify workflow to publish to test.pypi * (build) Test for manylinux_2_24 build on GH actions * (build) got that backwards. * try fixing manual triggering condition for testpypi * try if Ubuntu 18.04 is an easy fix to allow for `manylinux_2_24` compatibility * hardcode publish step to run to test publishing * set ubuntu to newest supported version * try statically linking libstdc++ to achieve manylinux_2_18 * last commit only brought us to manylinux_2_34, reverse * add misssing permission for publishing to pypi * snake case deprecated in favor of kebab * downgrade cuda ubuntu aiming for manylinux_2_24 * add step to upgrade cmake due to old Ubuntu for CUDA build * adjust path to prefer pip installed cmake * (cmake) set CMAKE_BUILD_TYPE=Release if unspecified * default to CMAKE_BUILD_TYPE Release for optimized releases and better many_linux compatibility * (build) back to ubuntu22.04 docker images * verify Cmake in separte step * add clarifying comment about Python version compatibility * (build) we don't need cmake for wheel step * fixup testpypi publish to run in PR for testing * add pypi publishing when tagged on main * add functionality to rewrite platform tags * (ci) adjust platform tags for wheels * fix for windows, get order right. * fix for windows, get order right. * (build) slim down those fatbins on windows cuda * sloppy * remove broken PyPi upload for now --------- Co-authored-by: Titus von Koeller <[email protected]>
1 parent ac5d6ee commit 1cfc277

File tree

3 files changed

+64
-24
lines changed

3 files changed

+64
-24
lines changed

.github/workflows/python-package.yml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
- 'pytest.ini'
1818
release:
1919
types: [ published ]
20+
workflow_dispatch: {} # Allow manual trigger
2021

2122
concurrency:
2223
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -82,10 +83,12 @@ jobs:
8283
matrix:
8384
os: [ubuntu-latest, windows-latest]
8485
arch: [x86_64, aarch64]
85-
cuda_version: ['12.1.0']
86+
cuda_version: ["11.7.1", "11.8.0", "12.0.1", "12.1.1", "12.2.2", "12.3.2"]
8687
exclude:
8788
- os: windows-latest # This probably requires arm64 Windows agents
8889
arch: aarch64
90+
- os: ubuntu-latest # Temporary. Takes too long, not ready yet.
91+
arch: aarch64
8992
runs-on: ${{ matrix.os }} # One day, we could run them on native agents. Azure supports this now but it's planned only for Q3 2023 for hosted agents
9093
steps:
9194
# Check out code
@@ -121,6 +124,9 @@ jobs:
121124
set -ex
122125
build_os=${{ matrix.os }}
123126
build_arch=${{ matrix.arch }}
127+
build_capability="50;52;60;61;70;75;80;86;89;90"
128+
[[ "${{ matrix.cuda_version }}" == 11.7.* ]] && build_capability=${build_capability%??????}
129+
[[ "${{ matrix.cuda_version }}" == 11.8.* ]] && build_capability=${build_capability%???}
124130
[[ "${{ matrix.os }}" = windows-* ]] && python3 -m pip install ninja
125131
for NO_CUBLASLT in ON OFF; do
126132
if [ ${build_os:0:6} == ubuntu ]; then
@@ -129,10 +135,10 @@ jobs:
129135
docker run --platform linux/$build_arch -i -w /src -v $PWD:/src $image sh -c \
130136
"apt-get update \
131137
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cmake \
132-
&& cmake -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY=\"50;52;60;61;70;75;80;86;89;90\" -DNO_CUBLASLT=${NO_CUBLASLT} . \
138+
&& cmake -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY=\"${build_capability}\" -DNO_CUBLASLT=${NO_CUBLASLT} . \
133139
&& cmake --build ."
134140
else
135-
cmake -G Ninja -DCOMPUTE_BACKEND=cuda -DNO_CUBLASLT=${NO_CUBLASLT} -DCMAKE_BUILD_TYPE=Release -S .
141+
cmake -G Ninja -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY="${build_capability}" -DNO_CUBLASLT=${NO_CUBLASLT} -DCMAKE_BUILD_TYPE=Release -S .
136142
cmake --build . --config Release
137143
fi
138144
done
@@ -151,7 +157,10 @@ jobs:
151157
strategy:
152158
matrix:
153159
os: [ubuntu-latest, macos-latest, windows-latest]
154-
python-version: ["3.9", "3.10", "3.11", "3.12"]
160+
# The specific Python version is irrelevant in this context as we are only packaging non-C extension
161+
# code. This ensures compatibility across Python versions, including Python 3.8, as compatibility is
162+
# dictated by the packaged code itself, not the Python version used for packaging.
163+
python-version: ["3.10"]
155164
arch: [x86_64, aarch64]
156165
exclude:
157166
- os: windows-latest # This probably requires arm64 Windows agents
@@ -192,27 +201,15 @@ jobs:
192201
- name: Build wheel
193202
shell: bash
194203
run: python -m build .
204+
- name: Determine and Set Platform Tag, then Tag Wheel
205+
shell: bash
206+
run: |
207+
PLATFORM_TAG=$(python scripts/set_platform_tag.py ${{ matrix.arch }})
208+
echo "PLATFORM_TAG=$PLATFORM_TAG"
209+
wheel tags --remove --abi-tag=none --python-tag=py3 --platform-tag=$PLATFORM_TAG dist/bitsandbytes-*.whl
195210
- name: Upload build artifact
196211
uses: actions/upload-artifact@v4
197212
with:
198-
name: bdist_wheel_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.python-version }}
213+
name: bdist_wheel_${{ matrix.os }}_${{ matrix.arch }}
199214
path: dist/bitsandbytes-*.whl
200215
retention-days: 7
201-
publish:
202-
needs: build-wheels
203-
runs-on: ubuntu-latest
204-
steps:
205-
- uses: actions/checkout@v4
206-
- name: Download build artifact
207-
uses: actions/download-artifact@v4
208-
with:
209-
path: dist/
210-
merge-multiple: true
211-
pattern: "bdist_wheel_*"
212-
- run: |
213-
ls -lR dist/
214-
- name: Publish to PyPi
215-
if: startsWith(github.ref, 'refs/tags')
216-
uses: pypa/gh-action-pypi-publish@release/v1
217-
with:
218-
password: ${{ secrets.pypi }}

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ cmake_minimum_required(VERSION 3.22.1)
1515

1616
project(bitsandbytes LANGUAGES CXX)
1717

18+
# If run without specifying a build type, default to using the Release configuration:
19+
# optimizing the generated binaries for performance and also adds the `-DNDEBUG` flag,
20+
# which turns off a bunch of asserts which seem to link to new symbols in libstdc++,
21+
# worsening our many_linux compliance..
22+
if(NOT CMAKE_BUILD_TYPE)
23+
set(CMAKE_BUILD_TYPE Release)
24+
endif()
25+
1826
# Define included source files
1927
set(CPP_FILES csrc/common.cpp csrc/cpu_ops.cpp csrc/pythonInterface.cpp)
2028
set(CUDA_FILES csrc/ops.cu csrc/kernels.cu)
@@ -108,6 +116,7 @@ if(BUILD_CUDA)
108116
endif()
109117

110118
string(APPEND CMAKE_CUDA_FLAGS " --use_fast_math")
119+
111120
if(PTXAS_VERBOSE)
112121
# Verbose? Outputs register usage information, and other things...
113122
string(APPEND CMAKE_CUDA_FLAGS " -Xptxas=-v")
@@ -220,4 +229,4 @@ if(MSVC)
220229
set_target_properties(bitsandbytes PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${PROJECT_SOURCE_DIR}/bitsandbytes")
221230
endif()
222231

223-
set_target_properties(bitsandbytes PROPERTIES LIBRARY_OUTPUT_DIRECTORY bitsandbytes)
232+
set_target_properties(bitsandbytes PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bitsandbytes")

scripts/set_platform_tag.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import argparse
2+
import platform
3+
import sys
4+
5+
6+
def get_platform_tag(architecture):
7+
system = platform.system()
8+
9+
if system == "Linux":
10+
tag = (
11+
"manylinux_2_24_x86_64" if architecture == "x86_64" else "manylinux_2_24_aarch64"
12+
)
13+
elif system == "Darwin":
14+
tag = "macosx_13_1_x86_64" if architecture == "x86_64" else "macosx_13_1_arm64"
15+
elif system == "Windows":
16+
tag = "win_amd64" if architecture == "x86_64" else "win_arm64"
17+
else:
18+
sys.exit(f"Unsupported system: {system}")
19+
20+
return tag
21+
22+
23+
def main():
24+
parser = argparse.ArgumentParser(description="Determine platform tag.")
25+
parser.add_argument("arch", type=str, help="Architecture (e.g., x86_64, aarch64)")
26+
args = parser.parse_args()
27+
28+
tag = get_platform_tag(args.arch)
29+
30+
print(tag) # This will be captured by the GitHub Actions workflow
31+
32+
33+
if __name__ == "__main__":
34+
main()

0 commit comments

Comments
 (0)