Skip to content

Commit 1e529cf

Browse files
Merge branch 'main' into feature/experts-4bit
2 parents 5a0c73a + 9da7109 commit 1e529cf

29 files changed

Lines changed: 896 additions & 816 deletions

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
cooldown:
8+
default-days: 7
9+
groups:
10+
actions:
11+
patterns:
12+
- "*"

.github/dependabot.yml.disabled

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/scripts/build-cpu.sh

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

7-
pip install cmake==3.28.3
4+
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows/macOS)}"
5+
: "${RUNNER_ARCH:?RUNNER_ARCH must be set (X64/ARM64)}"
86

9-
if [ "${build_os:0:5}" == macos ] && [ "${build_arch}" == aarch64 ]; then
7+
if [ "${RUNNER_OS}" == "macOS" ] && [ "${RUNNER_ARCH}" == "ARM64" ]; then
108
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 -DCOMPUTE_BACKEND=cpu .
119
else
1210
cmake -DCOMPUTE_BACKEND=cpu .
1311
fi
1412
cmake --build . --config Release
1513

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

.github/scripts/build-cuda.sh

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,47 @@
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
31-
32-
if [ "${build_os:0:6}" == ubuntu ]; then
29+
if [ "${RUNNER_OS}" == "Linux" ]; then
3330
# We'll use Rocky Linux 8 in order to maintain manylinux 2.24 compatibility.
34-
image="nvidia/cuda:${cuda_version}-devel-rockylinux8"
31+
image="nvidia/cuda:${CUDA_VERSION}-devel-rockylinux8"
3532
echo "Using image $image"
3633

3734
docker run -i -w /src -v "$PWD:/src" "$image" bash -c \
3835
"dnf -y --refresh update --security \
39-
&& dnf -y install cmake gcc-toolset-11 --setopt=install_weak_deps=False --setopt=tsflags=nodocs \
36+
&& dnf -y install cmake gcc-toolset-11-toolchain --setopt=install_weak_deps=False --setopt=tsflags=nodocs \
4037
&& source scl_source enable gcc-toolset-11 \
4138
&& cmake -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY=\"${build_capability}\" . \
42-
&& cmake --build . --config Release"
39+
&& cmake --build . --config Release --parallel"
4340
else
44-
pip install cmake==3.28.3
4541
cmake -G Ninja -DCOMPUTE_BACKEND=cuda -DCOMPUTE_CAPABILITY="${build_capability}" -DCMAKE_BUILD_TYPE=Release -S .
4642
cmake --build . --config Release
4743
fi
4844

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

.github/scripts/build-rocm.sh

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,52 @@
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 \
20-
"apt-get update \
21-
&& pip install cmake==3.31.6 \
20+
"pip install cmake==3.31.6 \
2221
&& cmake -DCOMPUTE_BACKEND=hip -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_HIP_FLAGS=\"--offload-compress\" -DBNB_ROCM_ARCH=\"${bnb_rocm_arch}\" . \
23-
&& cmake --build ."
22+
&& cmake --build . --parallel"
2423
else
2524
bnb_rocm_arch="gfx1100;gfx1101;gfx1102;gfx1150;gfx1151;gfx1200;gfx1201"
2625

27-
pip install ninja cmake==3.31.6
28-
2926
# Install ROCm SDK wheels from repo.radeon.com.
30-
rocm_base_url="https://repo.radeon.com/rocm/windows/rocm-rel-${rocm_version}"
27+
rocm_base_url="https://repo.radeon.com/rocm/windows/rocm-rel-${ROCM_VERSION}"
3128
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"
29+
"${rocm_base_url}/rocm_sdk_core-${ROCM_VERSION}-py3-none-win_amd64.whl" \
30+
"${rocm_base_url}/rocm_sdk_devel-${ROCM_VERSION}-py3-none-win_amd64.whl" \
31+
"${rocm_base_url}/rocm_sdk_libraries_custom-${ROCM_VERSION}-py3-none-win_amd64.whl" \
32+
"${rocm_base_url}/rocm-${ROCM_VERSION}.tar.gz"
3633

3734
# Expand the devel tarball
3835
rocm-sdk init
3936

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

4440
cmake -G Ninja \
4541
-DCOMPUTE_BACKEND=hip \
4642
-DBNB_ROCM_ARCH="${bnb_rocm_arch}" \
4743
-DCMAKE_BUILD_TYPE=MinSizeRel \
4844
-DCMAKE_HIP_FLAGS="--offload-compress" \
45+
-DCMAKE_HIP_COMPILER_ROCM_ROOT="${ROCM_PATH}" \
4946
-S .
5047
cmake --build .
5148
fi
5249

53-
output_dir="output/${build_os}/${build_arch}"
50+
output_dir="output/${RUNNER_OS}/X64"
5451
mkdir -p "${output_dir}"
5552
(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: 6 additions & 6 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"
@@ -14,9 +14,9 @@ if [ "${build_os:0:6}" == ubuntu ]; then
1414
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
1515
cmake bison intel-fw-gpu intel-ocloc \
1616
&& cmake -DCOMPUTE_BACKEND=xpu . \
17-
&& cmake --build . --config Release"
17+
&& cmake --build . --config Release --parallel"
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)

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
Lint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v4
13+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
14+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
1515
with:
1616
python-version: "3.12"
17-
- uses: pre-commit/action@v3.0.0
17+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
1818
env:
1919
RUFF_OUTPUT_FORMAT: github

0 commit comments

Comments
 (0)