summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6c7f578c4127b302bcb393e51c4c0e825a5568a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Maintainer: Lubosz Sarnecki <lubosz@gmail.com>
# Contributor: Cody Wyatt Neiman (xangelix) <neiman@cody.to>

_name=bitsandbytes
pkgname=python-$_name-rocm
pkgdesc="Accessible large language models via k-bit quantization for PyTorch (ROCm version)"
license=("MIT")
url="https://github.com/bitsandbytes-foundation/$_name"
pkgver=0.49.2
pkgrel=1
arch=("x86_64")
depends=(
  libgcc
  libstdc++
  glibc
  hipblas
  libgomp
  hipblaslt
  hipsparse
  hiprand
  hipcub
  python
  python-triton
  python-scipy
  python-pytorch
  python-numpy
  python-typing_extensions
  python-packaging
)
makedepends=(
  git
  make
  cmake
  python-build
  python-installer
  python-setuptools
  python-wheel
  python-scikit-build-core
  python-trove-classifiers
  rocm-toolchain
  rocminfo
)
provides=("python-$_name")
conflicts=("$pkgname-git")
source=("$pkgname::git+https://github.com/bitsandbytes-foundation/bitsandbytes.git#tag=${pkgver}")
sha512sums=("SKIP")

build() {
  cd $pkgname

  # Determine GPU targets
  GPU_TARGETS=$(rocm_agent_enumerator -t GPU)
  if [[ -n "$GPU_TARGETS" ]]; then
    echo "Building natively for enumerated GPU target: ${GPU_TARGETS}"
  else
    GPU_TARGETS="$(rocm-supported-gfx -e gfx950)"
    echo "Building in container for all supported GPU targets: ${GPU_TARGETS}"
  fi

  local cmake_options=(
    -W no-dev
    -S .
    -B .
    # Required to be picked up by python build
    -G "Unix Makefiles"
    -D CMAKE_BUILD_TYPE='Release'
    -D CMAKE_INSTALL_PREFIX='/usr'
    -D COMPUTE_BACKEND=hip
    # This won't actually do anything, just set it to silence a warning
    -D GPU_TARGETS=${GPU_TARGETS}
    # Actually used GPU targets
    -D CMAKE_HIP_ARCHITECTURES=${GPU_TARGETS}
  )
  cmake "${cmake_options[@]}"
  cmake --build .

  python -m build --wheel --no-isolation
}

package() {
  # Install license
  install -Dm644 $pkgname/LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # Install the python wheel
  python -m installer --destdir="$pkgdir" $pkgname/dist/*.whl
}