Skip to content

Commit b71b3e0

Browse files
authored
Merge branch 'main' into build-cmake
2 parents 9c90811 + cdcae8d commit b71b3e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4502
-4563
lines changed

.github/scripts/auditwheel_show.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def main():
2222
print(audit_wheel_output.stdout)
2323

2424
if audit_wheel_output.stderr:
25-
print(f"**Error:**\n```{audit_wheel_output.stderr}```")
25+
print(f"**Error:**\n```\n{audit_wheel_output.stderr}\n```")
2626

2727
print("---")
2828

.github/scripts/build-cpu.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ set -xeuo pipefail
66

77
pip install cmake==3.28.3
88

9-
if [ "${build_os:0:6}" == ubuntu ] && [ "${build_arch}" == aarch64 ]; then
10-
# Allow cross-compile on aarch64
11-
sudo apt-get update
12-
sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu g++-aarch64-linux-gnu
13-
cmake -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCOMPUTE_BACKEND=cpu .
14-
elif [ "${build_os:0:5}" == macos ] && [ "${build_arch}" == aarch64 ]; then
9+
if [ "${build_os:0:5}" == macos ] && [ "${build_arch}" == aarch64 ]; then
1510
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCOMPUTE_BACKEND=cpu .
1611
else
1712
cmake -DCOMPUTE_BACKEND=cpu .

.github/scripts/build-cuda.sh

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,38 @@
22
declare build_arch
33
declare build_os
44
declare cuda_version
5+
declare cuda_targets
56

67
set -xeuo pipefail
78

8-
# By default, target Maxwell through Hopper.
9-
build_capability="50;52;60;61;70;75;80;86;89;90"
9+
if [[ -v cuda_targets ]]; then
10+
build_capability="${cuda_targets}"
11+
elif [ "${build_arch}" = "aarch64" ]; then
12+
build_capability="75;80;90"
1013

11-
# CUDA 11.7: Remove sm89 and sm90
12-
[[ "${cuda_version}" == 11.7.* ]] && build_capability="50;52;60;61;70;75;80;86"
14+
# CUDA 12.8: Add sm100
15+
[[ "${cuda_version}" == 12.8.* ]] && build_capability="75;80;90;100"
16+
else
17+
# By default, target Maxwell through Hopper.
18+
build_capability="50;52;60;61;70;75;80;86;89;90"
1319

14-
# CUDA 12.8: Add sm100 and sm120; remove sm50 through sm61
15-
[[ "${cuda_version}" == 12.8.* ]] && build_capability="70;75;80;86;89;90;100;120"
20+
# CUDA 12.8: Add sm100 and sm120; remove < sm75 to align with PyTorch 2.7+cu128 minimum
21+
[[ "${cuda_version}" == 12.8.* ]] && build_capability="75;80;86;89;90;100;120"
22+
fi
1623

1724
[[ "${build_os}" = windows-* ]] && python3 -m pip install ninja
1825

1926
if [ "${build_os:0:6}" == ubuntu ]; then
20-
image=nvidia/cuda:${cuda_version}-devel-ubuntu22.04
27+
# We'll use Rocky Linux 8 in order to maintain manylinux 2.24 compatibility.
28+
image="nvidia/cuda:${cuda_version}-devel-rockylinux8"
2129
echo "Using image $image"
22-
docker run --platform "linux/$build_arch" -i -w /src -v "$PWD:/src" "$image" sh -c \
23-
"apt-get update \
24-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cmake \
25-
&& cmake -DPTXAS_VERBOSE=1 -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY=\"${build_capability}\" . \
26-
&& cmake --build ."
30+
31+
docker run -i -w /src -v "$PWD:/src" "$image" bash -c \
32+
"dnf update -y \
33+
&& dnf install cmake gcc-toolset-11 -y \
34+
&& source scl_source enable gcc-toolset-11 \
35+
&& cmake -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY=\"${build_capability}\" . \
36+
&& cmake --build . --config Release"
2737
else
2838
pip install cmake==3.28.3
2939
cmake -G Ninja -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY="${build_capability}" -DCMAKE_BUILD_TYPE=Release -S .

