Skip to content

Commit aee0ebb

Browse files
CI: compat for windows-2025 + vs2026 (#1975)
1 parent 936f60b commit aee0ebb

10 files changed

Lines changed: 91 additions & 138 deletions

File tree

.github/scripts/build-cpu.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/bin/bash
2-
declare build_arch
3-
declare build_os
4-
52
set -xeuo pipefail
63

7-
if [[ "${build_os}" == windows* ]]; then
4+
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows/macOS)}"
5+
: "${RUNNER_ARCH:?RUNNER_ARCH must be set (X64/ARM64)}"
6+
7+
if [[ "${RUNNER_OS}" == "Windows" ]]; then
88
pip install cmake==3.30.9
99
else
1010
pip install cmake==3.28.3
1111
fi
1212

13-
if [ "${build_os:0:5}" == macos ] && [ "${build_arch}" == aarch64 ]; then
13+
if [ "${RUNNER_OS}" == "macOS" ] && [ "${RUNNER_ARCH}" == "ARM64" ]; then
1414
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCOMPUTE_BACKEND=cpu .
1515
else
1616
cmake -DCOMPUTE_BACKEND=cpu .
1717
fi
1818
cmake --build . --config Release
1919

20-
output_dir="output/${build_os}/${build_arch}"
20+
output_dir="output/${RUNNER_OS}/${RUNNER_ARCH}"
2121
mkdir -p "${output_dir}"
2222
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")

.github/scripts/build-cuda.sh

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
#!/bin/bash
2-
declare build_arch
3-
declare build_os
4-
declare cuda_version
5-
declare cuda_targets
6-
72
set -xeuo pipefail
83

9-
if [[ -v cuda_targets ]]; then
10-
build_capability="${cuda_targets}"
11-
elif [ "${build_arch}" = "aarch64" ]; then
4+
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows/macOS)}"
5+
: "${RUNNER_ARCH:?RUNNER_ARCH must be set (X64/ARM64)}"
6+
: "${CUDA_VERSION:?CUDA_VERSION must be set}"
7+
8+
if [[ -v CUDA_TARGETS ]]; then
9+
build_capability="${CUDA_TARGETS}"
10+
elif [ "${RUNNER_ARCH}" = "ARM64" ]; then
1211
build_capability="75;80;90"
1312

1413
# CUDA 12.8-12.9: Add sm100/sm120
15-
[[ "${cuda_version}" == 12.8.* || "${cuda_version}" == 12.9.* ]] && build_capability="75;80;90;100;120"
14+
[[ "${CUDA_VERSION}" == 12.8.* || "${CUDA_VERSION}" == 12.9.* ]] && build_capability="75;80;90;100;120"
1615

1716
# CUDA 13.0+: Add sm100/sm110/sm120
18-
[[ "${cuda_version}" == 13.*.* ]] && build_capability="75;80;90;100;110;120;121"
17+
[[ "${CUDA_VERSION}" == 13.*.* ]] && build_capability="75;80;90;100;110;120;121"
1918
else
2019
# By default, target Pascal through Hopper.
2120
build_capability="60;70;75;80;86;89;90"
2221

2322
# CUDA 12.8+: Add sm100 and sm120; remove < sm70 to align with PyTorch 2.8+cu128 minimum
24-
[[ "${cuda_version}" == 12.8.* || "${cuda_version}" == 12.9.* ]] && build_capability="70;75;80;86;89;90;100;120"
23+
[[ "${CUDA_VERSION}" == 12.8.* || "${CUDA_VERSION}" == 12.9.* ]] && build_capability="70;75;80;86;89;90;100;120"
2524

2625
# CUDA 13.0+: Remove < sm75 to align with PyTorch 2.9+cu130 minimum
27-
[[ "${cuda_version}" == 13.*.* ]] && build_capability="75;80;86;89;90;100;120"
26+
[[ "${CUDA_VERSION}" == 13.*.* ]] && build_capability="75;80;86;89;90;100;120"
2827
fi
2928

30-
[[ "${build_os}" = windows-* ]] && python3 -m pip install ninja
29+
[[ "${RUNNER_OS}" == "Windows" ]] && python3 -m pip install ninja
3130

