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
12 changes: 6 additions & 6 deletions .github/scripts/build-cpu.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/bin/bash
declare build_arch
declare build_os

set -xeuo pipefail

if [[ "${build_os}" == windows* ]]; then
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows/macOS)}"
: "${RUNNER_ARCH:?RUNNER_ARCH must be set (X64/ARM64)}"

if [[ "${RUNNER_OS}" == "Windows" ]]; then
pip install cmake==3.30.9
else
pip install cmake==3.28.3
fi

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

output_dir="output/${build_os}/${build_arch}"
output_dir="output/${RUNNER_OS}/${RUNNER_ARCH}"
mkdir -p "${output_dir}"
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")
32 changes: 15 additions & 17 deletions .github/scripts/build-cuda.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
#!/bin/bash
declare build_arch
declare build_os
declare cuda_version
declare cuda_targets

set -xeuo pipefail

if [[ -v cuda_targets ]]; then
build_capability="${cuda_targets}"
elif [ "${build_arch}" = "aarch64" ]; then
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows/macOS)}"
: "${RUNNER_ARCH:?RUNNER_ARCH must be set (X64/ARM64)}"
: "${CUDA_VERSION:?CUDA_VERSION must be set}"

if [[ -v CUDA_TARGETS ]]; then
build_capability="${CUDA_TARGETS}"
elif [ "${RUNNER_ARCH}" = "ARM64" ]; then
build_capability="75;80;90"

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

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

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

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

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

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

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


output_dir="output/${build_os}/${build_arch}"
output_dir="output/${RUNNER_OS}/${RUNNER_ARCH}"
mkdir -p "${output_dir}"
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")
38 changes: 18 additions & 20 deletions .github/scripts/build-rocm.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/bin/bash
declare build_arch
declare build_os
declare rocm_version

set -xeuo pipefail

: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows)}"
: "${ROCM_VERSION:?ROCM_VERSION must be set}"

bnb_rocm_arch="gfx90a;gfx942;gfx1100;gfx1101;gfx1102;gfx1103"

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

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

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

pip install ninja cmake==3.31.6

# Install ROCm SDK wheels from repo.radeon.com.
rocm_base_url="https://repo.radeon.com/rocm/windows/rocm-rel-${rocm_version}"
rocm_base_url="https://repo.radeon.com/rocm/windows/rocm-rel-${ROCM_VERSION}"
pip install \
"${rocm_base_url}/rocm_sdk_core-${rocm_version}-py3-none-win_amd64.whl" \
"${rocm_base_url}/rocm_sdk_devel-${rocm_version}-py3-none-win_amd64.whl" \
"${rocm_base_url}/rocm_sdk_libraries_custom-${rocm_version}-py3-none-win_amd64.whl" \
"${rocm_base_url}/rocm-${rocm_version}.tar.gz"
"${rocm_base_url}/rocm_sdk_core-${ROCM_VERSION}-py3-none-win_amd64.whl" \
"${rocm_base_url}/rocm_sdk_devel-${ROCM_VERSION}-py3-none-win_amd64.whl" \
"${rocm_base_url}/rocm_sdk_libraries_custom-${ROCM_VERSION}-py3-none-win_amd64.whl" \
"${rocm_base_url}/rocm-${ROCM_VERSION}.tar.gz"

# Expand the devel tarball
rocm-sdk init

ROCM_PATH="$(rocm-sdk path --root)"
export ROCM_PATH
export PATH="${ROCM_PATH}/bin:${PATH}"
ROCM_PATH="$(rocm-sdk path --root | tr '\\' '/')"
export ROCM_PATH PATH="${ROCM_PATH}/bin:${PATH}"

cmake -G Ninja \
-DCOMPUTE_BACKEND=hip \
-DBNB_ROCM_ARCH="${bnb_rocm_arch}" \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_HIP_FLAGS="--offload-compress" \
-DCMAKE_HIP_COMPILER_ROCM_ROOT="${ROCM_PATH}" \
-S .
cmake --build .
fi

output_dir="output/${build_os}/${build_arch}"
output_dir="output/${RUNNER_OS}/X64"
mkdir -p "${output_dir}"
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")
2 changes: 1 addition & 1 deletion .github/scripts/build-xpu-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ if ERRORLEVEL 1 (
)
echo ::endgroup::

set output_dir=output\%build_os%\x86_64
set output_dir=output\Windows\X64
if not exist "%output_dir%" mkdir "%output_dir%"
copy bitsandbytes\*.dll "%output_dir%\" 2>nul
10 changes: 5 additions & 5 deletions .github/scripts/build-xpu.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash
declare build_os

set -xeuo pipefail

# We currently only build XPU on Linux.
if [ "${build_os:0:6}" == ubuntu ]; then
: "${RUNNER_OS:?RUNNER_OS must be set (Linux/Windows)}"

# We currently only build XPU on Linux x64 and Windows x64.
if [ "${RUNNER_OS}" == "Linux" ]; then
# TODO: We might want to pre-build this as our own customized image in the future.
image=intel/deep-learning-essentials:2025.1.3-0-devel-ubuntu22.04
echo "Using image $image"
Expand All @@ -17,6 +17,6 @@ if [ "${build_os:0:6}" == ubuntu ]; then
&& cmake --build . --config Release"
fi

output_dir="output/${build_os}/x86_64"
output_dir="output/${RUNNER_OS}/X64"
mkdir -p "${output_dir}"
(shopt -s nullglob && cp bitsandbytes/*.{so,dylib,dll} "${output_dir}")
8 changes: 5 additions & 3 deletions .github/scripts/set_platform_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@


def get_platform_tag(architecture):
arch = architecture.lower()
is_x64 = arch in ("x86_64", "x64")
system = platform.system()

if system == "Linux":
tag = "manylinux_2_24_x86_64" if architecture == "x86_64" else "manylinux_2_24_aarch64"
tag = "manylinux_2_24_x86_64" if is_x64 else "manylinux_2_24_aarch64"
elif system == "Darwin":
tag = "macosx_14_0_arm64"
elif system == "Windows":
tag = "win_amd64" if architecture == "x86_64" else "win_arm64"
tag = "win_amd64" if is_x64 else "win_arm64"
else:
sys.exit(f"Unsupported system: {system}")

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

def main():
parser = argparse.ArgumentParser(description="Determine platform tag.")
parser.add_argument("arch", type=str, help="Architecture (e.g., x86_64, aarch64)")
parser.add_argument("arch", type=str, help="Architecture (e.g., x86_64, aarch64, X64, ARM64)")
args = parser.parse_args()

tag = get_platform_tag(args.arch)
Expand Down
Loading
Loading