.github/workflows/python-package.yml

Lines changed: 136 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ jobs:
3030
build-shared-libs:
3131
strategy:
3232
matrix:
33-
os: [ubuntu-22.04, macos-latest, windows-latest]
34-
arch: [x86_64, aarch64]
35-
exclude:
36-
- os: windows-latest # This probably requires arm64 Windows agents
33+
include:
34+
- os: ubuntu-22.04
35+
arch: x86_64
36+
- os: ubuntu-22.04-arm
3737
arch: aarch64
38-
- os: ubuntu-latest # Temporary. Takes too long, not ready yet.
39-
arch: aarch64
40-
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
38+
- os: windows-latest
39+
arch: x86_64
40+
- os: macos-latest
41+
arch: arm64
42+
runs-on: ${{ matrix.os }}
4143
steps:
4244
- uses: actions/checkout@v4
4345
- name: Setup MSVC
@@ -61,24 +63,21 @@ jobs:
6163
strategy:
6264
fail-fast: false
6365
matrix:
64-
os: [ubuntu-latest, windows-latest]
65-
arch: [x86_64, aarch64]
66-
cuda_version:
67-
["11.7.1", "11.8.0", "12.0.1", "12.1.1", "12.2.2", "12.3.2", "12.4.1", "12.5.1", "12.6.3", "12.8.0"]
68-
exclude:
69-
- os: windows-latest # This probably requires arm64 Windows agents
66+
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-latest]
67+
include:
68+
- os: ubuntu-22.04
69+
arch: x86_64
70+
- os: ubuntu-22.04-arm
7071
arch: aarch64
71-
- os: ubuntu-latest # Temporary. Takes too long, not ready yet.
72-
arch: aarch64
73-
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
72+
- os: windows-latest
73+
arch: x86_64
74+
cuda_version:
75+
["11.8.0", "12.0.1", "12.1.1", "12.2.2", "12.3.2", "12.4.1", "12.5.1", "12.6.3", "12.8.1"]
76+
runs-on: ${{ matrix.os }}
7477
steps:
7578
- uses: actions/checkout@v4
76-
# Linux: We use Docker to build cross platform Cuda (aarch64 is built in emulation)
77-
- name: Set up Docker multiarch
78-
if: startsWith(matrix.os, 'ubuntu')
79-
uses: docker/setup-qemu-action@v3
8079
# Windows: We install Cuda on the agent (slow)
81-
- uses: Jimver/[email protected].21
80+
- uses: Jimver/[email protected].22
8281
if: startsWith(matrix.os, 'windows')
8382
id: cuda-toolkit
8483
with:
@@ -109,17 +108,20 @@ jobs:
109108
- build-shared-libs-cuda
110109
strategy:
111110
matrix:
112-
os: [ubuntu-latest, macos-latest, windows-latest]
111+
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-latest, macos-latest]
112+
include:
113+
- os: ubuntu-22.04
114+
arch: x86_64
115+
- os: ubuntu-22.04-arm
116+
arch: aarch64
117+
- os: windows-latest
118+
arch: x86_64
119+
- os: macos-latest
120+
arch: arm64
113121
# The specific Python version is irrelevant in this context as we are only packaging non-C extension
114-
# code. This ensures compatibility across Python versions, including Python 3.8, as compatibility is
122+
# code. This ensures compatibility across Python versions, including Python 3.9, as compatibility is
115123
# dictated by the packaged code itself, not the Python version used for packaging.
116124
python-version: ["3.10"]
117-
arch: [x86_64, aarch64]
118-
exclude:
119-
- os: windows-latest # This probably requires arm64 Windows agents
120-
arch: aarch64
121-
- os: ubuntu-latest # Temporary. Takes too long, not ready yet.
122-
arch: aarch64
123125
runs-on: ${{ matrix.os }}
124126
steps:
125127
- uses: actions/checkout@v4
@@ -169,43 +171,137 @@ jobs:
169171
path: tmp/
170172
pattern: "bdist_wheel_*"
171173
merge-multiple: true
174+
172175
- name: Inspect tmp directory after downloading artifacts
173-
run: ls -alFR tmp/
176+
run: |
177+
ls -alFR tmp/
178+
WHEEL_COUNT=$(find tmp/ -type f -name "*.whl" | wc -l)
179+
echo "Found $WHEEL_COUNT wheel files"
180+
if [ "$WHEEL_COUNT" -eq 0 ]; then
181+
echo "::error::No wheel files found in tmp directory! Cannot proceed with release."
182+
exit 1
183+
fi
184+
174185
- name: Move and rename wheel files with pattern replacement
175186
run: |
176187
mkdir -p wheels/
188+
189+
# The whole point of the continuous release is to have a stable download link and the only way to have a PEP 440–compliant wheel name
190+
# is to use a stable placeholder version. Otherwise, pip won't let you install the wheel. The cool thing is that we can now install the
191+
# wheel directly from the GH pre-release which gets updated continuously, e.g.
192+
# `pip install https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/bitsandbytes-1.33.7.preview-py3-none-manylinux_2_24_x86_64.whl`
193+
STABLE_PLACEHOLDER_VERSION="1.33.7.preview"
194+
177195
# exclude macos wheels for now
178196
find tmp/ -type f -name '*.whl' ! -name '*macos*' -print0 | while IFS= read -r -d '' wheel; do
179197
wheel_filename=$(basename "$wheel")
180-
# Remove the gith hash, e.g. `+1234567`, for a stable download link on the multi-backend pre-release
181-
cleaned_filename=$(echo "$wheel_filename" | sed -E 's/\+[0-9a-f]{7}-/-/g')
182-
mv "$wheel" "wheels/$cleaned_filename"
198+
199+
# Strip off the original version
200+
rest=${wheel_filename#bitsandbytes-*-}
201+
new_name="bitsandbytes-${STABLE_PLACEHOLDER_VERSION}-${rest}"
202+
203+
echo "Renaming $wheel_filename → $new_name"
204+
mv "$wheel" "wheels/${new_name}"
183205
done
206+
184207
- name: Inspect wheels directory after renaming files
185208
run: ls -alFR wheels/
186-
- name: Create release and upload artifacts
187-
uses: softprops/[email protected]
209+
210+
- uses: actions/checkout@v4
211+
with:
212+
path: repo
213+
- name: Delete old pre-release (if exists)
214+
run: |
215+
cd repo && gh release delete continuous-release_main --cleanup-tag -y
216+
env:
217+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
218+
219+
- name: Ensure tag exists
220+
run: |
221+
cd repo
222+
git tag -f continuous-release_main
223+
git push -f origin continuous-release_main
224+
env:
225+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226+
227+
- name: Generate pip install commands for release body
228+
run: |
229+
cat > body.md << 'ENDOFMARKDOWN'
230+
## Latest `main` pre-release wheel
231+
232+
This pre-release contains the latest development wheels for all supported platforms, rebuilt automatically on every commit to the `main` branch.
233+
234+
**How to install:**
235+
Pick the correct command for your platform and run it in your terminal:
236+
237+
ENDOFMARKDOWN
238+
239+
for whl in wheels/*.whl; do
240+
fname=$(basename "$whl")
241+
url="https://github.com/bitsandbytes-foundation/bitsandbytes/releases/download/continuous-release_main/$fname"
242+
243+
if [[ "$fname" == *"manylinux_2_24_x86_64"* ]]; then
244+
echo "### Linux (x86_64)" >> body.md
245+
elif [[ "$fname" == *"manylinux_2_24_aarch64"* ]]; then
246+
echo "### Linux (ARM/aarch64)" >> body.md
247+
elif [[ "$fname" == *"win_amd64"* ]]; then
248+
echo "### Windows (x86_64)" >> body.md
249+
else
250+
echo "### Other platform" >> body.md
251+
fi
252+
253+
echo "\`\`\`sh" >> body.md
254+
echo "pip install --force-reinstall $url" >> body.md
255+
echo "\`\`\`" >> body.md
256+
echo "" >> body.md
257+
done
258+
259+
cat >> body.md << 'ENDOFMARKDOWN'
260+
> **Note:**
261+
> These wheels are updated automatically with every commit to `main` and become available as soon as the [python-package.yml](.github/workflows/python-package.yml) workflow finishes.
262+
263+
The version number is replaced with 1.33.7-preview in order to keep the link stable, this however does not affect the installed version at all:
264+
```
265+
> pip install https://.../bitsandbytes-1.33.7-preview-py3-none-manylinux_2_24_x86_64.whl
266+
Collecting bitsandbytes==1.33.7rc0
267+
...
268+
Successfully installed bitsandbytes-0.46.0.dev0
269+
```
270+
ENDOFMARKDOWN
271+
272+
# for debugging:
273+
cat body.md
274+
275+
- name: Create new pre-release and upload artifacts
276+
uses: softprops/[email protected]
188277
with:
189278
files: wheels/*.whl
190279
prerelease: true
191280
name: Latest `main` wheel
281+
body_path: body.md
192282
tag_name: continuous-release_main
193283
make_latest: false
194284
draft: false
195-
target_commitish: ${{ github.sha }}
196285

197286
audit-wheels:
198287
needs: build-wheels
199-
runs-on: ubuntu-latest
288+
strategy:
289+
matrix:
290+
os: [ubuntu-22.04, ubuntu-22.04-arm]
291+
include:
292+
- os: ubuntu-22.04
293+
arch: x86_64
294+
- os: ubuntu-22.04-arm
295+
arch: aarch64
296+
runs-on: ${{ matrix.os }}
200297
env:
201298
PIP_DISABLE_PIP_VERSION_CHECK: 1
202299
steps:
203300
- uses: actions/checkout@v4
204-
- name: Download all wheels
301+
- name: Download wheel
205302
uses: actions/download-artifact@v4
206303
with:
207-
merge-multiple: true
208-
pattern: "bdist_wheel_*"
304+
name: bdist_wheel_${{ matrix.os }}_${{ matrix.arch }}
209305
path: wheels/
210306
- name: Set up Python
211307
uses: actions/setup-python@v5
@@ -241,33 +337,3 @@ jobs:
241337
uses: pypa/gh-action-pypi-publish@release/v1
242338
with:
243339
print-hash: true
244-
245-
# test:
246-
# needs:
247-
# - build-wheels
248-
# strategy:
249-
# fail-fast: false
250-
# matrix:
251-
# include:
252-
# - os: ubuntu-latest
253-
# arch: x86_64
254-
# python-version: "3.8"
255-
# - os: windows-latest
256-
# arch: x86_64
257-
# python-version: "3.8"
258-
# runs-on: ${{ matrix.os }}
259-
# steps:
260-
# - uses: actions/checkout@v4
261-
# - uses: actions/download-artifact@v4
262-
# with:
263-
# merge-multiple: true
264-
# pattern: "bdist_wheel_${{ matrix.os }}_${{ matrix.arch }}*"
265-
# path: wheel/
266-
# - uses: actions/setup-python@v5
267-
# with:
268-
# python-version: ${{ matrix.python-version }}
269-
# cache: pip
270-
# - shell: bash
271-
# run: ls -lar wheel/
272-
# - run: pip install wheel/*.whl -r requirements-ci.txt
273-
# - run: pytest --log-cli-level=DEBUG --continue-on-collection-errors tests

0 commit comments

Comments
 (0)