Maggie Moss
80ba6e458f
Add warning when users have incomplete setup for type checking ( #166603 )
...
Looking for feedback on this approach.
Received user reports of spurious pyrefly errors for users using hg instead of git. I think this was due to the fact that when using a venv and git, `make setup-env` installs requirements and pulls from a nightly torch wheel, which is needed for pyrefly to type check properly.
Initial documentation for `make setup-env` I found here: https://github.com/pytorch/pytorch/blob/main/CONTRIBUTING.md#developing-pytorch
Testing:
```
hg clone --git ssh://git@github.com/pytorch/pytorch.git
conda create -n pytorch_env python=3.10 # (or manually create venv instead of using script)
cd pytorch
pip install -r requirements.txt
pip install -r requirements-build.txt
lintrunner init
# check how many pyrefly errors - 15,709 errors (11,693 ignored)
lintrunner # confirm error message / warning appears
>>> General linter failure:
Warning (PYREFLY) nightly-wheel-not-run
pytorch-nightly.pth not found. You may need to run make setup-env or make
setup-env-conda to install nightly binaries and type stubs.
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/166603
Approved by: https://github.com/aorenste
2025-10-30 20:37:44 +00:00
Maggie Moss
5121499f6b
Fix pyrefly ignore syntax in /tools/... ( #166240 )
...
Second PR for this - only adjusts the syntax used for the ignores so the suppressions hide only one category of pyrefly errors.
test:
pyrefly check
lintrunner
Pull Request resolved: https://github.com/pytorch/pytorch/pull/166240
Approved by: https://github.com/oulgen
2025-10-26 04:20:16 +00:00
Aaron Orenstein
b55b779ad3
Add file size limits to linters and refactor grep_linter ( #166202 )
...
- Add 1GB file size limits to grep_linter, newlines_linter, codespell_linter
- Refactor grep_linter
- process files once instead of per-line
- Extract allowlist check to separate function
- Add 512KB limit for computing replacements, 100 match limit per file
- Detect duplicate arguments
- Fix .lintrunner.toml: RAWCUDADEVICE used --pattern twice
Pull Request resolved: https://github.com/pytorch/pytorch/pull/166202
Approved by: https://github.com/Skylion007
2025-10-25 14:57:19 +00:00
Catherine Lee
32ac38f85d
[lint] workflow consistency linter to look at all files instead of just changed files ( #165171 )
...
As in title
If you change only one workflow file, lintrunner (default arg, also the one in CI since it only inputs changed files) won't look at other files in the repo, but the sync-tag might come from those other files
This makes it so that it looks at all workflow files so it will catch those failures
Also change output line so it prints which file + which job it is different from
Pros:
catches errors
Cons:
unusual behavior (getting around what lintrunner says the linter should run on)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165171
Approved by: https://github.com/malfet , https://github.com/izaitsevfb , https://github.com/atalman
2025-10-24 21:43:18 +00:00
PyTorch MergeBot
05b2e02cb4
Revert "[lint] workflow consistency linter to look at all files instead of just changed files ( #165171 )"
...
This reverts commit c746feb86a .
Reverted https://github.com/pytorch/pytorch/pull/165171 on behalf of https://github.com/clee2000 due to broke lint [GH job link](https://github.com/pytorch/pytorch/actions/runs/18723760085/job/53402955955 ) [HUD commit link](c746feb86a ) ([comment](https://github.com/pytorch/pytorch/pull/165171#issuecomment-3433501457 ))
2025-10-22 17:47:29 +00:00
Catherine Lee
c746feb86a
[lint] workflow consistency linter to look at all files instead of just changed files ( #165171 )
...
As in title
If you change only one workflow file, lintrunner (default arg, also the one in CI since it only inputs changed files) won't look at other files in the repo, but the sync-tag might come from those other files
This makes it so that it looks at all workflow files so it will catch those failures
Pros:
catches errors
Cons:
unusual behavior (getting around what lintrunner says the linter should run on)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165171
Approved by: https://github.com/malfet
2025-10-22 16:57:59 +00:00
Yuanyuan Chen
3255e7872b
Enable all flake8-logging-format rules ( #164655 )
...
These rules are enabled by removing existing suppressions.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/164655
Approved by: https://github.com/janeyx99 , https://github.com/mlazos
2025-10-19 00:59:28 +00:00
Maggie Moss
f02e3947f6
Expand type checking to mypy strict files ( #165697 )
...
Expands Pyrefly type checking to check the files outlined in the mypy-strict.ini configuration file:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165697
Approved by: https://github.com/ezyang
2025-10-18 04:34:45 +00:00
Yuanyuan Chen
b2953f5643
[9/N] Apply ruff UP035 rule ( #165515 )
...
This is follow-up of #165214 to continue applying ruff UP035 rule to the code base.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165515
Approved by: https://github.com/Lucaskabela
2025-10-17 00:09:51 +00:00
Maggie Moss
d795fb225a
[RFC] Add pyrefly to lintrunner ( #165179 )
...
This will add pyrefly to lint runner as a warning only - and allow us to collect feedback about the tool before switching to pyrefly as the main type checker.
References the steps outlined here: : https://github.com/pytorch/pytorch/issues/163283 :
test plan:
`lintrunner init`
`lintrunner`
confirm when pyrefly errors are present results look like: https://gist.github.com/maggiemoss/e6cb2d015dd1ded560ae1329098cf33f
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165179
Approved by: https://github.com/ezyang
2025-10-16 20:07:09 +00:00
can-gaa-hou
af42256db4
Fix missing brackets ( #165138 )
...
As stated in the title.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/165138
Approved by: https://github.com/Aidyn-A , https://github.com/Skylion007
2025-10-10 17:23:31 +00:00
can-gaa-hou
ad32ed83b3
[Fix] Adding missing f prefixes to formatted strings [3/N] ( #164067 )
...
As stated in the title.
* #164068
* __->__ #164067
* #164066
* #164065
Pull Request resolved: https://github.com/pytorch/pytorch/pull/164067
Approved by: https://github.com/Skylion007
2025-09-29 04:35:23 +00:00
Eli Uriegas
8a0e8cad5f
lint: Only include files in pytorch ( #164008 )
...
We were seeing instances of stdlib files in clang-tidy output so this
just essentially removes them from the things that lintrunner will
report up. Longer term fix here would be to just modify the clang-tidy
configuration in order to do the correct thing here but that requires a
bit more investigation as to why this is only happening in CI and is not
reproduceable locally.
Signed-off-by: Eli Uriegas <eliuriegas@meta.com>
Pull Request resolved: https://github.com/pytorch/pytorch/pull/164008
Approved by: https://github.com/ZainRizvi
2025-09-27 00:54:07 +00:00
FFFrog
6f34cc040f
[Code Clean] Remove deadcodes about Python3.9 [5/N] ( #163644 )
...
As the title stated.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/163644
Approved by: https://github.com/jansel
ghstack dependencies: #163626 , #163627 , #163629 , #163643
2025-09-24 07:30:50 +00:00
Nikita Shulga
f9fa138a39
[BE] Delete all pre py-3.10 checks ( #163653 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/163653
Approved by: https://github.com/jansel
ghstack dependencies: #163648 , #163649
2025-09-23 23:22:53 +00:00
Aaryaman Vasishta
0826aafa04
[ROCm/Windows] Support aotriton for scaled_dot_product_attention on Windows. ( #162330 )
...
Enables flash attention and/or memory efficient attention on Windows with scaled_dot_product_attention via. aotriton.
Already tested to be working on Windows with TheRock.
Steps to enable: simply set `USE_FLASH_ATTENTION=1` and `USE_MEM_EFF_ATTENTION=1` as usual. See https://github.com/ROCm/TheRock/blob/main/external-builds/pytorch/build_prod_wheels.py#L578-L604
Pull Request resolved: https://github.com/pytorch/pytorch/pull/162330
Approved by: https://github.com/jeffdaily
Co-authored-by: Scott Todd <scott.todd0@gmail.com>
2025-09-15 16:13:03 +00:00
PyTorch MergeBot
5b9114bf19
Revert "[ROCm/Windows] Support aotriton for scaled_dot_product_attention on Windows. ( #162330 )"
...
This reverts commit 62843c14bb .
Reverted https://github.com/pytorch/pytorch/pull/162330 on behalf of https://github.com/atalman due to Sorry reverting looks like broke windows nightlies see https://github.com/pytorch/pytorch/issues/162881 ([comment](https://github.com/pytorch/pytorch/pull/162330#issuecomment-3288544921 ))
2025-09-13 15:43:50 +00:00
Nikita Shulga
84d8ec73f1
[CD] Build Mac wheels using setup-python action ( #162136 )
...
Biggest difference between both conda and homebrew CPython builds and one from python.org, is that later are universal binaries and they are always trying to build universal extension...
Workaround lots of universal binary build attempts by explicitly specifying both `_PYTHON_PLATFORM` and `--plat-name` as well as `ARCH_FLAGS`
Suppressed actionlint warning on use of `freethreaded` flag which is document in https://github.com/actions/setup-python/tree/v5
TODO: Remove lots of temporary workarounds when `3.14` is out in October 2025
Pull Request resolved: https://github.com/pytorch/pytorch/pull/162136
Approved by: https://github.com/atalman , https://github.com/huydhn
ghstack dependencies: #162297 , #162265
2025-09-12 00:16:31 +00:00
Aaryaman Vasishta
62843c14bb
[ROCm/Windows] Support aotriton for scaled_dot_product_attention on Windows. ( #162330 )
...
Enables flash attention and/or memory efficient attention on Windows with scaled_dot_product_attention via. aotriton.
Already tested to be working on Windows with TheRock.
Steps to enable: simply set `USE_FLASH_ATTENTION=1` and `USE_MEM_EFF_ATTENTION=1` as usual. See https://github.com/ROCm/TheRock/blob/main/external-builds/pytorch/build_prod_wheels.py#L578-L604
Pull Request resolved: https://github.com/pytorch/pytorch/pull/162330
Approved by: https://github.com/xinyazhang , https://github.com/ScottTodd , https://github.com/jeffdaily
Co-authored-by: Scott Todd <scott.todd0@gmail.com>
2025-09-11 22:35:09 +00:00
Tom Ritchford
83283ce7f5
docstring_linter: Fix #151692 and other issues ( #156596 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156596
Approved by: https://github.com/eellison
2025-08-25 16:04:14 +00:00
xinan.lin
8047421fbb
[Linter] Expanding the scope of detecting device-bias code. ( #159949 )
...
Currently, the device-bias linter only targets functions decorated with @requires_gpu. This PR adds support for two new detection scenarios:
1. Detect device-bias code in functions decorated with @requires_triton.
2. Detect device-bias code for entire test suites that are defined as shared across GPUs. For example:
```
if __name__ == "__main__":
if HAS_GPU:
run_tests()
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/159949
Approved by: https://github.com/EikanWang , https://github.com/jansel
2025-08-09 09:41:16 +00:00
Xuehai Pan
178515d0ff
[BE][PYFMT] remove black: finish black -> ruff format migration ( #144557 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144557
Approved by: https://github.com/ezyang
2025-08-08 07:46:10 +00:00
xinan.lin
2ea40fba84
[Linter] Improve device-bias linter by adding detection for with torch.device("cuda"). ( #159926 )
...
```
For example, detect the following situation:
>>>Lint for test/dynamo/test_modes.py:
Error (TEST_DEVICE_BIAS) [device-bias]
`@requires_gpu` function should not hardcode `with torch.device('cuda')`,
suggest to use torch.device(GPU_TYPE)
687 | flex_attention as flex_attention_eager,
688 | )
689 |
>>> 690 | with torch.device("cuda"):
691 | flex_attention = torch.compile(flex_attention_eager, dynamic=False)
692 |
693 | with self.assertRaisesRegex(
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/159926
Approved by: https://github.com/EikanWang , https://github.com/jansel
ghstack dependencies: #159759
2025-08-08 03:20:42 +00:00
Xuehai Pan
5cedc5a0ff
[BE][PYFMT] migrate PYFMT for torch/[p-z]*/ to ruff format ( #144552 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144552
Approved by: https://github.com/ezyang
2025-08-07 00:09:56 +00:00
Tom Ritchford
78b9dea754
[inductor] Fix set_linter's handling of f-strings for Python 3.12 and up ( fix #159056 ) ( #159252 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/159252
Approved by: https://github.com/Skylion007
2025-07-31 12:56:09 +00:00
drisspg
e221a1c853
[Code Motion]Restructure flex attention kernel into flex subdirectory ( #159437 )
...
Mostly code motion, updating relative paths, moving some imports that had to be lazy before to top level scope now that we are free from the curse.
This will make it easier to add newer templates and provide some organization
Pull Request resolved: https://github.com/pytorch/pytorch/pull/159437
Approved by: https://github.com/Chillee , https://github.com/BoyuanFeng , https://github.com/eellison , https://github.com/Skylion007
2025-07-30 20:12:35 +00:00
Xuehai Pan
775788f93b
[BE][PYFMT] migrate PYFMT for test/[i-z]*/ to ruff format ( #144556 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144556
Approved by: https://github.com/ezyang
2025-07-29 03:26:09 +00:00
Sidharth
4d5d56a30e
[dynamo] lintrunner for gb_registry adds/updates ( #158460 )
...
This PR adds automation to adding/updating the JSON registry through the lintrunner.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/158460
Approved by: https://github.com/williamwen42
2025-07-23 21:02:54 +00:00
albanD
d3f9107d68
Remove top limit for cpython version and fix lint appropriately. ( #158853 )
...
As per title.
Sorry for the churn in the main commit.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/158853
Approved by: https://github.com/seemethere , https://github.com/Skylion007 , https://github.com/jingsh , https://github.com/malfet , https://github.com/ZainRizvi
2025-07-22 23:59:00 +00:00
Xuehai Pan
637e75433c
[BE] always use uv pip if possible in pip_init.py for lintrunner init ( #157199 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157199
Approved by: https://github.com/ezyang , https://github.com/ZainRizvi
2025-07-21 17:56:05 +00:00
Xuehai Pan
d5af0eca8d
[BE][3/5] fix typos in aten/ (aten/src/ATen/native/) ( #157552 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157552
Approved by: https://github.com/albanD
ghstack dependencies: #156605 , #157637 , #157550 , #157551
2025-07-17 12:08:34 +00:00
Xuehai Pan
f57ef62ebc
[BE][2/5] fix typos in aten/ (aten/src/ATen/native/) ( #157551 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157551
Approved by: https://github.com/albanD
ghstack dependencies: #156605 , #157637 , #157550
2025-07-17 12:08:33 +00:00
Xuehai Pan
c8d43cbc6e
[BE][3/6] fix typos in test/ ( #157637 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157637
Approved by: https://github.com/yewentao256 , https://github.com/albanD
ghstack dependencies: #156605
2025-07-17 12:08:33 +00:00
Xuehai Pan
3f8e2e91ad
[BE][15/16] fix typos in torch/ (torch/distributed/tensor/) ( #156605 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156605
Approved by: https://github.com/wanchaol , https://github.com/albanD
2025-07-17 12:08:33 +00:00
Xuehai Pan
7f14b42adf
[BE][2/16] fix typos in torch/ (torch/_*/) ( #156312 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156312
Approved by: https://github.com/albanD
2025-07-12 05:47:06 +00:00
PyTorch MergeBot
cb711c8fa0
Revert "[BE] always use uv pip if possible in pip_init.py for lintrunner init ( #157199 )"
...
This reverts commit 754699610b .
Reverted https://github.com/pytorch/pytorch/pull/157199 on behalf of https://github.com/malfet due to It breaks lintrunner init` for default environments, see https://github.com/pytorch/pytorch/issues/152999 ([comment](https://github.com/pytorch/pytorch/pull/157199#issuecomment-3053279711 ))
2025-07-09 16:26:47 +00:00
Xuehai Pan
4cc8b60d1b
[BE][1/16] fix typos in torch/ ( #156311 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156311
Approved by: https://github.com/albanD
2025-07-09 11:02:22 +00:00
Xuehai Pan
924fc52e18
[BE] add a linter to check consistency for cmake minimum version in requirements ( #156961 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156961
Approved by: https://github.com/ezyang , https://github.com/malfet
2025-07-09 10:44:17 +00:00
Xuehai Pan
84b77ec128
[BE] add a minimal linter to check pyproject.toml consistency ( #156017 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156017
Approved by: https://github.com/ezyang
2025-07-08 08:17:36 +00:00
Xuehai Pan
3fd84a8592
[BE][PYFMT] migrate PYFMT for torch/[a-c]*/ to ruff format ( #144554 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144554
Approved by: https://github.com/soulitzer
2025-07-03 18:56:07 +00:00
Xuehai Pan
11c07c848c
[BE][14/16] fix typos in torch/ (torch/fx/) ( #156604 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156604
Approved by: https://github.com/jingsh
ghstack dependencies: #156318 , #156320 , #156602
2025-07-02 22:55:29 +00:00
Xuehai Pan
db259bd6b8
[BE][12/16] fix typos in torch/ ( #156602 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156602
Approved by: https://github.com/justinchuby , https://github.com/albanD
ghstack dependencies: #156318 , #156320
2025-07-02 22:55:29 +00:00
Xuehai Pan
d5cdc36943
[BE][10/16] fix typos in torch/ (torch/csrc/jit/) ( #156320 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156320
Approved by: https://github.com/albanD
ghstack dependencies: #156318
2025-07-02 22:55:29 +00:00
Xuehai Pan
541584d22e
[BE][8/16] fix typos in torch/ (torch/csrc/jit/) ( #156318 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156318
Approved by: https://github.com/albanD
2025-07-02 22:55:29 +00:00
Xuehai Pan
754699610b
[BE] always use uv pip if possible in pip_init.py for lintrunner init ( #157199 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/157199
Approved by: https://github.com/ezyang
2025-07-01 06:07:29 +00:00
Xuehai Pan
f8293116f5
[BE][13/16] fix typos in torch/ (torch/ao/) ( #156603 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156603
Approved by: https://github.com/msaroufim
2025-06-29 04:34:04 +00:00
Xuehai Pan
162ca185ff
[BE][PYFMT] migrate PYFMT for torch/_[a-h]*/ to ruff format ( #144551 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144551
Approved by: https://github.com/ezyang
ghstack dependencies: #148186
2025-06-25 06:16:06 +00:00
Xuehai Pan
f5e6e52f25
[BE][PYFMT] migrate PYFMT for test/inductor/ to ruff format ( #148186 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/148186
Approved by: https://github.com/jansel
2025-06-24 11:12:11 +00:00
Xuehai Pan
6d5c789ad5
[BE][PYFMT] migrate PYFMT for test/[a-h]*/ to ruff format ( #144555 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/144555
Approved by: https://github.com/ezyang
ghstack dependencies: #144551 , #144554
2025-06-24 04:53:54 +00:00
Tom Ritchford
98a34e8d4b
Move code out of individual token linters ( #152256 )
...
Pull Request resolved: https://github.com/pytorch/pytorch/pull/152256
Approved by: https://github.com/Skylion007
2025-06-23 18:16:33 +00:00