32-
if [ "${build_os:0:6}" == ubuntu ]; then
31+
if [ "${RUNNER_OS}" == "Linux" ]; then
3332
# We'll use Rocky Linux 8 in order to maintain manylinux 2.24 compatibility.
34-
image="nvidia/cuda:${cuda_version}-devel-rockylinux8"
33+
image="nvidia/cuda:${CUDA_VERSION}-devel-rockylinux8"
3534
echo "Using image $image"
3635

3736
docker run -i -w /src -v "$PWD:/src" "$image" bash -c \
@@ -46,7 +45,6 @@ else
4645
cmake --build . --config Release
4746
fi
4847

49-
50-
output_dir="output/${build_os}/${build_arch}"
48+
output_dir="output/${RUNNER_OS}/${RUNNER_ARCH}"
5149
mkdir -p "${output_dir}"
5250
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")

.github/scripts/build-rocm.sh

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/bin/bash
2-
declare build_arch
3-
declare build_os
4-
declare rocm_version
5-
62
set -xeuo pipefail
3+
4+
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows)}"
5+
: "${ROCM_VERSION:?ROCM_VERSION must be set}"
6+
77
bnb_rocm_arch="gfx90a;gfx942;gfx1100;gfx1101;gfx1102;gfx1103"
88

99
# ROCm 6.4+ - Add RDNA4 and RDNA3.5 targets. Note we assume >=6.4.4.
10-
[[ "${rocm_version}" == 6.4.* || "${rocm_version}" == 7.* ]] && bnb_rocm_arch="${bnb_rocm_arch};gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
10+
[[ "${ROCM_VERSION}" == 6.4.* || "${ROCM_VERSION}" == 7.* ]] && bnb_rocm_arch="${bnb_rocm_arch};gfx1150;gfx1151;gfx1152;gfx1153;gfx1200;gfx1201"
1111

1212
# ROCm 7.0+ - Add gfx950
13-
[[ "${rocm_version}" == 7.* ]] && bnb_rocm_arch="${bnb_rocm_arch};gfx950"
13+
[[ "${ROCM_VERSION}" == 7.* ]] && bnb_rocm_arch="${bnb_rocm_arch};gfx950"
1414

15-
if [ "${build_os:0:6}" == ubuntu ]; then
16-
image=rocm/dev-ubuntu-22.04:${rocm_version}-complete
15+
if [ "${RUNNER_OS}" == "Linux" ]; then
16+
image=rocm/dev-ubuntu-22.04:${ROCM_VERSION}-complete
1717
echo "Using image $image"
18-
docker run --rm --platform "linux/$build_arch" -i \
18+
docker run --rm -i \
1919
-w /src -v "$PWD:/src" "$image" sh -c \
2020
"apt-get update \
2121
&& pip install cmake==3.31.6 \
@@ -24,32 +24,30 @@ if [ "${build_os:0:6}" == ubuntu ]; then
2424
else
2525
bnb_rocm_arch="gfx1100;gfx1101;gfx1102;gfx1150;gfx1151;gfx1200;gfx1201"
2626

27-
pip install ninja cmake==3.31.6
28-
2927
# Install ROCm SDK wheels from repo.radeon.com.
30-
rocm_base_url="https://repo.radeon.com/rocm/windows/rocm-rel-${rocm_version}"
28+
rocm_base_url="https://repo.radeon.com/rocm/windows/rocm-rel-${ROCM_VERSION}"
3129
pip install \
32-
"${rocm_base_url}/rocm_sdk_core-${rocm_version}-py3-none-win_amd64.whl" \
33-
"${rocm_base_url}/rocm_sdk_devel-${rocm_version}-py3-none-win_amd64.whl" \
34-
"${rocm_base_url}/rocm_sdk_libraries_custom-${rocm_version}-py3-none-win_amd64.whl" \
35-
"${rocm_base_url}/rocm-${rocm_version}.tar.gz"
30+
"${rocm_base_url}/rocm_sdk_core-${ROCM_VERSION}-py3-none-win_amd64.whl" \
31+
"${rocm_base_url}/rocm_sdk_devel-${ROCM_VERSION}-py3-none-win_amd64.whl" \
32+
"${rocm_base_url}/rocm_sdk_libraries_custom-${ROCM_VERSION}-py3-none-win_amd64.whl" \
33+
"${rocm_base_url}/rocm-${ROCM_VERSION}.tar.gz"
3634

