Xuehai Pan
d55dc00f84
[BE][11/16] fix typos in torch/ (torch/csrc/distributed/) ( #156321 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156321
Approved by: https://github.com/jingsh
ghstack dependencies: #156313 , #156314 , #156315 , #156316 , #156317 , #156319
2025-06-23 02:57:50 +00:00
Xuehai Pan
ced90016c1
[BE][7/16] fix typos in torch/ (torch/csrc/) ( #156317 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156317
Approved by: https://github.com/albanD
ghstack dependencies: #156313 , #156314 , #156315 , #156316
2025-06-23 02:57:41 +00:00
Xuehai Pan
4ccc0381de
[BE][5/16] fix typos in torch/ (torch/distributed/) ( #156315 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156315
Approved by: https://github.com/Skylion007 , https://github.com/albanD
ghstack dependencies: #156313 , #156314
2025-06-23 02:57:28 +00:00
Xuehai Pan
6ff6630375
[BE][3/16] fix typos in torch/ (torch/_inductor/) ( #156313 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156313
Approved by: https://github.com/jingsh
2025-06-23 02:57:12 +00:00
PyTorch MergeBot
f1331f3f1b
Revert "[BE][3/16] fix typos in torch/ (torch/_inductor/) ( #156313 )"
...
This reverts commit 3627270bdf .
Reverted https://github.com/pytorch/pytorch/pull/156313 on behalf of https://github.com/atalman due to export/test_torchbind.py::TestCompileTorchbind::test_compile_error_on_input_aliasing_contents_backend_aot_eager [GH job link](https://github.com/pytorch/pytorch/actions/runs/15804799771/job/44548489912 ) [HUD commit link](c95f7fa874 ) ([comment](https://github.com/pytorch/pytorch/pull/156313#issuecomment-2994171213 ))
2025-06-22 12:31:57 +00:00
PyTorch MergeBot
145d4cdc11
Revert "[BE][5/16] fix typos in torch/ (torch/distributed/) ( #156315 )"
...
This reverts commit c2f0292bd5 .
Reverted https://github.com/pytorch/pytorch/pull/156315 on behalf of https://github.com/atalman due to export/test_torchbind.py::TestCompileTorchbind::test_compile_error_on_input_aliasing_contents_backend_aot_eager [GH job link](https://github.com/pytorch/pytorch/actions/runs/15804799771/job/44548489912 ) [HUD commit link](c95f7fa874 ) ([comment](https://github.com/pytorch/pytorch/pull/156313#issuecomment-2994171213 ))
2025-06-22 12:31:57 +00:00
PyTorch MergeBot
035a68d25a
Revert "[BE][7/16] fix typos in torch/ (torch/csrc/) ( #156317 )"
...
This reverts commit ee72815f11 .
Reverted https://github.com/pytorch/pytorch/pull/156317 on behalf of https://github.com/atalman due to export/test_torchbind.py::TestCompileTorchbind::test_compile_error_on_input_aliasing_contents_backend_aot_eager [GH job link](https://github.com/pytorch/pytorch/actions/runs/15804799771/job/44548489912 ) [HUD commit link](c95f7fa874 ) ([comment](https://github.com/pytorch/pytorch/pull/156313#issuecomment-2994171213 ))
2025-06-22 12:31:56 +00:00
PyTorch MergeBot
4b55871e06
Revert "[BE][11/16] fix typos in torch/ (torch/csrc/distributed/) ( #156321 )"
...
This reverts commit c95f7fa874 .
Reverted https://github.com/pytorch/pytorch/pull/156321 on behalf of https://github.com/atalman due to export/test_torchbind.py::TestCompileTorchbind::test_compile_error_on_input_aliasing_contents_backend_aot_eager [GH job link](https://github.com/pytorch/pytorch/actions/runs/15804799771/job/44548489912 ) [HUD commit link](c95f7fa874 ) ([comment](https://github.com/pytorch/pytorch/pull/156321#issuecomment-2994163667 ))
2025-06-22 12:27:36 +00:00
Xuehai Pan
c95f7fa874
[BE][11/16] fix typos in torch/ (torch/csrc/distributed/) ( #156321 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156321
Approved by: https://github.com/jingsh
ghstack dependencies: #156313 , #156314 , #156315 , #156316 , #156317 , #156319
2025-06-22 08:43:49 +00:00
Xuehai Pan
ee72815f11
[BE][7/16] fix typos in torch/ (torch/csrc/) ( #156317 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156317
Approved by: https://github.com/albanD
ghstack dependencies: #156313 , #156314 , #156315 , #156316
2025-06-22 08:43:41 +00:00
Xuehai Pan
c2f0292bd5
[BE][5/16] fix typos in torch/ (torch/distributed/) ( #156315 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156315
Approved by: https://github.com/Skylion007 , https://github.com/albanD
ghstack dependencies: #156313 , #156314
2025-06-22 08:43:26 +00:00
Xuehai Pan
3627270bdf
[BE][3/16] fix typos in torch/ (torch/_inductor/) ( #156313 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156313
Approved by: https://github.com/jingsh
2025-06-22 08:43:09 +00:00
Xuehai Pan
e3507c3777
[BE] fix typos in functorch/ and scripts/ ( #156081 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156081
Approved by: https://github.com/albanD
ghstack dependencies: #156080
2025-06-21 02:47:40 +00:00
Xuehai Pan
2ccfd14e23
[BE] fix typos in docs/ ( #156080 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156080
Approved by: https://github.com/cyyever , https://github.com/albanD
2025-06-21 02:47:32 +00:00
Xuehai Pan
402ae09e41
[BE] fix typos in c10/ ( #156078 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156078
Approved by: https://github.com/malfet , https://github.com/cyyever
2025-06-18 10:24:44 +00:00
Xuehai Pan
a69785b3ec
[BE] fix typos in tools/ ( #156082 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156082
Approved by: https://github.com/soulitzer
ghstack dependencies: #156079
2025-06-17 19:25:50 +00:00
Xuehai Pan
42015db6a9
[BE] fix typos in benchmarks/ ( #156077 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156077
Approved by: https://github.com/Skylion007 , https://github.com/malfet
ghstack dependencies: #156069
2025-06-17 13:12:18 +00:00
Xuehai Pan
1cce73b5f4
[build] Change --cmake{,-only} arguments to envvars to support modern Python build frontend ( #156045 )
...
See also:
- #156029
- #156027
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156045
Approved by: https://github.com/ezyang
ghstack dependencies: #156040 , #156041
2025-06-17 11:40:24 +00:00
Xuehai Pan
8d7ee0f4fb
[BE] fix typos in .ci/, .circleci/, .github/ ( #156069 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156069
Approved by: https://github.com/Skylion007 , https://github.com/malfet
2025-06-17 09:43:14 +00:00
Xuehai Pan
2e0e08588e
[BE][PYFMT] migrate PYFMT for torch/[e-n]*/ to ruff format ( #144553 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144553
Approved by: https://github.com/ezyang
ghstack dependencies: #144551
2025-06-17 08:18:47 +00:00
Xuehai Pan
013dfeabb4
[BE] fix typos in top-level files ( #156067 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156067
Approved by: https://github.com/malfet
ghstack dependencies: #156066
2025-06-16 14:56:07 +00:00
Xuehai Pan
6c493e2b14
[BE] add codespell linter ( #156066 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156066
Approved by: https://github.com/malfet
2025-06-16 14:56:07 +00:00
Xuehai Pan
279cae52e7
[BE][PYFMT] migrate PYFMT for torch/ao/ to ruff format ( #148185 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148185
Approved by: https://github.com/ezyang
2025-06-14 16:47:04 +00:00
Xuehai Pan
596b418391
[BE][PYFMT] migrate PYFMT for {torch,test}/{nn,optim}/** to ruff format ( #144548 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144548
Approved by: https://github.com/ezyang
2025-06-14 11:27:04 +00:00
Nikita Shulga
c10339559d
[BE] Better uv detection in pip init ( #155972 )
...
If one has some UV and non-UV environments locally, one shoudl call `uv
pip install` only on the UV-enabled ones, which could be detected by
checking if `uv/python` path is present in `sys.base_prefix`
Fixes https://github.com/pytorch/pytorch/issues/152999
Pull Request resolved: https://github.com/pytorch/pytorch/pull/155972
Approved by: https://github.com/janeyx99
2025-06-14 01:35:50 +00:00
Tom Ritchford
9a8c42ff94
Get rid of unused code in linters ( #154043 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/154043
Approved by: https://github.com/XuehaiPan , https://github.com/Skylion007
2025-05-22 15:24:54 +00:00
Jane Xu
fc33da410f
Add torch/header_only_apis.txt and enforce they're tested ( #153635 )
...
This PR adds enforcement of testing header only APIs.
The benefit of torch/header_only_apis.txt is twofold:
1) this gives us a clear view of what we expect to be header only
2) this allows us to enforce testing
The enforcement added in this PR is very basic--we literally string match that a symbol in `torch/header_only_apis.txt` is in a cpp test. This is meant to be a first step in verifying our APIs are properly tested and can get fancier over time. For now, I've added myself as a codeowner to learn what to look out for in terms of proper tests. Over time, I anticipate we can automate more steps, but right now let's just get something out the door.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153635
Approved by: https://github.com/albanD
ghstack dependencies: #153965
2025-05-20 23:42:24 +00:00
Jane Xu
8f943046f8
[BE] light cleanups to linter logic ( #153965 )
...
some BE cleanup on other lint things I saw while doing the top of the this stack
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153965
Approved by: https://github.com/soulitzer
2025-05-20 21:28:48 +00:00
Nikita Shulga
c4d1ff02f8
[Lint] Update clang-format to 19.1.4 ( #153889 )
...
All changes other than the one to `tools/linter/adapters/s3_init_config.json` are generated by newer clang-format
Pull Request resolved: https://github.com/pytorch/pytorch/pull/153889
Approved by: https://github.com/cyyever , https://github.com/atalman
2025-05-20 14:12:46 +00:00
xinan.lin
a9adc9a9b6
[Linter] Add linter to detect device-bias hard code in test cases. ( #152948 )
...
Since XPU does not gate community pull requests, we’ve observed that contributors often hardcode "cuda" in functions decorated with @requires_gpu() when adding new test cases. This causes the tests to fail on XPU and breaks XPU CI.
This PR adds a linter to detect such issues automatically. An example is shown below.
```
Error (TEST_DEVICE_BIAS) [device-bias]
`@requires_gpu` function should not hardcode device='cuda'
11670 | .contiguous()
11671 | )
11672 |
>>> 11673 | inp = torch.rand((64, 64), device="cuda") * 2 - 1
11674 | boundaries = torch.tensor([-0.9, -0.8, 0.1, 0.2, 0.5, 0.9])
11675 |
11676 | self.common(fn, (inp, boundaries), check_lowp=False)
Error (TEST_DEVICE_BIAS) [device-bias]
`@requires_gpu` function should not hardcode .cuda() call
11700 | self.assertEqual(ref, res)
11701 |
11702 | for offset2 in (0, 1, 2, 3, 4):
>>> 11703 | base2 = torch.randn(64 * 64 + 64, dtype=torch.float32).cuda()
11704 | inp2 = torch.as_strided(base2, (64, 64), (64, 1), offset2)
11705 | ref2 = fn(inp2)
11706 | res2 = fn_c(inp2)
Error (TEST_DEVICE_BIAS) [device-bias]
`@requires_gpu` function should not hardcode torch.device('cuda:0')
11723 | return x.sin() + x.cos()
11724 |
11725 | base = torch.randn(
>>> 11726 | 64 * 64 + 64, dtype=torch.float32, device=torch.device("cuda:0")
11727 | )
11728 |
11729 | inp1 = torch.as_strided(base, (32, 32), (32, 1), 4)
Error (TEST_DEVICE_BIAS) [device-bias]
`@requires_gpu` function should not hardcode .to('cuda') call
11771 | torch.manual_seed(42)
11772 | base = torch.randn(64 * 64 + 64, dtype=torch.float32, device=self.device)
11773 | torch.manual_seed(42)
>>> 11774 | base_ref = torch.randn(64 * 64 + 64, dtype=torch.float32).to("cuda")
11775 |
11776 | inp = torch.as_strided(base, size, stride, offset)
11777 | inp_ref = torch.as_strided(base_ref, size, stride, offset)
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152948
Approved by: https://github.com/EikanWang , https://github.com/cyyever , https://github.com/malfet , https://github.com/jansel
2025-05-16 08:03:54 +00:00
Tom Ritchford
2825a28bf1
Exempt overriding methods from docstring_linter ( fix #151692 ) ( #151906 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151906
Approved by: https://github.com/Skylion007
2025-05-05 12:39:42 +00:00
Tom Ritchford
596e44d26a
[inductor] Enable docstring_linter on _inductor ( #144622 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144622
Approved by: https://github.com/eellison
ghstack dependencies: #144621
2025-04-10 14:32:26 +00:00
Tom Ritchford
31fe258efc
[inductor] Add features to docstring_linter (see #142496 ) ( #145834 )
...
## Improvements to `docstring_linter`
* Add a "grandfather list" of existing undocumented classes and functions (`--grandfather`, `--grandfather-tolerance`, `--no-grandfather`, `--write-grandfather`)
* In classes, now just one of the class itself or its `__init__()` method needs to be documented (`--lint-init` turns the old behavior back on)
* Now classes and functions defined local to other functions do not need to be documented (`--lint-local` turns the old behavior back on)
* New `--report` flag produces a compact report of long, undocumented classes or function definitions: see attached example run over all pytorch: [pytorch-docs.json](https://github.com/user-attachments/files/18455981/pytorch-docs.json )
## Help text
```
$ python tools/linter/adapters/docstring_linter.py --help
usage: docstring_linter.py [-h] [-l] [-v] [--grandfather GRANDFATHER] [--grandfather-tolerance GRANDFATHER_TOLERANCE] [--lint-init]
[--lint-local] [--lint-protected] [--max-class MAX_CLASS] [--max-def MAX_DEF]
[--min-docstring MIN_DOCSTRING] [--no-grandfather] [--report] [--write-grandfather]
[files ...]
`docstring_linter` reports on long functions, methods or classes without docstrings
positional arguments:
files A list of files or directories to lint
optional arguments:
-h, --help show this help message and exit
-l, --lintrunner Run for lintrunner and print LintMessages which aren't edits
-v, --verbose Print more debug info
--grandfather GRANDFATHER, -g GRANDFATHER
Set the grandfather list
--grandfather-tolerance GRANDFATHER_TOLERANCE, -t GRANDFATHER_TOLERANCE
Tolerance for grandfather sizes, in percent
--lint-init, -i Lint __init__ and class separately
--lint-local, -o Lint definitions inside other functions
--lint-protected, -p Lint functions, methods and classes that start with _
--max-class MAX_CLASS, -c MAX_CLASS
Maximum number of lines for an undocumented class
--max-def MAX_DEF, -d MAX_DEF
Maximum number of lines for an undocumented function
--min-docstring MIN_DOCSTRING, -s MIN_DOCSTRING
Minimum number of characters for a docstring
--no-grandfather, -n Disable the grandfather list
--report, -r Print a report on all classes and defs
--write-grandfather, -w
Rewrite the grandfather list
```
---
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145834
Approved by: https://github.com/amjames , https://github.com/eellison
2025-04-09 21:38:36 +00:00
Nikita Shulga
29b3f409c2
[BE][CI] Update actionlint to 1.7.7 ( #149919 )
...
- fix anti-pattern started by https://github.com/pytorch/pytorch/pull/81922 when x86 actionlint binaries were placed in Linux-arm64 folder
- Fix renaming lint violations, namely
```
>>> Lint for .github/workflows/_linux-test.yml:
Error (ACTIONLINT) [expression]
property "workspace" is not defined in object type {arch: string; debug:
string; environment: string; name: string; os: string; temp: string;
tool_cache: string}
446 | if: failure() && steps.install-nvidia-driver.outcome && steps.install-nvidia-driver.outcome != 'skipped'
447 | shell: bash
448 | env:
>>> 449 | RUNNER_WORKSPACE: ${{ runner.workspace }}
450 | run: |
451 | set +e
452 | set -x
>>> Lint for .github/workflows/create_release.yml:
Error (ACTIONLINT) [deprecated-commands]
workflow command "set-output" was deprecated. use `echo "{name}={value}"
>> $GITHUB_OUTPUT` instead: https://docs.github.com/en/actions/using-
workflows/workflow-commands-for-github-actions
80 | path: ${{ env.PT_RELEASE_FILE }}
81 | - name: Set output
82 | id: release_name
>>> 83 | run: echo "::set-output name=pt_release_name::${{ env.PT_RELEASE_NAME }}.tar.gz"
84 |
85 | upload_source_code_to_s3:
86 | if: ${{ github.repository == 'pytorch/pytorch' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'rc') }}
>>> Lint for .github/workflows/target-determination-indexer.yml:
Error (ACTIONLINT) [shellcheck]
shellcheck reported issue in this script: SC2086:info:3:3: Double quote to
prevent globbing and word splitting
98 | DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }}
99 | GITHUB_RUN_ID: ${{ github.run_id }}
100 | AWS_DEFAULT_REGION: us-east-1
>>> 101 | run: |
102 | # detached container should get cleaned up by teardown_ec2_linux
103 | container_name=$(docker run \
104 | ${GPU_FLAG:-} \
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/149919
Approved by: https://github.com/jeanschmidt , https://github.com/atalman , https://github.com/Skylion007
ghstack dependencies: #149917 , #149918 , #149922
2025-03-25 14:37:10 +00:00
Nikita Shulga
f63b03e9fc
[BE] Add Mac ARM64 actionlint binary ( #149917 )
...
Downloaded from https://github.com/rhysd/actionlint/releases/tag/v1.6.21
Pull Request resolved: https://github.com/pytorch/pytorch/pull/149917
Approved by: https://github.com/Skylion007
2025-03-25 14:36:54 +00:00
Tom Ritchford
d90f9e9a34
[inductor] Fix issue with set_linter, improve linter framework ( #144620 )
...
### `set_linter` only
* Fix gnarly [bug](dbed747aae/tools/test/set_linter_testdata/python_code.py.txt.python (L42) ) which would have garbled Python files involving sets contained in sets.
* Better handling of new Python3.12 token types
### Both linters.
* Recover from and report on unparseable Python files
* Remove `ParseError.check()` (it made it harder to read the code)
* FileLinter is now generic on `PythonFile`
### Notes
As I started working on new docstring features, I found a nasty bug and an edge case bug in set linter, and realized both the linters crash when there is a badly-formed Python file in the repo.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144620
Approved by: https://github.com/amjames , https://github.com/jansel
2025-03-13 09:49:40 +00:00
cyy
203dd18c5c
Bump Clang-tidy to 19.1.4 ( #148648 )
...
Because Clang-tidy 19 has more powerful clang-analyzer checks to detect subtle bugs. New checks such as misc-use-internal-linkage can help identify potential static variables or functions, thus reducing binary sizes.
Some new checks are disabled temporarily for later enabling. Additional warnings have been fixed or suppressed.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148648
Approved by: https://github.com/Skylion007
2025-03-10 17:32:30 +00:00
Jason Ansel
85fe576ee3
[set_linter] allow x in {...} ( #148422 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148422
Approved by: https://github.com/Skylion007
2025-03-09 06:43:11 +00:00
Xuehai Pan
1cb4e2df65
[BE][PYFMT] migrate PYFMT for torch._inductor to ruff format ( #144550 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144550
Approved by: https://github.com/jansel
2025-02-28 13:33:19 +00:00
Xuehai Pan
995df34b19
[BE][PYFMT] migrate PYFMT for torch.{distributed,distributions} to ruff format ( #144547 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144547
Approved by: https://github.com/kwen2501
2025-02-28 07:35:56 +00:00
Xuehai Pan
3ce352e389
[BE][PYFMT] migrate PYFMT for torch._dynamo to ruff format ( #144549 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144549
Approved by: https://github.com/jansel
2025-02-28 03:03:53 +00:00
Catherine Lee
953e80936e
[linter] Grep linter batches long command ( #145950 )
...
If the command is too long, the linter fails with
```
Failed due to OSError:
[Errno 7] Argument list too long: 'grep'
```
Fix this by batching the command so it is shorter
Limit of 750k was chosen due to `getconf ARG_MAX` returns ~1M on my mac. My guess is that most people shouldn't hit this unless they run --all-files and the directory length is long.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145950
Approved by: https://github.com/wdvr
2025-01-29 21:23:27 +00:00
Zain Rizvi
a6e3f294f1
Don't use mypy daemon in CI ( #145961 )
...
This is an attempt to fix flaky mypy errors in CI that look like:
```
dmypy status --verbose
connection_name : /var/folders/rf/qrn1jkgj0b9_tcznwp8ck46w0000gn/T/tmpjoqsid7_/dmypy.sock
pid : 32233
error : timed out
Daemon is stuck; consider /Users/zainr/pytorch/venv/bin/dmypy kill
```
"Fix" it by not using the daemon at all, since it doesn't actually provide any perf benefits in CI.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145961
Approved by: https://github.com/malfet
2025-01-29 21:15:29 +00:00
Aaron Orenstein
1335882b2a
If mypy fails it should report the error back to lintrunner ( #145550 )
...
This happened to me because I had a bad LD_LIBRARY_PATH and mypy was failing to run (.so load error) - but lintrunner was silent about the underlying problem.
Differential Revision: [D68593081](https://our.internmc.facebook.com/intern/diff/D68593081 )
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145550
Approved by: https://github.com/bobrenjc93 , https://github.com/Skylion007
2025-01-24 15:40:30 +00:00
PyTorch MergeBot
dddf52b1b9
Revert "Enable grep_linter to use -a ( #144589 )"
...
This reverts commit 3c55669b88 .
Reverted https://github.com/pytorch/pytorch/pull/144589 on behalf of https://github.com/clee2000 due to the line parameter is kind of important and -a is not as important as I thought it was so I'm going to revert this ([comment](https://github.com/pytorch/pytorch/pull/144589#issuecomment-2608349155 ))
2025-01-22 21:55:27 +00:00
Aaron Orenstein
07669ed960
PEP585 update - benchmarks tools torchgen ( #145101 )
...
This is one of a series of PRs to update us to PEP585 (changing Dict -> dict, List -> list, etc). Most of the PRs were completely automated with RUFF as follows:
Since RUFF UP006 is considered an "unsafe" fix first we need to enable unsafe fixes:
```
--- a/tools/linter/adapters/ruff_linter.py
+++ b/tools/linter/adapters/ruff_linter.py
@@ -313,6 +313,7 @@
"ruff",
"check",
"--fix-only",
+ "--unsafe-fixes",
"--exit-zero",
*([f"--config={config}"] if config else []),
"--stdin-filename",
```
Then we need to tell RUFF to allow UP006 (as a final PR once all of these have landed this will be made permanent):
```
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -40,7 +40,7 @@
[tool.ruff]
-target-version = "py38"
+target-version = "py39"
line-length = 88
src = ["caffe2", "torch", "torchgen", "functorch", "test"]
@@ -87,7 +87,6 @@
"SIM116", # Disable Use a dictionary instead of consecutive `if` statements
"SIM117",
"SIM118",
- "UP006", # keep-runtime-typing
"UP007", # keep-runtime-typing
]
select = [
```
Finally running `lintrunner -a --take RUFF` will fix up the deprecated uses.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/145101
Approved by: https://github.com/bobrenjc93
2025-01-18 05:05:07 +00:00
Catherine Lee
3c55669b88
Enable grep_linter to use -a ( #144589 )
...
Lintrunner can only apply changes (-a) if only one suggestion is made per file. The grep_linter makes a suggestion for every line it finds incorrect, so it creates multiple suggestions per file if there are multiple lines that it wants to change
This sets the `line` parameter of the LintMessage to None for all of grep_linter, but I'm not sure if that entry did anything
I'm not sure if enabling -a is the best idea, since its currently used for tabs and tab width might differ each time? I had one instance where running with -a cause the spacing to change. On the other hand, -a would have already worked if only one line was bad
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144589
Approved by: https://github.com/huydhn
2025-01-13 21:18:24 +00:00
PyTorch MergeBot
99f2491af9
Revert "Use absolute path path.resolve() -> path.absolute() ( #129409 )"
...
This reverts commit 45411d1fc9 .
Reverted https://github.com/pytorch/pytorch/pull/129409 on behalf of https://github.com/jeanschmidt due to Breaking internal CI, @albanD please help get this PR merged ([comment](https://github.com/pytorch/pytorch/pull/129409#issuecomment-2571316444 ))
2025-01-04 14:17:20 +00:00
Xuehai Pan
45411d1fc9
Use absolute path path.resolve() -> path.absolute() ( #129409 )
...
Changes:
1. Always explicit `.absolute()`: `Path(__file__)` -> `Path(__file__).absolute()`
2. Replace `path.resolve()` with `path.absolute()` if the code is resolving the PyTorch repo root directory.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129409
Approved by: https://github.com/albanD
2025-01-03 20:03:40 +00:00
Xuehai Pan
b6bdb67f82
[BE][Easy] use pathlib.Path instead of dirname / ".." / pardir ( #129374 )
...
Changes by apply order:
1. Replace all `".."` and `os.pardir` usage with `os.path.dirname(...)`.
2. Replace nested `os.path.dirname(os.path.dirname(...))` call with `str(Path(...).parent.parent)`.
3. Reorder `.absolute()` ~/ `.resolve()`~ and `.parent`: always resolve the path first.
`.parent{...}.absolute()` -> `.absolute().parent{...}`
4. Replace chained `.parent x N` with `.parents[${N - 1}]`: the code is easier to read (see 5.)
`.parent.parent.parent.parent` -> `.parents[3]`
5. ~Replace `.parents[${N - 1}]` with `.parents[${N} - 1]`: the code is easier to read and does not introduce any runtime overhead.~
~`.parents[3]` -> `.parents[4 - 1]`~
6. ~Replace `.parents[2 - 1]` with `.parent.parent`: because the code is shorter and easier to read.~
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129374
Approved by: https://github.com/justinchuby , https://github.com/malfet
2024-12-29 17:23:13 +00:00
PyTorch MergeBot
475656fd9c
Revert "[BE][Easy] use pathlib.Path instead of dirname / ".." / pardir ( #129374 )"
...
This reverts commit 2293fe1024 .
Reverted https://github.com/pytorch/pytorch/pull/129374 on behalf of https://github.com/malfet due to failing internal ROCM builds with error: ModuleNotFoundError: No module named hipify ([comment](https://github.com/pytorch/pytorch/pull/129374#issuecomment-2562973920 ))
2024-12-26 17:32:23 +00:00
PyTorch MergeBot
cc4e70b7c3
Revert "Use absolute path path.resolve() -> path.absolute() ( #129409 )"
...
This reverts commit 135c7db99d .
Reverted https://github.com/pytorch/pytorch/pull/129409 on behalf of https://github.com/malfet due to need to revert to as dependency of https://github.com/pytorch/pytorch/pull/129374 ([comment](https://github.com/pytorch/pytorch/pull/129409#issuecomment-2562969825 ))
2024-12-26 17:26:06 +00:00
Xuehai Pan
135c7db99d
Use absolute path path.resolve() -> path.absolute() ( #129409 )
...
Changes:
1. Always explicit `.absolute()`: `Path(__file__)` -> `Path(__file__).absolute()`
2. Replace `path.resolve()` with `path.absolute()` if the code is resolving the PyTorch repo root directory.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129409
Approved by: https://github.com/albanD
2024-12-24 08:33:08 +00:00
Jason Ansel
eebc93d41e
Better fix for f-strings in set_linter for py3.12 ( #143725 )
...
#143628 didn't handle a few cases right for example:
```py
$ python3 tools/linter/adapters/set_linter.py torch/_inductor/scheduler.py
torch/_inductor/scheduler.py:261:24: Builtin `set` is deprecated
259 | multiline=False,
260 | )
261 | return f"{self}{data_str}"
^
262 |
263 | def log_details(self) -> None:
torch/_inductor/scheduler.py:261:33: Builtin `set` is deprecated
259 | multiline=False,
260 | )
261 | return f"{self}{data_str}"
^
262 |
263 | def log_details(self) -> None:
```
also multi-line fstrings
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143725
Approved by: https://github.com/yanboliang
2024-12-22 22:51:27 +00:00
Tom Ritchford
f1cbf4b1b5
Enable ruff's unused variable checking everywhere in pytorch ( #136965 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/136965
Approved by: https://github.com/cyyever , https://github.com/albanD
2024-12-22 02:33:11 +00:00
Xuehai Pan
2293fe1024
[BE][Easy] use pathlib.Path instead of dirname / ".." / pardir ( #129374 )
...
Changes by apply order:
1. Replace all `".."` and `os.pardir` usage with `os.path.dirname(...)`.
2. Replace nested `os.path.dirname(os.path.dirname(...))` call with `str(Path(...).parent.parent)`.
3. Reorder `.absolute()` ~/ `.resolve()`~ and `.parent`: always resolve the path first.
`.parent{...}.absolute()` -> `.absolute().parent{...}`
4. Replace chained `.parent x N` with `.parents[${N - 1}]`: the code is easier to read (see 5.)
`.parent.parent.parent.parent` -> `.parents[3]`
5. ~Replace `.parents[${N - 1}]` with `.parents[${N} - 1]`: the code is easier to read and does not introduce any runtime overhead.~
~`.parents[3]` -> `.parents[4 - 1]`~
6. ~Replace `.parents[2 - 1]` with `.parent.parent`: because the code is shorter and easier to read.~
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129374
Approved by: https://github.com/justinchuby , https://github.com/malfet
2024-12-21 22:08:01 +00:00
Jason Ansel
04b26ee1e8
Fix false positive from f-strings in set_linter ( #143628 )
...
This linter was going crazy in python 3.12, example:
```py
$ python3 tools/linter/adapters/set_linter.py torch/_inductor/runtime/triton_heuristics.py
torch/_inductor/runtime/triton_heuristics.py:192:25: Builtin `set` is deprecated
190 | args_str += ", ".join(call_args)
191 | for k, v in call_kwargs.items():
192 | args_str += f", {k}={v}"
^
193 |
194 | abs_path = os.path.abspath(sys.argv[0])
torch/_inductor/runtime/triton_heuristics.py:192:27: Builtin `set` is deprecated
190 | args_str += ", ".join(call_args)
191 | for k, v in call_kwargs.items():
192 | args_str += f", {k}={v}"
^
193 |
194 | abs_path = os.path.abspath(sys.argv[0])
torch/_inductor/runtime/triton_heuristics.py:192:29: Builtin `set` is deprecated
190 | args_str += ", ".join(call_args)
191 | for k, v in call_kwargs.items():
192 | args_str += f", {k}={v}"
^
193 |
194 | abs_path = os.path.abspath(sys.argv[0])
torch/_inductor/runtime/triton_heuristics.py:192:31: Builtin `set` is deprecated
190 | args_str += ", ".join(call_args)
191 | for k, v in call_kwargs.items():
192 | args_str += f", {k}={v}"
^
193 |
194 | abs_path = os.path.abspath(sys.argv[0])
torch/_inductor/runtime/triton_heuristics.py:195:17: Builtin `set` is deprecated
193 |
194 | abs_path = os.path.abspath(sys.argv[0])
195 | with open(f"{abs_path}.launch_params", "a") as f:
^
196 | f.write(f"{kernel_name} | {args_str}\n")
197 |
torch/_inductor/runtime/triton_heuristics.py:195:26: Builtin `set` is deprecated
193 |
194 | abs_path = os.path.abspath(sys.argv[0])
195 | with open(f"{abs_path}.launch_params", "a") as f:
^
196 | f.write(f"{kernel_name} | {args_str}\n")
197 |
torch/_inductor/runtime/triton_heuristics.py:196:19: Builtin `set` is deprecated
194 | abs_path = os.path.abspath(sys.argv[0])
195 | with open(f"{abs_path}.launch_params", "a") as f:
196 | f.write(f"{kernel_name} | {args_str}\n")
^
197 |
198 |
torch/_inductor/runtime/triton_heuristics.py:196:31: Builtin `set` is deprecated
194 | abs_path = os.path.abspath(sys.argv[0])
195 | with open(f"{abs_path}.launch_params", "a") as f:
196 | f.write(f"{kernel_name} | {args_str}\n")
^
197 |
198 |
torch/_inductor/runtime/triton_heuristics.py:196:35: Builtin `set` is deprecated
194 | abs_path = os.path.abspath(sys.argv[0])
195 | with open(f"{abs_path}.launch_params", "a") as f:
196 | f.write(f"{kernel_name} | {args_str}\n")
^
197 |
198 |
torch/_inductor/runtime/triton_heuristics.py:196:44: Builtin `set` is deprecated
194 | abs_path = os.path.abspath(sys.argv[0])
195 | with open(f"{abs_path}.launch_params", "a") as f:
196 | f.write(f"{kernel_name} | {args_str}\n")
^
197 |
198 |
torch/_inductor/runtime/triton_heuristics.py:729:26: Builtin `set` is deprecated
727 | exec(
728 | f"""
729 | def launcher({', '.join(def_args)}, grid, stream):
^
730 | if callable(grid):
731 | grid_0, grid_1, grid_2 = grid(grid_meta)
torch/_inductor/runtime/triton_heuristics.py:729:46: Builtin `set` is deprecated
727 | exec(
728 | f"""
729 | def launcher({', '.join(def_args)}, grid, stream):
^
730 | if callable(grid):
731 | grid_0, grid_1, grid_2 = grid(grid_meta)
torch/_inductor/runtime/triton_heuristics.py:735:24: Builtin `set` is deprecated
733 | grid_0, grid_1, grid_2 = grid
734 |
735 | args = {', '.join(call_args)},
^
736 | launch_args = get_launch_args(
737 | grid, grid_0, grid_1, grid_2, stream, function,
torch/_inductor/runtime/triton_heuristics.py:735:45: Builtin `set` is deprecated
733 | grid_0, grid_1, grid_2 = grid
734 |
735 | args = {', '.join(call_args)},
^
736 | launch_args = get_launch_args(
737 | grid, grid_0, grid_1, grid_2, stream, function,
torch/_inductor/runtime/triton_heuristics.py:1144:20: Builtin `set` is deprecated
1142 | cur_file = inspect.stack()[1].filename
1143 | summary_str = (
1144 | f"SUMMARY ({cur_file})\n"
^
1145 | f"{overall_time:.2f}ms \t {overall_gb:.2f} GB\t {overall_gb / (overall_time / 1e3):.2f}GB/s"
1146 | )
torch/_inductor/runtime/triton_heuristics.py:1144:29: Builtin `set` is deprecated
1142 | cur_file = inspect.stack()[1].filename
1143 | summary_str = (
1144 | f"SUMMARY ({cur_file})\n"
^
1145 | f"{overall_time:.2f}ms \t {overall_gb:.2f} GB\t {overall_gb / (overall_time / 1e3):.2f}GB/s"
1146 | )
torch/_inductor/runtime/triton_heuristics.py:1162:61: Builtin `set` is deprecated
1160 | )
1161 | file.write("====================\n")
1162 | file.write(f"TRITON KERNELS BANDWIDTH INFO ({cur_file})\n")
^
1163 | for ms, num_gb, gb_per_s, kernel_name in sorted_calls:
1164 | # also display the runtime percentage for each kernel
torch/_inductor/runtime/triton_heuristics.py:1162:70: Builtin `set` is deprecated
1160 | )
1161 | file.write("====================\n")
1162 | file.write(f"TRITON KERNELS BANDWIDTH INFO ({cur_file})\n")
^
1163 | for ms, num_gb, gb_per_s, kernel_name in sorted_calls:
1164 | # also display the runtime percentage for each kernel
torch/_inductor/runtime/triton_heuristics.py:1166:36: Builtin `set` is deprecated
1164 | # also display the runtime percentage for each kernel
1165 | percentage = f"{ms / overall_time * 100:.2f}%"
1166 | suffix = f" \t {percentage} \t {kernel_name}"
^
1167 | bw_info_str = create_bandwidth_info_str(
1168 | ms,
torch/_inductor/runtime/triton_heuristics.py:1166:47: Builtin `set` is deprecated
1164 | # also display the runtime percentage for each kernel
1165 | percentage = f"{ms / overall_time * 100:.2f}%"
1166 | suffix = f" \t {percentage} \t {kernel_name}"
^
1167 | bw_info_str = create_bandwidth_info_str(
1168 | ms,
torch/_inductor/runtime/triton_heuristics.py:1166:52: Builtin `set` is deprecated
1164 | # also display the runtime percentage for each kernel
1165 | percentage = f"{ms / overall_time * 100:.2f}%"
1166 | suffix = f" \t {percentage} \t {kernel_name}"
^
1167 | bw_info_str = create_bandwidth_info_str(
1168 | ms,
torch/_inductor/runtime/triton_heuristics.py:1166:64: Builtin `set` is deprecated
1164 | # also display the runtime percentage for each kernel
1165 | percentage = f"{ms / overall_time * 100:.2f}%"
1166 | suffix = f" \t {percentage} \t {kernel_name}"
^
1167 | bw_info_str = create_bandwidth_info_str(
1168 | ms,
torch/_inductor/runtime/triton_heuristics.py:1175:30: Builtin `set` is deprecated
1173 | )
1174 | file.write(bw_info_str + "\n")
1175 | file.write(f"{summary_str}\n\n")
^
1176 | except Exception as e:
1177 | log.warning(
torch/_inductor/runtime/triton_heuristics.py:1175:42: Builtin `set` is deprecated
1173 | )
1174 | file.write(bw_info_str + "\n")
1175 | file.write(f"{summary_str}\n\n")
^
1176 | except Exception as e:
1177 | log.warning(
torch/_inductor/runtime/triton_heuristics.py:1205:29: Builtin `set` is deprecated
1203 | else:
1204 | possible_names = _find_names(self)
1205 | kernel_name = f"{max(possible_names, key=len)}"
^
1206 | if not re.match(self.regex_filter, kernel_name):
1207 | return
torch/_inductor/runtime/triton_heuristics.py:1205:58: Builtin `set` is deprecated
1203 | else:
1204 | possible_names = _find_names(self)
1205 | kernel_name = f"{max(possible_names, key=len)}"
^
1206 | if not re.match(self.regex_filter, kernel_name):
1207 | return
torch/_inductor/runtime/triton_heuristics.py:1241:60: Builtin `set` is deprecated
1239 | "%s",
1240 | create_bandwidth_info_str(
1241 | ms, num_gb, gb_per_s, suffix=f" \t {kernel_name}"
^
1242 | ),
1243 | )
torch/_inductor/runtime/triton_heuristics.py:1241:72: Builtin `set` is deprecated
1239 | "%s",
1240 | create_bandwidth_info_str(
1241 | ms, num_gb, gb_per_s, suffix=f" \t {kernel_name}"
^
1242 | ),
1243 | )
torch/_inductor/runtime/triton_heuristics.py:1256:15: Builtin `set` is deprecated
1254 | for cfg in configs:
1255 | hasher.update(
1256 | f"{sorted(cfg.kwargs.items())} {cfg.num_warps} {cfg.num_stages}\n".encode()
^
1257 | )
1258 | return hasher.hexdigest()
torch/_inductor/runtime/triton_heuristics.py:1256:42: Builtin `set` is deprecated
1254 | for cfg in configs:
1255 | hasher.update(
1256 | f"{sorted(cfg.kwargs.items())} {cfg.num_warps} {cfg.num_stages}\n".encode()
^
1257 | )
1258 | return hasher.hexdigest()
torch/_inductor/runtime/triton_heuristics.py:1256:44: Builtin `set` is deprecated
1254 | for cfg in configs:
1255 | hasher.update(
1256 | f"{sorted(cfg.kwargs.items())} {cfg.num_warps} {cfg.num_stages}\n".encode()
^
1257 | )
1258 | return hasher.hexdigest()
torch/_inductor/runtime/triton_heuristics.py:1256:58: Builtin `set` is deprecated
1254 | for cfg in configs:
1255 | hasher.update(
1256 | f"{sorted(cfg.kwargs.items())} {cfg.num_warps} {cfg.num_stages}\n".encode()
^
1257 | )
1258 | return hasher.hexdigest()
torch/_inductor/runtime/triton_heuristics.py:1256:60: Builtin `set` is deprecated
1254 | for cfg in configs:
1255 | hasher.update(
1256 | f"{sorted(cfg.kwargs.items())} {cfg.num_warps} {cfg.num_stages}\n".encode()
^
1257 | )
1258 | return hasher.hexdigest()
torch/_inductor/runtime/triton_heuristics.py:1256:75: Builtin `set` is deprecated
1254 | for cfg in configs:
1255 | hasher.update(
1256 | f"{sorted(cfg.kwargs.items())} {cfg.num_warps} {cfg.num_stages}\n".encode()
^
1257 | )
1258 | return hasher.hexdigest()
torch/_inductor/runtime/triton_heuristics.py:1377:23: Builtin `set` is deprecated
1375 | if numel is None:
1376 | continue
1377 | block = cfg[f"{label}BLOCK"]
^
1378 | if numel == 1:
1379 | assert block == 1, (
torch/_inductor/runtime/triton_heuristics.py:1377:29: Builtin `set` is deprecated
1375 | if numel is None:
1376 | continue
1377 | block = cfg[f"{label}BLOCK"]
^
1378 | if numel == 1:
1379 | assert block == 1, (
torch/_inductor/runtime/triton_heuristics.py:1381:24: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:38: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:46: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:52: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:58: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:64: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:71: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:77: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:84: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1381:88: Builtin `set` is deprecated
1379 | assert block == 1, (
1380 | f"TritonKernel.indexing assumes numel == 1 => BLOCK == 1"
1381 | f" but {label.lower()}numel=={numel} and {label}BLOCK={block} (cfg={cfg})."
^
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
torch/_inductor/runtime/triton_heuristics.py:1384:52: Builtin `set` is deprecated
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
1384 | max_block_str = f'config.triton.max_block["{label}"]'
^
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
torch/_inductor/runtime/triton_heuristics.py:1384:58: Builtin `set` is deprecated
1382 | )
1383 | max_block = TRITON_MAX_BLOCK[label]
1384 | max_block_str = f'config.triton.max_block["{label}"]'
^
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
torch/_inductor/runtime/triton_heuristics.py:1386:45: Builtin `set` is deprecated
1384 | max_block_str = f'config.triton.max_block["{label}"]'
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
^
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
1388 | )
torch/_inductor/runtime/triton_heuristics.py:1386:51: Builtin `set` is deprecated
1384 | max_block_str = f'config.triton.max_block["{label}"]'
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
^
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
1388 | )
torch/_inductor/runtime/triton_heuristics.py:1386:66: Builtin `set` is deprecated
1384 | max_block_str = f'config.triton.max_block["{label}"]'
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
^
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
1388 | )
torch/_inductor/runtime/triton_heuristics.py:1386:80: Builtin `set` is deprecated
1384 | max_block_str = f'config.triton.max_block["{label}"]'
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
^
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
1388 | )
torch/_inductor/runtime/triton_heuristics.py:1387:20: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:26: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:33: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:39: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:45: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:59: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:61: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:71: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:78: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1387:82: Builtin `set` is deprecated
1385 | assert max_block % block == 0, (
1386 | f"TritonKernel.indexing assumes {label}BLOCK divides {max_block_str}"
1387 | f" but {label}BLOCK={block} and {max_block_str}={max_block} (cfg={cfg})."
^
1388 | )
1389 |
torch/_inductor/runtime/triton_heuristics.py:1402:19: Builtin `set` is deprecated
1400 | assert (
1401 | val <= max_block
1402 | ), f"'{var}' too large. Maximum: {max_block}. Actual: {val}."
^
1403 |
1404 |
torch/_inductor/runtime/triton_heuristics.py:1402:23: Builtin `set` is deprecated
1400 | assert (
1401 | val <= max_block
1402 | ), f"'{var}' too large. Maximum: {max_block}. Actual: {val}."
^
1403 |
1404 |
torch/_inductor/runtime/triton_heuristics.py:1402:46: Builtin `set` is deprecated
1400 | assert (
1401 | val <= max_block
1402 | ), f"'{var}' too large. Maximum: {max_block}. Actual: {val}."
^
1403 |
1404 |
torch/_inductor/runtime/triton_heuristics.py:1402:56: Builtin `set` is deprecated
1400 | assert (
1401 | val <= max_block
1402 | ), f"'{var}' too large. Maximum: {max_block}. Actual: {val}."
^
1403 |
1404 |
torch/_inductor/runtime/triton_heuristics.py:1402:67: Builtin `set` is deprecated
1400 | assert (
1401 | val <= max_block
1402 | ), f"'{var}' too large. Maximum: {max_block}. Actual: {val}."
^
1403 |
1404 |
torch/_inductor/runtime/triton_heuristics.py:1402:71: Builtin `set` is deprecated
1400 | assert (
1401 | val <= max_block
1402 | ), f"'{var}' too large. Maximum: {max_block}. Actual: {val}."
^
1403 |
1404 |
torch/_inductor/runtime/triton_heuristics.py:1551:21: Builtin `set` is deprecated
1549 | rnumels = {}
1550 | for idx in range(num_reduction_dims - 1, -1, -1):
1551 | prefix = f"r{idx}_"
^
1552 | max_size = min(size_hints[prefix], TRITON_MAX_BLOCK[prefix.upper()])
1553 | dim = min(max_size, remaining)
torch/_inductor/runtime/triton_heuristics.py:1551:25: Builtin `set` is deprecated
1549 | rnumels = {}
1550 | for idx in range(num_reduction_dims - 1, -1, -1):
1551 | prefix = f"r{idx}_"
^
1552 | max_size = min(size_hints[prefix], TRITON_MAX_BLOCK[prefix.upper()])
1553 | dim = min(max_size, remaining)
torch/_inductor/runtime/triton_heuristics.py:1556:34: Builtin `set` is deprecated
1554 | assert (
1555 | remaining % dim == 0
1556 | ), f"Expected dimension '{dim}' to divide remaining size '{remaining}'"
^
1557 | rnumels[prefix] = dim
1558 | remaining //= dim
torch/_inductor/runtime/triton_heuristics.py:1556:38: Builtin `set` is deprecated
1554 | assert (
1555 | remaining % dim == 0
1556 | ), f"Expected dimension '{dim}' to divide remaining size '{remaining}'"
^
1557 | rnumels[prefix] = dim
1558 | remaining //= dim
torch/_inductor/runtime/triton_heuristics.py:1556:67: Builtin `set` is deprecated
1554 | assert (
1555 | remaining % dim == 0
1556 | ), f"Expected dimension '{dim}' to divide remaining size '{remaining}'"
^
1557 | rnumels[prefix] = dim
1558 | remaining //= dim
torch/_inductor/runtime/triton_heuristics.py:1556:77: Builtin `set` is deprecated
1554 | assert (
1555 | remaining % dim == 0
1556 | ), f"Expected dimension '{dim}' to divide remaining size '{remaining}'"
^
1557 | rnumels[prefix] = dim
1558 | remaining //= dim
torch/_inductor/runtime/triton_heuristics.py:1564:38: Builtin `set` is deprecated
1562 | assert (
1563 | r == final_numel
1564 | ), f"Expected ND reduction size ({rnumels}) to have {r} elements."
^
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
torch/_inductor/runtime/triton_heuristics.py:1564:46: Builtin `set` is deprecated
1562 | assert (
1563 | r == final_numel
1564 | ), f"Expected ND reduction size ({rnumels}) to have {r} elements."
^
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
torch/_inductor/runtime/triton_heuristics.py:1564:57: Builtin `set` is deprecated
1562 | assert (
1563 | r == final_numel
1564 | ), f"Expected ND reduction size ({rnumels}) to have {r} elements."
^
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
torch/_inductor/runtime/triton_heuristics.py:1564:59: Builtin `set` is deprecated
1562 | assert (
1563 | r == final_numel
1564 | ), f"Expected ND reduction size ({rnumels}) to have {r} elements."
^
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
torch/_inductor/runtime/triton_heuristics.py:1567:37: Builtin `set` is deprecated
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
1567 | ), f"rnumels exceed size_hints. {rnumels} > {size_hints}"
^
1568 |
1569 | return rnumels
torch/_inductor/runtime/triton_heuristics.py:1567:45: Builtin `set` is deprecated
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
1567 | ), f"rnumels exceed size_hints. {rnumels} > {size_hints}"
^
1568 |
1569 | return rnumels
torch/_inductor/runtime/triton_heuristics.py:1567:49: Builtin `set` is deprecated
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
1567 | ), f"rnumels exceed size_hints. {rnumels} > {size_hints}"
^
1568 |
1569 | return rnumels
torch/_inductor/runtime/triton_heuristics.py:1567:60: Builtin `set` is deprecated
1565 | assert all(
1566 | rnumels[prefix] <= size_hints[prefix] for prefix in rnumels
1567 | ), f"rnumels exceed size_hints. {rnumels} > {size_hints}"
^
1568 |
1569 | return rnumels
torch/_inductor/runtime/triton_heuristics.py:1746:49: Builtin `set` is deprecated
1744 |
1745 | if not configs:
1746 | raise NotImplementedError(f"size_hints: {size_hints}")
^
1747 | return cached_autotune(
1748 | size_hints,
torch/_inductor/runtime/triton_heuristics.py:1746:60: Builtin `set` is deprecated
1744 |
1745 | if not configs:
1746 | raise NotImplementedError(f"size_hints: {size_hints}")
^
1747 | return cached_autotune(
1748 | size_hints,
torch/_inductor/runtime/triton_heuristics.py:1928:32: Builtin `set` is deprecated
1926 | for prefix in size_hints:
1927 | if prefix_is_reduction(prefix):
1928 | c.kwargs.pop(f"{prefix.upper()}BLOCK")
^
1929 |
1930 | if disable_pointwise_autotuning(inductor_meta):
torch/_inductor/runtime/triton_heuristics.py:1928:47: Builtin `set` is deprecated
1926 | for prefix in size_hints:
1927 | if prefix_is_reduction(prefix):
1928 | c.kwargs.pop(f"{prefix.upper()}BLOCK")
^
1929 |
1930 | if disable_pointwise_autotuning(inductor_meta):
torch/_inductor/runtime/triton_heuristics.py:1975:49: Builtin `set` is deprecated
1973 | assert triton_meta is not None
1974 | if len(size_hints) != 2:
1975 | raise NotImplementedError(f"size_hints: {size_hints}")
^
1976 |
1977 | configs = _reduction_configs(size_hints=size_hints, inductor_meta=inductor_meta)
torch/_inductor/runtime/triton_heuristics.py:1975:60: Builtin `set` is deprecated
1973 | assert triton_meta is not None
1974 | if len(size_hints) != 2:
1975 | raise NotImplementedError(f"size_hints: {size_hints}")
^
1976 |
1977 | configs = _reduction_configs(size_hints=size_hints, inductor_meta=inductor_meta)
torch/_inductor/runtime/triton_heuristics.py:2082:56: Builtin `set` is deprecated
2080 | xnumel, ynumel, znumel = numels[2], numels[1], numels[0]
2081 | else:
2082 | raise AssertionError(f"invalid size for numels {len(numels)}")
^
2083 |
2084 | def get_grid_dim(numel, block):
torch/_inductor/runtime/triton_heuristics.py:2082:68: Builtin `set` is deprecated
2080 | xnumel, ynumel, znumel = numels[2], numels[1], numels[0]
2081 | else:
2082 | raise AssertionError(f"invalid size for numels {len(numels)}")
^
2083 |
2084 | def get_grid_dim(numel, block):
torch/_inductor/runtime/triton_heuristics.py:2104:57: Builtin `set` is deprecated
2102 | torch._check(
2103 | y_grid <= max_y_grid,
2104 | lambda: f"Generated y grid beyond 2^16 ({y_grid}) not supported with z dimension present. File issue",
^
2105 | )
2106 |
torch/_inductor/runtime/triton_heuristics.py:2104:64: Builtin `set` is deprecated
2102 | torch._check(
2103 | y_grid <= max_y_grid,
2104 | lambda: f"Generated y grid beyond 2^16 ({y_grid}) not supported with z dimension present. File issue",
^
2105 | )
2106 |
torch/_inductor/runtime/triton_heuristics.py:2113:43: Builtin `set` is deprecated
2111 | )
2112 |
2113 | setattr(grid_fn, "grid_fn_str", f"grid{numels}") # noqa: B010
^
2114 |
2115 | return grid_fn
torch/_inductor/runtime/triton_heuristics.py:2113:50: Builtin `set` is deprecated
2111 | )
2112 |
2113 | setattr(grid_fn, "grid_fn_str", f"grid{numels}") # noqa: B010
^
2114 |
2115 | return grid_fn
torch/_inductor/runtime/triton_heuristics.py:2122:48: Builtin `set` is deprecated
2120 | return (meta["RSPLIT"], ceildiv(xnumel, meta.get("XBLOCK", 1)), 1)
2121 |
2122 | grid_fn_str = f"cooperative_reduction_grid({xnumel})"
^
2123 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2124 | return grid_fn
torch/_inductor/runtime/triton_heuristics.py:2122:55: Builtin `set` is deprecated
2120 | return (meta["RSPLIT"], ceildiv(xnumel, meta.get("XBLOCK", 1)), 1)
2121 |
2122 | grid_fn_str = f"cooperative_reduction_grid({xnumel})"
^
2123 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2124 | return grid_fn
torch/_inductor/runtime/triton_heuristics.py:2135:54: Builtin `set` is deprecated
2133 | coop_grid = cooperative_reduction_grid(xnumel)
2134 | normal_grid = grid(xnumel)
2135 | grid_fn_str = f"maybe_cooperative_reduction_grid({xnumel})"
^
2136 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2137 | return grid_fn
torch/_inductor/runtime/triton_heuristics.py:2135:61: Builtin `set` is deprecated
2133 | coop_grid = cooperative_reduction_grid(xnumel)
2134 | normal_grid = grid(xnumel)
2135 | grid_fn_str = f"maybe_cooperative_reduction_grid({xnumel})"
^
2136 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2137 | return grid_fn
torch/_inductor/runtime/triton_heuristics.py:2145:37: Builtin `set` is deprecated
2143 | return (ceildiv(rnumel, meta.get("R0_BLOCK", 1)), xnumel, 1)
2144 |
2145 | grid_fn_str = f"split_scan_grid({xnumel}, {rnumel})"
^
2146 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2147 |
torch/_inductor/runtime/triton_heuristics.py:2145:44: Builtin `set` is deprecated
2143 | return (ceildiv(rnumel, meta.get("R0_BLOCK", 1)), xnumel, 1)
2144 |
2145 | grid_fn_str = f"split_scan_grid({xnumel}, {rnumel})"
^
2146 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2147 |
torch/_inductor/runtime/triton_heuristics.py:2145:47: Builtin `set` is deprecated
2143 | return (ceildiv(rnumel, meta.get("R0_BLOCK", 1)), xnumel, 1)
2144 |
2145 | grid_fn_str = f"split_scan_grid({xnumel}, {rnumel})"
^
2146 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2147 |
torch/_inductor/runtime/triton_heuristics.py:2145:54: Builtin `set` is deprecated
2143 | return (ceildiv(rnumel, meta.get("R0_BLOCK", 1)), xnumel, 1)
2144 |
2145 | grid_fn_str = f"split_scan_grid({xnumel}, {rnumel})"
^
2146 | setattr(grid_fn, "grid_fn_str", grid_fn_str) # noqa: B010
2147 |
torch/_inductor/runtime/triton_heuristics.py:2173:42: Builtin `set` is deprecated
2171 | assert (
2172 | min_blocks_d is None or min_blocks == min_blocks_d
2173 | ), f"inconsistent min_blocks {min_blocks} vs x grid {numels[-1]}"
^
2174 | else:
2175 | # sequential dispatch
torch/_inductor/runtime/triton_heuristics.py:2173:53: Builtin `set` is deprecated
2171 | assert (
2172 | min_blocks_d is None or min_blocks == min_blocks_d
2173 | ), f"inconsistent min_blocks {min_blocks} vs x grid {numels[-1]}"
^
2174 | else:
2175 | # sequential dispatch
torch/_inductor/runtime/triton_heuristics.py:2173:66: Builtin `set` is deprecated
2171 | assert (
2172 | min_blocks_d is None or min_blocks == min_blocks_d
2173 | ), f"inconsistent min_blocks {min_blocks} vs x grid {numels[-1]}"
^
2174 | else:
2175 | # sequential dispatch
torch/_inductor/runtime/triton_heuristics.py:2173:77: Builtin `set` is deprecated
2171 | assert (
2172 | min_blocks_d is None or min_blocks == min_blocks_d
2173 | ), f"inconsistent min_blocks {min_blocks} vs x grid {numels[-1]}"
^
2174 | else:
2175 | # sequential dispatch
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/143628
Approved by: https://github.com/yanboliang , https://github.com/rec
2024-12-20 11:45:26 +00:00
Ryan Guo
629de4da60
[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-19 20:59:16 +00:00
cyy
82aaf64422
[3/N] Apply py39 ruff fixes ( #142115 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/142115
Approved by: https://github.com/ezyang
2024-12-11 17:50:10 +00:00
Tom Ritchford
dc7461d6f5
docstring_linter finds long classes and functions without docstrings (#140426 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/140426
Approved by: https://github.com/eellison
2024-12-08 17:03:57 +00:00
Tom Ritchford
d0b9874603
Teach ruff_linter to report syntax errors ( fix #140228 ) ( #142312 )
...
Now syntax errors look like this:
```
torch/_dynamo/variables/base.py:20:
Error (RUFF) E999
SyntaxError: Expected ',', found indent.
See https://beta.ruff.rs/docs/rules/
>>> 19 |class SourceType(Enum]:
20 | """
21 | This Enum divides VariableTracker into 2 cases, depending on the variable
22 | it represents:
[...more errors...]
```
Note that most syntax errors lead to a cascade of other errors, so the exception is generally wrong, but the location and name are good.
Before they looked like this:
```
>>> General linter failure:
Error (RUFF) Linter failed
Linter failed. This a bug, please file an issue against the linter
maintainer.
CONTEXT:
Linter command failed with non-zero exit code.
STDERR:
<MainThread:DEBUG> $ /home/rec/.conda/envs/pytorch-dev-constant/
bin/python3 -m ruff check --exit-zero --quiet --output-format=json
--config=pyproject.toml /home/rec/git-constant/pytorch/torch/_dynamo/
variables/base.py
<MainThread:DEBUG> took 38ms
Traceback (most recent call last):
File "/home/rec/git-constant/pytorch/tools/linter/adapters/
ruff_linter.py", line 465, in <module>
main()
File "/home/rec/git-constant/pytorch/tools/linter/adapters/
ruff_linter.py", line 424, in main
lint_messages = check_files(
File "/home/rec/git-constant/pytorch/tools/linter/adapters/
ruff_linter.py", line 273, in check_files
return [
File "/home/rec/git-constant/pytorch/tools/linter/adapters/
ruff_linter.py", line 288, in <listcomp>
severity=severities.get(vuln["code"],
get_issue_severity(vuln["code"])),
File "/home/rec/git-constant/pytorch/tools/linter/adapters/
ruff_linter.py", line 172, in get_issue_severity
if any(
File "/home/rec/git-constant/pytorch/tools/linter/adapters/
ruff_linter.py", line 173, in <genexpr>
code.startswith(x)
AttributeError: 'NoneType' object has no attribute 'startswith'
STDOUT:
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/142312
Approved by: https://github.com/Skylion007
2024-12-08 16:48:05 +00:00
Edward Z. Yang
08df79819d
Uniformly pass secrets: inherit to all jobs that go to _linux-build/_linux-test ( #141995 )
...
There's also a new lint to make sure you did it right.
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141995
Approved by: https://github.com/albanD , https://github.com/malfet
2024-12-05 14:52:43 +00:00
Tom Ritchford
6ad422d778
set_linter finds and replaces built-in set in Python code (#138454 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138454
Approved by: https://github.com/eellison
2024-12-04 14:31:24 +00:00
Nikita Shulga
93efddc67a
Use pip corresponding to python executable ( #141165 )
...
Sometimes `python3` and `pip` are aliased to different runtimes, so it's better to always use `pip3`, but as linter should install packages into the same python environment, it's even better to just call sys.executable with `-mpip install XYZ` arguments
Fixes regression introduced by https://github.com/pytorch/pytorch/pull/124033
Pull Request resolved: https://github.com/pytorch/pytorch/pull/141165
Approved by: https://github.com/Skylion007 , https://github.com/kit1980
2024-11-20 22:58:33 +00:00
cyy
a2bc2e38f9
Use clang-tidy 17 ( #139678 )
...
Fixes #ISSUE_NUMBER
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139678
Approved by: https://github.com/Skylion007
2024-11-05 16:00:25 +00:00
Edward Z. Yang
e0156f9faa
HACK: use FB proxy for testowners ( #139473 )
...
I got fed up with this always timing out when I didn't have
correct proxy settings.
Signed-off-by: Edward Z. Yang <ezyang@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/139473
Approved by: https://github.com/malfet
2024-11-05 15:35:41 +00:00
Catherine Lee
66a3c249ae
Linter for no workflows on fork ( #138849 )
...
MInor, adds a linter that ensures that all jobs run on pull_request, schedule, push etc have a `if: github.repository_owner == 'pytorch'` or are dependent on a job that has that check
There is also a setting in Github repos that can disable all workflows for that repo
A lot of these are unnecessary because many jobs use reusable workflows that have that check. However, this is a one time change so I'm not that bothered
Unfortunately I can't put this at the workflow level, which would make this better
Lots of weird string parsing
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138849
Approved by: https://github.com/malfet
2024-10-28 17:46:50 +00:00
Richard Barnes
dbf0fa811a
Remove C10_HOST_CONSTEXPR_EXCEPT_WIN_CUDA and CONSTEXPR_EXCEPT_WIN_CUDA ( #138479 )
...
BC linter suppressed due to removal of `tools/linter/adapters/constexpr_linter.py`
Pull Request resolved: https://github.com/pytorch/pytorch/pull/138479
Approved by: https://github.com/eqy , https://github.com/malfet
2024-10-24 07:51:05 +00:00
Xuehai Pan
267f82b860
[BE] Format .ci/ / .github/ / benchmarks/ / functorch/ / tools/ / torchgen/ with ruff format ( #132577 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132577
Approved by: https://github.com/malfet
2024-10-11 18:30:26 +00:00
Justin Chu
b319fa3fd9
[ONNX] Opt into ruff fmt ( #134120 )
...
Add ONNX directory to use ruff format.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/134120
Approved by: https://github.com/XuehaiPan , https://github.com/Skylion007
2024-08-22 22:44:03 +00:00
PyTorch MergeBot
b0171c3920
Revert "[ONNX] Opt into ruff fmt ( #134120 )"
...
This reverts commit 0870398fa8 .
Reverted https://github.com/pytorch/pytorch/pull/134120 on behalf of https://github.com/albanD due to Breaks main branch lint ([comment](https://github.com/pytorch/pytorch/pull/134120#issuecomment-2305089756 ))
2024-08-22 15:48:14 +00:00
Justin Chu
0870398fa8
[ONNX] Opt into ruff fmt ( #134120 )
...
Add ONNX directory to use ruff format.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/134120
Approved by: https://github.com/XuehaiPan , https://github.com/Skylion007
2024-08-21 21:43:55 +00:00
Xuehai Pan
758a0a88a2
[BE][Easy] enable ruff rule PIE790: unnecessary pass statement ( #133200 )
...
This PR removes unnecessary `pass` statement. This is semanticly safe because the bytecode for the Python code does not change.
Note that if there is a docstring in the function, a empty function does not need a `pass` statement as placeholder.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/133200
Approved by: https://github.com/malfet , https://github.com/eqy , https://github.com/kit1980
2024-08-15 15:50:19 +00:00
Xuehai Pan
4226ed1585
[BE] Format uncategorized Python files with ruff format ( #132576 )
...
Remove patterns `**`, `test/**`, and `torch/**` in `tools/linter/adapters/pyfmt_linter.py` and run `lintrunner`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132576
Approved by: https://github.com/ezyang , https://github.com/Skylion007
ghstack dependencies: #132574
2024-08-04 17:13:31 +00:00
Xuehai Pan
c35061c542
Migrate Python code formatter from black to ruff format ( #132574 )
...
See also:
- #124845
- #123062
Closes #124845
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132574
Approved by: https://github.com/ezyang
2024-08-04 17:13:31 +00:00
Xuehai Pan
d2dc173664
Remove lint dependency ufmt ( #132573 )
...
`ufmt` is a combination of `black + usort`.
This PR removes `ufmt` and run `black` and `usort` separately.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132573
Approved by: https://github.com/ezyang
ghstack dependencies: #129769 , #132572
2024-08-04 10:24:09 +00:00
Xuehai Pan
f7aeb394b6
[BE][Easy] Remove empty ISORT_SKIPLIST ( #132572 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/132572
Approved by: https://github.com/ezyang , https://github.com/justinchuby
ghstack dependencies: #129769
2024-08-04 10:24:09 +00:00
Xuehai Pan
f3fce597e9
[BE][Easy][17/19] enforce style for empty lines in import segments in torch/[a-c]*/ and torch/[e-n]*/ ( #129769 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129769
Approved by: https://github.com/ezyang
2024-08-04 10:24:09 +00:00
Xuehai Pan
30293319a8
[BE][Easy][19/19] enforce style for empty lines in import segments in torch/[o-z]*/ ( #129771 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129771
Approved by: https://github.com/justinchuby , https://github.com/janeyx99
2024-08-01 17:07:14 +00:00
Xuehai Pan
6ff1e43a41
[BE][Easy][13/19] enforce style for empty lines in import segments in test/j*/ ( #129764 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129764
Approved by: https://github.com/ezyang
2024-08-01 12:13:42 +00:00
Xuehai Pan
b25ef91bf1
[BE][Easy][18/19] enforce style for empty lines in import segments in torch/d*/ ( #129770 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129770
Approved by: https://github.com/wconstab
2024-08-01 04:22:50 +00:00
Xuehai Pan
e74ba1b34a
[BE][Easy][15/19] enforce style for empty lines in import segments in torch/_d*/ ( #129767 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129767
Approved by: https://github.com/anijain2305
2024-07-31 21:18:11 +00:00
Xuehai Pan
548c460bf1
[BE][Easy][7/19] enforce style for empty lines in import segments in test/[a-c]*/ and test/[q-z]*/ ( #129758 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129758
Approved by: https://github.com/ezyang
2024-07-31 10:54:03 +00:00
Xuehai Pan
e7eeee473c
[BE][Easy][14/19] enforce style for empty lines in import segments in torch/_[a-c]*/ and torch/_[e-h]*/ and torch/_[j-z]*/ ( #129765 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129765
Approved by: https://github.com/ezyang
2024-07-31 10:42:50 +00:00
Xuehai Pan
fbe6f42dcf
[BE][Easy][8/19] enforce style for empty lines in import segments in test/[k-p]*/ ( #129759 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129759
Approved by: https://github.com/justinchuby , https://github.com/ezyang
2024-07-31 02:09:20 +00:00
Xuehai Pan
918ece4f4d
[BE][Easy][11/19] enforce style for empty lines in import segments in test/dy*/ ( #129762 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129762
Approved by: https://github.com/anijain2305
2024-07-27 17:43:53 +00:00
Xuehai Pan
42a4df9447
Support CUDA nightly package in tools/nightly.py ( #131133 )
...
Add a new option `--cuda` to `tools/nightly.py` to pull the nightly packages with CUDA support.
```bash
# installs pytorch-nightly with cpuonly
tools/nightly.py pull
# The following only available on Linux and Windows
# installs pytorch-nightly with latest CUDA we support
tools/nightly.py pull --cuda
# installs pytorch-nightly with CUDA 12.1
tools/nightly.py pull --cuda 12.1
```
Also add targets in `Makefile` and instructions in constribution guidelines.
```bash
# setup conda environment with pytorch-nightly
make setup-env
# setup conda environment with pytorch-nightly with CUDA support
make setup-env-cuda
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/131133
Approved by: https://github.com/ezyang
2024-07-25 05:33:52 +00:00
Xuehai Pan
b6d477fd56
[BE][Easy][16/19] enforce style for empty lines in import segments in torch/_i*/ ( #129768 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129768
Approved by: https://github.com/jansel
2024-07-20 16:20:58 +00:00
Xuehai Pan
134bc4fc34
[BE][Easy][12/19] enforce style for empty lines in import segments in test/i*/ ( #129763 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129763
Approved by: https://github.com/jansel
2024-07-18 07:49:19 +00:00
PyTorch MergeBot
b732b52f1e
Revert "[BE][Easy][12/19] enforce style for empty lines in import segments in test/i*/ ( #129763 )"
...
This reverts commit aecc746fcc .
Reverted https://github.com/pytorch/pytorch/pull/129763 on behalf of https://github.com/XuehaiPan due to need reland after rerunning lintrunner on main ([comment](https://github.com/pytorch/pytorch/pull/129763#issuecomment-2235736732 ))
2024-07-18 06:39:58 +00:00
Xuehai Pan
aecc746fcc
[BE][Easy][12/19] enforce style for empty lines in import segments in test/i*/ ( #129763 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129763
Approved by: https://github.com/jansel
2024-07-18 05:13:41 +00:00
Xuehai Pan
740fb22966
[BE][Easy][4/19] enforce style for empty lines in import segments in functorch/ ( #129755 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129755
Approved by: https://github.com/zou3519
ghstack dependencies: #129752
2024-07-18 05:08:03 +00:00
Nikita Shulga
ebdfc7e37d
[BE] Rename ISORT_WHITELIST to ISORT_SKIPLIST ( #130987 )
...
To better represent what this list is doing
Pull Request resolved: https://github.com/pytorch/pytorch/pull/130987
Approved by: https://github.com/seemethere , https://github.com/ZainRizvi
2024-07-17 21:52:56 +00:00
Xuehai Pan
db3290846e
[BE][Easy][10/19] enforce style for empty lines in import segments in test/d*/ ( #129761 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129761
Approved by: https://github.com/fegin
2024-07-17 16:57:39 +00:00
Xuehai Pan
c0ed38e644
[BE][Easy][3/19] enforce style for empty lines in import segments in benchmarks/ ( #129754 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129754
Approved by: https://github.com/ezyang
2024-07-17 14:34:42 +00:00
Xuehai Pan
76169cf691
[BE][Easy][9/19] enforce style for empty lines in import segments in test/[e-h]*/ ( #129760 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129760
Approved by: https://github.com/ezyang
2024-07-17 14:25:29 +00:00
Xuehai Pan
f6838d521a
[BE][Easy][5/19] enforce style for empty lines in import segments in tools/ and torchgen/ ( #129756 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129756
Approved by: https://github.com/ezyang
2024-07-17 06:44:35 +00:00
Xuehai Pan
ba48cf6535
[BE][Easy][6/19] enforce style for empty lines in import segments in test/ ( #129757 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129757
Approved by: https://github.com/ezyang
2024-07-17 06:42:37 +00:00
Xuehai Pan
747b38c131
[BE][Easy][2/19] enforce style for empty lines in import segments in .ci/ and .github/ ( #129753 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129753
Approved by: https://github.com/malfet
ghstack dependencies: #129752
2024-07-16 09:40:00 +00:00
Xuehai Pan
a3abfa5cb5
[BE][Easy][1/19] enforce style for empty lines in import segments ( #129752 )
...
See https://github.com/pytorch/pytorch/pull/129751#issue-2380881501 . Most changes are auto-generated by linter.
You can review these PRs via:
```bash
git diff --ignore-all-space --ignore-blank-lines HEAD~1
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/129752
Approved by: https://github.com/ezyang , https://github.com/malfet
2024-07-16 00:42:56 +00:00