summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: dcc3fa47f7a917840d02397d749b287360df3293 (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
# Maintainer: Hu Butui <hot123tea123@gmail.com>

# update _CUDA_ARCH_LIST for your nvidia cards
# note: ktransformers works for compute capability >= 8.0
_CUDA_ARCH_LIST="8.0;8.6;8.9;9.0;10.0;10.0+PTX"
pkgname=python-ktransformers
_pkgname=ktransformers
pkgver=0.2.1.post1
pkgrel=5
pkgdesc="A Flexible Framework for Experiencing Cutting-edge LLM Inference Optimizations"
arch=('x86_64')
url="https://github.com/kvcache-ai/ktransformers"
license=('Apache-2.0')
depends=(
	python-accelerate
	python-blessed
	python-colorlog
	python-fastapi
	python-fire
	python-flash-attn
	python-langchain
	python-protobuf
	python-pytorch-opt-cuda
	python-sentencepiece
	python-transformers
	uvicorn
)
makedepends=(
	git
	ninja
	python-build
	python-cpufeature
	cmake
	python-installer
	python-setuptools
	python-wheel
)
source=("${_pkgname}::git+https://github.com/kvcache-ai/ktransformers.git#tag=v${pkgver}"
        "0001-fix-building-torch-extension-with-glog.patch"
)
sha256sums=('dc686362ff38c0fbbe45993ff6c45b2a94b6bef314b8571918ef51ab0da3e99a'
            '96691013ece0c195f2f2476789eb2287d1e1ead9786cf2a5f8f95247e4f61dca')

prepare() {
	cd "${srcdir}/${_pkgname}"
	git submodule update --init --recursive
	patch -p1 -i "${srcdir}/0001-fix-building-torch-extension-with-glog.patch"
}

build() {
	cd "${srcdir}/${_pkgname}"
	CUDA_HOME=/opt/cuda \
	TORCH_CUDA_ARCH_LIST=${_CUDA_ARCH_LIST} \
	KTRANSFORMERS_FORCE_BUILD=TRUE \
	python -m build --wheel --no-isolation -x
}

package() {
	cd "${srcdir}/${_pkgname}"
	python -m installer --destdir="$pkgdir" dist/*.whl
	install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

	# remove unused dirs and files
	local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
	rm -rfv "${pkgdir}${_site_packages}/${_pkgname}/tests"
}