Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
428 lines (400 loc) · 13.3 KB
/
Copy pathpyproject.toml
File metadata and controls
428 lines (400 loc) · 13.3 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
# Package ######################################################################
[build-system]
requires = [
"numpy",
"packaging>=24.2", # required by setuptools>=77 to validate PEP 639 license expressions
"pyyaml",
"scikit-build-core>=1.1.1",
"typing-extensions>=4.10.0",
]
build-backend = "scikit_build_core.build"
[tool.scikit-build]
# Track the build-system.requires floor so the schema and defaults are pinned
# to the version we build against.
minimum-version = "build-system.requires"
# Separate from the legacy setup.py build dir ("build"), so the SKBUILD cache
# variables and ninja state never leak into / conflict with the legacy build.
build-dir = "build-skbuild"
[tool.scikit-build.env]
# MAX_JOBS is the umbrella parallelism knob (also read by setup.py's build_clib);
# alias it to the variable CMake natively honors for `cmake --build`.
# setdefault semantics: a user-set CMAKE_BUILD_PARALLEL_LEVEL always wins.
CMAKE_BUILD_PARALLEL_LEVEL = { env = "MAX_JOBS" }
# Listing CC/CXX here opts out of scikit-build-core's sysconfig-compiler
# injection, so CMake detects the compiler from PATH. An ambient CC/CXX is
# still respected.
CC = { env = "CC" }
CXX = { env = "CXX" }
# cmake.build-type is deliberately not set: it defaults to Release. The
# overrides below map the DEBUG and REL_WITH_DEB_INFO env vars (read by
# setup.py's get_build_type) to the corresponding build types.
[[tool.scikit-build.overrides]]
if.env.DEBUG = true
cmake.build-type = "Debug"
[[tool.scikit-build.overrides]]
if.env.REL_WITH_DEB_INFO = true
cmake.build-type = "RelWithDebInfo"
[[tool.dynamic-metadata]]
# Delegates to tools/setup_helpers/version.py which resolves the version from
# TORCH_VERSION (release build) or the installed PyTorch version.
provider = { path = "tools/metadata", module = "version" }
[[tool.dynamic-metadata]]
# Emits torch==<base>.* plus numpy, mirroring setup.py's _get_torch_requires().
provider = { path = "tools/metadata", module = "dependencies" }
[tool.scikit-build.install]
# scikit-build-core auto-strips binaries in Release builds. torch_npu keeps
# symbols (e.g. for auditwheel repair and ABI checks in CI).
strip = false
[tool.scikit-build.wheel]
# CMake install destinations are relative to CMAKE_INSTALL_PREFIX; placing them
# under torch_npu/ matches the legacy build/packages/torch_npu layout.
install-dir = "torch_npu"
# Python packages to include in the wheel.
packages = ["torch_npu", "torchnpugen"]
# Drop build sources and docs from the wheel. wheel.packages walks each package
# directory (skipping .gitignore'd files, which is why gitignored generated
# files are installed explicitly in CMakeLists.txt), so the C++ sources under
# csrc/ (whose headers are re-added under include/ by the CMake install rules)
# and the documentation/media files must be excluded explicitly. These patterns
# apply to both the package scan and the CMake install tree.
exclude = [
# C++ sources/headers under csrc/ are re-added under include/ by the CMake
# install rules; exclude them here but keep csrc/aten/*.yaml (op-plugin's
# compatibility test reads those two schema files from the installed pkg).
"torch_npu/csrc/**/*.h",
"torch_npu/csrc/**/*.hpp",
"torch_npu/csrc/**/*.cpp",
"torch_npu/csrc/**/*.cc",
"torch_npu/csrc/**/*.cu",
"torch_npu/csrc/**/*.c",
"torch_npu/_inductor/experimental/python_wrapper_fast_launch/csrc/**",
# add_subdirectory(third_party/Tensorpipe) runs Tensorpipe's own install()
# rules at cmake --install time, leaking its public headers, a duplicate
# lib64/ copy of libtensorpipe.so, and its CMake package config into the
# install tree. The legacy wheel ships none of these (only
# torch_npu/lib/libtensorpipe.so, installed explicitly in CMakeLists.txt).
"torch_npu/include/tensorpipe/**",
"torch_npu/lib64/**",
"torch_npu/share/**",
"**/*.a",
"**/*.md",
"**/*.txt",
"**/*.png",
"**/*.svg",
"**/*.gitkeep",
"**/*.pyc",
"**/__pycache__/**",
"**/CMakeLists.txt",
]
[project]
name = "torch_npu"
description = "NPU bridge for PyTorch"
readme = "README.md"
requires-python = ">=3.10"
license = "BSD-3-Clause"
authors = [{ name = "Huawei Technologies Co., Ltd" }]
keywords = ["pytorch", "npu", "ascend"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: POSIX :: Linux",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dynamic = ["version", "dependencies"]
[project.scripts]
torch_npu_run = "torch_npu.distributed.run:_main"
[project.entry-points."torch.backends"]
torch_npu = "torch_npu:_autoload"
[project.entry-points."torch.distributed.backends"]
hccl = "torch_npu._init.registry.distributed:register_distributed_backend_for_npu"
lccl = "torch_npu._init.registry.distributed:register_distributed_backend_for_npu"
[project.entry-points."torch_dynamo_backends"]
npu = "torch_npu.dynamo:_npu_backend_entrypoint"
npugraph_ex = "torch_npu.dynamo:_npugraph_ex_backend_entrypoint"
npugraphs = "torch_npu.dynamo:_npugraphs_backend_entrypoint"
fxrt = "torch_npu.fxrt:_backend"
[project.urls]
Homepage = "https://gitcode.com/ascend/pytorch"
# Linter tools #################################################################
[tool.isort]
src_paths = ["torch_npu", "torchnpugen", "test"]
extra_standard_library = ["typing_extensions"]
skip_gitignore = true
skip_glob = ["third_party/*"]
atomic = true
profile = "black"
indent = 4
line_length = 88
lines_after_imports = 2
multi_line_output = 3
include_trailing_comma = true
combine_as_imports = true
[tool.usort]
preserve_inline_comments = true
collapse_blank_lines_in_category = false
[tool.usort.known]
first_party = ["torch_npu", "torchnpugen", "test"]
standard_library = ["typing_extensions"]
[tool.ruff]
line-length = 88
src = ["caffe2", "torch", "torchgen", "functorch", "test"]
extend-exclude = ["third_party", "test/dynamo/cpython", "test/npu/test_fault_mode.py"]
[tool.ruff.per-file-target-version]
"**/py312_intrinsics.py" = "py312"
[tool.ruff.format]
docstring-code-format = true
quote-style = "double"
[tool.ruff.lint]
# NOTE: Synchoronize the ignores with .flake8
external = [
"B001",
"B902",
"B950",
"E121",
"E122",
"E128",
"E131",
"E704",
"E723",
"F723",
"F812",
"P201",
"P204",
"T484",
"TOR901",
]
ignore = [
# these ignores are from flake8-bugbear; please fix!
"B007", "B008", "B017",
"B018", # Useless expression
"B023",
"B028", # No explicit `stacklevel` keyword argument found
"E402",
"C408", # C408 ignored because we like the dict keyword argument syntax
"E501", # E501 is not flexible enough, we're using B950 instead
"E741",
"EXE001",
"F405",
"FURB122", # writelines
# these ignores are from ruff NPY; please fix!
"NPY002",
# these ignores are from ruff PERF; please fix!
"PERF203",
"PERF401",
# these ignores are from PYI; please fix!
"PYI024",
"PYI036",
"PYI041",
"PYI056",
"SIM102", "SIM103", "SIM112", # flake8-simplify code styles
"SIM105", # these ignores are from flake8-simplify. please fix or ignore with commented reason
"SIM108", # SIM108 ignored because we prefer if-else-block instead of ternary expression
"SIM110", # Checks for for loops that can be replaced with a builtin function, like any or all.
"SIM114", # Combine `if` branches using logical `or` operator
"SIM116", # Disable Use a dictionary instead of consecutive `if` statements
"SIM117",
"SIM300", # Yoda condition detected
"TC006",
# TODO: Remove Python-3.10 specific suppressions
"B905",
]
select = [
"B",
"B904", # Re-raised error without specifying the cause via the from keyword
"C4",
"G",
"E",
"EXE",
"F",
"SIM",
"W",
# Not included in flake8
"FURB",
"LOG",
"NPY",
"PERF",
"PGH004",
"PIE",
"PLC0131", # type bivariance
"PLC0132", # type param mismatch
"PLC1802", # len({expression}) used as condition without comparison
"PLC0205", # string as __slots__
"PLC3002", # unnecessary-direct-lambda-call
"PLC0414", # Import alias does not rename original package
"PLE",
"PLR0133", # constant comparison
"PLR0206", # property with params
"PLR1722", # use sys exit
"PLR1736", # unnecessary list index
"PLW0127", # Self-assignment of variable
"PLW0129", # assert on string literal
"PLW0131", # named expr without context
"PLW0133", # useless exception statement
"PLW0245", # super without brackets
"PLW0406", # import self
"PLW0711", # binary op exception
"PLW1501", # bad open mode
"PLW1507", # shallow copy os.environ
"PLW1509", # preexec_fn not safe with threads
"PLW2101", # useless lock statement
"PLW3301", # nested min max
"PT006", # TODO: enable more PT rules
"PT014", # duplicate parameterize case
"PT022",
"PT023",
"PT024",
"PT025",
"PT026",
"PYI",
"Q003", # avoidable escaped quote
"Q004", # unnecessary escaped quote
"RSE",
"RUF007", # pairwise over zip
"RUF008", # mutable dataclass default
"RUF013", # ban implicit optional
"RUF015", # access first ele in constant time
"RUF016", # type error non-integer index
"RUF017",
"RUF018", # no assignment in assert
"RUF019", # unnecessary-key-check
"RUF020", # never union
"RUF024", # from keys mutable
"RUF026", # default factory kwarg
"RUF030", # No print statement in assert
"RUF033", # default values __post_init__ dataclass
"RUF041", # simplify nested Literal
"RUF048", # properly parse `__version__`
"RUF200", # validate pyproject.toml
"S324", # for hashlib FIPS compliance
"SLOT",
"TC",
"TRY002", # ban vanilla raise (todo fix NOQAs)
"TRY203",
"TRY401", # verbose-log-message
"UP",
"YTT",
"S101",
]
[tool.ruff.lint.per-file-ignores]
"torch_npu/distributed/fsdp/_add_fsdp_patch.py" = [
"UP007",
"UP045",
]
"__init__.py" = [
"F401",
]
"*.pyi" = [
"PYI011", # typed-argument-default-in-stub
"PYI021", # docstring-in-stub
"PYI053", # string-or-bytes-too-long
]
# upstream community path (not present in torch_npu)
# "functorch/docs/source/tutorials/**" = [
# "F401",
# ]
# upstream community path (not present in torch_npu)
# "test/export/**" = [
# "PGH004",
# ]
# upstream community path (not present in torch_npu)
# "test/typing/**" = [
# "PGH004"
# ]
# upstream community path (not present in torch_npu)
# "test/typing/reveal/**" = [
# "F821",
# ]
# upstream community path (not present in torch_npu)
# "test/torch_np/numpy_tests/**" = [
# "F821",
# "NPY201",
# ]
# upstream community path (not present in torch_npu)
# "test/dynamo/test_bytecode_utils.py" = [
# "F821",
# ]
"test/dynamo/test_debug_utils.py" = [
"UP037",
]
"test/dynamo/test_misc.py" = [
"PGH004",
]
"test/jit/**" = [
"PLR0133", # tests require this for JIT
"PYI",
"RUF015",
"UP", # We don't want to modify the jit test as they test specify syntax
]
"test/test_jit.py" = [
"PLR0133", # tests require this for JIT
"PYI",
"RUF015",
"UP", # We don't want to modify the jit test as they test specify syntax
]
"test/**" = ["S101"]
# upstream community path (not present in torch_npu)
# "test/inductor/s429861_repro.py" = [
# "PGH004",
# ]
# upstream community path (not present in torch_npu)
# "test/inductor/test_torchinductor.py" = [
# "UP037",
# ]
# autogenerated #TODO figure out why file level noqa is ignored
# upstream community paths (not present in torch_npu)
# "torch/_appdirs.py" = ["PGH004"]
# "torch/jit/_shape_functions.py" = ["PGH004"]
# "torch/_inductor/fx_passes/serialized_patterns/**" = ["F401", "F501"]
# "torch/_inductor/autoheuristic/artifacts/**" = ["F401", "F501"]
"torch_npu/_inductor/codegen/**" = [
"PGH004"
]
# upstream community path (not present in torch_npu)
# "torchgen/api/types/__init__.py" = [
# "F401",
# "F403",
# ]
"torch_npu/utils/collect_env.py" = [
"UP", # collect_env.py needs to work with older versions of Python
]
# upstream community path (not present in torch_npu)
# "torch/_vendor/**" = [
# "UP", # No need to mess with _vendor
# ]
"tools/linter/**" = [
"LOG015" # please fix
]
# torch_npu/ folders still needing S101 migration
# upstream community path (not present in torch_npu)
# "torch/_dynamo/**" = ["S101"]
"torch_npu/_inductor/**" = ["S101"]
[tool.codespell]
ignore-words = "tools/linter/dictionary.txt"
[tool.spin]
package = 'torch_npu'
[tool.spin.commands]
# upstream community paths (`.spin/cmds.py` not present in torch_npu)
"Build" = [
".spin/cmds.py:lint",
".spin/cmds.py:fixlint",
".spin/cmds.py:quicklint",
".spin/cmds.py:quickfix",
]
"Regenerate" = [
".spin/cmds.py:regenerate_version",
".spin/cmds.py:regenerate_type_stubs",
".spin/cmds.py:regenerate_clangtidy_files",
".spin/cmds.py:regenerate_github_workflows",
]