forked from mosaicml/llm-foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
170 lines (149 loc) · 4.86 KB
/
setup.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Copyright 2024 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0
"""MosaicML LLM Foundry package setup."""
import copy
import os
from typing import Any, Mapping
import setuptools
from setuptools import setup
_PACKAGE_NAME = 'llm-foundry'
_PACKAGE_DIR = 'llmfoundry'
_REPO_REAL_PATH = os.path.dirname(os.path.realpath(__file__))
_PACKAGE_REAL_PATH = os.path.join(_REPO_REAL_PATH, _PACKAGE_DIR)
# Read the llm-foundry version
# We can't use `.__version__` from the library since it's not installed yet
version_path = os.path.join(_PACKAGE_REAL_PATH, '_version.py')
with open(version_path, encoding='utf-8') as f:
version_globals: dict[str, Any] = {}
version_locals: Mapping[str, object] = {}
content = f.read()
exec(content, version_globals, version_locals)
repo_version = str(version_locals['__version__'])
# Use repo README for PyPi description
with open('README.md', 'r', encoding='utf-8') as fh:
long_description = fh.read()
# Hide the content between <!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_BEGIN --> and
# <!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_END --> tags in the README
while True:
start_tag = '<!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_BEGIN -->'
end_tag = '<!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_END -->'
start = long_description.find(start_tag)
end = long_description.find(end_tag)
if start == -1:
assert end == -1, 'there should be a balanced number of start and ends'
break
else:
assert end != -1, 'there should be a balanced number of start and ends'
long_description = long_description[:start] + long_description[
end + len(end_tag):]
classifiers = [
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
]
install_requires = [
'mosaicml[libcloud,wandb,oci,gcs,mlflow]>=0.27.0,<0.28',
'mlflow>=2.14.1,<2.18',
'accelerate>=0.25,<1.2', # for HF inference `device_map`
'transformers>=4.43.2,<4.47',
'mosaicml-streaming>=0.9.0,<0.10',
'torch>=2.5.1,<2.5.2',
'datasets>=2.20.0,<2.21',
'fsspec==2023.6.0', # newer version results in a bug in datasets that duplicates data
'sentencepiece==0.2.0',
'einops==0.8.0',
'omegaconf>=2.2.3,<3',
'slack-sdk<4',
'mosaicml-cli>=0.6.10,<1',
'onnx==1.17.0',
'onnxruntime==1.19.2',
'boto3>=1.21.45,<2',
'huggingface-hub>=0.19.0,<0.27',
'beautifulsoup4>=4.12.2,<5', # required for model download utils
'tenacity>=8.2.3,<10',
'catalogue>=2,<3',
'typer<1',
'GitPython==3.1.43',
]
extra_deps = {}
extra_deps['dev'] = [
'coverage[toml]==7.6.4',
'pre-commit>=3.4.0,<4',
'pytest>=7.2.1,<9',
'pytest_codeblocks>=0.16.1,<0.18',
'pytest-cov>=4,<7',
'pyright==1.1.256',
'toml>=0.10.2,<0.11',
'packaging>=21,<25',
'hf_transfer==0.1.8',
]
extra_deps['databricks'] = [
'mosaicml[databricks]>=0.27.0,<0.28',
'numpy<2',
'databricks-sql-connector>=3,<4',
'databricks-connect==14.1.0',
'lz4>=4,<5',
]
extra_deps['tensorboard'] = [
'mosaicml[tensorboard]>=0.27.0,<0.28',
]
# Flash 2 group kept for backwards compatibility
extra_deps['gpu-flash2'] = [
'flash-attn==2.6.3',
]
extra_deps['gpu'] = copy.deepcopy(extra_deps['gpu-flash2'])
extra_deps['peft'] = [
'mosaicml[peft]>=0.27.0,<0.28',
]
extra_deps['openai'] = [
'openai==1.3.8',
'tiktoken>=0.4,<0.8.1',
]
extra_deps['megablocks'] = [
'megablocks<1.0',
'grouped-gemm==0.1.6',
]
extra_deps['te'] = [
'transformer-engine[pytorch]>=1.11.0,<1.12',
]
extra_deps['databricks-serverless'] = {
dep for key, deps in extra_deps.items() for dep in deps
if 'gpu' not in key and 'megablocks' not in key and 'te' not in key and
'databricks-connect' not in dep
}
extra_deps['all-cpu'] = {
dep for key, deps in extra_deps.items() for dep in deps
if 'gpu' not in key and 'megablocks' not in key and 'te' not in key
}
extra_deps['all'] = {
dep for key, deps in extra_deps.items() for dep in deps
if key not in {'gpu-flash2', 'all-cpu'}
}
extra_deps['all-flash2'] = {
dep for key, deps in extra_deps.items() for dep in deps
if key not in {'gpu', 'all', 'all-cpu'}
}
setup(
name=_PACKAGE_NAME,
version=repo_version,
author='MosaicML',
author_email='[email protected]',
description='LLM Foundry',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/mosaicml/llm-foundry/',
package_data={
'llmfoundry': ['py.typed'],
},
packages=setuptools.find_packages(
exclude=['.github*', 'mcli*', 'scripts*', 'tests*'],
),
classifiers=classifiers,
install_requires=install_requires,
extras_require=extra_deps,
python_requires='>=3.9',
entry_points={
'console_scripts': ['llmfoundry = llmfoundry.cli.cli:app'],
},
)