forked from NVIDIA/Model-Optimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
301 lines (270 loc) · 8.92 KB
/
pyproject.toml
File metadata and controls
301 lines (270 loc) · 8.92 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
292
293
294
295
296
297
298
299
300
301
####################################################################################################
############################### BUILD CONFIGURATION ##############################################
####################################################################################################
[build-system]
requires = ["setuptools>=80", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
fallback_version = "0.0.0"
####################################################################################################
############################### PROJECT METADATA #################################################
####################################################################################################
[project]
name = "nvidia-modelopt"
dynamic = ["version"]
description = "Nvidia Model Optimizer: a unified model optimization and deployment toolkit."
readme = { text = "Checkout https://github.com/nvidia/Model-Optimizer for more information.", content-type = "text/markdown" }
license = "Apache-2.0"
license-files = ["LICENSE_HEADER"]
requires-python = ">=3.10,<3.13"
authors = [{ name = "NVIDIA Corporation" }]
classifiers = [
"Programming Language :: Python :: 3",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
# Common
"ninja", # for faster building of C++ / CUDA extensions
"numpy",
"nvidia-ml-py>=12",
"packaging",
"setuptools>=80", # torch.utils.cpp_extension imports setuptools at load time
"torch>=2.6",
"tqdm",
# modelopt.torch
"pulp",
"pydantic>=2.0",
"regex",
"rich",
"safetensors",
"scipy",
]
[project.optional-dependencies]
onnx = [
"cppimport",
"cupy-cuda12x; platform_machine != 'aarch64' and platform_system != 'Darwin'",
"lief",
"ml_dtypes",
"onnx-graphsurgeon",
"onnx~=1.19.0",
"onnxconverter-common~=1.16.0",
# ORT for Windows
"onnxruntime-gpu==1.22.0; platform_system == 'Windows'",
# ORT with Python <= 3.10
"onnxruntime~=1.22.0; python_version <= '3.10' and (platform_machine == 'aarch64' or platform_system == 'Darwin')",
"onnxruntime-gpu~=1.22.0; python_version <= '3.10' and platform_machine != 'aarch64' and platform_system != 'Darwin' and platform_system != 'Windows'",
# ORT with Python > 3.10
"onnxruntime~=1.24.2; python_version > '3.10' and (platform_machine == 'aarch64' or platform_system == 'Darwin')",
"onnxruntime-gpu~=1.24.2; python_version > '3.10' and platform_machine != 'aarch64' and platform_system != 'Darwin' and platform_system != 'Windows'",
"onnxscript",
"onnxslim>=0.1.76",
"polygraphy>=0.49.22",
]
hf = [
"accelerate>=1.0.0",
"datasets>=3.0.0",
"deepspeed>=0.9.6; platform_system != 'Darwin' and platform_system != 'Windows'",
"diffusers>=0.32.2",
"huggingface_hub>=0.24.0",
"nltk",
"peft>=0.17.0",
"sentencepiece>=0.2.1", # Also implicitly used in test_unified_export_megatron, test_vllm_fakequant_megatron_export
"transformers>=4.53,<5.0", # Should match modelopt/torch/__init__.py and tox.ini
"wonderwords",
]
dev-lint = [
"bandit[toml]==1.7.9", # security/compliance checks
"mypy==1.17.1",
"pre-commit==4.3.0",
"ruff==0.12.11",
]
dev-docs = [
"autodoc_pydantic>=2.1.0",
"sphinx~=8.1.0",
"sphinx-argparse>=0.5.2",
"sphinx-autobuild>=2024.10.3",
"sphinx-copybutton>=0.5.2",
"sphinx-inline-tabs>=2023.4.21",
"sphinx-rtd-theme~=3.0.0",
"sphinx-togglebutton>=0.3.2",
]
dev-test = [
"pytest",
"pytest-cov",
"pytest-instafail",
"pytest-timeout",
"timm",
"torchprofile>=0.0.4", # optional dependency for modelopt.torch
"torchvision",
"torch-geometric",
"tox>4.18",
"tox-current-env>=0.0.12",
]
# Compound extras via self-references
all = ["nvidia-modelopt[onnx,hf]"]
dev = ["nvidia-modelopt[all,dev-docs,dev-lint,dev-test]"]
[project.urls]
Homepage = "https://github.com/NVIDIA/Model-Optimizer"
[tool.setuptools.packages.find]
include = ["modelopt*"]
[tool.setuptools.package-data]
modelopt = ["**/*.h", "**/*.cpp", "**/*.cu"]
[tool.uv]
managed = true
# override-dependencies = ["torch; sys_platform == 'never'"]
####################################################################################################
############################### LINTING, FORMATTING AND TESTING CONFIGURATION ####################
####################################################################################################
[tool.ruff]
target-version = "py310"
line-length = 100 # Line length limit for code
fix = true
[tool.ruff.format]
# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false
docstring-code-format = true
# Set the line length limit used when formatting code snippets in docstrings.
docstring-code-line-length = "dynamic"
[tool.ruff.lint]
# See available rules at https://docs.astral.sh/ruff/rules/
# Flake8 is equivalent to pycodestyle + pyflakes + mccabe.
select = [
"C4", # Flake8 comprehensions
"D", # pydocstyle
"E", # pycodestyle errors
"F", # pyflakes
"FURB", # refurb
"I", # isort
"ISC", # flake8-implicit-str-concat
"N", # pep8 naming
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PLE", # pylint errors
"PLR", # pylint refactor
"PT", # flake8-pytest-style
"RUF", # ruff
"SIM", # flake8-simplify
"TC", # flake8-type-checking
"UP", # pyupgrade
"W", # pycodestyle warnings
]
extend-ignore = [
"D105",
"D417",
"N812",
"PLR0402",
"PLR0912",
"PLR0913",
"PLR0915",
"PLR2004",
"PLR0911",
"PT011",
"PT018",
"PT028",
"PT030",
"RUF002",
"RUF012",
"SIM102",
"SIM108",
"SIM115",
"UP032",
"UP038",
]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "F403"]
"examples/*" = ["D"]
"tests/*" = ["B017", "D", "E402", "PT012"]
"*/_[a-zA-Z]*" = ["D"] # Private packages (_abc/*.py) or modules (_xyz.py)
"*.ipynb" = [
"D",
"E501",
] # Ignore missing docstrings or line length for Jupyter notebooks
"modelopt/torch/quantization/triton/*" = ["N803", "N806", "E731"] # triton style
"examples/deepseek/ds_kernel.py" = ["N803", "N806", "E731"] # triton style
[tool.ruff.lint.pycodestyle]
max-line-length = 120 # Line length limit for comments and docstrings
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.isort]
known-first-party = ["modelopt"]
split-on-trailing-comma = false
[tool.mypy]
files = "."
install_types = true
non_interactive = true
show_error_codes = true
disable_error_code = [
"assignment",
"operator",
"has-type",
"var-annotated",
"override",
]
explicit_package_bases = true
namespace_packages = true
# strict checks
strict = true
disallow_subclassing_any = false
disallow_untyped_decorators = false
disallow_any_generics = false
disallow_untyped_calls = false
disallow_incomplete_defs = false
disallow_untyped_defs = false
warn_return_any = false
[[tool.mypy.overrides]]
module = ["tests.*"]
ignore_errors = true
[[tool.mypy.overrides]]
module = ["examples.*"]
disable_error_code = ["attr-defined"]
[tool.pytest.ini_options]
# Default additional options
# Show a short test summary info for all except passed tests with -ra flag
# print execution time for 50 slowest tests and generate coverage reports
addopts = "-v -ra --instafail --cov-report=term-missing --cov-report=html --cov-report=xml:coverage.xml --cov-config=pyproject.toml --durations=50 --strict-markers"
pythonpath = ["tests/"]
markers = [
"manual: Only run when --run-manual is given",
"release: Regression tests that should be run before every release",
]
[tool.coverage.run]
branch = false
include = ["modelopt/*"]
omit = ["*/plugins/*", "*/export/*"]
[tool.coverage.report]
fail_under = 70
skip_covered = true
ignore_errors = true
exclude_lines = [
"pragma: no cover",
# Don't complain about missing debug or verbose code
"def __repr__",
"if verbose",
# Don't complain if tests don't hit defensive exception handling code
"raise AssertionError",
"raise NotImplementedError",
"raise RuntimeError",
"raise ValueError",
"raise KeyError",
"raise AttributeError",
"except ImportError",
# Don't complain if non-runnable code isn't run
"if __name__ == \"__main__\":",
"if TYPE_CHECKING:",
# Don't complain about abstract methods, they aren't run
"@(abc\\.)?abstractmethod",
]
[tool.bandit]
exclude_dirs = [".github/", "examples/", "tests/"]
# Do not change `skips`. It should be consistent with NVIDIA's Wheel-CI-CD bandit.yml config.
# Use of `# nosec BXXX` requires special approval
skips = [
"B101", # assert_used
"B110", # try_except_pass
"B112", # try_except_continue
"B303", # MD2, MD4, MD5, or SHA1
"B311", # random
]