forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
690 lines (656 loc) · 25.4 KB
/
Copy pathpyproject.toml
File metadata and controls
690 lines (656 loc) · 25.4 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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# Package ######################################################################
[build-system]
requires = [
"numpy",
"packaging>=24.2", # required by setuptools>=77 to validate PEP 639 license expressions
"pyyaml",
# 1.0 is required for [[tool.dynamic-metadata]], the [tool.scikit-build.env]
# table, and native CMAKE_BUILD_TYPE env handling used below. CI pins the
# exact patch we test against in .ci/docker/requirements-ci.txt.
"scikit-build-core>=1.0",
# Imported by torchgen at build time (cmake/Codegen.cmake runs
# `python -m torchgen.gen`, and torchgen/utils.py uses `Self` /
# `assert_never`). Currently also pulled in transitively through
# scikit-build-core, but list it explicitly as a direct build-time
# dep. The CI Docker image ships 4.12.2 on Python <3.14, so do not
# raise the lower bound without bumping CI.
"typing-extensions>=4.10.0",
# Dependency chain: NNPACK -> PeachPy -> six. PeachPy emits NNPACK's hot
# assembly loops at build time and does `import six`. NNPACK is on by
# default (USE_NNPACK=ON); isolated PEP 517 builds need six available.
"six",
]
build-backend = "scikit_build_core.build"
[tool.scikit-build]
# Track the build-system.requires floor (scikit-build-core>=1.0) so the schema
# and defaults are pinned to the version we build against.
minimum-version = "build-system.requires"
build-dir = "build"
[tool.scikit-build.env]
# MAX_JOBS is PyTorch's umbrella parallelism knob (also read by
# linters, cpp_extension JIT, nccl/MKLDNN sub-builds); 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 (a documented env-table behavior), so CMake detects the compiler
# from PATH -- avoids the conda compiler_compat / stale-venv-gcc probe breaks.
# An ambient CC/CXX is still respected.
CC = { env = "CC" }
CXX = { env = "CXX" }
# cmake.build-type is deliberately not set: it defaults to Release, and
# leaving it unconfigured lets scikit-build-core honor a CMAKE_BUILD_TYPE
# set in the environment (.ci/pytorch/build.sh exports RelWithAssert for
# *-debug CI images). The overrides below map PyTorch's DEBUG and
# REL_WITH_DEB_INFO env vars to the corresponding build types; on
# multi-config generators (Visual Studio) the resolved type is passed as
# --config to cmake --build and cmake --install, ensuring they match.
[[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.scikit-build.overrides]]
# Force the Ninja generator on Windows. scikit-build-core otherwise defaults to
# the Visual Studio (multi-config) generator, under which the oneDNN-XPU
# ExternalProject's -DCMAKE_CXX_COMPILER=icx is ignored (VS picks the compiler by
# toolset), so oneDNN configures with MSVC and fails its -fsycl driver check.
# Generator resolution honors cmake.define.CMAKE_GENERATOR, so this lives
# here as the single source of truth
# (and covers plain non-CI editable builds too) instead of a CI-exported env var.
#
# Under Ninja, CMake does not default to MSVC: with the Intel oneAPI environment
# active (XPU builds) icx is on PATH and gets picked up as the host compiler,
# which miscompiles CPU code (icx passes sleef's __float128 cmake probe but then
# cannot compile sleefqp.c on the Windows target, ENABLEFLOAT128 gets set, the
# build fails). Pin CC/CXX=cl so the host build stays on MSVC while the XPU
# sub-projects keep using icx. env.CC/CXX setdefault semantics respect an
# explicitly set CC/CXX (e.g. clang-cl); platform-system matches sys.platform.
if.platform-system = "win32"
cmake.define.CMAKE_GENERATOR = "Ninja"
env.CC = "cl"
env.CXX = "cl"
# Other than CMAKE_GENERATOR above (win32), cmake.define is intentionally absent
# -- all BUILD_*/USE_* env vars and additional passthrough variables are
# forwarded by cmake/EnvVarForwarding.cmake so there is a single source of truth.
[[tool.dynamic-metadata]]
# Delegates to tools/generate_torch_version.py which resolves the version from
# PYTORCH_BUILD_VERSION (release/nightly), PKG-INFO (sdist), or version.txt.
provider = { path = "tools/metadata", module = "version" }
[[tool.dynamic-metadata]]
# Reads PYTORCH_EXTRA_INSTALL_REQUIREMENTS env var (pipe-separated PEP 508
# strings) to inject CUDA/ROCm/XPU pip package dependencies into the wheel.
provider = { path = "tools/metadata", module = "dependencies" }
[tool.scikit-build.sdist]
# Goal: ship exactly the git-tracked sources, minus repo/CI plumbing. The
# sdist file walk applies gitignore semantics, and several vendored trees
# commit files their own .gitignore matches (XNNPACK gen/ microkernels,
# oneDNN *.cpp via ideep, protobuf *.pb.cc, clog under deps/); PyTorch's own
# .gitignore (gen, *.pb.h) also hits tracked third-party files. The blanket
# includes below restore all of them.
#
# Mechanics governing both lists: an include match beats every exclude
# source (this exclude list, gitignore, built-ins). A !-negation inside
# include is not an exclusion -- it only withdraws include protection, and
# the file still ships unless an exclude source then catches it (built-ins
# catch .git and bytecode; .gitignore catches nccl, which is not a submodule
# but cloned into the tree at build time; the exclude list catches .github).
# That is why **/.github/** appears twice: the negation unprotects it under
# third_party/**, the exclude entry actually drops it -- there and at the
# top level. The exclude list is likewise the only mechanism dropping
# plumbing (.ci, .claude, .spin) that no include pattern covers.
#
# The flatbuffers/ittapi entries drop unneeded language bindings, which
# also contain symlinks (#157814) that sdist.resolve-symlinks="all" would
# otherwise dereference into duplicated content.
include = [
"third_party/**",
"aten/src/ATen/native/quantized/cpu/qnnpack/deps/**",
"!**/.git",
"!**/__pycache__/**",
"!**/*.pyc",
"!third_party/nccl/**",
# third_party/build/ is an in-tree CMake build dir (gitignored); un-include
# it so a dirty checkout does not leak build output into the sdist. Anchored
# like the .gitignore entry, so it does not touch tracked build/ dirs deeper
# in vendored trees (e.g. cutlass docs, ideep).
"!third_party/build/**",
"!**/.github/**",
"!third_party/flatbuffers/java/**",
"!third_party/flatbuffers/kotlin/**",
"!third_party/flatbuffers/docs/source/CONTRIBUTING.md",
"!third_party/ittapi/rust/**",
]
exclude = [
"**/.github/**",
".ci/**",
".claude/**",
".spin/**",
"third_party/flatbuffers/java/**",
"third_party/flatbuffers/kotlin/**",
"third_party/flatbuffers/docs/source/CONTRIBUTING.md",
"third_party/ittapi/rust/**",
]
[tool.scikit-build.install]
# scikit-build-core auto-strips binaries in Release builds. PyTorch needs to
# keep symbols (e.g. for torch.utils.cpp_extension, ABI checks in CI).
strip = false
[tool.scikit-build.wheel]
# CMake install destinations (lib/, include/, share/cmake/) are relative to
# CMAKE_INSTALL_PREFIX. This setting places them under torch/ in the wheel,
# matching the existing layout (e.g., torch/lib/libtorch_cpu.so).
install-dir = "torch"
# Python packages to include in the wheel.
packages = ["torch", "torchgen", "functorch"]
# license-files is declared once under [project] (PEP 639 canonical location);
# scikit-build-core honors it directly. Do NOT also declare it here -- as of
# 0.12 that triggers an AssertionError.
# Mirror the legacy setup.py package_data allowlist as gitignore-style
# exclusions: without it, scikit-build-core's package walk plus the CMake
# install step ship ~2300 extra files (source trees, third-party static
# archives, cmake configs, dev artifacts) that the legacy setup.py omitted.
# This block is intended as a temporary filter; a follow-up will replace
# it with an install-component-based scheme that suppresses third-party
# install rules at source.
exclude = [
# Static archives never belong in a Python wheel (legacy package_data
# used a "lib/*.so*"/".dylib*"/".dll"/".lib" allowlist that excluded *.a
# implicitly). The largest single offender today is libtorch_xpu_ops.a
# at ~1.1GB.
"**/*.a",
# GNUInstallDirs places third-party cmake configs and static libs under
# lib64/ on x86_64; we don't ship any of them.
"torch/lib64/**",
# Bulk C++ source tree -- only the AOTI runtime header is consumed by
# downstream AOTInductor builds (and is staged explicitly via cmake).
"torch/csrc/**",
"!torch/csrc/inductor/aoti_runtime/model.h",
# Source-only directories the package walk picks up but setup.py excluded.
# Keep the .py modules nightly ships under torch/nativert/, and the
# libshm headers consumed at runtime (torch/lib/libshm/{*.h},
# torch/lib/libshm_windows/libshm.h).
"torch/nativert/**",
"!torch/nativert/**/*.py",
"torch/headeronly/**",
"torch/lib/libshm/**",
"!torch/lib/libshm/**/*.h",
"torch/lib/libshm_windows/**",
"!torch/lib/libshm_windows/**/*.h",
# Stray CMakeLists.txt copied in by directory installs.
"**/CMakeLists.txt",
# functorch dev artifacts (docs, notebooks, examples, op-analysis tools).
"functorch/docs/**",
"functorch/examples/**",
"functorch/benchmarks/**",
"functorch/op_analysis/**",
# torchgen autoheuristic tuning scripts (used to generate heuristics,
# not consumed at runtime).
"torchgen/_autoheuristic/**",
# Third-party cmake configs / docs that subproject installs leak in via
# GNUInstallDirs share/cmake/ destinations.
"torch/share/doc/**",
"torch/share/cmake/fbgemm/**",
"torch/share/cmake/kineto/**",
"torch/share/cmake/sleef/**",
"torch/share/cmake/XNNPACK/**",
"torch/share/cmake/ittapi/**",
"torch/share/cmake/dnnl/**",
"torch/share/cpuinfo/**",
# Windows analog of the above: third-party import libs and their CMake
# package configs / pkg-config files leak in via the subproject install()
# rules (GNUInstallDirs lib/cmake, plus *.lib), the way *.a + share/cmake/*
# do on Linux. The setuptools wheel ships none of these and downstream
# find_package(Torch) works: nothing in torch/share/cmake/ (the Torch
# config tree, shipped identically) consumes them -- MKLDNN/Protobuf resolve
# via QUIET + bundled-static fallbacks, and dnnl is statically linked into
# torch_cpu.dll. dnnl.lib alone is ~1.3GB uncompressed. Do NOT broaden to
# **/*.lib: torch's own c10/torch/torch_cpu/torch_python import libs are
# required for Windows downstream linking and must stay.
"torch/lib/dnnl.lib",
"torch/lib/kineto.lib",
"torch/lib/libprotobuf.lib",
"torch/lib/libprotobuf-lite.lib",
"torch/lib/libprotoc.lib",
"torch/lib/mimalloc-2.3/mimalloc.lib",
"torch/lib/cmake/**",
"torch/cmake/**",
"torch/lib/pkgconfig/**",
# File types that are unambiguously build inputs or dev artifacts; none
# of these appear in nightly wheels today.
"**/*.bzl",
"**/*.ipynb",
"**/*.png",
"**/*.sh",
"**/*.proto",
"**/*.pyi.in", # codegen templates -> .pyi at build time
"**/BUCK.oss", # Bazel build file
# Docs and editor / dev metadata that scikit-build-core's package walk
# picks up but legacy setup.py omitted.
"**/*.md",
"**/.gitignore",
"**/*.vim",
# Lint-tool input only (consumed by tools/linter/adapters/header_only_linter.py),
# not at runtime.
"torch/header_only_apis.txt",
# Example / benchmark sub-trees that look like Python sub-packages but
# which legacy setup.py shipped 0 files from. Keeping them in lockstep
# with the legacy wheel surface.
"torch/ao/pruning/_experimental/data_sparsifier/benchmarks/**",
"torch/ao/pruning/_experimental/data_sparsifier/lightning/tests/**",
"torch/ao/quantization/experimental/**",
"torch/distributed/benchmarks/**",
"torch/distributed/checkpoint/examples/**",
"torch/distributed/examples/**",
"torch/distributed/tensor/examples/**",
"torch/fx/experimental/shape_inference/**",
# Only the sparse/ sub-dir is leakage; legacy ships the rest of
# torch/utils/benchmark/examples/.
"torch/utils/benchmark/examples/sparse/**",
"torch/utils/_strobelight/examples/**",
# Stray license file under torch/fx/experimental/unification/ that
# legacy did not ship (the canonical vendored-code licenses we do ship
# live under torch/_vendor/).
"torch/fx/experimental/unification/LICENSE.txt",
# torchgen codegen-generator scripts (not consumed at runtime); legacy
# did not ship these either.
"torchgen/decompositions/gen_*.py",
"torchgen/fuse/gen_*.py",
"torchgen/shape_functions/gen_*.py",
# Thrift-generated C++ headers under torch/_export/serde/gen-cpp2/ and
# the ATen Declarations.yaml codegen artefact -- not in legacy wheels.
"torch/_export/serde/gen-cpp2/**",
"torch/share/ATen/Declarations.yaml",
# Convenience headers duplicated at the package root; the canonical
# copies live at torch/include/torch/*.h. legacy ships only the
# torch/include/... versions.
"torch/script.h",
"torch/library.h",
"torch/extension.h",
"torch/custom_class.h",
"torch/custom_class_detail.h",
# .py files placed under torch/include/fp16/ by the third_party/FP16
# source layout (legacy ships only the .h files from that directory);
# and protobuf .inc files legacy did not ship under torch/include/google/.
"torch/include/fp16/*.py",
"torch/include/google/protobuf/*.inc",
# Browser-side JS files loaded from a CDN URL (torch/cuda/_memory_viz.py
# references the jsdelivr URL directly) -- the local install copy is
# never consumed.
"torch/utils/viz/*.js",
"torch/distributed/tensor/debug/*.js",
]
[tool.scikit-build.editable]
# Editable installs use redirect mode: Python files come from the source tree,
# CMake-built artifacts from the build tree. Auto-rebuild-on-import is left OFF:
# scikit-build-core's redirect finder otherwise re-runs cmake/ninja on every
# import (~7x, ~25s per `import torch` with no source change, plus build chatter
# on captured stderr). Rebuild explicitly instead; rebuild-on-import can be
# opted into per-install with SKBUILD_EDITABLE_REBUILD=true (or
# -C editable.rebuild=true).
mode = "redirect"
rebuild = false
[dependency-groups]
dev = [
# This list should be kept in sync with the requirements-build.txt
# in PyTorch root until the project fully migrates to pyproject.toml
# after which this can be removed as it is already specified in the
# [build-system] section
"scikit-build-core>=1.0",
"setuptools>=77.0.0,<82", # 77.0 is the first release with PEP 639 license-files support
"spin",
"cmake>=3.27",
"ninja",
"numpy",
"packaging>=24.2", # required by setuptools>=77 to validate PEP 639 license expressions
"pyyaml",
"requests",
"six", # dependency chain: NNPACK -> PeachPy -> six
"typing-extensions>=4.15.0",
"pip", # not technically needed, but this makes setup.py invocation work
# This list should be kept in sync with the requirements.txt in
# PyTorch root until the project fully migrates to pyproject.toml
"build[uv]", # for building sdist and wheel
"expecttest>=0.3.0",
"filelock",
"fsspec>=0.8.5",
"hypothesis",
"jinja2",
"lintrunner ; platform_machine != \"s390x\"",
"networkx>=2.5.1",
"optree>=0.13.0",
"psutil",
"spin",
"sympy>=1.13.3",
"wheel"
]
[project]
name = "torch"
description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration"
readme = "README.md"
requires-python = ">=3.10"
# License info:
# - The main Pytorch project license is BSD-3-Clause.
# - The SPDX license expression below reflects installed pytorch packages.
license = "Apache-2.0 AND Apache-2.0 WITH LLVM-exception AND BSD-2-Clause AND BSD-3-Clause AND BSL-1.0 AND MIT"
license-files = [
"LICENSE",
"third_party/**/LICENSE",
"third_party/**/LICENSE.txt",
"third_party/**/LICENSE.rst",
]
authors = [{ name = "PyTorch Team", email = "packages@pytorch.org" }]
keywords = ["pytorch", "machine learning"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"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 :: C++",
"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",
"Programming Language :: Python :: 3.15",
]
dynamic = ["version", "dependencies"]
[project.scripts]
torchrun = "torch.distributed.run:main"
torchfrtrace = "torch.distributed.flight_recorder.fr_trace:main"
[project.entry-points."torchrun.logs_specs"]
default = "torch.distributed.elastic.multiprocessing:DefaultLogsSpecs"
[project.entry-points."torch.distributed.backends"]
mpi = "torch.distributed.distributed_c10d:_register_builtin_mpi_backend"
gloo = "torch.distributed.distributed_c10d:_register_builtin_gloo_backend"
nccl = "torch.distributed.distributed_c10d:_register_builtin_nccl_backend"
nccl2 = "torch.distributed.distributed_c10d:_register_builtin_nccl2_backend"
"nccl-lazy" = "torch.distributed.distributed_c10d:_register_builtin_nccl_lazy_backend"
ucc = "torch.distributed.distributed_c10d:_register_builtin_ucc_backend"
xccl = "torch.distributed.distributed_c10d:_register_builtin_xccl_backend"
[project.urls]
Homepage = "https://pytorch.org"
Repository = "https://github.com/pytorch/pytorch"
Documentation = "https://pytorch.org/docs"
"Issue Tracker" = "https://github.com/pytorch/pytorch/issues"
Forum = "https://discuss.pytorch.org"
[project.optional-dependencies]
optree = ["optree>=0.13.0"]
opt-einsum = ["opt-einsum>=3.3"]
pyyaml = ["pyyaml"]
# Linter tools #################################################################
[tool.isort]
src_paths = ["caffe2", "torch", "torchgen", "functorch", "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 = ["caffe2", "torch", "torchgen", "functorch", "test"]
standard_library = ["typing_extensions"]
[tool.ruff]
line-length = 88
src = ["caffe2", "torch", "torchgen", "functorch", "test"]
extend-exclude = ["third_party", "test/cpython"]
[tool.ruff.per-file-target-version]
"**/py312_intrinsics.py" = "py312"
[tool.ruff.format]
docstring-code-format = true
quote-style = "double"
[tool.ruff.lint]
# NOTE: Synchronize the ignores with .flake8
external = [
# lintrunner grep-linter codes (see .lintrunner.toml) suppressed via `# noqa:`.
"ISINSTANCE_FAKE_TENSOR",
# Codes from flake8-only plugins that ruff doesn't implement.
"P201",
"P204",
"T484",
# Codes that are preview-only in ruff, so flake8 is still the enforcer.
# As ruff promotes these out of preview, move them to flake8's ignore list.
"B901",
"B909",
"E115",
"E201",
"E221",
"E225",
"E226",
"E227",
"E231",
"E241",
"E261",
"E262",
"E265",
"E266",
"E272",
"E306",
]
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",
# 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__`
"RUF100", # unused noqa
"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]
"__init__.py" = [
"F401",
]
"*.pyi" = [
"PYI011", # typed-argument-default-in-stub
"PYI021", # docstring-in-stub
"PYI053", # string-or-bytes-too-long
]
"functorch/docs/source/tutorials/**" = [
"F401",
]
"test/export/**" = [
"PGH004",
]
"test/typing/**" = [
"PGH004"
]
"test/typing/reveal/**" = [
"F821",
]
"test/torch_np/numpy_tests/**" = [
"F821",
"NPY201",
]
"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/inductor/s429861_repro.py" = [
"PGH004",
]
"test/inductor/test_torchinductor.py" = [
"UP037",
]
# autogenerated #TODO figure out why file level noqa is ignored
"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/_inductor/codegen/**" = [
"PGH004"
]
"torchgen/api/types/__init__.py" = [
"F401",
"F403",
]
"torch/utils/collect_env.py" = [
"UP", # collect_env.py needs to work with older versions of Python
]
"torch/_vendor/**" = [
"UP", # No need to mess with _vendor
]
"tools/linter/**" = [
"LOG015" # please fix
]
[tool.codespell]
ignore-words = "tools/linter/dictionary.txt"
[tool.spin]
package = 'torch'
[tool.spin.commands]
"Build" = [
".spin/cmds.py:develop",
".spin/cmds.py:editable",
".spin/cmds.py:install",
".spin/cmds.py:clean",
".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",
]
"Documentation" = [
".spin/cmds.py:docs",
]
"Type" = [
".spin/cmds.py:pyrefly",
]