1{ lib
2, buildPythonPackage
3, hatch-fancy-pypi-readme
4, hatch-vcs
5, hatchling
6, pytestCheckHook
7, pythonOlder
8, pythonRelaxDepsHook
9, accelerate
10, bentoml
11, bitsandbytes
12, click
13, datasets
14, docker
15, einops
16, fairscale
17, flax
18, hypothesis
19, ipython
20, jax
21, jaxlib
22, jupyter
23, jupytext
24, keras
25, nbformat
26, notebook
27, openai
28, openllm-client
29, openllm-core
30, optimum
31, peft
32, pytest-mock
33, pytest-randomly
34, pytest-rerunfailures
35, pytest-xdist
36, ray
37, safetensors
38, sentencepiece
39, soundfile
40, syrupy
41, tabulate
42, tensorflow
43, tiktoken
44, transformers
45, openai-triton
46, xformers
47}:
48
49buildPythonPackage rec {
50 inherit (openllm-core) src version;
51 pname = "openllm";
52 format = "pyproject";
53
54 disabled = pythonOlder "3.8";
55
56 sourceRoot = "source/openllm-python";
57
58 nativeBuildInputs = [
59 hatch-fancy-pypi-readme
60 hatch-vcs
61 hatchling
62 pythonRelaxDepsHook
63 ];
64
65 pythonRemoveDeps = [
66 # remove cuda-python as it has an unfree license
67 "cuda-python"
68 ];
69
70 propagatedBuildInputs = [
71 bentoml
72 bitsandbytes
73 click
74 openllm-client
75 optimum
76 safetensors
77 tabulate
78 transformers
79 ] ++ bentoml.optional-dependencies.io
80 ++ tabulate.optional-dependencies.widechars
81 # ++ transformers.optional-dependencies.accelerate
82 ++ transformers.optional-dependencies.tokenizers
83 ++ transformers.optional-dependencies.torch;
84
85 passthru.optional-dependencies = {
86 agents = [
87 # diffusers
88 soundfile
89 transformers
90 ] ++ transformers.optional-dependencies.agents;
91 baichuan = [
92 # cpm-kernels
93 sentencepiece
94 ];
95 chatglm = [
96 # cpm-kernels
97 sentencepiece
98 ];
99 falcon = [
100 einops
101 xformers
102 ];
103 fine-tune = [
104 accelerate
105 bitsandbytes
106 datasets
107 peft
108 # trl
109 ];
110 flan-t5 = [
111 flax
112 jax
113 jaxlib
114 keras
115 tensorflow
116 ];
117 ggml = [
118 # ctransformers
119 ];
120 gptq = [
121 # auto-gptq
122 ]; # ++ autogptq.optional-dependencies.triton;
123 grpc = [
124 openllm-client
125 ] ++ openllm-client.optional-dependencies.grpc;
126 llama = [
127 fairscale
128 sentencepiece
129 ];
130 mpt = [
131 einops
132 openai-triton
133 ];
134 openai = [
135 openai
136 tiktoken
137 ];
138 opt = [
139 flax
140 jax
141 jaxlib
142 keras
143 tensorflow
144 ];
145 playground = [
146 ipython
147 jupyter
148 jupytext
149 nbformat
150 notebook
151 ];
152 starcoder = [
153 bitsandbytes
154 ];
155 vllm = [
156 ray
157 # vllm
158 ];
159 all = with passthru.optional-dependencies; (
160 agents ++ baichuan ++ chatglm ++ falcon ++ fine-tune ++ flan-t5 ++ ggml ++ gptq ++ llama ++ mpt ++ openai ++ opt ++ playground ++ starcoder ++ vllm
161 );
162 };
163
164 nativeCheckInputs = [
165 docker
166 hypothesis
167 pytest-mock
168 pytest-randomly
169 pytest-rerunfailures
170 pytest-xdist
171 pytestCheckHook
172 syrupy
173 ];
174
175 preCheck = ''
176 export HOME=$TMPDIR
177 # skip GPUs test on CI
178 export GITHUB_ACTIONS=1
179 '';
180
181 disabledTests = [
182 # these tests access to huggingface.co
183 "test_opt_125m"
184 "test_opt_125m"
185 "test_flan_t5"
186 "test_flan_t5"
187 ];
188
189 pythonImportsCheck = [ "openllm" ];
190
191 meta = with lib; {
192 description = "Operating LLMs in production";
193 homepage = "https://github.com/bentoml/OpenLLM/tree/main/openllm-python";
194 changelog = "https://github.com/bentoml/OpenLLM/blob/${src.rev}/CHANGELOG.md";
195 license = licenses.asl20;
196 maintainers = with maintainers; [ happysalada natsukium ];
197 };
198}