pytorch
/
.lintrunner.toml
1675 строк · 52.8 Кб
1[[linter]]2code = 'FLAKE8'3include_patterns = ['**/*.py']4exclude_patterns = [5'.git/**',6'build_test_custom_build/**',7'build/**',8'caffe2/**',9'docs/caffe2/**',10'docs/cpp/src/**',11'docs/src/**',12'fb/**',13'**/fb/**',14'functorch/docs/**',15'functorch/examples/**',16'functorch/notebooks/**',17'torch/_inductor/fx_passes/serialized_patterns/**',18'torch/_inductor/autoheuristic/artifacts/**',19'scripts/**',20'test/generated_type_hints_smoketest.py',21# Tests from the NumPy test suite22'test/torch_np/numpy_test/**/*.py',23'third_party/**',24'torch/include/**',25'torch/lib/**',26'venv/**',27'**/*.pyi',28'tools/test/test_selective_build.py',29]
30command = [31'python3',32'tools/linter/adapters/flake8_linter.py',33'--',34'@{{PATHSFILE}}'35]
36init_command = [37'python3',38'tools/linter/adapters/pip_init.py',39'--dry-run={{DRYRUN}}',40'flake8==6.1.0',41'flake8-bugbear==23.3.23',42'flake8-comprehensions==3.15.0',43'flake8-executable==2.1.3',44'flake8-logging-format==0.9.0',45'flake8-pyi==23.3.1',46'flake8-simplify==0.19.3',47'mccabe==0.7.0',48'pycodestyle==2.11.1',49'pyflakes==3.1.0',50'torchfix==0.4.0 ; python_version >= "3.9"',51]
52
53
54[[linter]]55code = 'CLANGFORMAT'56include_patterns = [57'aten/src/ATen/*.h',58'aten/src/ATen/mps/**/*.mm',59'aten/src/ATen/xpu/**/*.h',60'aten/src/ATen/xpu/**/*.cpp',61'aten/src/ATen/native/mps/**/*.mm',62'aten/src/ATen/native/vulkan/**/*.h',63'aten/src/ATen/native/vulkan/**/*.cpp',64'aten/src/ATen/native/cuda/MultiTensorApply.cuh',65'aten/src/ATen/native/**/Foreach*.*',66'aten/src/ATen/native/cuda/fused*.*',67'aten/src/ATen/native/cuda/Fused*.cu',68'aten/src/ATen/native/cudnn/*.h',69'aten/src/ATen/native/cudnn/*.cpp',70'c10/**/*.h',71'c10/**/*.cpp',72'distributed/c10d/*DMAConnectivity.*',73'distributed/c10d/*SymmetricMemory.*',74'torch/csrc/**/*.h',75'torch/csrc/**/*.hpp',76'torch/csrc/**/*.cpp',77'test/cpp/**/*.h',78'test/cpp/**/*.cpp',79]
80exclude_patterns = [81'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',82'c10/util/strong_type.h',83'**/fb/**',84'torch/csrc/inductor/aoti_torch/generated/**',85'torch/csrc/jit/serialization/mobile_bytecode_generated.h',86'torch/csrc/utils/pythoncapi_compat.h',87'aten/src/ATen/dlpack.h',88]
89init_command = [90'python3',91'tools/linter/adapters/s3_init.py',92'--config-json=tools/linter/adapters/s3_init_config.json',93'--linter=clang-format',94'--dry-run={{DRYRUN}}',95'--output-dir=.lintbin',96'--output-name=clang-format',97]
98command = [99'python3',100'tools/linter/adapters/clangformat_linter.py',101'--binary=.lintbin/clang-format',102'--',103'@{{PATHSFILE}}'104]
105is_formatter = true106
107[[linter]]108code = 'MYPY'109include_patterns = [110'torch/**/*.py',111'torch/**/*.pyi',112'caffe2/**/*.py',113'caffe2/**/*.pyi',114'test/test_bundled_images.py',115'test/test_bundled_inputs.py',116'test/test_complex.py',117'test/test_datapipe.py',118'test/test_futures.py',119# 'test/test_numpy_interop.py',120'test/test_torch.py',121'test/test_type_hints.py',122'test/test_type_info.py',123'test/test_utils.py',124]
125exclude_patterns = [126'**/fb/**',127]
128command = [129'python3',130'tools/linter/adapters/mypy_linter.py',131'--config=mypy.ini',132'--',133'@{{PATHSFILE}}'134]
135init_command = [136'python3',137'tools/linter/adapters/pip_init.py',138'--dry-run={{DRYRUN}}',139'numpy==1.24.3 ; python_version == "3.8"',140'numpy==1.26.0 ; python_version >= "3.9"',141'expecttest==0.1.6',142'mypy==1.10.0',143'sympy==1.12.1 ; python_version == "3.8"',144'sympy==1.13.0 ; python_version >= "3.9"',145'types-requests==2.27.25',146'types-PyYAML==6.0.7',147'types-tabulate==0.8.8',148'types-protobuf==3.19.18',149'types-pkg-resources==0.1.3',150'types-Jinja2==2.11.9',151'types-colorama==0.4.6',152'filelock==3.13.1',153'junitparser==2.1.1',154'rich==10.9.0',155'pyyaml==6.0.1',156'optree==0.12.1',157]
158
159[[linter]]160code = 'MYPYSTRICT'161include_patterns = [162'.github/**/*.py',163'benchmarks/instruction_counts/**/*.py',164'tools/**/*.py',165'torchgen/**/*.py',166'torch/utils/_pytree.py',167'torch/utils/_cxx_pytree.py',168'torch/utils/benchmark/utils/common.py',169'torch/utils/benchmark/utils/timer.py',170'torch/utils/benchmark/utils/valgrind_wrapper/**/*.py',171]
172exclude_patterns = [173# (linbinyu) copied from internal repo174'**/fb/**',175'tools/code_analyzer/gen_operators_yaml.py',176'tools/dynamo/verify_dynamo.py',177'tools/gen_vulkan_spv.py',178'tools/test/gen_operators_yaml_test.py',179'tools/test/gen_oplist_test.py',180'tools/test/test_selective_build.py',181]
182command = [183'python3',184'tools/linter/adapters/mypy_linter.py',185'--config=mypy-strict.ini',186'--code=MYPYSTRICT',187'--',188'@{{PATHSFILE}}'189]
190
191[[linter]]192code = 'CLANGTIDY'193include_patterns = [194# Enable coverage of headers in aten/src/ATen195# and excluding most sub-directories for now.196'aten/src/ATen/*.h',197'aten/src/ATen/*.cpp',198'aten/src/ATen/cpu/*.h',199'aten/src/ATen/cpu/*.cpp',200'aten/src/ATen/core/*.h',201'aten/src/ATen/core/*.cpp',202'aten/src/ATen/cudnn/*.h',203'aten/src/ATen/cudnn/*.cpp',204'aten/src/ATen/detail/*',205'aten/src/ATen/functorch/*.h',206'aten/src/ATen/functorch/*.cpp',207'aten/src/ATen/native/nested/cuda/*.cpp',208'aten/src/ATen/native/nested/cuda/*.h',209'aten/src/ATen/native/nested/*.cpp',210'aten/src/ATen/native/nested/*.h',211'c10/**/*.cpp',212'c10/**/*.h',213'torch/*.h',214'torch/csrc/*.h',215'torch/csrc/*.cpp',216'torch/csrc/**/*.h',217'torch/csrc/**/*.cpp',218'torch/csrc/jit/serialization/*.h',219'torch/csrc/jit/serialization/*.cpp',220]
221exclude_patterns = [222# The negative filters below are to exclude files that include onnx_pb.h or223# caffe2_pb.h, otherwise we'd have to build protos as part of this CI job.224# CUDA files are also excluded.225'**/fb/**',226'**/*pb.h',227'aten/**/cuda/*pp',228'c10/xpu/**/*.h',229'c10/xpu/**/*.cpp',230'c10/cuda/CUDAAlgorithm.h',231'c10/util/complex_math.h',232'c10/util/complex_utils.h',233'c10/util/flat_hash_map.h',234'c10/util/logging*.h',235'c10/util/hash.h',236'c10/util/strong_type.h',237'c10/util/SmallVector.h',238'c10/util/win32-headers.h',239'c10/util/*inl.h',240'c10/test/**/*.h',241'third_party/**/*',242'torch/csrc/api/**',243'torch/csrc/autograd/generated/**',244'torch/csrc/distributed/**/*',245'torch/csrc/dynamo/eval_frame.h',246'torch/csrc/inductor/aoti_torch/c/shim.h',247'torch/csrc/jit/**/*',248'torch/csrc/jit/serialization/mobile_bytecode_generated.h',249'torch/csrc/lazy/**/*',250]
251init_command = [252'python3',253'tools/linter/adapters/s3_init.py',254'--config-json=tools/linter/adapters/s3_init_config.json',255'--linter=clang-tidy',256'--dry-run={{DRYRUN}}',257'--output-dir=.lintbin',258'--output-name=clang-tidy',259]
260command = [261'python3',262'tools/linter/adapters/clangtidy_linter.py',263'--binary=.lintbin/clang-tidy',264'--build_dir=./build',265'--',266'@{{PATHSFILE}}'267]
268
269[[linter]]270code = 'TYPEIGNORE'271include_patterns = ['**/*.py', '**/*.pyi']272exclude_patterns = [273'fb/**',274'**/fb/**',275'test/test_jit.py',276]
277command = [278'python3',279'tools/linter/adapters/grep_linter.py',280'--pattern=# type:\s*ignore([^\[]|$)',281'--linter-name=TYPEIGNORE',282'--error-name=unqualified type: ignore',283"""--error-description=\284This line has an unqualified `type: ignore`; \
285please convert it to `type: ignore[xxxx]`\
286""",287'--',288'@{{PATHSFILE}}'289]
290
291[[linter]]292code = 'TYPENOSKIP'293include_patterns = ['mypy.ini']294command = [295'python3',296'tools/linter/adapters/grep_linter.py',297'--pattern=follow_imports\s*=\s*skip',298'--linter-name=TYPENOSKIP',299'--error-name=use of follow_imports = skip',300"""--error-description=\301follow_imports = skip is forbidden from mypy.ini configuration as it \
302is extremely easy to accidentally turn off type checking unintentionally. If \
303you need to suppress type errors, use a top level # mypy: ignore-errors. \
304Do not rely on automatic Any substitution; instead, manually # type: ignore \
305at use sites or define a pyi type stub with more relaxed types. \
306""",307'--',308'@{{PATHSFILE}}'309]
310
311[[linter]]312code = 'NOQA'313include_patterns = ['**/*.py', '**/*.pyi']314exclude_patterns = [315'caffe2/**',316'fb/**',317'**/fb/**'318]319command = [320'python3',321'tools/linter/adapters/grep_linter.py',322'--pattern=# noqa([^:]|$)',323'--linter-name=NOQA',324'--error-name=unqualified noqa',325"""--error-description=\326This line has an unqualified `noqa`; \
327please convert it to `noqa: XXXX`\
328""",329'--',330'@{{PATHSFILE}}'331]
332
333[[linter]]334code = 'NATIVEFUNCTIONS'335include_patterns=['aten/src/ATen/native/native_functions.yaml']336command = [337'python3',338'tools/linter/adapters/nativefunctions_linter.py',339'--native-functions-yml=aten/src/ATen/native/native_functions.yaml',340]
341init_command = [342'python3',343'tools/linter/adapters/pip_init.py',344'--dry-run={{DRYRUN}}',345'ruamel.yaml==0.17.4',346]
347is_formatter = true348
349[[linter]]350code = 'NEWLINE'351include_patterns=['**']352exclude_patterns=[353'**/contrib/**',354'third_party/**',355'**/*.bat',356'**/*.expect',357'**/*.ipynb',358'**/*.ps1',359'**/*.ptl',360'fb/**',361'**/fb/**',362'tools/clang_format_hash/**',363'test/cpp/jit/upgrader_models/*.ptl',364'test/cpp/jit/upgrader_models/*.ptl.ff',365'**/*.png',366'**/*.gz',367]
368command = [369'python3',370'tools/linter/adapters/newlines_linter.py',371'--',372'@{{PATHSFILE}}',373]
374is_formatter = true375
376[[linter]]377code = 'CONSTEXPR'378include_patterns=['aten/src/ATen/native/cuda/*.cu']379command = [380'python3',381'tools/linter/adapters/constexpr_linter.py',382'--',383'@{{PATHSFILE}}',384]
385is_formatter = true386
387[[linter]]388code = 'SPACES'389include_patterns = ['**']390exclude_patterns = [391'**/contrib/**',392'**/*.diff',393'**/*.patch',394'third_party/**',395'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',396'fb/**',397'**/fb/**',398'test/cpp/jit/upgrader_models/*.ptl',399'test/cpp/jit/upgrader_models/*.ptl.ff',400]
401command = [402'python3',403'tools/linter/adapters/grep_linter.py',404'--pattern=[[:blank:]]$',405'--linter-name=SPACES',406'--error-name=trailing spaces',407'--replace-pattern=s/[[:blank:]]+$//',408"""--error-description=\409This line has trailing spaces; please remove them.\
410""",411'--',412'@{{PATHSFILE}}'413]
414
415[[linter]]416code = 'TABS'417include_patterns = ['**']418exclude_patterns = [419'**/*.svg',420'**/*Makefile',421'**/contrib/**',422'third_party/**',423'**/.gitattributes',424'**/.gitmodules',425'fb/**',426'**/fb/**',427'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',428'test/cpp/jit/upgrader_models/*.ptl',429'test/cpp/jit/upgrader_models/*.ptl.ff',430'.ci/docker/common/install_rocm_drm.sh',431'.lintrunner.toml',432]
433command = [434'python3',435'tools/linter/adapters/grep_linter.py',436# @lint-ignore TXT2437'--pattern= ',438'--linter-name=TABS',439'--error-name=saw some tabs',440'--replace-pattern=s/\t/ /',441"""--error-description=\442This line has tabs; please replace them with spaces.\
443""",444'--',445'@{{PATHSFILE}}'446]
447
448[[linter]]449code = 'INCLUDE'450include_patterns = [451'c10/**',452'aten/**',453'torch/csrc/**',454]
455exclude_patterns = [456'aten/src/ATen/native/quantized/cpu/qnnpack/**',457'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',458'aten/src/ATen/native/vulkan/glsl/**',459'**/fb/**',460'torch/csrc/jit/serialization/mobile_bytecode_generated.h',461'torch/csrc/utils/pythoncapi_compat.h',462]
463command = [464'python3',465'tools/linter/adapters/grep_linter.py',466'--pattern=#include "',467'--linter-name=INCLUDE',468'--error-name=quoted include',469'--replace-pattern=s/#include "(.*)"$/#include <\1>/',470"""--error-description=\471This #include uses quotes; please convert it to #include <xxxx>\
472""",473'--',474'@{{PATHSFILE}}'475]
476
477[[linter]]478code = 'PYBIND11_INCLUDE'479include_patterns = [480'**/*.cpp',481'**/*.h',482]
483exclude_patterns = [484'torch/csrc/utils/pybind.h',485'torch/utils/benchmark/utils/valgrind_wrapper/compat_bindings.cpp',486'caffe2/**/*',487]
488command = [489'python3',490'tools/linter/adapters/grep_linter.py',491'--pattern=#include <pybind11\/',492'--allowlist-pattern=#include <torch\/csrc\/utils\/pybind.h>',493'--linter-name=PYBIND11_INCLUDE',494'--match-first-only',495'--error-name=direct include of pybind11',496# https://stackoverflow.com/a/33416489/23845497# NB: this won't work if the pybind11 include is on the first line;498# but that's fine because it will just mean the lint will still fail499# after applying the change and you will have to fix it manually500'--replace-pattern=1,/(#include <pybind11\/)/ s/(#include <pybind11\/)/#include <torch\/csrc\/utils\/pybind.h>\n\1/',501"""--error-description=\502This #include directly includes pybind11 without also including \
503#include <torch/csrc/utils/pybind.h>; this means some important \
504specializations may not be included.\
505""",506'--',507'@{{PATHSFILE}}'508]
509
510[[linter]]511code = 'ERROR_PRONE_ISINSTANCE'512include_patterns = [513'torch/_refs/**/*.py',514'torch/_prims/**/*.py',515'torch/_prims_common/**/*.py',516'torch/_decomp/**/*.py',517'torch/_meta_registrations.py',518]
519exclude_patterns = [520'**/fb/**',521]
522command = [523'python3',524'tools/linter/adapters/grep_linter.py',525'--pattern=isinstance\([^)]+(int|float)\)',526'--linter-name=ERROR_PRONE_ISINSTANCE',527'--error-name=error prone isinstance',528"""--error-description=\529This line has an isinstance call that directly refers to \
530int or float. This is error-prone because you may also \
531have wanted to allow SymInt or SymFloat in your test. \
532To suppress this lint, use an appropriate type alias defined \
533in torch._prims_common; use IntLike/FloatLike when you would accept \
534both regular and symbolic numbers, Dim for ints representing \
535dimensions, or IntWithoutSymInt/FloatWithoutSymFloat if you really \
536meant to exclude symbolic numbers.
537""",538'--',539'@{{PATHSFILE}}'540]
541
542[[linter]]543code = 'PYBIND11_SPECIALIZATION'544include_patterns = [545'**/*.cpp',546'**/*.h',547]
548exclude_patterns = [549# The place for all orphan specializations550'torch/csrc/utils/pybind.h',551# These specializations are non-orphan552'torch/csrc/distributed/c10d/init.cpp',553'torch/csrc/jit/python/pybind.h',554'fb/**',555'**/fb/**',556# These are safe to exclude as they do not have Python557'c10/**/*',558]
559command = [560'python3',561'tools/linter/adapters/grep_linter.py',562'--pattern=PYBIND11_DECLARE_HOLDER_TYPE',563'--linter-name=PYBIND11_SPECIALIZATION',564'--error-name=pybind11 specialization in non-standard location',565"""--error-description=\566This pybind11 specialization (PYBIND11_DECLARE_HOLDER_TYPE) should \
567be placed in torch/csrc/utils/pybind.h so that it is guaranteed to be \
568included at any site that may potentially make use of it via py::cast. \
569If your specialization is in the same header file as the definition \
570of the holder type, you can ignore this lint by adding your header to \
571the exclude_patterns for this lint in .lintrunner.toml. For more \
572information see https://github.com/pybind/pybind11/issues/4099 \
573""",574'--',575'@{{PATHSFILE}}'576]
577
578[[linter]]579code = 'PYPIDEP'580include_patterns = ['.github/**']581exclude_patterns = [582'**/*.rst',583'**/*.py',584'**/*.md',585'**/*.diff',586'**/fb/**',587]
588command = [589'python3',590'tools/linter/adapters/grep_linter.py',591"""--pattern=\592(pip|pip3|python -m pip|python3 -m pip|python3 -mpip|python -mpip) \
593install ([a-zA-Z0-9][A-Za-z0-9\\._\\-]+)([^/=<>~!]+)[A-Za-z0-9\\._\\-\\*\\+\\!]*$\
594""",595'--linter-name=PYPIDEP',596'--error-name=unpinned PyPI install',597"""--error-description=\598This line has unpinned PyPi installs; \
599please pin them to a specific version: e.g. 'thepackage==1.2'\
600""",601'--',602'@{{PATHSFILE}}'603]
604
605[[linter]]606code = 'EXEC'607include_patterns = ['**']608exclude_patterns = [609'third_party/**',610'torch/bin/**',611'**/*.so',612'**/*.py',613'**/*.sh',614'**/*.bash',615'**/git-pre-commit',616'**/git-clang-format',617'**/gradlew',618'fb/**',619'**/fb/**',620]
621command = [622'python3',623'tools/linter/adapters/exec_linter.py',624'--',625'@{{PATHSFILE}}',626]
627
628[[linter]]629code = 'CUBINCLUDE'630include_patterns = ['aten/**']631exclude_patterns = [632'aten/src/ATen/cuda/cub*.cuh',633'**/fb/**',634]
635command = [636'python3',637'tools/linter/adapters/grep_linter.py',638'--pattern=#include <cub/',639'--linter-name=CUBINCLUDE',640'--error-name=direct cub include',641"""--error-description=\642This line has a direct cub include; please include \
643ATen/cuda/cub.cuh instead and wrap your cub calls in \
644at::native namespace if necessary.
645""",646'--',647'@{{PATHSFILE}}'648]
649
650[[linter]]651code = 'RAWCUDA'652include_patterns = [653'aten/**',654'c10/**',655]
656exclude_patterns = [657'aten/src/ATen/test/**',658'c10/cuda/CUDAFunctions.h',659'c10/cuda/CUDACachingAllocator.cpp',660'**/fb/**',661]
662command = [663'python3',664'tools/linter/adapters/grep_linter.py',665'--pattern=cudaStreamSynchronize',666'--linter-name=RAWCUDA',667'--error-name=raw CUDA API usage',668"""--error-description=\669This line calls raw CUDA APIs directly; please use at::cuda wrappers instead.
670""",671'--',672'@{{PATHSFILE}}'673]
674
675[[linter]]676code = 'RAWCUDADEVICE'677include_patterns = [678'aten/**',679'c10/**',680'torch/csrc/**',681]
682exclude_patterns = [683'aten/src/ATen/cuda/CUDAContext.cpp',684'aten/src/ATen/cuda/CUDAGeneratorImpl.cpp',685'aten/src/ATen/test/**',686'c10/core/impl/InlineDeviceGuard.h',687'c10/cuda/CUDAFunctions.cpp',688'c10/cuda/CUDAGuard.h',689'c10/cuda/impl/CUDATest.cpp',690'torch/csrc/cuda/nccl.cpp',691'**/fb/**',692]
693command = [694'python3',695'tools/linter/adapters/grep_linter.py',696'--pattern=cudaSetDevice(',697'--pattern=cudaGetDevice(',698'--linter-name=RAWCUDADEVICE',699'--error-name=raw CUDA API usage',700"""--error-description=\701This line calls raw CUDA APIs directly; please use c10::cuda wrappers instead.
702""",703'--',704'@{{PATHSFILE}}'705]
706
707[[linter]]708code = 'ROOT_LOGGING'709include_patterns = [710'**/*.py',711]
712# These are not library code, but scripts in their own right, and so
713# therefore are permitted to use logging
714exclude_patterns = [715'tools/**',716'test/**',717'benchmarks/**',718'torch/distributed/run.py',719'functorch/benchmarks/**',720# Grandfathered in721'caffe2/**',722'fb/**',723'**/fb/**',724]
725command = [726'python3',727'tools/linter/adapters/grep_linter.py',728'--pattern=logging\.(debug|info|warn|warning|error|critical|log|exception)\(',729'--replace-pattern=s/logging\.(debug|info|warn|warning|error|critical|log|exception)\(/log.\1(/',730'--linter-name=ROOT_LOGGING',731'--error-name=use of root logger',732"""--error-description=\733Do not use root logger (logging.info, etc) directly; instead \
734define 'log = logging.getLogger(__name__)' and call, e.g., log.info().
735""",736'--',737'@{{PATHSFILE}}'738]
739
740[[linter]]741code = 'DEPLOY_DETECTION'742include_patterns = [743'**/*.py',744]
745command = [746'python3',747'tools/linter/adapters/grep_linter.py',748'--pattern=sys\.executable == .torch_deploy.',749'--replace-pattern=s/sys\.executable == .torch_deploy./torch._running_with_deploy\(\)/',750'--linter-name=DEPLOY_DETECTION',751'--error-name=properly detect deploy runner',752"""--error-description=\753Do not use sys.executable to detect if running within deploy/multipy, use torch._running_with_deploy().
754""",755'--',756'@{{PATHSFILE}}'757]
758
759[[linter]]760code = 'CMAKE'761include_patterns = [762"**/*.cmake",763"**/*.cmake.in",764"**/CMakeLists.txt",765]
766exclude_patterns = [767'cmake/Modules/**',768'cmake/Modules_CUDA_fix/**',769'cmake/Caffe2Config.cmake.in',770'aten/src/ATen/ATenConfig.cmake.in',771'cmake/TorchConfig.cmake.in',772'cmake/TorchConfigVersion.cmake.in',773'cmake/cmake_uninstall.cmake.i',774'fb/**',775'**/fb/**',776]
777command = [778'python3',779'tools/linter/adapters/cmake_linter.py',780'--config=.cmakelintrc',781'--',782'@{{PATHSFILE}}',783]
784init_command = [785'python3',786'tools/linter/adapters/pip_init.py',787'--dry-run={{DRYRUN}}',788'cmakelint==1.4.1',789]
790
791[[linter]]792code = 'SHELLCHECK'793include_patterns = [794'.ci/pytorch/**/*.sh'795]
796exclude_patterns = [797'**/fb/**',798]
799command = [800'python3',801'tools/linter/adapters/shellcheck_linter.py',802'--',803'@{{PATHSFILE}}',804]
805init_command = [806'python3',807'tools/linter/adapters/pip_init.py',808'--dry-run={{DRYRUN}}',809'shellcheck-py==0.7.2.1',810]
811
812[[linter]]813code = 'ACTIONLINT'814include_patterns = [815'.github/workflows/*.yml',816'.github/workflows/*.yaml',817# actionlint does not support composite actions yet818# '.github/actions/**/*.yml',819# '.github/actions/**/*.yaml',820]
821exclude_patterns = [822'**/fb/**',823]
824command = [825'python3',826'tools/linter/adapters/actionlint_linter.py',827'--binary=.lintbin/actionlint',828'--',829'@{{PATHSFILE}}',830]
831init_command = [832'python3',833'tools/linter/adapters/s3_init.py',834'--config-json=tools/linter/adapters/s3_init_config.json',835'--linter=actionlint',836'--dry-run={{DRYRUN}}',837'--output-dir=.lintbin',838'--output-name=actionlint',839]
840
841[[linter]]842code = 'TESTOWNERS'843include_patterns = [844'test/**/test_*.py',845'test/**/*_test.py',846]
847exclude_patterns = [848'test/run_test.py',849'**/fb/**',850]
851command = [852'python3',853'tools/linter/adapters/testowners_linter.py',854'--',855'@{{PATHSFILE}}',856]
857
858[[linter]]859code = 'TEST_HAS_MAIN'860include_patterns = [861'test/**/test_*.py',862]
863exclude_patterns = [864'test/run_test.py',865'**/fb/**',866'test/quantization/**', # should be run through test/test_quantization.py867'test/jit/**', # should be run through test/test_jit.py868'test/ao/sparsity/**', # should be run through test/test_ao_sparsity.py869'test/fx/**', # should be run through test/test_fx.py870'test/bottleneck_test/**', # excluded by test/run_test.py871'test/package/**', # excluded by test/run_test.py872'test/distributed/argparse_util_test.py',873'test/distributed/bin/test_script.py',874'test/distributed/elastic/agent/server/test/local_elastic_agent_test.py',875'test/distributed/elastic/multiprocessing/bin/test_script.py',876'test/distributed/elastic/multiprocessing/bin/zombie_test.py',877'test/distributed/elastic/multiprocessing/errors/api_test.py',878'test/distributed/elastic/multiprocessing/errors/error_handler_test.py',879'test/distributed/elastic/multiprocessing/redirects_test.py',880'test/distributed/elastic/multiprocessing/tail_log_test.py',881'test/distributed/elastic/rendezvous/api_test.py',882'test/distributed/elastic/rendezvous/c10d_rendezvous_backend_test.py',883'test/distributed/elastic/rendezvous/dynamic_rendezvous_test.py',884'test/distributed/elastic/rendezvous/etcd_rendezvous_backend_test.py',885'test/distributed/elastic/rendezvous/etcd_rendezvous_test.py',886'test/distributed/elastic/rendezvous/etcd_server_test.py',887'test/distributed/elastic/rendezvous/rendezvous_backend_test.py',888'test/distributed/elastic/rendezvous/static_rendezvous_test.py',889'test/distributed/elastic/rendezvous/utils_test.py',890'test/distributed/elastic/timer/api_test.py',891'test/distributed/elastic/utils/data/cycling_iterator_test.py',892'test/distributed/launcher/api_test.py',893'test/distributed/launcher/bin/test_script.py',894'test/distributed/launcher/bin/test_script_init_method.py',895'test/distributed/launcher/bin/test_script_is_torchelastic_launched.py',896'test/distributed/launcher/bin/test_script_local_rank.py',897'test/distributed/launcher/launch_test.py',898'test/distributed/launcher/run_test.py',899'test/distributed/optim/test_apply_optimizer_in_backward.py',900'test/distributed/optim/test_named_optimizer.py',901'test/distributed/test_c10d_spawn.py',902'test/distributed/test_collective_utils.py',903'test/distributions/test_distributions.py',904'test/inductor/test_aot_inductor_utils.py',905'test/lazy/test_bindings.py',906'test/lazy/test_extract_compiled_graph.py',907'test/lazy/test_meta_kernel.py',908'test/nn/test_init.py',909'test/onnx/model_defs/op_test.py',910'test/onnx/test_models_quantized_onnxruntime.py',911'test/onnx/test_onnxscript_no_runtime.py',912'test/onnx_caffe2/test_caffe2_common.py',913'test/optim/test_lrscheduler.py',914'test/optim/test_optim.py',915'test/optim/test_swa_utils.py',916'test/run_test.py',917'test/test_bundled_images.py',918'test/test_cuda_expandable_segments.py',919'test/test_hub.py',920]
921command = [922'python3',923'tools/linter/adapters/test_has_main_linter.py',924'--',925'@{{PATHSFILE}}',926]
927
928[[linter]]929code = 'CALL_ONCE'930include_patterns = [931'c10/**',932'aten/**',933'torch/csrc/**',934]
935exclude_patterns = [936'c10/util/CallOnce.h',937'**/fb/**',938]
939command = [940'python3',941'tools/linter/adapters/grep_linter.py',942'--pattern=std::call_once',943'--linter-name=CALL_ONCE',944'--error-name=invalid call_once',945'--replace-pattern=s/std::call_once/c10::call_once/',946"""--error-description=\947Use of std::call_once is forbidden and should be replaced with c10::call_once\
948""",949'--',950'@{{PATHSFILE}}'951]
952
953[[linter]]954code = 'CONTEXT_DECORATOR'955include_patterns = [956'torch/**',957]
958command = [959'python3',960'tools/linter/adapters/grep_linter.py',961'--pattern=@.*(dynamo_timed|preserve_rng_state|clear_frame|with_fresh_cache_if_config|use_lazy_graph_module|_disable_current_modes)',962'--linter-name=CONTEXT_DECORATOR',963'--error-name=avoid context decorator',964"""--error-description=\965Do not use context manager as decorator as it breaks cProfile traces. Use it as \
966a context manager instead\
967""",968'--',969'@{{PATHSFILE}}'970]
971
972[[linter]]973code = 'ONCE_FLAG'974include_patterns = [975'c10/**',976'aten/**',977'torch/csrc/**',978]
979exclude_patterns = [980'**/fb/**',981]
982command = [983'python3',984'tools/linter/adapters/grep_linter.py',985'--pattern=std::once_flag',986'--linter-name=ONCE_FLAG',987'--error-name=invalid once_flag',988'--replace-pattern=s/std::once_flag/c10::once_flag/',989"""--error-description=\990Use of std::once_flag is forbidden and should be replaced with c10::once_flag\
991""",992'--',993'@{{PATHSFILE}}'994]
995
996[[linter]]997code = 'WORKFLOWSYNC'998include_patterns = [999'.github/workflows/pull.yml',1000'.github/workflows/trunk.yml',1001'.github/workflows/periodic.yml',1002'.github/workflows/mac-mps.yml',1003'.github/workflows/slow.yml',1004]
1005command = [1006'python3',1007'tools/linter/adapters/workflow_consistency_linter.py',1008'--',1009'@{{PATHSFILE}}'1010]
1011init_command = [1012'python3',1013'tools/linter/adapters/pip_init.py',1014'--dry-run={{DRYRUN}}',1015'PyYAML==6.0.1',1016]
1017
1018# usort + ruff-format
1019[[linter]]1020code = 'PYFMT'1021include_patterns = [1022'**/*.py',1023'**/*.pyi',1024]
1025command = [1026'python3',1027'tools/linter/adapters/pyfmt_linter.py',1028'--',1029'@{{PATHSFILE}}'1030]
1031exclude_patterns = [1032'tools/gen_vulkan_spv.py',1033# We don't care too much about files in this directory, don't enforce1034# formatting on them1035'caffe2/**/*.py',1036'caffe2/**/*.pyi',1037'fb/**',1038'**/fb/**',1039'third_party/**/*.py',1040'third_party/**/*.pyi',1041'torch/_inductor/fx_passes/serialized_patterns/**',1042'torch/_inductor/autoheuristic/artifacts/**',1043# These files are all grandfathered in, feel free to remove from this list1044# as necessary1045'test/_nvfuser/__init__.py',1046'test/_nvfuser/test_dynamo.py',1047'test/_nvfuser/test_python_frontend.py',1048'test/_nvfuser/test_torchscript.py',1049'test/delete.py',1050'test/expect/__init__.py',1051'test/quantization/__init__.py',1052'test/quantization/core/__init__.py',1053'test/quantization/core/experimental/apot_fx_graph_mode_ptq.py',1054'test/quantization/core/experimental/apot_fx_graph_mode_qat.py',1055'test/quantization/core/experimental/quantization_util.py',1056'test/quantization/core/experimental/test_bits.py',1057'test/quantization/core/experimental/test_fake_quantize.py',1058'test/quantization/core/experimental/test_linear.py',1059'test/quantization/core/experimental/test_nonuniform_observer.py',1060'test/quantization/core/experimental/test_quantized_tensor.py',1061'test/quantization/core/experimental/test_quantizer.py',1062'test/quantization/core/test_backend_config.py',1063'test/quantization/core/test_docs.py',1064'test/quantization/core/test_quantized_functional.py',1065'test/quantization/core/test_quantized_module.py',1066'test/quantization/core/test_quantized_op.py',1067'test/quantization/core/test_quantized_tensor.py',1068'test/quantization/core/test_top_level_apis.py',1069'test/quantization/core/test_utils.py',1070'test/quantization/core/test_workflow_module.py',1071'test/quantization/core/test_workflow_ops.py',1072'test/quantization/eager/__init__.py',1073'test/quantization/eager/test_bias_correction_eager.py',1074'test/quantization/eager/test_equalize_eager.py',1075'test/quantization/eager/test_fuse_eager.py',1076'test/quantization/eager/test_model_numerics.py',1077'test/quantization/eager/test_numeric_suite_eager.py',1078'test/quantization/eager/test_quantize_eager_ptq.py',1079'test/quantization/eager/test_quantize_eager_qat.py',1080'test/quantization/fx/__init__.py',1081'test/quantization/fx/test_equalize_fx.py',1082'test/quantization/fx/test_model_report_fx.py',1083'test/quantization/fx/test_numeric_suite_fx.py',1084'test/quantization/fx/test_quantize_fx.py',1085'test/quantization/fx/test_subgraph_rewriter.py',1086'test/test_fake_tensor.py',1087'test/test_flop_counter.py',1088'test/test_function_schema.py',1089'test/test_functional_autograd_benchmark.py',1090'test/test_functional_optim.py',1091'test/test_functionalization_of_rng_ops.py',1092'test/test_datapipe.py',1093'test/test_futures.py',1094'test/test_fx.py',1095'test/test_fx_experimental.py',1096'test/test_fx_passes.py',1097'test/test_fx_reinplace_pass.py',1098'test/test_import_stats.py',1099'test/test_itt.py',1100'test/test_jit.py',1101'test/test_jit_autocast.py',1102'test/test_jit_cuda_fuser.py',1103'test/test_jit_disabled.py',1104'test/test_jit_fuser.py',1105'test/test_jit_fuser_legacy.py',1106'test/test_jit_legacy.py',1107'test/test_jit_llga_fuser.py',1108'test/test_jit_profiling.py',1109'test/test_jit_simple.py',1110'test/test_jit_string.py',1111'test/test_jiterator.py',1112'test/test_kernel_launch_checks.py',1113'test/test_linalg.py',1114'test/test_masked.py',1115'test/test_maskedtensor.py',1116'test/test_matmul_cuda.py',1117'test/test_meta.py',1118'test/test_metal.py',1119'test/test_mkl_verbose.py',1120'test/test_mkldnn.py',1121'test/test_mkldnn_fusion.py',1122'test/test_mkldnn_verbose.py',1123'test/test_mobile_optimizer.py',1124'test/test_model_dump.py',1125'test/test_modules.py',1126'test/test_monitor.py',1127'test/test_mps.py',1128'test/test_multiprocessing_spawn.py',1129'test/test_namedtensor.py',1130'test/test_namedtuple_return_api.py',1131'test/test_native_functions.py',1132'test/test_native_mha.py',1133'test/test_nn.py',1134'test/test_out_dtype_op.py',1135'test/test_overrides.py',1136'test/test_prims.py',1137'test/test_proxy_tensor.py',1138'test/test_pruning_op.py',1139'test/test_quantization.py',1140'test/test_reductions.py',1141'test/test_scatter_gather_ops.py',1142'test/test_schema_check.py',1143'test/test_segment_reductions.py',1144'test/test_serialization.py',1145'test/test_set_default_mobile_cpu_allocator.py',1146'test/test_sparse.py',1147'test/test_sparse_csr.py',1148'test/test_sparse_semi_structured.py',1149'test/test_spectral_ops.py',1150'test/test_stateless.py',1151'test/test_static_runtime.py',1152'test/test_subclass.py',1153'test/test_sympy_utils.py',1154'test/test_tensor_creation_ops.py',1155'test/test_tensorboard.py',1156'test/test_tensorexpr.py',1157'test/test_tensorexpr_pybind.py',1158'test/test_testing.py',1159'test/test_torch.py',1160'test/test_transformers.py',1161'test/test_type_promotion.py',1162'test/test_unary_ufuncs.py',1163'test/test_vulkan.py',1164'torch/_awaits/__init__.py',1165'torch/_custom_op/__init__.py',1166'torch/_custom_op/autograd.py',1167'torch/_custom_op/functional.py',1168'torch/_custom_op/impl.py',1169'torch/_export/__init__.py',1170'torch/_export/constraints.py',1171'torch/_export/db/__init__.py',1172'torch/_export/db/case.py',1173'torch/_export/db/examples/__init__.py',1174'torch/_export/db/examples/assume_constant_result.py',1175'torch/_export/db/examples/autograd_function.py',1176'torch/_export/db/examples/class_method.py',1177'torch/_export/db/examples/cond_branch_class_method.py',1178'torch/_export/db/examples/cond_branch_nested_function.py',1179'torch/_export/db/examples/cond_branch_nonlocal_variables.py',1180'torch/_export/db/examples/cond_closed_over_variable.py',1181'torch/_export/db/examples/cond_operands.py',1182'torch/_export/db/examples/cond_predicate.py',1183'torch/_export/db/examples/decorator.py',1184'torch/_export/db/examples/dictionary.py',1185'torch/_export/db/examples/dynamic_shape_assert.py',1186'torch/_export/db/examples/dynamic_shape_constructor.py',1187'torch/_export/db/examples/dynamic_shape_if_guard.py',1188'torch/_export/db/examples/dynamic_shape_map.py',1189'torch/_export/db/examples/dynamic_shape_round.py',1190'torch/_export/db/examples/dynamic_shape_slicing.py',1191'torch/_export/db/examples/dynamic_shape_view.py',1192'torch/_export/db/examples/fn_with_kwargs.py',1193'torch/_export/db/examples/list_contains.py',1194'torch/_export/db/examples/list_unpack.py',1195'torch/_export/db/examples/nested_function.py',1196'torch/_export/db/examples/null_context_manager.py',1197'torch/_export/db/examples/pytree_flatten.py',1198'torch/_export/db/examples/scalar_output.py',1199'torch/_export/db/examples/specialized_attribute.py',1200'torch/_export/db/examples/static_for_loop.py',1201'torch/_export/db/examples/static_if.py',1202'torch/_export/db/examples/tensor_setattr.py',1203'torch/_export/db/examples/type_reflection_method.py',1204'torch/_export/db/gen_example.py',1205'torch/_export/db/logging.py',1206'torch/_export/error.py',1207'torch/_export/exported_program.py',1208'torch/_export/pass_base.py',1209'torch/_export/pass_infra/__init__.py',1210'torch/_export/pass_infra/node_metadata.py',1211'torch/_export/pass_infra/proxy_value.py',1212'torch/_export/passes/__init__.py',1213'torch/_export/passes/add_runtime_assertions_for_constraints_pass.py',1214'torch/_export/passes/const_prop_pass.py',1215'torch/_export/passes/functionalize_side_effectful_ops_pass.py',1216'torch/_export/passes/replace_sym_size_ops_pass.py',1217'torch/_export/passes/replace_view_ops_with_view_copy_ops_pass.py',1218'torch/_export/serde/__init__.py',1219'torch/_export/serde/schema.py',1220'torch/_export/serde/serialize.py',1221'torch/_export/serde/upgrade.py',1222'torch/_export/trace.py',1223'torch/_export/verifier.py',1224'torch/_vendor/**',1225'torch/contrib/__init__.py',1226'torch/contrib/_tensorboard_vis.py',1227"torch/cuda/_gpu_trace.py",1228'torch/cuda/_memory_viz.py', # mypy: Value of type "object" is not indexable1229'torch/fft/__init__.py',1230'torch/func/__init__.py',1231'torch/futures/__init__.py',1232'torch/fx/__init__.py',1233'torch/fx/_compatibility.py',1234'torch/fx/_symbolic_trace.py',1235'torch/fx/annotate.py',1236'torch/fx/config.py',1237'torch/fx/experimental/__init__.py',1238'torch/fx/experimental/accelerator_partitioner.py',1239'torch/fx/experimental/const_fold.py',1240'torch/fx/experimental/debug.py',1241'torch/fx/experimental/graph_gradual_typechecker.py',1242'torch/fx/experimental/merge_matmul.py',1243'torch/fx/experimental/meta_tracer.py',1244'torch/fx/experimental/migrate_gradual_types/__init__.py',1245'torch/fx/experimental/migrate_gradual_types/constraint.py',1246'torch/fx/experimental/migrate_gradual_types/constraint_generator.py',1247'torch/fx/experimental/migrate_gradual_types/constraint_transformation.py',1248'torch/fx/experimental/migrate_gradual_types/operation.py',1249'torch/fx/experimental/migrate_gradual_types/transform_to_z3.py',1250'torch/fx/experimental/migrate_gradual_types/util.py',1251'torch/fx/experimental/migrate_gradual_types/z3_types.py',1252'torch/fx/experimental/normalize.py',1253'torch/fx/experimental/optimization.py',1254'torch/fx/experimental/partitioner_utils.py',1255'torch/fx/experimental/refinement_types.py',1256'torch/fx/experimental/rewriter.py',1257'torch/fx/experimental/schema_type_annotation.py',1258'torch/fx/experimental/symbolic_shapes.py',1259'torch/fx/experimental/unification/__init__.py',1260'torch/fx/experimental/unification/core.py',1261'torch/fx/experimental/unification/dispatch.py',1262'torch/fx/experimental/unification/match.py',1263'torch/fx/experimental/unification/more.py',1264'torch/fx/experimental/unification/multipledispatch/__init__.py',1265'torch/fx/experimental/unification/multipledispatch/conflict.py',1266'torch/fx/experimental/unification/multipledispatch/core.py',1267'torch/fx/experimental/unification/multipledispatch/dispatcher.py',1268'torch/fx/experimental/unification/multipledispatch/utils.py',1269'torch/fx/experimental/unification/multipledispatch/variadic.py',1270'torch/fx/experimental/unification/unification_tools.py',1271'torch/fx/experimental/unification/utils.py',1272'torch/fx/experimental/unification/variable.py',1273'torch/fx/experimental/unify_refinements.py',1274'torch/fx/experimental/validator.py',1275'torch/fx/graph.py',1276'torch/fx/graph_module.py',1277'torch/fx/interpreter.py',1278'torch/fx/node.py',1279'torch/fx/operator_schemas.py',1280'torch/fx/passes/__init__.py',1281'torch/fx/passes/annotate_getitem_nodes.py',1282'torch/fx/passes/backends/__init__.py',1283'torch/fx/passes/backends/cudagraphs.py',1284'torch/fx/passes/dialect/__init__.py',1285'torch/fx/passes/dialect/common/__init__.py',1286'torch/fx/passes/dialect/common/cse_pass.py',1287'torch/fx/passes/fake_tensor_prop.py',1288'torch/fx/passes/graph_drawer.py',1289'torch/fx/passes/graph_manipulation.py',1290'torch/fx/passes/infra/__init__.py',1291'torch/fx/passes/infra/partitioner.py',1292'torch/fx/passes/infra/pass_base.py',1293'torch/fx/passes/infra/pass_manager.py',1294'torch/fx/passes/net_min_base.py',1295'torch/fx/passes/operator_support.py',1296'torch/fx/passes/param_fetch.py',1297'torch/fx/passes/pass_manager.py',1298'torch/fx/passes/reinplace.py',1299'torch/fx/passes/shape_prop.py',1300'torch/fx/passes/split_module.py',1301'torch/fx/passes/split_utils.py',1302'torch/fx/passes/splitter_base.py',1303'torch/fx/passes/tests/__init__.py',1304'torch/fx/passes/tests/test_pass_manager.py',1305'torch/fx/passes/tools_common.py',1306'torch/fx/passes/utils/__init__.py',1307'torch/fx/passes/utils/common.py',1308'torch/fx/passes/utils/fuser_utils.py',1309'torch/fx/passes/utils/matcher_utils.py',1310'torch/fx/passes/utils/source_matcher_utils.py',1311'torch/fx/proxy.py',1312'torch/fx/subgraph_rewriter.py',1313'torch/fx/tensor_type.py',1314'torch/fx/traceback.py',1315'torch/linalg/__init__.py',1316'torch/monitor/__init__.py',1317'torch/nested/__init__.py',1318'torch/signal/__init__.py',1319'torch/signal/windows/__init__.py',1320'torch/signal/windows/windows.py',1321'torch/special/__init__.py',1322'torch/testing/_internal/__init__.py',1323'torch/testing/_internal/autocast_test_lists.py',1324'torch/testing/_internal/autograd_function_db.py',1325'torch/testing/_internal/check_kernel_launches.py',1326'torch/testing/_internal/codegen/__init__.py',1327'torch/testing/_internal/codegen/random_topo_test.py',1328'torch/testing/_internal/common_cuda.py',1329'torch/testing/_internal/common_distributed.py',1330'torch/testing/_internal/common_jit.py',1331'torch/testing/_internal/common_methods_invocations.py',1332'torch/testing/_internal/common_modules.py',1333'torch/testing/_internal/common_nn.py',1334'torch/testing/_internal/common_pruning.py',1335'torch/testing/_internal/common_quantization.py',1336'torch/testing/_internal/common_quantized.py',1337'torch/testing/_internal/common_subclass.py',1338'torch/testing/_internal/common_utils.py',1339'torch/testing/_internal/composite_compliance.py',1340'torch/testing/_internal/hop_db.py',1341'torch/testing/_internal/custom_op_db.py',1342'torch/testing/_internal/data/__init__.py',1343'torch/testing/_internal/data/network1.py',1344'torch/testing/_internal/data/network2.py',1345'torch/testing/_internal/dist_utils.py',1346'torch/testing/_internal/distributed/__init__.py',1347'torch/testing/_internal/distributed/_shard/__init__.py',1348'torch/testing/_internal/distributed/_shard/sharded_tensor/__init__.py',1349'torch/testing/_internal/distributed/_shard/sharded_tensor/_test_ops_common.py',1350'torch/testing/_internal/distributed/_shard/sharded_tensor/_test_st_common.py',1351'torch/testing/_internal/distributed/_shard/test_common.py',1352'torch/testing/_internal/distributed/_tensor/__init__.py',1353'torch/testing/_internal/distributed/_tensor/common_dtensor.py',1354'torch/testing/_internal/distributed/ddp_under_dist_autograd_test.py',1355'torch/testing/_internal/distributed/distributed_test.py',1356'torch/testing/_internal/distributed/distributed_utils.py',1357'torch/testing/_internal/distributed/fake_pg.py',1358'torch/testing/_internal/distributed/multi_threaded_pg.py',1359'torch/testing/_internal/distributed/nn/__init__.py',1360'torch/testing/_internal/distributed/nn/api/__init__.py',1361'torch/testing/_internal/distributed/nn/api/remote_module_test.py',1362'torch/testing/_internal/distributed/rpc/__init__.py',1363'torch/testing/_internal/distributed/rpc/dist_autograd_test.py',1364'torch/testing/_internal/distributed/rpc/dist_optimizer_test.py',1365'torch/testing/_internal/distributed/rpc/examples/__init__.py',1366'torch/testing/_internal/distributed/rpc/examples/parameter_server_test.py',1367'torch/testing/_internal/distributed/rpc/examples/reinforcement_learning_rpc_test.py',1368'torch/testing/_internal/distributed/rpc/faulty_agent_rpc_test.py',1369'torch/testing/_internal/distributed/rpc/faulty_rpc_agent_test_fixture.py',1370'torch/testing/_internal/distributed/rpc/jit/__init__.py',1371'torch/testing/_internal/distributed/rpc/jit/dist_autograd_test.py',1372'torch/testing/_internal/distributed/rpc/jit/rpc_test.py',1373'torch/testing/_internal/distributed/rpc/jit/rpc_test_faulty.py',1374'torch/testing/_internal/distributed/rpc/rpc_agent_test_fixture.py',1375'torch/testing/_internal/distributed/rpc/rpc_test.py',1376'torch/testing/_internal/distributed/rpc/tensorpipe_rpc_agent_test_fixture.py',1377'torch/testing/_internal/distributed/rpc_utils.py',1378'torch/testing/_internal/generated/__init__.py',1379'torch/testing/_internal/hypothesis_utils.py',1380'torch/testing/_internal/inductor_utils.py',1381'torch/testing/_internal/jit_metaprogramming_utils.py',1382'torch/testing/_internal/jit_utils.py',1383'torch/testing/_internal/logging_tensor.py',1384'torch/testing/_internal/logging_utils.py',1385'torch/testing/_internal/optests/__init__.py',1386'torch/testing/_internal/optests/aot_autograd.py',1387'torch/testing/_internal/optests/compile_check.py',1388'torch/testing/_internal/optests/fake_tensor.py',1389'torch/testing/_internal/optests/make_fx.py',1390'torch/testing/_internal/quantization_torch_package_models.py',1391'torch/testing/_internal/test_module/__init__.py',1392'torch/testing/_internal/test_module/future_div.py',1393'torch/testing/_internal/test_module/no_future_div.py',1394'torch/utils/_contextlib.py',1395'torch/utils/_cpp_extension_versioner.py',1396'torch/utils/_crash_handler.py',1397'torch/utils/_device.py',1398'torch/utils/_foreach_utils.py',1399'torch/utils/_freeze.py',1400'torch/utils/_mode_utils.py',1401'torch/utils/_python_dispatch.py',1402'torch/utils/_stats.py',1403'torch/utils/_traceback.py',1404'torch/utils/_zip.py',1405'torch/utils/backcompat/__init__.py',1406'torch/utils/backend_registration.py',1407'torch/utils/benchmark/__init__.py',1408'torch/utils/benchmark/examples/__init__.py',1409'torch/utils/benchmark/examples/blas_compare.py',1410'torch/utils/benchmark/examples/blas_compare_setup.py',1411'torch/utils/benchmark/examples/compare.py',1412'torch/utils/benchmark/examples/end_to_end.py',1413'torch/utils/benchmark/examples/fuzzer.py',1414'torch/utils/benchmark/examples/op_benchmark.py',1415'torch/utils/benchmark/examples/simple_timeit.py',1416'torch/utils/benchmark/examples/sparse/compare.py',1417'torch/utils/benchmark/examples/sparse/fuzzer.py',1418'torch/utils/benchmark/examples/sparse/op_benchmark.py',1419'torch/utils/benchmark/examples/spectral_ops_fuzz_test.py',1420'torch/utils/benchmark/op_fuzzers/__init__.py',1421'torch/utils/benchmark/op_fuzzers/binary.py',1422'torch/utils/benchmark/op_fuzzers/sparse_binary.py',1423'torch/utils/benchmark/op_fuzzers/sparse_unary.py',1424'torch/utils/benchmark/op_fuzzers/spectral.py',1425'torch/utils/benchmark/op_fuzzers/unary.py',1426'torch/utils/benchmark/utils/__init__.py',1427'torch/utils/benchmark/utils/_stubs.py',1428'torch/utils/benchmark/utils/common.py',1429'torch/utils/benchmark/utils/compare.py',1430'torch/utils/benchmark/utils/compile.py',1431'torch/utils/benchmark/utils/cpp_jit.py',1432'torch/utils/benchmark/utils/fuzzer.py',1433'torch/utils/benchmark/utils/sparse_fuzzer.py',1434'torch/utils/benchmark/utils/timer.py',1435'torch/utils/benchmark/utils/valgrind_wrapper/__init__.py',1436'torch/utils/benchmark/utils/valgrind_wrapper/timer_interface.py',1437'torch/utils/bottleneck/__init__.py',1438'torch/utils/bottleneck/__main__.py',1439'torch/utils/bundled_inputs.py',1440'torch/utils/checkpoint.py',1441'torch/utils/collect_env.py',1442'torch/utils/cpp_backtrace.py',1443'torch/utils/cpp_extension.py',1444'torch/utils/dlpack.py',1445'torch/utils/file_baton.py',1446'torch/utils/flop_counter.py',1447'torch/utils/hipify/__init__.py',1448'torch/utils/hipify/constants.py',1449'torch/utils/hipify/cuda_to_hip_mappings.py',1450'torch/utils/hipify/hipify_python.py',1451'torch/utils/hipify/version.py',1452'torch/utils/hooks.py',1453'torch/utils/jit/__init__.py',1454'torch/utils/jit/log_extract.py',1455'torch/utils/mkldnn.py',1456'torch/utils/mobile_optimizer.py',1457'torch/utils/model_dump/__init__.py',1458'torch/utils/model_dump/__main__.py',1459'torch/utils/model_zoo.py',1460'torch/utils/show_pickle.py',1461'torch/utils/tensorboard/__init__.py',1462'torch/utils/tensorboard/_caffe2_graph.py',1463'torch/utils/tensorboard/_convert_np.py',1464'torch/utils/tensorboard/_embedding.py',1465'torch/utils/tensorboard/_onnx_graph.py',1466'torch/utils/tensorboard/_proto_graph.py',1467'torch/utils/tensorboard/_pytorch_graph.py',1468'torch/utils/tensorboard/_utils.py',1469'torch/utils/tensorboard/summary.py',1470'torch/utils/tensorboard/writer.py',1471'torch/utils/throughput_benchmark.py',1472'torch/utils/viz/__init__.py',1473'torch/utils/viz/_cycles.py',1474'torch/utils/weak.py',1475'torch/xpu/_gpu_trace.py',1476]
1477init_command = [1478'python3',1479'tools/linter/adapters/pip_init.py',1480'--dry-run={{DRYRUN}}',1481'--no-black-binary',1482'black==23.12.1',1483'usort==1.0.8.post1',1484'isort==5.13.2',1485'ruff==0.6.3', # sync with RUFF1486]
1487is_formatter = true1488
1489[[linter]]1490code = 'COPYRIGHT'1491include_patterns = ['**']1492exclude_patterns = [1493'.lintrunner.toml',1494'fb/**',1495'**/fb/**',1496]
1497command = [1498'python3',1499'tools/linter/adapters/grep_linter.py',1500'--pattern=Confidential and proprietary',1501'--linter-name=COPYRIGHT',1502'--error-name=Confidential Code',1503"""--error-description=\1504Proprietary and confidential source code\
1505should not be contributed to PyTorch codebase\
1506""",1507'--',1508'@{{PATHSFILE}}'1509]
1510
1511[[linter]]1512code = 'BAZEL_LINTER'1513include_patterns = ['WORKSPACE']1514command = [1515'python3',1516'tools/linter/adapters/bazel_linter.py',1517'--binary=.lintbin/bazel',1518'--',1519'@{{PATHSFILE}}'1520]
1521init_command = [1522'python3',1523'tools/linter/adapters/s3_init.py',1524'--config-json=tools/linter/adapters/s3_init_config.json',1525'--linter=bazel',1526'--dry-run={{DRYRUN}}',1527'--output-dir=.lintbin',1528'--output-name=bazel',1529]
1530is_formatter = true1531
1532[[linter]]1533code = 'LINTRUNNER_VERSION'1534include_patterns = ['**']1535exclude_patterns = [1536'fb/**',1537'**/fb/**',1538]
1539command = [1540'python3',1541'tools/linter/adapters/lintrunner_version_linter.py'1542]
1543
1544[[linter]]1545code = 'RUFF'1546include_patterns = ['**/*.py', '**/*.pyi']1547exclude_patterns = [1548'caffe2/**',1549'functorch/docs/**',1550'functorch/notebooks/**',1551'torch/_inductor/fx_passes/serialized_patterns/**',1552'torch/_inductor/autoheuristic/artifacts/**',1553'scripts/**',1554'third_party/**',1555'fb/**',1556'**/fb/**',1557]
1558command = [1559'python3',1560'tools/linter/adapters/ruff_linter.py',1561'--config=pyproject.toml',1562'--show-disable',1563'--',1564'@{{PATHSFILE}}'1565]
1566init_command = [1567'python3',1568'tools/linter/adapters/pip_init.py',1569'--dry-run={{DRYRUN}}',1570'ruff==0.6.3', # sync with PYFMT1571]
1572is_formatter = true1573
1574# This linter prevents merge conlicts in csv files in pytorch by enforcing
1575# three lines of whitespace between entries such that unless people are modifying
1576# the same line, merge conflicts should not arise in git or hg
1577[[linter]]1578code = 'MERGE_CONFLICTLESS_CSV'1579include_patterns = ['benchmarks/dynamo/ci_expected_accuracy/*.csv']1580command = [1581'python3',1582'tools/linter/adapters/no_merge_conflict_csv_linter.py',1583'--',1584'@{{PATHSFILE}}'1585]
1586is_formatter = true1587
1588[[linter]]1589code = 'ATEN_CPU_GPU_AGNOSTIC'1590include_patterns = [1591# aten source1592"aten/src/ATen/*.cpp",1593"aten/src/ATen/cpu/*.cpp",1594"aten/src/ATen/functorch/**/*.cpp",1595"aten/src/ATen/nnapi/*.cpp",1596"aten/src/ATen/quantized/*.cpp",1597"aten/src/ATen/vulkan/*.cpp",1598"aten/src/ATen/metal/*.cpp",1599"aten/src/ATen/detail/CPUGuardImpl.cpp",1600"aten/src/ATen/detail/MetaGuardImpl.cpp",1601# aten native source1602"aten/src/ATen/native/cpu/*.cpp",1603"aten/src/ATen/native/ao_sparse/cpu/kernels/*.cpp",1604"aten/src/ATen/native/ao_sparse/quantized/cpu/kernels/*.cpp",1605"aten/src/ATen/native/quantized/cpu/kernels/*.cpp",1606"aten/src/ATen/native/*.cpp",1607"aten/src/ATen/native/cpu/**/*.cpp",1608"aten/src/ATen/native/ao_sparse/*.cpp",1609"aten/src/ATen/native/ao_sparse/**/*.cpp",1610"aten/src/ATen/native/ao_sparse/quantized/*.cpp",1611"aten/src/ATen/native/ao_sparse/quantized/**/*.cpp",1612"aten/src/ATen/native/nested/*.cpp",1613"aten/src/ATen/native/quantized/*.cpp",1614"aten/src/ATen/native/quantized/**/*.cpp",1615"aten/src/ATen/native/sparse/*.cpp",1616"aten/src/ATen/native/transformers/*.cpp",1617"aten/src/ATen/native/utils/*.cpp",1618"aten/src/ATen/native/xnnpack/*.cpp",1619"aten/src/ATen/native/metal/MetalPrepackOpRegister.cpp",1620# aten headers1621"aten/src/ATen/*.h",1622"aten/src/ATen/functorch/**/*.h",1623"aten/src/ATen/ops/*.h",1624"aten/src/ATen/cpu/**/*.h",1625"aten/src/ATen/nnapi/*.h",1626"aten/src/ATen/quantized/*.h",1627"aten/src/ATen/vulkan/*.h",1628"aten/src/ATen/metal/*.h",1629"aten/src/ATen/mps/*.h",1630# aten native headers1631"aten/src/ATen/native/*.h",1632"aten/src/ATen/native/cpu/**/*.h",1633"aten/src/ATen/native/nested/*.h",1634"aten/src/ATen/native/sparse/*.h",1635"aten/src/ATen/native/ao_sparse/*.h",1636"aten/src/ATen/native/ao_sparse/cpu/*.h",1637"aten/src/ATen/native/ao_sparse/quantized/*.h",1638"aten/src/ATen/native/ao_sparse/quantized/cpu/*.h",1639"aten/src/ATen/native/quantized/*.h",1640"aten/src/ATen/native/quantized/cpu/*.h",1641"aten/src/ATen/native/transformers/*.h",1642"aten/src/ATen/native/quantized/cpu/qnnpack/include/*.h",1643"aten/src/ATen/native/utils/*.h",1644"aten/src/ATen/native/vulkan/ops/*.h",1645"aten/src/ATen/native/xnnpack/*.h",1646"aten/src/ATen/native/metal/MetalPrepackOpContext.h",1647"aten/src/ATen/native/mps/Copy.h",1648"aten/src/ATen/native/mkldnn/**/*.h",1649]
1650exclude_patterns = [1651"aten/src/ATen/Context.h",1652"aten/src/ATen/Context.cpp",1653"aten/src/ATen/DLConvertor.cpp",1654"aten/src/ATen/core/Array.h",1655"aten/src/ATen/native/quantized/ConvUtils.h",1656"aten/src/ATen/native/sparse/SparseBlasImpl.cpp", # triton implementation1657"aten/src/ATen/native/transformers/attention.cpp",1658"aten/src/ATen/native/**/cudnn/**", # cudnn is cuda specific1659]
1660command = [1661'python3',1662'tools/linter/adapters/grep_linter.py',1663'--pattern=(^#if.*USE_ROCM.*)|(^#if.*USE_CUDA.*)',1664'--linter-name=ATEN_CPU',1665'--error-name=aten-cpu should be gpu agnostic',1666"""--error-description=\1667We strongly discourage the compile-time divergence \
1668on ATen-CPU code for different GPU code. This \
1669disallows sharing the same aten-cpu shared object \
1670between different GPU backends \
1671""",1672'--',1673'@{{PATHSFILE}}'1674]
1675is_formatter = true1676