3735
# Expand the devel tarball
3836
rocm-sdk init
3937

40-
ROCM_PATH="$(rocm-sdk path --root)"
41-
export ROCM_PATH
42-
export PATH="${ROCM_PATH}/bin:${PATH}"
38+
ROCM_PATH="$(rocm-sdk path --root | tr '\\' '/')"
39+
export ROCM_PATH PATH="${ROCM_PATH}/bin:${PATH}"
4340

4441
cmake -G Ninja \
4542
-DCOMPUTE_BACKEND=hip \
4643
-DBNB_ROCM_ARCH="${bnb_rocm_arch}" \
4744
-DCMAKE_BUILD_TYPE=MinSizeRel \
4845
-DCMAKE_HIP_FLAGS="--offload-compress" \
46+
-DCMAKE_HIP_COMPILER_ROCM_ROOT="${ROCM_PATH}" \
4947
-S .
5048
cmake --build .
5149
fi
5250

53-
output_dir="output/${build_os}/${build_arch}"
51+
output_dir="output/${RUNNER_OS}/X64"
5452
mkdir -p "${output_dir}"
5553
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")

.github/scripts/build-xpu-windows.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ if ERRORLEVEL 1 (
2929
)
3030
echo ::endgroup::
3131

32-
set output_dir=output\%build_os%\x86_64
32+
set output_dir=output\Windows\X64
3333
if not exist "%output_dir%" mkdir "%output_dir%"
3434
copy bitsandbytes\*.dll "%output_dir%\" 2>nul

.github/scripts/build-xpu.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
2-
declare build_os
3-
42
set -xeuo pipefail
53

6-
# We currently only build XPU on Linux.
7-
if [ "${build_os:0:6}" == ubuntu ]; then
4+
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows)}"
5+
6+
# We currently only build XPU on Linux x64 and Windows x64.
7+
if [ "${RUNNER_OS}" == "Linux" ]; then
88
# TODO: We might want to pre-build this as our own customized image in the future.
99
image=intel/deep-learning-essentials:2025.1.3-0-devel-ubuntu22.04
1010
echo "Using image $image"
@@ -17,6 +17,6 @@ if [ "${build_os:0:6}" == ubuntu ]; then
1717
&& cmake --build . --config Release"
1818
fi
1919

20-
output_dir="output/${build_os}/x86_64"
20+
output_dir="output/${RUNNER_OS}/X64"
2121
mkdir -p "${output_dir}"
2222
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")

.github/scripts/set_platform_tag.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55

66
def get_platform_tag(architecture):
7+
arch = architecture.lower()
8+
is_x64 = arch in ("x86_64", "x64")
79
system = platform.system()
810

911
if system == "Linux":
10-
tag = "manylinux_2_24_x86_64" if architecture == "x86_64" else "manylinux_2_24_aarch64"
12+
tag = "manylinux_2_24_x86_64" if is_x64 else "manylinux_2_24_aarch64"
1113
elif system == "Darwin":
1214
tag = "macosx_14_0_arm64"
1315
elif system == "Windows":
14-
tag = "win_amd64" if architecture == "x86_64" else "win_arm64"
16+
tag = "win_amd64" if is_x64 else "win_arm64"
1517
else:
1618
sys.exit(f"Unsupported system: {system}")
1719

@@ -20,7 +22,7 @@ def get_platform_tag(architecture):
2022

2123
def main():
2224
parser = argparse.ArgumentParser(description="Determine platform tag.")
23-
parser.add_argument("arch", type=str, help="Architecture (e.g., x86_64, aarch64)")
25+
parser.add_argument("arch", type=str, help="Architecture (e.g., x86_64, aarch64, X64, ARM64)")
2426
args = parser.parse_args()
2527

2628
tag = get_platform_tag(args.arch)

0 commit comments

Comments
 (0)