-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathpyproject.toml
More file actions
291 lines (281 loc) · 9.58 KB
/
Copy pathpyproject.toml
File metadata and controls
291 lines (281 loc) · 9.58 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
[build-system]
build-backend = "setuptools.build_meta"
requires = [ "setuptools>=42" ]
[project]
name = "coreai-opt"
description = "A library for PyTorch model compression and optimizations for deployment via Core AI on Apple silicon."
readme = { file = "README.pypi.md", content-type = "text/markdown" }
keywords = [
"apple",
"compression",
"core ai",
"machine learning",
"model optimization",
"palettization",
"pytorch",
"quantization",
]
license = "BSD-3-Clause"
requires-python = ">=3.11,<3.14"
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Operating System :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dynamic = [ "version" ]
dependencies = [
"coremltools>=8.3",
"numpy>=2,<2.4", # TODO: Remove once coremltools has released a version > 9.0
"pydantic>=2.0.0",
"rich>=13.0.0",
"safetensors>=0.5.3,<=0.7.0",
# PyTorch >= 2.9.0 requires torchao >= 0.15.0
# Python's standard dependency specification (PEP 508) doesn't support conditional dependencies
# based on other package versions. We can either 1) add a stricter check to require the newer torchao
# version for everyone, or 2) add a runtime check in src/coreai_opt/init.py to ensure torchao
# version >= 0.15.0 for torch version >= 2.9.0. Opting option 1.
# These torch versions must be in bounds of lowest_tested_torch and highest_tested_torch
"torch>=2.8.0,<=2.11.0",
"torchao>=0.15.0,<=0.17.0",
"tqdm>=4.65",
]
[[project.authors]]
name = "Apple Core AI Optimization Team"
[project.optional-dependencies]
coreai = [
"coreai-core==1.0.0b2",
"coreai-torch==0.4.1",
"scikit-learn>=1.7.2",
]
[project.urls]
Changelog = "https://github.com/apple/coreai-optimization/blob/main/CHANGELOG.md"
Repository = "https://github.com/apple/coreai-optimization"
[dependency-groups]
dev = [
"build>=1.0.0",
"mypy>=1.0.0",
"nox>=2025.11.12",
"nox-uv>=0.7.0",
"packaging",
"py-repo-root>=2.0.1",
"setuptools",
"towncrier",
"types-setuptools",
{ include-group = "pre-commit" },
{ include-group = "test" },
{ include-group = "torchvision" },
]
test = [
"junitparser>=4.0.2",
"pytest>=9.0.0",
"pytest-cov>=4.0.0",
"pytest-xdist>=3.0.0",
]
docs = [
"autodoc-pydantic==2.2.0",
"ipython",
"myst-parser==4.0.0",
"nbsphinx>=0.9.0",
"shibuya==2026.5.19",
"sphinx==8.0.2",
"sphinx-copybutton==0.5.2",
"sphinx-llm==0.3.0",
"sphinxcontrib-mermaid==1.0.0",
{ include-group = "coreai" },
]
# `coreai` group mirrors the `coreai` optional-dependency (extra) so `uv sync`
# installs CoreAI by default (see tool.uv.default-groups). The extra is the
# single source of truth; this group self-references it to avoid duplicating the
# package list.
coreai = [ "coreai-opt[coreai]" ]
# Used in CI to force latest mimimum supported torch version
# These torch versions must be in bounds of torch versions listed in project dependencies
highest_tested_torch = [
"torch==2.11.0",
"torchao==0.17.0",
"torchvision==0.26.0",
]
# Used in CI to force lowest mimimum supported torch version
# These torch versions must be in bounds of torch versions listed in project dependencies
lowest_tested_torch = [
"torch==2.8.0",
"torchao==0.15.0",
"torchvision==0.23.0",
]
pre-commit = [
"bashate>=2.1.1",
"darker>=3.0.0",
"jinja2>=3.0",
"mbake",
"mdformat>=0.7.22",
"mdformat-black",
"mdformat-frontmatter",
"mdformat-gfm",
"pre-commit>=3.0.0",
"pre-commit-hooks>=5.0.0",
"pymarkdownlnt>=0.9.33",
"pyproject-fmt",
"python-kacl",
"ruff>=0.14.8",
"taplo>=0.9.3",
# pyproject-fmt 2.21.2 imports the private `_build_cli` from toml-fmt-common,
# which was renamed to `build_cli` in 1.3.3. Pin until pyproject-fmt updates.
"toml-fmt-common==1.3.2",
"toml-sort>=0.24.3",
"tomli-w>=1.0.0",
]
tamm-export = []
# Since torch and torchao are project dependencies, we need to include torchvision in dev
# This allows standard `make test` to find torchvision
torchvision = [
"torchvision>=0.23.0,<=0.26.0",
]
tutorial = [
"ipykernel>=7.2.0",
"jupyter>=1.1.1",
"nbconvert>=7.17.1",
"papermill>=2.7.0",
"torchinfo>=1.8.0",
{ include-group = "coreai" },
{ include-group = "torchvision" },
]
[tool.setuptools]
package-dir = { "" = "src" }
[tool.setuptools.dynamic]
version = { attr = "coreai_opt._about.__version__" }
[tool.setuptools.package-data]
coreai_opt = [ "py.typed" ]
[tool.setuptools.packages]
find.exclude = [ "coreai_opt_benchmarking*", "tests*" ]
find.where = [ "src" ]
# make env group installed by default with uv sync
[tool.uv]
default-groups = [ "dev", "coreai" ]
index = [
{ explicit = true, name = "pytorch-cpu", url = "https://download.pytorch.org/whl/cpu" },
{ explicit = true, name = "pytorch-cu128", url = "https://download.pytorch.org/whl/cu128" },
]
# Only resolve for platforms where all dependencies (including coreai) exist
environments = [
"sys_platform == 'darwin' and platform_machine == 'arm64'",
"sys_platform == 'linux' and platform_machine == 'x86_64'",
]
# Security: only install distributions on PyPI for at least 3 days, giving
# malicious uploads time to be detected and yanked before they reach CI.
# coreai-core/coreai-torch are exempted (false) so CI tests their latest releases.
exclude-newer = "3 days"
exclude-newer-package = { coreai-core = false, coreai-torch = false }
# Declare conflicting groups so uv does not error
conflicts = [
[
{ group = "highest_tested_torch" },
{ group = "lowest_tested_torch" },
],
]
[tool.uv.sources]
torch = [
{ index = "pytorch-cpu", marker = "sys_platform != 'linux'" },
{ index = "pytorch-cu128", marker = "sys_platform == 'linux'" },
]
torchvision = [
{ index = "pytorch-cpu", marker = "sys_platform != 'linux'" },
{ index = "pytorch-cu128", marker = "sys_platform == 'linux'" },
]
[tool.ruff]
target-version = "py311"
line-length = 100
exclude = [ ".oss-export" ]
[tool.ruff.lint]
select = [
"B", # enable flake8-bugbear checks
"E", # enable pycodestyle error checks
"E4", # pycodestyle E4xx (import style)
"E5", # pycodestyle E5xx (line length/backslash)
"E7", # pycodestyle E7xx (multiple statements)
"E9", # pycodestyle E9xx (runtime errors)
"F", # enable Pyflakes error checks
"I", # sort imports
"PLC", # Add Python Library Checker convention rules
"PLE", # Add Python Library Checker error rules
"RUF022", # sort __all__ lists
"RUF100", # remove unused noqa pragmas
"TC004", # catch runtime imports in TYPE_CHECKING blocks
"UP", # apply pyupgrade modernization rules
]
ignore = [
"ANN401", # allow type `Any`.
"RUF100", # disable the "unused-noqa" rule
]
per-file-ignores."__init__.py" = [ "F401" ] # Ignore unused imports in __init__.py files
per-file-ignores."scripts/release/*.py" = [ "S603", "T201" ]
per-file-ignores."tests/**/*.py" = [ "ANN001", "ANN201", "D103", "PLR2004", "S101" ]
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
flake8-annotations.allow-star-arg-any = true
isort.combine-as-imports = true
isort.force-single-line = false
isort.known-first-party = [ "coreai_opt" ]
pylint.max-args = 8
# A sorting utility for toml files. The `toml-sort-fix` pre-commit hook
# excludes pyproject-shaped files (which are owned by pyproject-fmt), so this
# config only governs other TOML files in the repo (lychee, bake, etc.).
[tool.tomlsort]
in_place = true # overwrite the original input file with changes
sort_table_keys = true # sort keys within tables
spaces_indent_inline_array = 4 # 4 spaces to indent a multiline inline array
trailing_comma_inline_array = true # add trailing comma to the last item in a multiline inline array
[tool.mypy]
exclude = [ "\\.oss-export/" ]
python_version = "3.11"
disallow_untyped_defs = true
disallow_incomplete_defs = true
check_untyped_defs = true
disallow_untyped_decorators = true
strict_optional = true
warn_return_any = true
plugins = [ "pydantic.mypy" ]
warn_unused_configs = true
overrides = [
{ follow_imports = "skip", module = "numpy.*" },
{ follow_imports = "skip", module = "torch.*" },
{ follow_imports = "skip", module = "torchvision.*" },
{ module = "torchao.*", ignore_missing_imports = true, follow_imports = "skip" },
{ module = "tests.*", ignore_errors = true },
]
no_implicit_optional = true
[tool.pytest]
[tool.pytest.ini_options]
log_date_format = "%Y-%m-%d %H:%M:%S.%f%z"
log_format = "%(asctime)s %(levelname)s %(name)s:%(lineno)d: %(message)s"
log_level = "NOTSET"
markers = [
"seed(value): enable deterministic seeding; no value uses default seed (42), value=None means nondeterministic seeding",
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
]
norecursedirs = [ ".oss-export" ]
strict = true
testpaths = [ "tests" ]
[tool.towncrier]
directory = "changelog.d"
filename = "CHANGELOG.md"
start_string = "<!-- towncrier release notes start -->\n"
title_format = "## [{version}] - {project_date}"
issue_format = "" # Don't include issue names in the changelog
underlines = [ "", "", "" ]
create_add_extension = false
type = [
{ name = "Added" },
{ name = "Changed" },
{ name = "Deprecated" },
{ name = "Removed" },
{ name = "Fixed" },
{ name = "Security" },
]
[tool.pymarkdown]
[tool.pymarkdown.plugins]
md010.code_blocks = false