2021-11-03 19:34:02 +00:00
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'FLAKE8'
|
2021-11-03 19:34:02 +00:00
|
|
|
include_patterns = ['**/*.py']
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'.git/**',
|
|
|
|
|
'build_test_custom_build/**',
|
|
|
|
|
'build/**',
|
|
|
|
|
'caffe2/**',
|
|
|
|
|
'docs/caffe2/**',
|
|
|
|
|
'docs/cpp/src/**',
|
|
|
|
|
'docs/src/**',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2022-07-22 15:48:16 +00:00
|
|
|
'functorch/docs/**',
|
|
|
|
|
'functorch/examples/**',
|
|
|
|
|
'functorch/notebooks/**',
|
2023-09-20 00:08:09 +00:00
|
|
|
'torch/_inductor/fx_passes/serialized_patterns/**',
|
AutoHeuristic: mixed_mm heuristic for A100 (#131613)
This PR introduces changes to AutoHeuristic that allow one to learn a heuristic as a decision tree. I used this to learn a heuristic for mixed_mm on A100 that consistenly performs better than the default choice (https://github.com/pytorch/pytorch/blob/main/torch/_inductor/kernel/mm.py#L402).
This is how the results look like:
Explanation of columns:
**wrong_max_spdup**: In the worst case, how much better would the best choice have been
**wrong_gman_spdup**: For inputs where the heuristic is wrong, how much better is the best choice on average (geomean)
**max_spdup_default**: Highest speedup achieved by the learned heuristic over the default choice
**gman_spdup_default**: Geomean speedup achived by the learned heuristic over the default choice
**max_slowdown_default**: If the default choice is better than the choice predicted by the learned heuristic, how much is it better in the worst case
**non_default_preds**: Number of times the learned heuristic predicted a choice that is not the default choice
**default_better**: Number of times the default choice is better than the choice made by the heuristic
```
set crit max_depth min_samples_leaf correct wrong unsure total wrong_max_spdup wrong_gman_spdup max_spdup_default gman_spdup_default max_slowdown_default non_default_preds default_better
train entropy 5 0.01 2376 740 323 3439 1.855386 1.063236 11.352318 3.438279 1.022164 3116 2
test entropy 5 0.01 563 183 71 817 1.622222 1.060897 10.084181 3.507741 1.017039 746 2
```
While the number of wrong predictions is high, on average the best choice is only around 6% better. What is important is that the choice predicted by the learned heuristic performs better than the default choice.
I evaluated my heuristic on gpt-fast `meta-llama/Llama-2-7b-chat-hf` with int8 weight quantization. To get the `tuned_mixed_mm` to trigger, I had to replace `F.linear()` in https://github.com/pytorch-labs/gpt-fast/blob/main/quantize.py#L355 with `torch.matmul(input, self.weight.t().to(dtype=input.dtype))` because the mixed_mm pattern does not match if there is a transpose between a cast and the matmul.
|batch size|prompt length| fallback | heuristic | speedup |
|----------|-------------|------------:|------------:|--------:|
| 1 | 7 | 75.31 tok/s | 148.83 tok/s| 1.97 |
| 1 | 11 | 75.99 tok/s | 148.15 tok/s| 1.94 |
| 4 | 7 | 103.48 tok/s | 472.00 tok/s| 4.56 |
| 4 | 11 | 103.56 tok/s | 371.36 tok/s| 3.58 |
| 8 | 7 | 201.92 tok/s | 813.44 tok/s| 4.02 |
| 8 | 11 | 201.76 tok/s | 699.36 tok/s| 3.46 |
Currently, the heuristic only applies to the following inputs:
- m <= 128, k >= 1024, n >= 1024 (For these sizes, one of the triton kernels wins in most cases, but the heuristic still has to be careful to not choose a config that performs worse than the fallback)
- k % 256 == 0 (If k is not a multiple of the block size, some choices perform extremely bad. In one case one config, that usually performs very well, was 130x slower.)
- mat1 not transposed
- mat2 transposed (In some cases, it was hard for the learned heuristic to detect some cases where it
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131613
Approved by: https://github.com/eellison
2024-08-01 22:48:47 +00:00
|
|
|
'torch/_inductor/autoheuristic/artifacts/**',
|
2021-11-03 19:34:02 +00:00
|
|
|
'scripts/**',
|
|
|
|
|
'test/generated_type_hints_smoketest.py',
|
2023-08-11 00:39:32 +00:00
|
|
|
# Tests from the NumPy test suite
|
|
|
|
|
'test/torch_np/numpy_test/**/*.py',
|
2021-11-03 19:34:02 +00:00
|
|
|
'third_party/**',
|
|
|
|
|
'torch/include/**',
|
|
|
|
|
'torch/lib/**',
|
|
|
|
|
'venv/**',
|
|
|
|
|
'**/*.pyi',
|
2022-06-29 23:27:47 +00:00
|
|
|
'tools/test/test_selective_build.py',
|
2021-11-03 19:34:02 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-03 19:34:02 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/flake8_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
init_command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
2024-01-03 06:04:44 +00:00
|
|
|
'flake8==6.1.0',
|
2023-03-28 23:51:51 +00:00
|
|
|
'flake8-bugbear==23.3.23',
|
2024-07-16 13:47:49 +00:00
|
|
|
'flake8-comprehensions==3.15.0',
|
2023-03-28 23:51:51 +00:00
|
|
|
'flake8-executable==2.1.3',
|
2023-02-15 17:54:50 +00:00
|
|
|
'flake8-logging-format==0.9.0',
|
2023-03-28 23:51:51 +00:00
|
|
|
'flake8-pyi==23.3.1',
|
2023-03-31 03:40:21 +00:00
|
|
|
'flake8-simplify==0.19.3',
|
2023-03-28 23:51:51 +00:00
|
|
|
'mccabe==0.7.0',
|
2024-01-03 06:04:44 +00:00
|
|
|
'pycodestyle==2.11.1',
|
|
|
|
|
'pyflakes==3.1.0',
|
2024-11-14 17:52:05 +00:00
|
|
|
'torchfix==0.4.0 ; python_version >= "3.9" and python_version < "3.13"',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'CLANGFORMAT'
|
2021-11-03 19:34:02 +00:00
|
|
|
include_patterns = [
|
2021-11-09 20:46:59 +00:00
|
|
|
'aten/src/ATen/*.h',
|
2023-03-10 23:17:54 +00:00
|
|
|
'aten/src/ATen/mps/**/*.mm',
|
|
|
|
|
'aten/src/ATen/mps/**/*.h',
|
2024-01-17 11:06:22 +00:00
|
|
|
'aten/src/ATen/xpu/**/*.h',
|
|
|
|
|
'aten/src/ATen/xpu/**/*.cpp',
|
2024-03-20 06:17:37 +00:00
|
|
|
'aten/src/ATen/core/boxing/**/*.h',
|
|
|
|
|
'aten/src/ATen/core/dispatch/**/*.h',
|
2023-03-10 23:17:54 +00:00
|
|
|
'aten/src/ATen/native/mps/**/*.metal',
|
|
|
|
|
'aten/src/ATen/native/mps/**/*.mm',
|
|
|
|
|
'aten/src/ATen/native/mps/**/*.h',
|
2022-07-13 07:05:46 +00:00
|
|
|
'aten/src/ATen/native/vulkan/**/*.h',
|
|
|
|
|
'aten/src/ATen/native/vulkan/**/*.cpp',
|
2023-02-04 11:25:30 +00:00
|
|
|
'aten/src/ATen/native/cuda/MultiTensorApply.cuh',
|
2022-07-13 07:05:46 +00:00
|
|
|
'aten/src/ATen/native/**/Foreach*.*',
|
2023-02-04 11:25:30 +00:00
|
|
|
'aten/src/ATen/native/cuda/fused*.*',
|
|
|
|
|
'aten/src/ATen/native/cuda/Fused*.cu',
|
2024-01-26 17:53:22 +00:00
|
|
|
'aten/src/ATen/native/cudnn/*.h',
|
|
|
|
|
'aten/src/ATen/native/cudnn/*.cpp',
|
2024-11-11 08:46:11 +00:00
|
|
|
'aten/src/ATen/native/mkldnn/xpu/**/*.h',
|
|
|
|
|
'aten/src/ATen/native/mkldnn/xpu/**/*.cpp',
|
2024-12-13 00:06:48 +00:00
|
|
|
'aten/src/ATen/native/Tensor*.h',
|
|
|
|
|
'aten/src/ATen/native/Tensor*.cpp',
|
2021-11-03 19:34:02 +00:00
|
|
|
'c10/**/*.h',
|
|
|
|
|
'c10/**/*.cpp',
|
|
|
|
|
'torch/csrc/**/*.h',
|
2023-08-14 18:34:35 +00:00
|
|
|
'torch/csrc/**/*.hpp',
|
2021-11-03 19:34:02 +00:00
|
|
|
'torch/csrc/**/*.cpp',
|
|
|
|
|
'test/cpp/**/*.h',
|
|
|
|
|
'test/cpp/**/*.cpp',
|
|
|
|
|
]
|
2022-04-13 16:09:39 +00:00
|
|
|
exclude_patterns = [
|
2022-07-13 07:05:46 +00:00
|
|
|
'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',
|
2024-03-06 23:51:40 +00:00
|
|
|
'aten/src/ATen/native/mps/kernels/Quantized.metal',
|
2022-06-07 19:51:33 +00:00
|
|
|
'c10/util/strong_type.h',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2024-05-08 20:38:28 +00:00
|
|
|
'torch/csrc/inductor/aoti_torch/generated/**',
|
2022-04-13 16:09:39 +00:00
|
|
|
'torch/csrc/jit/serialization/mobile_bytecode_generated.h',
|
2022-12-21 13:45:26 +00:00
|
|
|
'torch/csrc/utils/pythoncapi_compat.h',
|
2023-09-08 17:55:33 +00:00
|
|
|
'aten/src/ATen/dlpack.h',
|
2022-04-13 16:09:39 +00:00
|
|
|
]
|
2021-11-15 19:04:30 +00:00
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/s3_init.py',
|
|
|
|
|
'--config-json=tools/linter/adapters/s3_init_config.json',
|
|
|
|
|
'--linter=clang-format',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'--output-dir=.lintbin',
|
|
|
|
|
'--output-name=clang-format',
|
|
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-03 19:34:02 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/clangformat_linter.py',
|
2021-11-15 19:04:30 +00:00
|
|
|
'--binary=.lintbin/clang-format',
|
2021-11-03 19:34:02 +00:00
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
2022-05-03 18:38:58 +00:00
|
|
|
is_formatter = true
|
2021-11-03 19:34:02 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'MYPY'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns = [
|
|
|
|
|
'torch/**/*.py',
|
2022-04-13 16:09:39 +00:00
|
|
|
'torch/**/*.pyi',
|
2021-11-08 17:34:39 +00:00
|
|
|
'caffe2/**/*.py',
|
2022-04-13 16:09:39 +00:00
|
|
|
'caffe2/**/*.pyi',
|
2021-11-08 17:34:39 +00:00
|
|
|
'test/test_bundled_images.py',
|
|
|
|
|
'test/test_bundled_inputs.py',
|
|
|
|
|
'test/test_complex.py',
|
|
|
|
|
'test/test_datapipe.py',
|
|
|
|
|
'test/test_futures.py',
|
2022-04-13 16:09:39 +00:00
|
|
|
# 'test/test_numpy_interop.py',
|
2021-11-08 17:34:39 +00:00
|
|
|
'test/test_torch.py',
|
|
|
|
|
'test/test_type_hints.py',
|
|
|
|
|
'test/test_type_info.py',
|
2023-11-15 08:50:07 +00:00
|
|
|
'test/test_utils.py',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/mypy_linter.py',
|
|
|
|
|
'--config=mypy.ini',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
init_command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
2024-11-14 17:52:05 +00:00
|
|
|
'numpy==1.26.4 ; python_version >= "3.9" and python_version <= "3.11"',
|
|
|
|
|
'numpy==2.1.0 ; python_version >= "3.12"',
|
2024-12-11 15:34:12 +00:00
|
|
|
'expecttest==0.3.0',
|
2024-12-03 02:50:07 +00:00
|
|
|
'mypy==1.13.0',
|
2024-07-19 14:09:52 +00:00
|
|
|
'sympy==1.13.0 ; python_version >= "3.9"',
|
2022-05-03 20:30:59 +00:00
|
|
|
'types-requests==2.27.25',
|
|
|
|
|
'types-PyYAML==6.0.7',
|
|
|
|
|
'types-tabulate==0.8.8',
|
|
|
|
|
'types-protobuf==3.19.18',
|
|
|
|
|
'types-pkg-resources==0.1.3',
|
|
|
|
|
'types-Jinja2==2.11.9',
|
2024-01-28 03:30:50 +00:00
|
|
|
'types-colorama==0.4.6',
|
2024-02-07 20:14:28 +00:00
|
|
|
'filelock==3.13.1',
|
2021-11-08 17:34:39 +00:00
|
|
|
'junitparser==2.1.1',
|
|
|
|
|
'rich==10.9.0',
|
2024-03-19 12:23:49 +00:00
|
|
|
'pyyaml==6.0.1',
|
2024-10-07 09:57:14 +00:00
|
|
|
'optree==0.13.0',
|
2025-01-29 23:48:47 +00:00
|
|
|
'dataclasses_json==0.6.7',
|
|
|
|
|
'pandas==2.2.3',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'MYPYSTRICT'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns = [
|
|
|
|
|
'.github/**/*.py',
|
|
|
|
|
'benchmarks/instruction_counts/**/*.py',
|
|
|
|
|
'tools/**/*.py',
|
2022-08-01 16:19:18 +00:00
|
|
|
'torchgen/**/*.py',
|
2021-11-08 17:34:39 +00:00
|
|
|
'torch/utils/_pytree.py',
|
2023-10-04 23:40:43 +00:00
|
|
|
'torch/utils/_cxx_pytree.py',
|
2021-11-08 17:34:39 +00:00
|
|
|
'torch/utils/benchmark/utils/common.py',
|
|
|
|
|
'torch/utils/benchmark/utils/timer.py',
|
|
|
|
|
'torch/utils/benchmark/utils/valgrind_wrapper/**/*.py',
|
|
|
|
|
]
|
2022-05-17 00:30:11 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
# (linbinyu) copied from internal repo
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2022-05-17 00:30:11 +00:00
|
|
|
'tools/code_analyzer/gen_operators_yaml.py',
|
2022-10-21 17:30:14 +00:00
|
|
|
'tools/dynamo/verify_dynamo.py',
|
2022-06-29 23:27:47 +00:00
|
|
|
'tools/gen_vulkan_spv.py',
|
|
|
|
|
'tools/test/gen_operators_yaml_test.py',
|
|
|
|
|
'tools/test/gen_oplist_test.py',
|
|
|
|
|
'tools/test/test_selective_build.py',
|
2022-05-17 00:30:11 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-03 19:34:02 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/mypy_linter.py',
|
2021-11-08 17:34:39 +00:00
|
|
|
'--config=mypy-strict.ini',
|
2022-12-07 20:01:34 +00:00
|
|
|
'--code=MYPYSTRICT',
|
2021-11-03 19:34:02 +00:00
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'CLANGTIDY'
|
|
|
|
|
include_patterns = [
|
2024-03-07 15:11:07 +00:00
|
|
|
# Enable coverage of headers in aten/src/ATen
|
|
|
|
|
# and excluding most sub-directories for now.
|
|
|
|
|
'aten/src/ATen/*.h',
|
|
|
|
|
'aten/src/ATen/*.cpp',
|
2024-09-23 03:44:53 +00:00
|
|
|
'aten/src/ATen/cuda/*.cpp',
|
2024-08-07 14:44:17 +00:00
|
|
|
'aten/src/ATen/cpu/*.h',
|
|
|
|
|
'aten/src/ATen/cpu/*.cpp',
|
2024-03-20 06:17:37 +00:00
|
|
|
'aten/src/ATen/core/*.h',
|
|
|
|
|
'aten/src/ATen/core/*.cpp',
|
2024-08-02 17:39:37 +00:00
|
|
|
'aten/src/ATen/cudnn/*.h',
|
|
|
|
|
'aten/src/ATen/cudnn/*.cpp',
|
2024-11-11 08:46:11 +00:00
|
|
|
'aten/src/ATen/native/mkldnn/xpu/**/*.h',
|
|
|
|
|
'aten/src/ATen/native/mkldnn/xpu/**/*.cpp',
|
2024-05-27 06:28:07 +00:00
|
|
|
'aten/src/ATen/detail/*',
|
2024-03-29 14:01:28 +00:00
|
|
|
'aten/src/ATen/functorch/*.h',
|
|
|
|
|
'aten/src/ATen/functorch/*.cpp',
|
2024-08-20 01:52:15 +00:00
|
|
|
'aten/src/ATen/native/nested/cuda/*.cpp',
|
|
|
|
|
'aten/src/ATen/native/nested/cuda/*.h',
|
|
|
|
|
'aten/src/ATen/native/nested/*.cpp',
|
|
|
|
|
'aten/src/ATen/native/nested/*.h',
|
2023-06-04 06:33:01 +00:00
|
|
|
'c10/**/*.cpp',
|
2024-01-18 08:15:50 +00:00
|
|
|
'c10/**/*.h',
|
2024-08-15 18:52:05 +00:00
|
|
|
'torch/*.h',
|
2024-01-10 23:58:04 +00:00
|
|
|
'torch/csrc/*.h',
|
2024-02-25 03:29:38 +00:00
|
|
|
'torch/csrc/*.cpp',
|
|
|
|
|
'torch/csrc/**/*.h',
|
2023-09-12 00:54:53 +00:00
|
|
|
'torch/csrc/**/*.cpp',
|
2024-07-02 20:08:46 +00:00
|
|
|
'torch/csrc/jit/serialization/*.h',
|
|
|
|
|
'torch/csrc/jit/serialization/*.cpp',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-11 22:52:04 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
# The negative filters below are to exclude files that include onnx_pb.h or
|
|
|
|
|
# caffe2_pb.h, otherwise we'd have to build protos as part of this CI job.
|
2023-09-12 00:54:53 +00:00
|
|
|
# CUDA files are also excluded.
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2024-10-30 14:20:06 +00:00
|
|
|
'**/generated/**',
|
2023-09-12 00:54:53 +00:00
|
|
|
'**/*pb.h',
|
2024-11-04 00:47:19 +00:00
|
|
|
'**/*inl.h',
|
2024-11-04 23:57:39 +00:00
|
|
|
'aten/src/ATen/cpu/FlushDenormal.cpp',
|
|
|
|
|
'aten/src/ATen/cpu/Utils.cpp',
|
|
|
|
|
'aten/src/ATen/cpu/vml.h',
|
2024-11-04 00:47:19 +00:00
|
|
|
'aten/src/ATen/CPUFixedAllocator.h',
|
|
|
|
|
'aten/src/ATen/Parallel*.h',
|
2024-02-28 01:35:25 +00:00
|
|
|
'c10/xpu/**/*.h',
|
|
|
|
|
'c10/xpu/**/*.cpp',
|
2024-10-30 14:20:06 +00:00
|
|
|
'c10/benchmark/intrusive_ptr_benchmark.cpp',
|
2024-01-18 08:15:50 +00:00
|
|
|
'c10/cuda/CUDAAlgorithm.h',
|
2024-01-08 11:07:55 +00:00
|
|
|
'c10/util/complex_math.h',
|
|
|
|
|
'c10/util/complex_utils.h',
|
|
|
|
|
'c10/util/flat_hash_map.h',
|
|
|
|
|
'c10/util/logging*.h',
|
2025-01-18 00:43:01 +00:00
|
|
|
'c10/metal/*.h',
|
2024-01-08 11:07:55 +00:00
|
|
|
'c10/util/hash.h',
|
|
|
|
|
'c10/util/strong_type.h',
|
|
|
|
|
'c10/util/SmallVector.h',
|
|
|
|
|
'c10/util/win32-headers.h',
|
2024-01-18 08:15:50 +00:00
|
|
|
'c10/test/**/*.h',
|
2023-09-12 00:54:53 +00:00
|
|
|
'third_party/**/*',
|
2024-10-21 14:22:36 +00:00
|
|
|
'torch/csrc/api/include/torch/nn/modules/common.h',
|
|
|
|
|
'torch/csrc/api/include/torch/linalg.h',
|
2023-09-17 17:11:50 +00:00
|
|
|
'torch/csrc/autograd/generated/**',
|
2024-10-28 13:56:54 +00:00
|
|
|
'torch/csrc/distributed/**/*.cu',
|
|
|
|
|
'torch/csrc/distributed/c10d/WinSockUtils.hpp',
|
|
|
|
|
'torch/csrc/distributed/c10d/quantization/quantization_gpu.h',
|
2024-03-24 05:26:32 +00:00
|
|
|
'torch/csrc/dynamo/eval_frame.h',
|
2024-07-30 13:04:57 +00:00
|
|
|
'torch/csrc/inductor/aoti_torch/c/shim.h',
|
2023-09-12 00:54:53 +00:00
|
|
|
'torch/csrc/jit/**/*',
|
2024-07-02 20:08:46 +00:00
|
|
|
'torch/csrc/jit/serialization/mobile_bytecode_generated.h',
|
2024-12-24 03:29:35 +00:00
|
|
|
'torch/csrc/utils/generated_serialization_types.h',
|
2024-10-30 14:20:06 +00:00
|
|
|
'torch/csrc/utils/pythoncapi_compat.h',
|
2024-11-26 05:41:28 +00:00
|
|
|
'torch/csrc/inductor/aoti_runtime/sycl_runtime_wrappers.h',
|
2021-11-11 22:52:04 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
init_command = [
|
2021-11-03 19:34:02 +00:00
|
|
|
'python3',
|
2021-11-15 19:04:30 +00:00
|
|
|
'tools/linter/adapters/s3_init.py',
|
|
|
|
|
'--config-json=tools/linter/adapters/s3_init_config.json',
|
|
|
|
|
'--linter=clang-tidy',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'--output-dir=.lintbin',
|
|
|
|
|
'--output-name=clang-tidy',
|
2021-11-03 19:34:02 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-03 19:34:02 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/clangtidy_linter.py',
|
2021-11-15 19:04:30 +00:00
|
|
|
'--binary=.lintbin/clang-tidy',
|
2021-11-03 19:34:02 +00:00
|
|
|
'--build_dir=./build',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'TYPEIGNORE'
|
2021-11-03 19:34:02 +00:00
|
|
|
include_patterns = ['**/*.py', '**/*.pyi']
|
2022-07-15 18:30:36 +00:00
|
|
|
exclude_patterns = [
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2022-07-15 18:30:36 +00:00
|
|
|
'test/test_jit.py',
|
|
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-03 19:34:02 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
2022-05-06 07:26:12 +00:00
|
|
|
'--pattern=# type:\s*ignore([^\[]|$)',
|
2021-11-08 17:34:39 +00:00
|
|
|
'--linter-name=TYPEIGNORE',
|
|
|
|
|
'--error-name=unqualified type: ignore',
|
|
|
|
|
"""--error-description=\
|
2021-11-03 19:34:02 +00:00
|
|
|
This line has an unqualified `type: ignore`; \
|
|
|
|
|
please convert it to `type: ignore[xxxx]`\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2024-01-28 03:39:24 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'TYPENOSKIP'
|
|
|
|
|
include_patterns = ['mypy.ini']
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=follow_imports\s*=\s*skip',
|
|
|
|
|
'--linter-name=TYPENOSKIP',
|
|
|
|
|
'--error-name=use of follow_imports = skip',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
follow_imports = skip is forbidden from mypy.ini configuration as it \
|
|
|
|
|
is extremely easy to accidentally turn off type checking unintentionally. If \
|
|
|
|
|
you need to suppress type errors, use a top level # mypy: ignore-errors. \
|
|
|
|
|
Do not rely on automatic Any substitution; instead, manually # type: ignore \
|
|
|
|
|
at use sites or define a pyi type stub with more relaxed types. \
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2021-11-03 19:34:02 +00:00
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'NOQA'
|
2021-11-03 19:34:02 +00:00
|
|
|
include_patterns = ['**/*.py', '**/*.pyi']
|
2023-07-31 23:46:39 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'caffe2/**',
|
|
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**'
|
|
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-03 19:34:02 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
2022-05-06 07:26:12 +00:00
|
|
|
'--pattern=# noqa([^:]|$)',
|
2021-11-15 19:04:30 +00:00
|
|
|
'--linter-name=NOQA',
|
2021-11-08 17:34:39 +00:00
|
|
|
'--error-name=unqualified noqa',
|
|
|
|
|
"""--error-description=\
|
2021-11-03 19:34:02 +00:00
|
|
|
This line has an unqualified `noqa`; \
|
|
|
|
|
please convert it to `noqa: XXXX`\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
|
2021-11-08 17:34:39 +00:00
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'NATIVEFUNCTIONS'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns=['aten/src/ATen/native/native_functions.yaml']
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/nativefunctions_linter.py',
|
|
|
|
|
'--native-functions-yml=aten/src/ATen/native/native_functions.yaml',
|
|
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
init_command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'ruamel.yaml==0.17.4',
|
|
|
|
|
]
|
2022-05-03 18:38:58 +00:00
|
|
|
is_formatter = true
|
2021-11-08 17:34:39 +00:00
|
|
|
|
2024-12-05 14:22:21 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'GHA'
|
|
|
|
|
include_patterns=['.github/workflows/**/*.yml']
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/gha_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2021-11-08 17:34:39 +00:00
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'NEWLINE'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns=['**']
|
|
|
|
|
exclude_patterns=[
|
|
|
|
|
'**/contrib/**',
|
|
|
|
|
'third_party/**',
|
2022-10-15 00:20:42 +00:00
|
|
|
'**/*.bat',
|
2021-11-08 17:34:39 +00:00
|
|
|
'**/*.expect',
|
|
|
|
|
'**/*.ipynb',
|
2022-10-15 00:20:42 +00:00
|
|
|
'**/*.ps1',
|
2022-04-15 20:38:52 +00:00
|
|
|
'**/*.ptl',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2021-11-08 17:34:39 +00:00
|
|
|
'tools/clang_format_hash/**',
|
2022-04-16 02:01:10 +00:00
|
|
|
'test/cpp/jit/upgrader_models/*.ptl',
|
|
|
|
|
'test/cpp/jit/upgrader_models/*.ptl.ff',
|
2023-08-23 18:54:33 +00:00
|
|
|
'**/*.png',
|
2023-09-27 21:21:29 +00:00
|
|
|
'**/*.gz',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/newlines_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
2022-05-03 18:38:58 +00:00
|
|
|
is_formatter = true
|
2021-11-08 17:34:39 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'SPACES'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns = ['**']
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/contrib/**',
|
|
|
|
|
'**/*.diff',
|
2023-02-28 03:51:08 +00:00
|
|
|
'**/*.patch',
|
2021-11-08 17:34:39 +00:00
|
|
|
'third_party/**',
|
2022-07-14 21:30:24 +00:00
|
|
|
'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2022-04-16 02:01:10 +00:00
|
|
|
'test/cpp/jit/upgrader_models/*.ptl',
|
|
|
|
|
'test/cpp/jit/upgrader_models/*.ptl.ff',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=[[:blank:]]$',
|
|
|
|
|
'--linter-name=SPACES',
|
|
|
|
|
'--error-name=trailing spaces',
|
|
|
|
|
'--replace-pattern=s/[[:blank:]]+$//',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This line has trailing spaces; please remove them.\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'TABS'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns = ['**']
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/*.svg',
|
|
|
|
|
'**/*Makefile',
|
|
|
|
|
'**/contrib/**',
|
|
|
|
|
'third_party/**',
|
|
|
|
|
'**/.gitattributes',
|
|
|
|
|
'**/.gitmodules',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2022-07-14 21:30:24 +00:00
|
|
|
'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',
|
2022-04-16 02:01:10 +00:00
|
|
|
'test/cpp/jit/upgrader_models/*.ptl',
|
|
|
|
|
'test/cpp/jit/upgrader_models/*.ptl.ff',
|
2024-07-25 14:36:13 +00:00
|
|
|
'.ci/docker/common/install_rocm_drm.sh',
|
2022-05-06 07:26:12 +00:00
|
|
|
'.lintrunner.toml',
|
Build magma binary tarballs for various cuda (#139888)
This is a first step towards removing builds dependency to conda.
Currently we build magma as a conda package in a pytorch conda channel, implemented in https://github.com/pytorch/builder/tree/a1b372dbda2e9e3bd946cf135aa3b0137dfdf052/magma.
This commit adapts the logic from pytorch/builder as follows:
- use pytorch/manylinux-cuda<cuda-version> as base image
- apply patches and invoke the build.sh script directly (not anymore through conda build)
- stores license and build files along with the built artifact, in an info subfolder
- create a tarball file which resembles that created by conda, without any conda-specific metadata
A new matrix workflow is added, which runs the build for each supported cuda version, and uploads the binaries to pyorch s3 bucket.
For the upload, define an upload.sh script, which will be used by the magma windows job as well, to upload to `s3://ossci-*` buckets.
The build runs on PR and push, upload runs in DRY_RUN mode in case of PR.
Fixes #139397
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139888
Approved by: https://github.com/atalman, https://github.com/malfet, https://github.com/seemethere
2024-11-08 13:28:27 +00:00
|
|
|
'.ci/magma/package_files/*.patch',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
2022-06-29 23:27:47 +00:00
|
|
|
# @lint-ignore TXT2
|
2022-05-06 07:26:12 +00:00
|
|
|
'--pattern= ',
|
2021-11-08 17:34:39 +00:00
|
|
|
'--linter-name=TABS',
|
|
|
|
|
'--error-name=saw some tabs',
|
|
|
|
|
'--replace-pattern=s/\t/ /',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This line has tabs; please replace them with spaces.\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2024-11-11 19:54:46 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'C10_UNUSED'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'**/*.cpp',
|
|
|
|
|
'**/*.h',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'c10/macros/Macros.h',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=C10_UNUSED',
|
|
|
|
|
'--linter-name=C10_UNUSED',
|
|
|
|
|
'--error-name=deprecated C10_UNUSED macro',
|
|
|
|
|
'--replace-pattern=s/C10_UNUSED/[[maybe_unused]]/',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Deprecated macro, use [[maybe_unused]] directly\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'C10_NODISCARD'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'**/*.cpp',
|
|
|
|
|
'**/*.h',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'c10/macros/Macros.h',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=C10_NODISCARD',
|
|
|
|
|
'--linter-name=C10_NODISCARD',
|
|
|
|
|
'--error-name=deprecated C10_NODISCARD macro',
|
|
|
|
|
'--replace-pattern=s/C10_NODISCARD/[[nodiscard]]/',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Deprecated macro, use [[nodiscard]] directly\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2021-11-08 17:34:39 +00:00
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'INCLUDE'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns = [
|
|
|
|
|
'c10/**',
|
|
|
|
|
'aten/**',
|
|
|
|
|
'torch/csrc/**',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'aten/src/ATen/native/quantized/cpu/qnnpack/**',
|
2022-07-14 21:30:24 +00:00
|
|
|
'aten/src/ATen/native/vulkan/api/vk_mem_alloc.h',
|
2022-11-08 21:44:43 +00:00
|
|
|
'aten/src/ATen/native/vulkan/glsl/**',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2022-04-13 16:09:39 +00:00
|
|
|
'torch/csrc/jit/serialization/mobile_bytecode_generated.h',
|
2022-12-21 13:45:26 +00:00
|
|
|
'torch/csrc/utils/pythoncapi_compat.h',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=#include "',
|
|
|
|
|
'--linter-name=INCLUDE',
|
|
|
|
|
'--error-name=quoted include',
|
|
|
|
|
'--replace-pattern=s/#include "(.*)"$/#include <\1>/',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This #include uses quotes; please convert it to #include <xxxx>\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2022-08-02 14:44:36 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'PYBIND11_INCLUDE'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'**/*.cpp',
|
|
|
|
|
'**/*.h',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'torch/csrc/utils/pybind.h',
|
|
|
|
|
'torch/utils/benchmark/utils/valgrind_wrapper/compat_bindings.cpp',
|
|
|
|
|
'caffe2/**/*',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
2025-01-29 21:08:45 +00:00
|
|
|
'--pattern=#include <pybind11\/(^|[^(gil\.h)])',
|
2022-08-02 14:44:36 +00:00
|
|
|
'--allowlist-pattern=#include <torch\/csrc\/utils\/pybind.h>',
|
|
|
|
|
'--linter-name=PYBIND11_INCLUDE',
|
|
|
|
|
'--match-first-only',
|
|
|
|
|
'--error-name=direct include of pybind11',
|
|
|
|
|
# https://stackoverflow.com/a/33416489/23845
|
|
|
|
|
# NB: this won't work if the pybind11 include is on the first line;
|
|
|
|
|
# but that's fine because it will just mean the lint will still fail
|
|
|
|
|
# after applying the change and you will have to fix it manually
|
|
|
|
|
'--replace-pattern=1,/(#include <pybind11\/)/ s/(#include <pybind11\/)/#include <torch\/csrc\/utils\/pybind.h>\n\1/',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This #include directly includes pybind11 without also including \
|
|
|
|
|
#include <torch/csrc/utils/pybind.h>; this means some important \
|
|
|
|
|
specializations may not be included.\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2022-10-21 12:54:15 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'ERROR_PRONE_ISINSTANCE'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'torch/_refs/**/*.py',
|
|
|
|
|
'torch/_prims/**/*.py',
|
|
|
|
|
'torch/_prims_common/**/*.py',
|
|
|
|
|
'torch/_decomp/**/*.py',
|
|
|
|
|
'torch/_meta_registrations.py',
|
|
|
|
|
]
|
2023-07-31 23:46:39 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
]
|
2022-10-21 12:54:15 +00:00
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=isinstance\([^)]+(int|float)\)',
|
|
|
|
|
'--linter-name=ERROR_PRONE_ISINSTANCE',
|
|
|
|
|
'--error-name=error prone isinstance',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This line has an isinstance call that directly refers to \
|
|
|
|
|
int or float. This is error-prone because you may also \
|
Unify SymIntNode and SymFloatNode into SymNode (#87817)
This refactor was prompted by challenges handling mixed int/float
operations in C++. A previous version of this patch
added overloads for each permutation of int/float and was unwieldy
https://github.com/pytorch/pytorch/pull/87722/ This PR takes a different
approach.
The general outline of the patch is to combine the C++ types SymIntNode
and SymFloatNode into a single type, SymNode. This is type erased; we
no longer know statically at C++ if we have an int/float and have to test
it with the is_int()/is_float() virtual methods. This has a number of
knock on effects.
- We no longer have C++ classes to bind to Python. Instead, we take an
entirely new approach to our Python API, where we have a SymInt/SymFloat
class defined entirely in Python, which hold a SymNode (which corresponds
to the C++ SymNode). However, SymNode is not pybind11-bound; instead,
it lives as-is in Python, and is wrapped into C++ SymNode using PythonSymNode
when it goes into C++. This implies a userland rename.
In principle, it is also possible for the canonical implementation of SymNode
to be written in C++, and then bound to Python with pybind11 (we have
this code, although it is commented out.) However, I did not implement
this as we currently have no C++ implementations of SymNode.
Because we do return SymInt/SymFloat from C++ bindings, the C++ binding
code needs to know how to find these classes. Currently, this is done
just by manually importing torch and getting the attributes.
- Because SymInt/SymFloat are easy Python wrappers, __sym_dispatch__ now
takes SymInt/SymFloat, rather than SymNode, bringing it in line with how
__torch_dispatch__ works.
Some miscellaneous improvements:
- SymInt now has a constructor that takes SymNode. Note that this
constructor is ambiguous if you pass in a subclass of SymNode,
so an explicit downcast is necessary. This means toSymFloat/toSymInt
are no more. This is a mild optimization as it means rvalue reference
works automatically.
- We uniformly use the caster for c10::SymInt/SymFloat, rather than
going the long way via the SymIntNode/SymFloatNode.
- Removed some unnecessary toSymInt/toSymFloat calls in normalize_*
functions, pretty sure this doesn't do anything.
- guard_int is now a free function, since to guard on an int you cannot
assume the method exists. A function can handle both int and SymInt
inputs.
- We clean up the magic method definition code for SymInt/SymFloat/SymNode.
ONLY the user classes (SymInt/SymFloat) get magic methods; SymNode gets
plain methods; this is to help avoid confusion between the two types.
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
cc @jansel @mlazos @soumith @voznesenskym @yanboliang @penguinwu @anijain2305
Pull Request resolved: https://github.com/pytorch/pytorch/pull/87817
Approved by: https://github.com/albanD, https://github.com/anjali411
2022-10-27 20:49:11 +00:00
|
|
|
have wanted to allow SymInt or SymFloat in your test. \
|
2022-10-21 12:54:15 +00:00
|
|
|
To suppress this lint, use an appropriate type alias defined \
|
|
|
|
|
in torch._prims_common; use IntLike/FloatLike when you would accept \
|
|
|
|
|
both regular and symbolic numbers, Dim for ints representing \
|
|
|
|
|
dimensions, or IntWithoutSymInt/FloatWithoutSymFloat if you really \
|
|
|
|
|
meant to exclude symbolic numbers.
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2022-08-02 14:44:37 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'PYBIND11_SPECIALIZATION'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'**/*.cpp',
|
|
|
|
|
'**/*.h',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
# The place for all orphan specializations
|
|
|
|
|
'torch/csrc/utils/pybind.h',
|
|
|
|
|
# These specializations are non-orphan
|
|
|
|
|
'torch/csrc/distributed/c10d/init.cpp',
|
|
|
|
|
'torch/csrc/jit/python/pybind.h',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2022-08-02 14:44:37 +00:00
|
|
|
# These are safe to exclude as they do not have Python
|
|
|
|
|
'c10/**/*',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=PYBIND11_DECLARE_HOLDER_TYPE',
|
|
|
|
|
'--linter-name=PYBIND11_SPECIALIZATION',
|
|
|
|
|
'--error-name=pybind11 specialization in non-standard location',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This pybind11 specialization (PYBIND11_DECLARE_HOLDER_TYPE) should \
|
|
|
|
|
be placed in torch/csrc/utils/pybind.h so that it is guaranteed to be \
|
|
|
|
|
included at any site that may potentially make use of it via py::cast. \
|
|
|
|
|
If your specialization is in the same header file as the definition \
|
|
|
|
|
of the holder type, you can ignore this lint by adding your header to \
|
|
|
|
|
the exclude_patterns for this lint in .lintrunner.toml. For more \
|
|
|
|
|
information see https://github.com/pybind/pybind11/issues/4099 \
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2021-11-08 17:34:39 +00:00
|
|
|
[[linter]]
|
2021-11-08 17:34:39 +00:00
|
|
|
code = 'PYPIDEP'
|
2021-11-08 17:34:39 +00:00
|
|
|
include_patterns = ['.github/**']
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/*.rst',
|
|
|
|
|
'**/*.py',
|
|
|
|
|
'**/*.md',
|
|
|
|
|
'**/*.diff',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2021-11-08 17:34:39 +00:00
|
|
|
]
|
2021-11-08 17:34:39 +00:00
|
|
|
command = [
|
2021-11-08 17:34:39 +00:00
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
"""--pattern=\
|
|
|
|
|
(pip|pip3|python -m pip|python3 -m pip|python3 -mpip|python -mpip) \
|
2022-05-06 07:26:12 +00:00
|
|
|
install ([a-zA-Z0-9][A-Za-z0-9\\._\\-]+)([^/=<>~!]+)[A-Za-z0-9\\._\\-\\*\\+\\!]*$\
|
2021-11-08 17:34:39 +00:00
|
|
|
""",
|
|
|
|
|
'--linter-name=PYPIDEP',
|
|
|
|
|
'--error-name=unpinned PyPI install',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This line has unpinned PyPi installs; \
|
|
|
|
|
please pin them to a specific version: e.g. 'thepackage==1.2'\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
2021-11-09 20:46:59 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'EXEC'
|
|
|
|
|
include_patterns = ['**']
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'third_party/**',
|
|
|
|
|
'torch/bin/**',
|
|
|
|
|
'**/*.so',
|
|
|
|
|
'**/*.py',
|
|
|
|
|
'**/*.sh',
|
|
|
|
|
'**/*.bash',
|
|
|
|
|
'**/git-pre-commit',
|
|
|
|
|
'**/git-clang-format',
|
|
|
|
|
'**/gradlew',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2021-11-09 20:46:59 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
2021-11-11 20:17:19 +00:00
|
|
|
'tools/linter/adapters/exec_linter.py',
|
2021-11-09 20:46:59 +00:00
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'CUBINCLUDE'
|
|
|
|
|
include_patterns = ['aten/**']
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'aten/src/ATen/cuda/cub*.cuh',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2021-11-09 20:46:59 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=#include <cub/',
|
|
|
|
|
'--linter-name=CUBINCLUDE',
|
|
|
|
|
'--error-name=direct cub include',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This line has a direct cub include; please include \
|
|
|
|
|
ATen/cuda/cub.cuh instead and wrap your cub calls in \
|
|
|
|
|
at::native namespace if necessary.
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'RAWCUDA'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'aten/**',
|
|
|
|
|
'c10/**',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'aten/src/ATen/test/**',
|
|
|
|
|
'c10/cuda/CUDAFunctions.h',
|
2023-04-17 02:05:07 +00:00
|
|
|
'c10/cuda/CUDACachingAllocator.cpp',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2021-11-09 20:46:59 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=cudaStreamSynchronize',
|
|
|
|
|
'--linter-name=RAWCUDA',
|
|
|
|
|
'--error-name=raw CUDA API usage',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This line calls raw CUDA APIs directly; please use at::cuda wrappers instead.
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
2021-11-11 20:17:19 +00:00
|
|
|
|
2023-04-10 17:31:12 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'RAWCUDADEVICE'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'aten/**',
|
|
|
|
|
'c10/**',
|
|
|
|
|
'torch/csrc/**',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'aten/src/ATen/cuda/CUDAContext.cpp',
|
|
|
|
|
'aten/src/ATen/cuda/CUDAGeneratorImpl.cpp',
|
|
|
|
|
'aten/src/ATen/test/**',
|
|
|
|
|
'c10/core/impl/InlineDeviceGuard.h',
|
|
|
|
|
'c10/cuda/CUDAFunctions.cpp',
|
|
|
|
|
'c10/cuda/CUDAGuard.h',
|
|
|
|
|
'c10/cuda/impl/CUDATest.cpp',
|
|
|
|
|
'torch/csrc/cuda/nccl.cpp',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2023-04-10 17:31:12 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
2023-04-17 02:05:07 +00:00
|
|
|
'--pattern=cudaSetDevice(',
|
|
|
|
|
'--pattern=cudaGetDevice(',
|
2023-04-10 17:31:12 +00:00
|
|
|
'--linter-name=RAWCUDADEVICE',
|
|
|
|
|
'--error-name=raw CUDA API usage',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
This line calls raw CUDA APIs directly; please use c10::cuda wrappers instead.
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2022-12-16 00:56:17 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'ROOT_LOGGING'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'**/*.py',
|
|
|
|
|
]
|
|
|
|
|
# These are not library code, but scripts in their own right, and so
|
|
|
|
|
# therefore are permitted to use logging
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'tools/**',
|
|
|
|
|
'test/**',
|
|
|
|
|
'benchmarks/**',
|
|
|
|
|
'torch/distributed/run.py',
|
|
|
|
|
'functorch/benchmarks/**',
|
|
|
|
|
# Grandfathered in
|
|
|
|
|
'caffe2/**',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2022-12-16 00:56:17 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=logging\.(debug|info|warn|warning|error|critical|log|exception)\(',
|
|
|
|
|
'--replace-pattern=s/logging\.(debug|info|warn|warning|error|critical|log|exception)\(/log.\1(/',
|
|
|
|
|
'--linter-name=ROOT_LOGGING',
|
|
|
|
|
'--error-name=use of root logger',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Do not use root logger (logging.info, etc) directly; instead \
|
|
|
|
|
define 'log = logging.getLogger(__name__)' and call, e.g., log.info().
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2023-05-16 16:05:44 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'DEPLOY_DETECTION'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'**/*.py',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=sys\.executable == .torch_deploy.',
|
|
|
|
|
'--replace-pattern=s/sys\.executable == .torch_deploy./torch._running_with_deploy\(\)/',
|
|
|
|
|
'--linter-name=DEPLOY_DETECTION',
|
|
|
|
|
'--error-name=properly detect deploy runner',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Do not use sys.executable to detect if running within deploy/multipy, use torch._running_with_deploy().
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2021-11-11 20:17:19 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'CMAKE'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
"**/*.cmake",
|
|
|
|
|
"**/*.cmake.in",
|
|
|
|
|
"**/CMakeLists.txt",
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'cmake/Modules/**',
|
|
|
|
|
'cmake/Modules_CUDA_fix/**',
|
|
|
|
|
'cmake/Caffe2Config.cmake.in',
|
|
|
|
|
'aten/src/ATen/ATenConfig.cmake.in',
|
|
|
|
|
'cmake/TorchConfig.cmake.in',
|
|
|
|
|
'cmake/TorchConfigVersion.cmake.in',
|
|
|
|
|
'cmake/cmake_uninstall.cmake.i',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2021-11-11 20:17:19 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/cmake_linter.py',
|
|
|
|
|
'--config=.cmakelintrc',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'cmakelint==1.4.1',
|
|
|
|
|
]
|
2022-04-15 03:52:22 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'SHELLCHECK'
|
|
|
|
|
include_patterns = [
|
2023-01-30 18:28:32 +00:00
|
|
|
'.ci/pytorch/**/*.sh'
|
2022-04-15 03:52:22 +00:00
|
|
|
]
|
2023-07-31 23:46:39 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
]
|
2022-04-15 03:52:22 +00:00
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/shellcheck_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'shellcheck-py==0.7.2.1',
|
|
|
|
|
]
|
2022-04-15 03:52:22 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'ACTIONLINT'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'.github/workflows/*.yml',
|
|
|
|
|
'.github/workflows/*.yaml',
|
|
|
|
|
# actionlint does not support composite actions yet
|
|
|
|
|
# '.github/actions/**/*.yml',
|
|
|
|
|
# '.github/actions/**/*.yaml',
|
|
|
|
|
]
|
2023-07-31 23:46:39 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
]
|
2022-04-15 03:52:22 +00:00
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/actionlint_linter.py',
|
|
|
|
|
'--binary=.lintbin/actionlint',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/s3_init.py',
|
|
|
|
|
'--config-json=tools/linter/adapters/s3_init_config.json',
|
|
|
|
|
'--linter=actionlint',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'--output-dir=.lintbin',
|
|
|
|
|
'--output-name=actionlint',
|
|
|
|
|
]
|
2022-04-15 18:07:31 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'TESTOWNERS'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'test/**/test_*.py',
|
|
|
|
|
'test/**/*_test.py',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'test/run_test.py',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2022-04-15 18:07:31 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/testowners_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
2022-04-26 00:23:02 +00:00
|
|
|
|
2023-12-01 17:24:08 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'TEST_HAS_MAIN'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'test/**/test_*.py',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'test/run_test.py',
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
'test/quantization/**', # should be run through test/test_quantization.py
|
|
|
|
|
'test/jit/**', # should be run through test/test_jit.py
|
|
|
|
|
'test/ao/sparsity/**', # should be run through test/test_ao_sparsity.py
|
|
|
|
|
'test/fx/**', # should be run through test/test_fx.py
|
2023-12-07 08:27:37 +00:00
|
|
|
'test/bottleneck_test/**', # excluded by test/run_test.py
|
2023-12-19 22:20:07 +00:00
|
|
|
'test/package/**', # excluded by test/run_test.py
|
2023-12-01 17:24:08 +00:00
|
|
|
'test/distributed/argparse_util_test.py',
|
|
|
|
|
'test/distributed/bin/test_script.py',
|
|
|
|
|
'test/distributed/elastic/agent/server/test/local_elastic_agent_test.py',
|
|
|
|
|
'test/distributed/elastic/multiprocessing/bin/test_script.py',
|
|
|
|
|
'test/distributed/elastic/multiprocessing/bin/zombie_test.py',
|
|
|
|
|
'test/distributed/elastic/multiprocessing/errors/api_test.py',
|
|
|
|
|
'test/distributed/elastic/multiprocessing/errors/error_handler_test.py',
|
|
|
|
|
'test/distributed/elastic/multiprocessing/redirects_test.py',
|
|
|
|
|
'test/distributed/elastic/multiprocessing/tail_log_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/api_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/c10d_rendezvous_backend_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/dynamic_rendezvous_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/etcd_rendezvous_backend_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/etcd_rendezvous_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/etcd_server_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/rendezvous_backend_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/static_rendezvous_test.py',
|
|
|
|
|
'test/distributed/elastic/rendezvous/utils_test.py',
|
|
|
|
|
'test/distributed/elastic/timer/api_test.py',
|
|
|
|
|
'test/distributed/elastic/utils/data/cycling_iterator_test.py',
|
|
|
|
|
'test/distributed/launcher/api_test.py',
|
|
|
|
|
'test/distributed/launcher/bin/test_script.py',
|
|
|
|
|
'test/distributed/launcher/bin/test_script_init_method.py',
|
|
|
|
|
'test/distributed/launcher/bin/test_script_is_torchelastic_launched.py',
|
|
|
|
|
'test/distributed/launcher/bin/test_script_local_rank.py',
|
|
|
|
|
'test/distributed/launcher/launch_test.py',
|
|
|
|
|
'test/distributed/launcher/run_test.py',
|
|
|
|
|
'test/distributed/optim/test_apply_optimizer_in_backward.py',
|
|
|
|
|
'test/distributed/optim/test_named_optimizer.py',
|
|
|
|
|
'test/distributed/test_c10d_spawn.py',
|
|
|
|
|
'test/distributed/test_collective_utils.py',
|
|
|
|
|
'test/distributions/test_distributions.py',
|
2023-12-09 19:03:32 +00:00
|
|
|
'test/inductor/test_aot_inductor_utils.py',
|
2023-12-01 17:24:08 +00:00
|
|
|
'test/lazy/test_bindings.py',
|
|
|
|
|
'test/lazy/test_extract_compiled_graph.py',
|
|
|
|
|
'test/lazy/test_meta_kernel.py',
|
|
|
|
|
'test/nn/test_init.py',
|
|
|
|
|
'test/onnx/model_defs/op_test.py',
|
|
|
|
|
'test/onnx/test_models_quantized_onnxruntime.py',
|
|
|
|
|
'test/onnx/test_onnxscript_no_runtime.py',
|
|
|
|
|
'test/onnx_caffe2/test_caffe2_common.py',
|
|
|
|
|
'test/optim/test_lrscheduler.py',
|
|
|
|
|
'test/optim/test_optim.py',
|
|
|
|
|
'test/optim/test_swa_utils.py',
|
|
|
|
|
'test/run_test.py',
|
|
|
|
|
'test/test_bundled_images.py',
|
|
|
|
|
'test/test_cuda_expandable_segments.py',
|
|
|
|
|
'test/test_hub.py',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/test_has_main_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
|
|
|
|
|
2022-06-28 15:47:00 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'CALL_ONCE'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'c10/**',
|
|
|
|
|
'aten/**',
|
|
|
|
|
'torch/csrc/**',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'c10/util/CallOnce.h',
|
2023-07-31 23:46:39 +00:00
|
|
|
'**/fb/**',
|
2022-06-28 15:47:00 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=std::call_once',
|
|
|
|
|
'--linter-name=CALL_ONCE',
|
|
|
|
|
'--error-name=invalid call_once',
|
|
|
|
|
'--replace-pattern=s/std::call_once/c10::call_once/',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Use of std::call_once is forbidden and should be replaced with c10::call_once\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2024-08-01 17:00:12 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'CONTEXT_DECORATOR'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'torch/**',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
2024-08-07 15:08:00 +00:00
|
|
|
'--pattern=@.*(dynamo_timed|preserve_rng_state|clear_frame|with_fresh_cache_if_config|use_lazy_graph_module|_disable_current_modes)',
|
2024-08-01 17:00:12 +00:00
|
|
|
'--linter-name=CONTEXT_DECORATOR',
|
|
|
|
|
'--error-name=avoid context decorator',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Do not use context manager as decorator as it breaks cProfile traces. Use it as \
|
|
|
|
|
a context manager instead\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2022-06-28 15:47:00 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'ONCE_FLAG'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'c10/**',
|
|
|
|
|
'aten/**',
|
|
|
|
|
'torch/csrc/**',
|
|
|
|
|
]
|
2023-07-31 23:46:39 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
]
|
2022-06-28 15:47:00 +00:00
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=std::once_flag',
|
|
|
|
|
'--linter-name=ONCE_FLAG',
|
|
|
|
|
'--error-name=invalid once_flag',
|
|
|
|
|
'--replace-pattern=s/std::once_flag/c10::once_flag/',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Use of std::once_flag is forbidden and should be replaced with c10::once_flag\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
2022-07-02 08:31:57 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'WORKFLOWSYNC'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'.github/workflows/pull.yml',
|
|
|
|
|
'.github/workflows/trunk.yml',
|
|
|
|
|
'.github/workflows/periodic.yml',
|
2023-08-01 00:47:28 +00:00
|
|
|
'.github/workflows/mac-mps.yml',
|
|
|
|
|
'.github/workflows/slow.yml',
|
2022-07-02 08:31:57 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/workflow_consistency_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
2024-03-19 12:23:49 +00:00
|
|
|
'PyYAML==6.0.1',
|
2022-07-02 08:31:57 +00:00
|
|
|
]
|
2022-07-11 19:20:22 +00:00
|
|
|
|
2024-10-28 17:46:50 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'NO_WORKFLOWS_ON_FORK'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'.github/**/*.yml',
|
|
|
|
|
'.github/**/*.yaml',
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/no_workflows_on_fork.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}',
|
|
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'PyYAML==6.0.1',
|
|
|
|
|
]
|
|
|
|
|
|
2024-08-04 14:11:04 +00:00
|
|
|
# usort + ruff-format
|
2022-07-11 19:20:22 +00:00
|
|
|
[[linter]]
|
2024-08-04 02:41:36 +00:00
|
|
|
code = 'PYFMT'
|
2022-07-13 07:59:20 +00:00
|
|
|
include_patterns = [
|
2023-07-19 14:42:23 +00:00
|
|
|
'**/*.py',
|
2023-07-19 18:20:17 +00:00
|
|
|
'**/*.pyi',
|
2022-07-13 07:59:20 +00:00
|
|
|
]
|
2022-07-11 19:20:22 +00:00
|
|
|
command = [
|
|
|
|
|
'python3',
|
2024-08-04 02:41:36 +00:00
|
|
|
'tools/linter/adapters/pyfmt_linter.py',
|
2022-07-11 19:20:22 +00:00
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
'tools/gen_vulkan_spv.py',
|
2023-07-19 14:42:23 +00:00
|
|
|
# We don't care too much about files in this directory, don't enforce
|
|
|
|
|
# formatting on them
|
|
|
|
|
'caffe2/**/*.py',
|
2023-07-19 18:20:17 +00:00
|
|
|
'caffe2/**/*.pyi',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2023-07-19 14:42:23 +00:00
|
|
|
'third_party/**/*.py',
|
2023-07-19 18:20:17 +00:00
|
|
|
'third_party/**/*.pyi',
|
2024-12-23 10:44:24 +00:00
|
|
|
'torch/_vendor/**',
|
2023-09-20 00:08:09 +00:00
|
|
|
'torch/_inductor/fx_passes/serialized_patterns/**',
|
AutoHeuristic: mixed_mm heuristic for A100 (#131613)
This PR introduces changes to AutoHeuristic that allow one to learn a heuristic as a decision tree. I used this to learn a heuristic for mixed_mm on A100 that consistenly performs better than the default choice (https://github.com/pytorch/pytorch/blob/main/torch/_inductor/kernel/mm.py#L402).
This is how the results look like:
Explanation of columns:
**wrong_max_spdup**: In the worst case, how much better would the best choice have been
**wrong_gman_spdup**: For inputs where the heuristic is wrong, how much better is the best choice on average (geomean)
**max_spdup_default**: Highest speedup achieved by the learned heuristic over the default choice
**gman_spdup_default**: Geomean speedup achived by the learned heuristic over the default choice
**max_slowdown_default**: If the default choice is better than the choice predicted by the learned heuristic, how much is it better in the worst case
**non_default_preds**: Number of times the learned heuristic predicted a choice that is not the default choice
**default_better**: Number of times the default choice is better than the choice made by the heuristic
```
set crit max_depth min_samples_leaf correct wrong unsure total wrong_max_spdup wrong_gman_spdup max_spdup_default gman_spdup_default max_slowdown_default non_default_preds default_better
train entropy 5 0.01 2376 740 323 3439 1.855386 1.063236 11.352318 3.438279 1.022164 3116 2
test entropy 5 0.01 563 183 71 817 1.622222 1.060897 10.084181 3.507741 1.017039 746 2
```
While the number of wrong predictions is high, on average the best choice is only around 6% better. What is important is that the choice predicted by the learned heuristic performs better than the default choice.
I evaluated my heuristic on gpt-fast `meta-llama/Llama-2-7b-chat-hf` with int8 weight quantization. To get the `tuned_mixed_mm` to trigger, I had to replace `F.linear()` in https://github.com/pytorch-labs/gpt-fast/blob/main/quantize.py#L355 with `torch.matmul(input, self.weight.t().to(dtype=input.dtype))` because the mixed_mm pattern does not match if there is a transpose between a cast and the matmul.
|batch size|prompt length| fallback | heuristic | speedup |
|----------|-------------|------------:|------------:|--------:|
| 1 | 7 | 75.31 tok/s | 148.83 tok/s| 1.97 |
| 1 | 11 | 75.99 tok/s | 148.15 tok/s| 1.94 |
| 4 | 7 | 103.48 tok/s | 472.00 tok/s| 4.56 |
| 4 | 11 | 103.56 tok/s | 371.36 tok/s| 3.58 |
| 8 | 7 | 201.92 tok/s | 813.44 tok/s| 4.02 |
| 8 | 11 | 201.76 tok/s | 699.36 tok/s| 3.46 |
Currently, the heuristic only applies to the following inputs:
- m <= 128, k >= 1024, n >= 1024 (For these sizes, one of the triton kernels wins in most cases, but the heuristic still has to be careful to not choose a config that performs worse than the fallback)
- k % 256 == 0 (If k is not a multiple of the block size, some choices perform extremely bad. In one case one config, that usually performs very well, was 130x slower.)
- mat1 not transposed
- mat2 transposed (In some cases, it was hard for the learned heuristic to detect some cases where it
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131613
Approved by: https://github.com/eellison
2024-08-01 22:48:47 +00:00
|
|
|
'torch/_inductor/autoheuristic/artifacts/**',
|
2023-07-19 14:42:23 +00:00
|
|
|
# These files are all grandfathered in, feel free to remove from this list
|
|
|
|
|
# as necessary
|
|
|
|
|
'test/_nvfuser/__init__.py',
|
|
|
|
|
'test/_nvfuser/test_dynamo.py',
|
|
|
|
|
'test/_nvfuser/test_python_frontend.py',
|
|
|
|
|
'test/_nvfuser/test_torchscript.py',
|
|
|
|
|
'test/delete.py',
|
|
|
|
|
'test/expect/__init__.py',
|
|
|
|
|
'test/quantization/__init__.py',
|
|
|
|
|
'test/quantization/core/__init__.py',
|
|
|
|
|
'test/quantization/core/experimental/apot_fx_graph_mode_ptq.py',
|
|
|
|
|
'test/quantization/core/experimental/apot_fx_graph_mode_qat.py',
|
|
|
|
|
'test/quantization/core/experimental/quantization_util.py',
|
|
|
|
|
'test/quantization/core/experimental/test_bits.py',
|
|
|
|
|
'test/quantization/core/experimental/test_fake_quantize.py',
|
|
|
|
|
'test/quantization/core/experimental/test_linear.py',
|
|
|
|
|
'test/quantization/core/experimental/test_nonuniform_observer.py',
|
|
|
|
|
'test/quantization/core/experimental/test_quantized_tensor.py',
|
|
|
|
|
'test/quantization/core/experimental/test_quantizer.py',
|
|
|
|
|
'test/quantization/core/test_backend_config.py',
|
|
|
|
|
'test/quantization/core/test_docs.py',
|
|
|
|
|
'test/quantization/core/test_quantized_functional.py',
|
|
|
|
|
'test/quantization/core/test_quantized_module.py',
|
|
|
|
|
'test/quantization/core/test_quantized_op.py',
|
|
|
|
|
'test/quantization/core/test_quantized_tensor.py',
|
|
|
|
|
'test/quantization/core/test_top_level_apis.py',
|
|
|
|
|
'test/quantization/core/test_utils.py',
|
|
|
|
|
'test/quantization/core/test_workflow_module.py',
|
|
|
|
|
'test/quantization/core/test_workflow_ops.py',
|
|
|
|
|
'test/quantization/eager/__init__.py',
|
|
|
|
|
'test/quantization/eager/test_bias_correction_eager.py',
|
|
|
|
|
'test/quantization/eager/test_equalize_eager.py',
|
|
|
|
|
'test/quantization/eager/test_fuse_eager.py',
|
|
|
|
|
'test/quantization/eager/test_model_numerics.py',
|
|
|
|
|
'test/quantization/eager/test_numeric_suite_eager.py',
|
|
|
|
|
'test/quantization/eager/test_quantize_eager_ptq.py',
|
|
|
|
|
'test/quantization/eager/test_quantize_eager_qat.py',
|
|
|
|
|
'test/quantization/fx/__init__.py',
|
|
|
|
|
'test/quantization/fx/test_equalize_fx.py',
|
|
|
|
|
'test/quantization/fx/test_model_report_fx.py',
|
|
|
|
|
'test/quantization/fx/test_numeric_suite_fx.py',
|
|
|
|
|
'test/quantization/fx/test_quantize_fx.py',
|
|
|
|
|
'test/quantization/fx/test_subgraph_rewriter.py',
|
2024-05-15 21:58:31 +00:00
|
|
|
'test/test_fake_tensor.py',
|
|
|
|
|
'test/test_flop_counter.py',
|
|
|
|
|
'test/test_function_schema.py',
|
|
|
|
|
'test/test_functional_autograd_benchmark.py',
|
|
|
|
|
'test/test_functional_optim.py',
|
|
|
|
|
'test/test_functionalization_of_rng_ops.py',
|
2023-07-19 14:42:23 +00:00
|
|
|
'test/test_datapipe.py',
|
|
|
|
|
'test/test_futures.py',
|
|
|
|
|
'test/test_fx.py',
|
|
|
|
|
'test/test_fx_experimental.py',
|
|
|
|
|
'test/test_fx_passes.py',
|
|
|
|
|
'test/test_fx_reinplace_pass.py',
|
|
|
|
|
'test/test_import_stats.py',
|
|
|
|
|
'test/test_itt.py',
|
|
|
|
|
'test/test_jit.py',
|
|
|
|
|
'test/test_jit_autocast.py',
|
|
|
|
|
'test/test_jit_cuda_fuser.py',
|
|
|
|
|
'test/test_jit_disabled.py',
|
|
|
|
|
'test/test_jit_fuser.py',
|
|
|
|
|
'test/test_jit_fuser_legacy.py',
|
|
|
|
|
'test/test_jit_legacy.py',
|
|
|
|
|
'test/test_jit_llga_fuser.py',
|
|
|
|
|
'test/test_jit_profiling.py',
|
|
|
|
|
'test/test_jit_simple.py',
|
|
|
|
|
'test/test_jit_string.py',
|
|
|
|
|
'test/test_jiterator.py',
|
|
|
|
|
'test/test_kernel_launch_checks.py',
|
|
|
|
|
'test/test_linalg.py',
|
|
|
|
|
'test/test_masked.py',
|
|
|
|
|
'test/test_maskedtensor.py',
|
|
|
|
|
'test/test_matmul_cuda.py',
|
|
|
|
|
'test/test_meta.py',
|
|
|
|
|
'test/test_metal.py',
|
|
|
|
|
'test/test_mkl_verbose.py',
|
|
|
|
|
'test/test_mkldnn.py',
|
|
|
|
|
'test/test_mkldnn_fusion.py',
|
|
|
|
|
'test/test_mkldnn_verbose.py',
|
|
|
|
|
'test/test_mobile_optimizer.py',
|
|
|
|
|
'test/test_model_dump.py',
|
|
|
|
|
'test/test_modules.py',
|
|
|
|
|
'test/test_monitor.py',
|
|
|
|
|
'test/test_mps.py',
|
|
|
|
|
'test/test_multiprocessing_spawn.py',
|
|
|
|
|
'test/test_namedtensor.py',
|
|
|
|
|
'test/test_namedtuple_return_api.py',
|
|
|
|
|
'test/test_native_functions.py',
|
|
|
|
|
'test/test_native_mha.py',
|
|
|
|
|
'test/test_nn.py',
|
|
|
|
|
'test/test_out_dtype_op.py',
|
|
|
|
|
'test/test_overrides.py',
|
|
|
|
|
'test/test_prims.py',
|
|
|
|
|
'test/test_proxy_tensor.py',
|
|
|
|
|
'test/test_pruning_op.py',
|
|
|
|
|
'test/test_quantization.py',
|
|
|
|
|
'test/test_reductions.py',
|
|
|
|
|
'test/test_scatter_gather_ops.py',
|
|
|
|
|
'test/test_schema_check.py',
|
|
|
|
|
'test/test_segment_reductions.py',
|
|
|
|
|
'test/test_serialization.py',
|
|
|
|
|
'test/test_set_default_mobile_cpu_allocator.py',
|
|
|
|
|
'test/test_sparse.py',
|
|
|
|
|
'test/test_sparse_csr.py',
|
|
|
|
|
'test/test_sparse_semi_structured.py',
|
|
|
|
|
'test/test_spectral_ops.py',
|
|
|
|
|
'test/test_stateless.py',
|
|
|
|
|
'test/test_static_runtime.py',
|
|
|
|
|
'test/test_subclass.py',
|
|
|
|
|
'test/test_sympy_utils.py',
|
|
|
|
|
'test/test_tensor_creation_ops.py',
|
|
|
|
|
'test/test_tensorboard.py',
|
|
|
|
|
'test/test_tensorexpr.py',
|
|
|
|
|
'test/test_tensorexpr_pybind.py',
|
|
|
|
|
'test/test_testing.py',
|
|
|
|
|
'test/test_torch.py',
|
|
|
|
|
'test/test_transformers.py',
|
|
|
|
|
'test/test_type_promotion.py',
|
|
|
|
|
'test/test_unary_ufuncs.py',
|
|
|
|
|
'test/test_vulkan.py',
|
|
|
|
|
'torch/_awaits/__init__.py',
|
|
|
|
|
'torch/_custom_op/__init__.py',
|
|
|
|
|
'torch/_custom_op/autograd.py',
|
|
|
|
|
'torch/_custom_op/functional.py',
|
|
|
|
|
'torch/_custom_op/impl.py',
|
|
|
|
|
'torch/_export/__init__.py',
|
|
|
|
|
'torch/_export/constraints.py',
|
|
|
|
|
'torch/_export/db/__init__.py',
|
|
|
|
|
'torch/_export/db/case.py',
|
|
|
|
|
'torch/_export/db/examples/__init__.py',
|
|
|
|
|
'torch/_export/db/examples/assume_constant_result.py',
|
|
|
|
|
'torch/_export/db/examples/autograd_function.py',
|
|
|
|
|
'torch/_export/db/examples/class_method.py',
|
|
|
|
|
'torch/_export/db/examples/cond_branch_class_method.py',
|
|
|
|
|
'torch/_export/db/examples/cond_branch_nested_function.py',
|
|
|
|
|
'torch/_export/db/examples/cond_branch_nonlocal_variables.py',
|
|
|
|
|
'torch/_export/db/examples/cond_closed_over_variable.py',
|
|
|
|
|
'torch/_export/db/examples/cond_operands.py',
|
|
|
|
|
'torch/_export/db/examples/cond_predicate.py',
|
|
|
|
|
'torch/_export/db/examples/decorator.py',
|
|
|
|
|
'torch/_export/db/examples/dictionary.py',
|
|
|
|
|
'torch/_export/db/examples/dynamic_shape_assert.py',
|
|
|
|
|
'torch/_export/db/examples/dynamic_shape_constructor.py',
|
|
|
|
|
'torch/_export/db/examples/dynamic_shape_if_guard.py',
|
|
|
|
|
'torch/_export/db/examples/dynamic_shape_map.py',
|
|
|
|
|
'torch/_export/db/examples/dynamic_shape_round.py',
|
|
|
|
|
'torch/_export/db/examples/dynamic_shape_slicing.py',
|
|
|
|
|
'torch/_export/db/examples/dynamic_shape_view.py',
|
|
|
|
|
'torch/_export/db/examples/fn_with_kwargs.py',
|
|
|
|
|
'torch/_export/db/examples/list_contains.py',
|
|
|
|
|
'torch/_export/db/examples/list_unpack.py',
|
|
|
|
|
'torch/_export/db/examples/nested_function.py',
|
|
|
|
|
'torch/_export/db/examples/null_context_manager.py',
|
|
|
|
|
'torch/_export/db/examples/pytree_flatten.py',
|
|
|
|
|
'torch/_export/db/examples/scalar_output.py',
|
|
|
|
|
'torch/_export/db/examples/specialized_attribute.py',
|
|
|
|
|
'torch/_export/db/examples/static_for_loop.py',
|
|
|
|
|
'torch/_export/db/examples/static_if.py',
|
|
|
|
|
'torch/_export/db/examples/tensor_setattr.py',
|
|
|
|
|
'torch/_export/db/examples/type_reflection_method.py',
|
|
|
|
|
'torch/_export/db/gen_example.py',
|
|
|
|
|
'torch/_export/db/logging.py',
|
|
|
|
|
'torch/_export/error.py',
|
|
|
|
|
'torch/_export/exported_program.py',
|
|
|
|
|
'torch/_export/pass_base.py',
|
|
|
|
|
'torch/_export/pass_infra/__init__.py',
|
|
|
|
|
'torch/_export/pass_infra/node_metadata.py',
|
|
|
|
|
'torch/_export/pass_infra/proxy_value.py',
|
|
|
|
|
'torch/_export/passes/__init__.py',
|
|
|
|
|
'torch/_export/passes/add_runtime_assertions_for_constraints_pass.py',
|
|
|
|
|
'torch/_export/passes/const_prop_pass.py',
|
|
|
|
|
'torch/_export/passes/functionalize_side_effectful_ops_pass.py',
|
|
|
|
|
'torch/_export/passes/replace_sym_size_ops_pass.py',
|
|
|
|
|
'torch/_export/passes/replace_view_ops_with_view_copy_ops_pass.py',
|
|
|
|
|
'torch/_export/serde/__init__.py',
|
|
|
|
|
'torch/_export/serde/schema.py',
|
|
|
|
|
'torch/_export/serde/serialize.py',
|
|
|
|
|
'torch/_export/serde/upgrade.py',
|
|
|
|
|
'torch/_export/trace.py',
|
|
|
|
|
'torch/_export/verifier.py',
|
|
|
|
|
'torch/testing/_internal/__init__.py',
|
|
|
|
|
'torch/testing/_internal/autocast_test_lists.py',
|
|
|
|
|
'torch/testing/_internal/autograd_function_db.py',
|
|
|
|
|
'torch/testing/_internal/check_kernel_launches.py',
|
|
|
|
|
'torch/testing/_internal/codegen/__init__.py',
|
|
|
|
|
'torch/testing/_internal/codegen/random_topo_test.py',
|
|
|
|
|
'torch/testing/_internal/common_cuda.py',
|
|
|
|
|
'torch/testing/_internal/common_distributed.py',
|
|
|
|
|
'torch/testing/_internal/common_jit.py',
|
|
|
|
|
'torch/testing/_internal/common_methods_invocations.py',
|
|
|
|
|
'torch/testing/_internal/common_modules.py',
|
|
|
|
|
'torch/testing/_internal/common_nn.py',
|
|
|
|
|
'torch/testing/_internal/common_pruning.py',
|
|
|
|
|
'torch/testing/_internal/common_quantization.py',
|
|
|
|
|
'torch/testing/_internal/common_quantized.py',
|
|
|
|
|
'torch/testing/_internal/common_subclass.py',
|
|
|
|
|
'torch/testing/_internal/common_utils.py',
|
|
|
|
|
'torch/testing/_internal/composite_compliance.py',
|
2024-03-28 17:33:51 +00:00
|
|
|
'torch/testing/_internal/hop_db.py',
|
2023-07-19 14:42:23 +00:00
|
|
|
'torch/testing/_internal/custom_op_db.py',
|
|
|
|
|
'torch/testing/_internal/data/__init__.py',
|
|
|
|
|
'torch/testing/_internal/data/network1.py',
|
|
|
|
|
'torch/testing/_internal/data/network2.py',
|
|
|
|
|
'torch/testing/_internal/dist_utils.py',
|
|
|
|
|
'torch/testing/_internal/distributed/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/_shard/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/_shard/sharded_tensor/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/_shard/sharded_tensor/_test_ops_common.py',
|
|
|
|
|
'torch/testing/_internal/distributed/_shard/sharded_tensor/_test_st_common.py',
|
|
|
|
|
'torch/testing/_internal/distributed/_shard/test_common.py',
|
|
|
|
|
'torch/testing/_internal/distributed/_tensor/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/_tensor/common_dtensor.py',
|
|
|
|
|
'torch/testing/_internal/distributed/ddp_under_dist_autograd_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/distributed_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/distributed_utils.py',
|
|
|
|
|
'torch/testing/_internal/distributed/fake_pg.py',
|
|
|
|
|
'torch/testing/_internal/distributed/multi_threaded_pg.py',
|
|
|
|
|
'torch/testing/_internal/distributed/nn/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/nn/api/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/nn/api/remote_module_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/dist_autograd_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/dist_optimizer_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/examples/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/examples/parameter_server_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/examples/reinforcement_learning_rpc_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/faulty_agent_rpc_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/faulty_rpc_agent_test_fixture.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/jit/__init__.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/jit/dist_autograd_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/jit/rpc_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/jit/rpc_test_faulty.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/rpc_agent_test_fixture.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/rpc_test.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc/tensorpipe_rpc_agent_test_fixture.py',
|
|
|
|
|
'torch/testing/_internal/distributed/rpc_utils.py',
|
|
|
|
|
'torch/testing/_internal/generated/__init__.py',
|
|
|
|
|
'torch/testing/_internal/hypothesis_utils.py',
|
|
|
|
|
'torch/testing/_internal/inductor_utils.py',
|
|
|
|
|
'torch/testing/_internal/jit_metaprogramming_utils.py',
|
|
|
|
|
'torch/testing/_internal/jit_utils.py',
|
|
|
|
|
'torch/testing/_internal/logging_tensor.py',
|
|
|
|
|
'torch/testing/_internal/logging_utils.py',
|
|
|
|
|
'torch/testing/_internal/optests/__init__.py',
|
|
|
|
|
'torch/testing/_internal/optests/aot_autograd.py',
|
|
|
|
|
'torch/testing/_internal/optests/compile_check.py',
|
|
|
|
|
'torch/testing/_internal/optests/fake_tensor.py',
|
|
|
|
|
'torch/testing/_internal/optests/make_fx.py',
|
|
|
|
|
'torch/testing/_internal/quantization_torch_package_models.py',
|
|
|
|
|
'torch/testing/_internal/test_module/__init__.py',
|
|
|
|
|
'torch/testing/_internal/test_module/future_div.py',
|
|
|
|
|
'torch/testing/_internal/test_module/no_future_div.py',
|
|
|
|
|
'torch/utils/_contextlib.py',
|
|
|
|
|
'torch/utils/_cpp_extension_versioner.py',
|
|
|
|
|
'torch/utils/_crash_handler.py',
|
|
|
|
|
'torch/utils/_device.py',
|
|
|
|
|
'torch/utils/_foreach_utils.py',
|
|
|
|
|
'torch/utils/_freeze.py',
|
|
|
|
|
'torch/utils/_mode_utils.py',
|
|
|
|
|
'torch/utils/_python_dispatch.py',
|
|
|
|
|
'torch/utils/_stats.py',
|
|
|
|
|
'torch/utils/_traceback.py',
|
|
|
|
|
'torch/utils/_zip.py',
|
|
|
|
|
'torch/utils/backcompat/__init__.py',
|
|
|
|
|
'torch/utils/backend_registration.py',
|
|
|
|
|
'torch/utils/benchmark/__init__.py',
|
|
|
|
|
'torch/utils/benchmark/examples/__init__.py',
|
|
|
|
|
'torch/utils/benchmark/examples/blas_compare.py',
|
|
|
|
|
'torch/utils/benchmark/examples/blas_compare_setup.py',
|
|
|
|
|
'torch/utils/benchmark/examples/compare.py',
|
|
|
|
|
'torch/utils/benchmark/examples/end_to_end.py',
|
|
|
|
|
'torch/utils/benchmark/examples/fuzzer.py',
|
|
|
|
|
'torch/utils/benchmark/examples/op_benchmark.py',
|
|
|
|
|
'torch/utils/benchmark/examples/simple_timeit.py',
|
|
|
|
|
'torch/utils/benchmark/examples/sparse/compare.py',
|
|
|
|
|
'torch/utils/benchmark/examples/sparse/fuzzer.py',
|
|
|
|
|
'torch/utils/benchmark/examples/sparse/op_benchmark.py',
|
|
|
|
|
'torch/utils/benchmark/examples/spectral_ops_fuzz_test.py',
|
|
|
|
|
'torch/utils/benchmark/op_fuzzers/__init__.py',
|
|
|
|
|
'torch/utils/benchmark/op_fuzzers/binary.py',
|
|
|
|
|
'torch/utils/benchmark/op_fuzzers/sparse_binary.py',
|
|
|
|
|
'torch/utils/benchmark/op_fuzzers/sparse_unary.py',
|
|
|
|
|
'torch/utils/benchmark/op_fuzzers/spectral.py',
|
|
|
|
|
'torch/utils/benchmark/op_fuzzers/unary.py',
|
|
|
|
|
'torch/utils/benchmark/utils/__init__.py',
|
|
|
|
|
'torch/utils/benchmark/utils/_stubs.py',
|
|
|
|
|
'torch/utils/benchmark/utils/common.py',
|
|
|
|
|
'torch/utils/benchmark/utils/compare.py',
|
|
|
|
|
'torch/utils/benchmark/utils/compile.py',
|
|
|
|
|
'torch/utils/benchmark/utils/cpp_jit.py',
|
|
|
|
|
'torch/utils/benchmark/utils/fuzzer.py',
|
|
|
|
|
'torch/utils/benchmark/utils/sparse_fuzzer.py',
|
|
|
|
|
'torch/utils/benchmark/utils/timer.py',
|
|
|
|
|
'torch/utils/benchmark/utils/valgrind_wrapper/__init__.py',
|
|
|
|
|
'torch/utils/benchmark/utils/valgrind_wrapper/timer_interface.py',
|
|
|
|
|
'torch/utils/bottleneck/__init__.py',
|
|
|
|
|
'torch/utils/bottleneck/__main__.py',
|
|
|
|
|
'torch/utils/bundled_inputs.py',
|
|
|
|
|
'torch/utils/checkpoint.py',
|
|
|
|
|
'torch/utils/collect_env.py',
|
|
|
|
|
'torch/utils/cpp_backtrace.py',
|
|
|
|
|
'torch/utils/cpp_extension.py',
|
|
|
|
|
'torch/utils/dlpack.py',
|
|
|
|
|
'torch/utils/file_baton.py',
|
|
|
|
|
'torch/utils/flop_counter.py',
|
|
|
|
|
'torch/utils/hipify/__init__.py',
|
|
|
|
|
'torch/utils/hipify/constants.py',
|
|
|
|
|
'torch/utils/hipify/cuda_to_hip_mappings.py',
|
|
|
|
|
'torch/utils/hipify/hipify_python.py',
|
|
|
|
|
'torch/utils/hipify/version.py',
|
|
|
|
|
'torch/utils/hooks.py',
|
|
|
|
|
'torch/utils/jit/__init__.py',
|
|
|
|
|
'torch/utils/jit/log_extract.py',
|
|
|
|
|
'torch/utils/mkldnn.py',
|
|
|
|
|
'torch/utils/mobile_optimizer.py',
|
|
|
|
|
'torch/utils/model_dump/__init__.py',
|
|
|
|
|
'torch/utils/model_dump/__main__.py',
|
|
|
|
|
'torch/utils/model_zoo.py',
|
|
|
|
|
'torch/utils/show_pickle.py',
|
|
|
|
|
'torch/utils/tensorboard/__init__.py',
|
|
|
|
|
'torch/utils/tensorboard/_caffe2_graph.py',
|
|
|
|
|
'torch/utils/tensorboard/_convert_np.py',
|
|
|
|
|
'torch/utils/tensorboard/_embedding.py',
|
|
|
|
|
'torch/utils/tensorboard/_onnx_graph.py',
|
|
|
|
|
'torch/utils/tensorboard/_proto_graph.py',
|
|
|
|
|
'torch/utils/tensorboard/_pytorch_graph.py',
|
|
|
|
|
'torch/utils/tensorboard/_utils.py',
|
|
|
|
|
'torch/utils/tensorboard/summary.py',
|
|
|
|
|
'torch/utils/tensorboard/writer.py',
|
|
|
|
|
'torch/utils/throughput_benchmark.py',
|
|
|
|
|
'torch/utils/viz/__init__.py',
|
|
|
|
|
'torch/utils/viz/_cycles.py',
|
|
|
|
|
'torch/utils/weak.py',
|
2022-07-11 19:20:22 +00:00
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
2022-10-05 21:08:40 +00:00
|
|
|
'--no-black-binary',
|
2024-01-01 08:40:46 +00:00
|
|
|
'black==23.12.1',
|
2024-06-29 13:06:58 +00:00
|
|
|
'usort==1.0.8.post1',
|
|
|
|
|
'isort==5.13.2',
|
2024-12-24 08:15:15 +00:00
|
|
|
'ruff==0.8.4', # sync with RUFF
|
2022-07-11 19:20:22 +00:00
|
|
|
]
|
|
|
|
|
is_formatter = true
|
2022-12-14 20:30:31 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'COPYRIGHT'
|
|
|
|
|
include_patterns = ['**']
|
2023-07-31 23:46:39 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'.lintrunner.toml',
|
|
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
]
|
2022-12-14 20:30:31 +00:00
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=Confidential and proprietary',
|
|
|
|
|
'--linter-name=COPYRIGHT',
|
|
|
|
|
'--error-name=Confidential Code',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Proprietary and confidential source code\
|
|
|
|
|
should not be contributed to PyTorch codebase\
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
Remove SHA checksum for bazel http_archive from GitHub (#95039)
An action item from https://github.com/pytorch/pytorch/issues/94346
Although the security practice of setting the checksum is good, it doesn't work when the archive is downloaded from some sites like GitHub because it can change. Specifically, GitHub gives no guarantee to keep the same value forever https://github.com/community/community/discussions/46034.
This also adds a new linter to make sure that SHA checksum from GitHub can be removed quickly. The WORKSPACE file is actually updated using the new linter:
```
>>> Lint for WORKSPACE:
Advice (BAZEL_LINTER) format
Redundant SHA checksum. Run `lintrunner -a` to apply this patch.
You can run `lintrunner -a` to apply this patch.
5 5 |
6 6 | http_archive(
7 7 | name = "rules_cuda",
7 |- sha256 = "f80438bee9906e9ecb1a8a4ae2365374ac1e8a283897281a2db2fb7fcf746333",
9 8 | strip_prefix = "runtime-b1c7cce21ba4661c17ac72421c6a0e2015e7bef3/third_party/rules_cuda",
10 9 | urls = ["https://github.com/tensorflow/runtime/archive/b1c7cce21ba4661c17ac72421c6a0e2015e7bef3.tar.gz"],
11 10 | )
--------------------------------------------------------------------------------
29 28 | name = "pybind11_bazel",
30 29 | strip_prefix = "pybind11_bazel-992381ced716ae12122360b0fbadbc3dda436dbf",
31 30 | urls = ["https://github.com/pybind/pybind11_bazel/archive/992381ced716ae12122360b0fbadbc3dda436dbf.zip"],
31 |- sha256 = "3dc6435bd41c058453efe102995ef084d0a86b0176fd6a67a6b7100a2e9a940e",
33 31 | )
34 32 |
35 33 | new_local_repository(
--------------------------------------------------------------------------------
52 50 | urls = [
53 51 | "https://github.com/gflags/gflags/archive/v2.2.2.tar.gz",
54 52 | ],
54 |- sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
56 53 | )
57 54 |
58 55 | new_local_repository(
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/95039
Approved by: https://github.com/ZainRizvi
2023-02-22 04:39:19 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'BAZEL_LINTER'
|
|
|
|
|
include_patterns = ['WORKSPACE']
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/bazel_linter.py',
|
|
|
|
|
'--binary=.lintbin/bazel',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/s3_init.py',
|
|
|
|
|
'--config-json=tools/linter/adapters/s3_init_config.json',
|
|
|
|
|
'--linter=bazel',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
|
|
|
|
'--output-dir=.lintbin',
|
|
|
|
|
'--output-name=bazel',
|
|
|
|
|
]
|
|
|
|
|
is_formatter = true
|
2023-03-08 18:41:31 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'LINTRUNNER_VERSION'
|
|
|
|
|
include_patterns = ['**']
|
2023-07-31 23:46:39 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
|
|
|
|
]
|
2023-03-08 18:41:31 +00:00
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/lintrunner_version_linter.py'
|
|
|
|
|
]
|
2023-04-24 15:37:13 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'RUFF'
|
2023-08-21 18:55:41 +00:00
|
|
|
include_patterns = ['**/*.py', '**/*.pyi']
|
2023-04-24 15:37:13 +00:00
|
|
|
exclude_patterns = [
|
|
|
|
|
'caffe2/**',
|
|
|
|
|
'functorch/docs/**',
|
|
|
|
|
'functorch/notebooks/**',
|
2023-09-20 00:08:09 +00:00
|
|
|
'torch/_inductor/fx_passes/serialized_patterns/**',
|
AutoHeuristic: mixed_mm heuristic for A100 (#131613)
This PR introduces changes to AutoHeuristic that allow one to learn a heuristic as a decision tree. I used this to learn a heuristic for mixed_mm on A100 that consistenly performs better than the default choice (https://github.com/pytorch/pytorch/blob/main/torch/_inductor/kernel/mm.py#L402).
This is how the results look like:
Explanation of columns:
**wrong_max_spdup**: In the worst case, how much better would the best choice have been
**wrong_gman_spdup**: For inputs where the heuristic is wrong, how much better is the best choice on average (geomean)
**max_spdup_default**: Highest speedup achieved by the learned heuristic over the default choice
**gman_spdup_default**: Geomean speedup achived by the learned heuristic over the default choice
**max_slowdown_default**: If the default choice is better than the choice predicted by the learned heuristic, how much is it better in the worst case
**non_default_preds**: Number of times the learned heuristic predicted a choice that is not the default choice
**default_better**: Number of times the default choice is better than the choice made by the heuristic
```
set crit max_depth min_samples_leaf correct wrong unsure total wrong_max_spdup wrong_gman_spdup max_spdup_default gman_spdup_default max_slowdown_default non_default_preds default_better
train entropy 5 0.01 2376 740 323 3439 1.855386 1.063236 11.352318 3.438279 1.022164 3116 2
test entropy 5 0.01 563 183 71 817 1.622222 1.060897 10.084181 3.507741 1.017039 746 2
```
While the number of wrong predictions is high, on average the best choice is only around 6% better. What is important is that the choice predicted by the learned heuristic performs better than the default choice.
I evaluated my heuristic on gpt-fast `meta-llama/Llama-2-7b-chat-hf` with int8 weight quantization. To get the `tuned_mixed_mm` to trigger, I had to replace `F.linear()` in https://github.com/pytorch-labs/gpt-fast/blob/main/quantize.py#L355 with `torch.matmul(input, self.weight.t().to(dtype=input.dtype))` because the mixed_mm pattern does not match if there is a transpose between a cast and the matmul.
|batch size|prompt length| fallback | heuristic | speedup |
|----------|-------------|------------:|------------:|--------:|
| 1 | 7 | 75.31 tok/s | 148.83 tok/s| 1.97 |
| 1 | 11 | 75.99 tok/s | 148.15 tok/s| 1.94 |
| 4 | 7 | 103.48 tok/s | 472.00 tok/s| 4.56 |
| 4 | 11 | 103.56 tok/s | 371.36 tok/s| 3.58 |
| 8 | 7 | 201.92 tok/s | 813.44 tok/s| 4.02 |
| 8 | 11 | 201.76 tok/s | 699.36 tok/s| 3.46 |
Currently, the heuristic only applies to the following inputs:
- m <= 128, k >= 1024, n >= 1024 (For these sizes, one of the triton kernels wins in most cases, but the heuristic still has to be careful to not choose a config that performs worse than the fallback)
- k % 256 == 0 (If k is not a multiple of the block size, some choices perform extremely bad. In one case one config, that usually performs very well, was 130x slower.)
- mat1 not transposed
- mat2 transposed (In some cases, it was hard for the learned heuristic to detect some cases where it
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131613
Approved by: https://github.com/eellison
2024-08-01 22:48:47 +00:00
|
|
|
'torch/_inductor/autoheuristic/artifacts/**',
|
2023-04-24 15:37:13 +00:00
|
|
|
'scripts/**',
|
|
|
|
|
'third_party/**',
|
2023-07-31 23:46:39 +00:00
|
|
|
'fb/**',
|
|
|
|
|
'**/fb/**',
|
2023-04-24 15:37:13 +00:00
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/ruff_linter.py',
|
|
|
|
|
'--config=pyproject.toml',
|
|
|
|
|
'--show-disable',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
init_command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/pip_init.py',
|
|
|
|
|
'--dry-run={{DRYRUN}}',
|
2024-12-24 08:15:15 +00:00
|
|
|
'ruff==0.8.4', # sync with PYFMT
|
2023-04-24 15:37:13 +00:00
|
|
|
]
|
|
|
|
|
is_formatter = true
|
2023-10-13 05:15:32 +00:00
|
|
|
|
|
|
|
|
# This linter prevents merge conlicts in csv files in pytorch by enforcing
|
|
|
|
|
# three lines of whitespace between entries such that unless people are modifying
|
|
|
|
|
# the same line, merge conflicts should not arise in git or hg
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'MERGE_CONFLICTLESS_CSV'
|
|
|
|
|
include_patterns = ['benchmarks/dynamo/ci_expected_accuracy/*.csv']
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/no_merge_conflict_csv_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
is_formatter = true
|
2024-03-06 23:51:40 +00:00
|
|
|
|
2024-09-25 03:44:20 +00:00
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'META_NO_CREATE_UNBACKED'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
"torch/_meta_registrations.py"
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=create_unbacked',
|
|
|
|
|
'--linter-name=META_NO_CREATE_UNBACKED',
|
|
|
|
|
'--error-name=no create_unbacked in meta registrations',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
Data-dependent operators should have their meta \
|
|
|
|
|
registration in torch/_subclasses/fake_impls.py, \
|
|
|
|
|
not torch/_meta_registrations.py
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
|
2024-03-06 23:51:40 +00:00
|
|
|
[[linter]]
|
|
|
|
|
code = 'ATEN_CPU_GPU_AGNOSTIC'
|
|
|
|
|
include_patterns = [
|
|
|
|
|
# aten source
|
|
|
|
|
"aten/src/ATen/*.cpp",
|
|
|
|
|
"aten/src/ATen/cpu/*.cpp",
|
|
|
|
|
"aten/src/ATen/functorch/**/*.cpp",
|
|
|
|
|
"aten/src/ATen/nnapi/*.cpp",
|
|
|
|
|
"aten/src/ATen/quantized/*.cpp",
|
|
|
|
|
"aten/src/ATen/vulkan/*.cpp",
|
|
|
|
|
"aten/src/ATen/metal/*.cpp",
|
|
|
|
|
"aten/src/ATen/detail/CPUGuardImpl.cpp",
|
|
|
|
|
"aten/src/ATen/detail/MetaGuardImpl.cpp",
|
|
|
|
|
# aten native source
|
|
|
|
|
"aten/src/ATen/native/cpu/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/cpu/kernels/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/quantized/cpu/kernels/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/quantized/cpu/kernels/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/cpu/**/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/**/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/quantized/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/quantized/**/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/nested/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/quantized/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/quantized/**/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/sparse/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/transformers/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/utils/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/xnnpack/*.cpp",
|
|
|
|
|
"aten/src/ATen/native/metal/MetalPrepackOpRegister.cpp",
|
|
|
|
|
# aten headers
|
|
|
|
|
"aten/src/ATen/*.h",
|
|
|
|
|
"aten/src/ATen/functorch/**/*.h",
|
|
|
|
|
"aten/src/ATen/ops/*.h",
|
|
|
|
|
"aten/src/ATen/cpu/**/*.h",
|
|
|
|
|
"aten/src/ATen/nnapi/*.h",
|
|
|
|
|
"aten/src/ATen/quantized/*.h",
|
|
|
|
|
"aten/src/ATen/vulkan/*.h",
|
|
|
|
|
"aten/src/ATen/metal/*.h",
|
|
|
|
|
"aten/src/ATen/mps/*.h",
|
|
|
|
|
# aten native headers
|
|
|
|
|
"aten/src/ATen/native/*.h",
|
|
|
|
|
"aten/src/ATen/native/cpu/**/*.h",
|
|
|
|
|
"aten/src/ATen/native/nested/*.h",
|
|
|
|
|
"aten/src/ATen/native/sparse/*.h",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/*.h",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/cpu/*.h",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/quantized/*.h",
|
|
|
|
|
"aten/src/ATen/native/ao_sparse/quantized/cpu/*.h",
|
|
|
|
|
"aten/src/ATen/native/quantized/*.h",
|
|
|
|
|
"aten/src/ATen/native/quantized/cpu/*.h",
|
|
|
|
|
"aten/src/ATen/native/transformers/*.h",
|
|
|
|
|
"aten/src/ATen/native/quantized/cpu/qnnpack/include/*.h",
|
|
|
|
|
"aten/src/ATen/native/utils/*.h",
|
|
|
|
|
"aten/src/ATen/native/vulkan/ops/*.h",
|
|
|
|
|
"aten/src/ATen/native/xnnpack/*.h",
|
|
|
|
|
"aten/src/ATen/native/metal/MetalPrepackOpContext.h",
|
|
|
|
|
"aten/src/ATen/native/mps/Copy.h",
|
|
|
|
|
"aten/src/ATen/native/mkldnn/**/*.h",
|
|
|
|
|
]
|
|
|
|
|
exclude_patterns = [
|
|
|
|
|
"aten/src/ATen/Context.h",
|
|
|
|
|
"aten/src/ATen/Context.cpp",
|
|
|
|
|
"aten/src/ATen/DLConvertor.cpp",
|
|
|
|
|
"aten/src/ATen/core/Array.h",
|
|
|
|
|
"aten/src/ATen/native/quantized/ConvUtils.h",
|
|
|
|
|
"aten/src/ATen/native/sparse/SparseBlasImpl.cpp", # triton implementation
|
|
|
|
|
"aten/src/ATen/native/transformers/attention.cpp",
|
|
|
|
|
"aten/src/ATen/native/**/cudnn/**", # cudnn is cuda specific
|
|
|
|
|
]
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/grep_linter.py',
|
|
|
|
|
'--pattern=(^#if.*USE_ROCM.*)|(^#if.*USE_CUDA.*)',
|
|
|
|
|
'--linter-name=ATEN_CPU',
|
|
|
|
|
'--error-name=aten-cpu should be gpu agnostic',
|
|
|
|
|
"""--error-description=\
|
|
|
|
|
We strongly discourage the compile-time divergence \
|
|
|
|
|
on ATen-CPU code for different GPU code. This \
|
|
|
|
|
disallows sharing the same aten-cpu shared object \
|
|
|
|
|
between different GPU backends \
|
|
|
|
|
""",
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
is_formatter = true
|
2024-12-02 18:32:12 +00:00
|
|
|
|
|
|
|
|
# `set_linter` detects occurrences of built-in `set` in areas of Python code like
|
|
|
|
|
# _inductor where the instability of iteration in `set` has proven a problem.
|
|
|
|
|
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'SET_LINTER'
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/set_linter.py',
|
|
|
|
|
'--lintrunner',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
include_patterns = [
|
2024-12-13 12:37:22 +00:00
|
|
|
"torch/_inductor/**/*.py",
|
2025-02-04 00:02:20 +00:00
|
|
|
"torch/_functorch/partitioners.py",
|
2024-12-02 18:32:12 +00:00
|
|
|
]
|
|
|
|
|
is_formatter = true
|
2024-12-07 20:52:05 +00:00
|
|
|
|
|
|
|
|
# `docstring_linter` reports on long Python classes, methods, and functions
|
|
|
|
|
# whose definitions have very small docstrings or none at all.
|
|
|
|
|
#
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'DOCSTRING_LINTER'
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/docstring_linter.py',
|
|
|
|
|
'--lintrunner',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'torch/**/not-exist.py'
|
|
|
|
|
]
|
|
|
|
|
is_formatter = false
|
[dynamo] Add a lint rule to restrict what 3P library one can import (#143312)
As title, this patch prevents developers from importing third party
libraries to patch things in Dynamo, unless there's no other easy
workaround (in which case one would add the library to the allowlist in
`import_linter.py`, as instructed by the lint error).
For instance, if we remove `einops` from the allowlist, we'd get this
```verbatim
>>> Lint for torch/_dynamo/decorators.py:
Error (IMPORT) Disallowed import
importing from einops is not allowed, if you believe there's a valid
reason, please add it to import_linter.py
608 |# Note: this carefully avoids eagerly import einops.
609 |# TODO: we should delete this whole _allow_in_graph_einops logic by approximately 2024 Q2
610 |def _allow_in_graph_einops():
>>> 611 | import einops
612 |
613 | try:
614 | # requires einops > 0.6.1, torch >= 2.0
Error (IMPORT) Disallowed import
importing from einops is not allowed, if you believe there's a valid
reason, please add it to import_linter.py
612 |
613 | try:
614 | # requires einops > 0.6.1, torch >= 2.0
>>> 615 | from einops._torch_specific import ( # type: ignore[attr-defined] # noqa: F401
616 | _ops_were_registered_in_torchdynamo,
617 | )
618 |
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143312
Approved by: https://github.com/zou3519
2024-12-18 19:52:45 +00:00
|
|
|
|
|
|
|
|
# `import_linter` reports on importing disallowed third party libraries.
|
|
|
|
|
[[linter]]
|
|
|
|
|
code = 'IMPORT_LINTER'
|
|
|
|
|
command = [
|
|
|
|
|
'python3',
|
|
|
|
|
'tools/linter/adapters/import_linter.py',
|
|
|
|
|
'--',
|
|
|
|
|
'@{{PATHSFILE}}'
|
|
|
|
|
]
|
|
|
|
|
include_patterns = [
|
|
|
|
|
'torch/_dynamo/**',
|
|
|
|
|
]
|
|
|
|
|
is_formatter = false
|