Skip to content

Use Python 3.11 across lint tooling and drop the ruff py310 pin - #203051

Closed
atalman wants to merge 4 commits into
pytorch:mainfrom
atalman:ruff_py311_target
Closed

atalman wants to merge 4 commits into
pytorch:mainfrom
atalman:ruff_py311_target

Conversation

@atalman

@atalman atalman commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Go through the following checklist

  • Passes lint (checked ruff and the PYFMT adapter directly, not through lintrunner)
  • Added/updated tests
  • Updated documentation (if applicable)
  • Included benchmark results (for PRs impacting perf)

Linked issue or supporting maintainer

Follow-up to #202271 / #202273, which raised requires-python to >=3.11 and (via #202303 on release/2.15) pinned ruff to 3.10 until this cleanup.

BC-breaking?

No. Lint configuration and Python 3.11-only syntax/imports only. Behaviour is unchanged: the rewritten sys.version_info >= (3, 11) branches were already the live ones.

Summary (human written only)

Removes target-version = "py310" from [tool.ruff] so ruff takes its target from requires-python (3.11) again, and applies the findings that turns on.

Agent details (if applicable)

Drafted with Claude Code; diff reviewed by hand. The commit message follows.

Without the pin, ruff check . (ruff 0.14.4, the version lintrunner pins) goes from 941 to 1115 findings: 174 new, in 143 files, from five rules.

Rule Count What Fix
UP035 103 typing_extensions imports that are in typing / collections.abc on 3.11 safe
UP044 30 Unpack[...] unsafe
UP017 20 timezone.utc -> UTC safe
UP036 19 obsolete sys.version_info checks unsafe
UP041 2 aliased errors safe

Changes:

  • Delete the pin.
  • ruff check --fix --unsafe-fixes for those five rules. I read the UP036 rewrites (e.g. torch/_inductor/await_utils.py, the bisect_left paths in torch/fx/proxy.py and symbolic_shapes.py); each keeps the 3.11 branch.
  • Clean up what the fixes leave behind (27 unused imports and similar, all safe fixes), then usort + ruff format on the 94 files where moving imports changed their order. One import tomllib in test/spincli/test_spin.py was left out of order and is moved by hand.
  • Python 3.11 across the lint tooling, instead of carving out the adapters. lintrunner runs 15 adapters with uv run --python 3.10, where the autofix's import tomllib and typing.Self would not exist. Rather than pin them to a 3.10 ruff target, the second commit moves those 15 --python 3.10 entries in .lintrunner.toml and their requires-python script headers to 3.11, drops the tomli ; python_version < '3.11' dependency markers, and applies the same fixes to tools/linter/adapters/**. mypy-strict.ini moves from python_version = 3.10 to 3.11 too.

Not changed: pyrefly.toml (python-version = "3.12"), and the B905 entry in [tool.ruff.lint] ignore, whose comment says "TODO: Remove Python-3.10 specific suppressions". I did not check what removing it would change; it is a separate cleanup.

This touches 161 files (+294/-427) across torch/, torchgen/, test/, .github/scripts and tools, so it will conflict with in-flight PRs; the sooner it lands the fewer rebases.

Testing

With ruff==0.14.4 and the repo config, on the tree at this PR's base:

  • Before the change (pin in place): 941 findings.
  • With the pin removed and no fixes: 1115 findings (174 new).
  • This PR: 939 findings, none beyond the 941 baseline.
  • pyfmt_linter.py (usort + ruff format) on the changed .py files introduces nothing new; it flags only torch/utils/checkpoint.py, which it also flags without this change.
  • Smoke-tested under uv run --python 3.11 --script: pyfmt_linter, pyproject_linter and cmake_minimum_required_linter (clean on pyproject.toml), and license_files_linter starts. The other moved adapters were not run individually.
  • All 139 changed .py/.pyi files parse on CPython 3.11.

Not run: lintrunner end to end, mypy --config-file mypy-strict.ini on 3.11 (used by test/test_type_hints.py), and the test suites. CI is the verification for those.

Authored with an AI assistant; the diff was reviewed by hand.

🤖 Generated with Claude Code

cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @aditew01 @voznesenskym @penguinwu @EikanWang @Guobing-Chen @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo @azahed98

@pytorch-bot

pytorch-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

⚪ AUTOMATED REVIEW - Skipped, PR too large to review:

This PR is over the automated review's size limit, so it was not reviewed.

Reviewed commit: 73ab073

Review run

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/203051

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 25 Pending

As of commit 73ab073 with merge base 4fb332d (image):
💚 Looks good so far! There are no failures yet. 💚

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Scope
    • The diff exceeds the size cap the automated reviewer can read in full
    • The size gate declined it before any review ran, so nothing in it was examined
    • A human reviewer should assess this change

reason: scope_too_large
Reviewed commit: 40621a5 (NOT the current head 73ab073)

Inference job

🐛 Report a wrong verdict

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@atalman atalman changed the title Stop pinning ruff to Python 3.10 now that requires-python is >=3.11 Use Python 3.11 across lint tooling and drop the ruff py310 pin Nov 2, 2026
@atalman
atalman marked this pull request as ready for review November 2, 2026 19:29
Drop `target-version = "py310"` so ruff takes its target from
requires-python again, and apply the pyupgrade findings that turns on:
UP035 (typing_extensions imports now in typing), UP044 (Unpack),
UP017 (timezone.utc -> UTC), UP036 (dead sys.version_info checks) and
UP041. Imports are re-sorted and reformatted where the fixes moved them.

tools/linter/adapters/** keeps a per-file py310 target: lintrunner runs
those adapters with `uv run --python 3.10`, where `tomllib` and
`typing.Self` do not exist.

Co-authored-by: Claude Code
Drop the per-file py310 ruff target for tools/linter/adapters/** and move
what it protected to 3.11 instead: the 15 `uv run --python 3.10` entries in
.lintrunner.toml and their `requires-python` script headers, plus
`python_version` in mypy-strict.ini. With that, the adapters use `tomllib`
and `typing.Self` directly, and the `tomli ; python_version < '3.11'`
dependency markers go away.

Co-authored-by: Claude Code
`spin lint` rejected the 3.11 `uv run --script` linters with "must specify
`--python 3.10`" before running any linter, which is why the lintrunner jobs
failed without producing lint.json. Check for 3.11, and run lintrunner itself
under 3.11.

Co-authored-by: Claude Code
Removing the dead `sys.version_info >= (3, 11)` branches lost the
`# pyrefly: ignore [bad-argument-type]` above `asyncio.Task(...)`, narrowed
the `task_factory(...)` ignore to `arg-type`, and moved the dead Callable
alias's `valid-type` ignore onto `TaskFactoryType = TaskFactory`. Restore
the comments the 3.11 branch had.

Co-authored-by: Claude Code
@meta-codesync

meta-codesync Bot commented Nov 3, 2026

Copy link
Copy Markdown

@atalman has imported this pull request. If you are a Meta employee, you can view this in D129356013.

@atalman

atalman commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "lint is passing the signal was green already on this PR"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Nov 3, 2026
… 300 (#203217)

Raise `MAX_CHANGED_FILES` in `hardened-pr-review-run.yml` from 100 to 300.

PRs that touch many files with small per-file edits (lint autofixes, renames, version-pin bumps) were being recorded as `skipped_too_large` even though their diffs are small. For example, #203051 changes 161 files with a 106 KB diff.

- `MAX_DIFF_BYTES` is unchanged at 400000, so a large diff is still skipped whatever its file count, and the context/cost bound on a single review is the same as before.
- `MAX_CHANGED_FILES` is one workflow-level env read by both `prepare` and `review`, so the early gate and the real-diff gate move together.
- No test pins the number: `scripts/pr_review/test_workflow_contract.py` only requires a single numeric workflow-level value (its `"100"` at line 831 is a stub input to a unit test).

Tested: `python3 -m unittest scripts.pr_review.test_workflow_contract` — 183 tests, OK.

Created with Claude

Pull Request resolved: #203217
Approved by: https://github.com/huydhn
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
pytorchmergebot pushed a commit that referenced this pull request Nov 5, 2026
…ew (#203136)

✴️ iz2: When a PR is over the automated review's size gate (300 changed files or 400 KB of diff), the review only wrote an S3 telemetry row and Dr.CI showed a collapsed "Skipped, PR too large" line with no next step. Authors read that as the review being broken (#203051: 162 files, skipped under the earlier 100-file cap that #203217 raised to 300).

The skip now posts a COMMENT review that says the PR is over the limit, suggests splitting it, and gives the opt-out command (`@pytorchbot label "no automated review"`). The bot never applies the label itself; that stays the author's call.

- File-count path (decided in `prepare`): `announce` posts the notice with a new `post_review.py --too-large` mode. It already has the right token: `pull-requests: write`, no AWS, no environment, no PR code.
- Diff-bytes path (decided in `review`): `publish` posts the same notice from the `skipped_too_large` row.
- The notice hides earlier automated reviews like any new review. It dismisses no standing change request, since the large PR was not evaluated; after an opt-out that request stays until a maintainer dismisses it. It is not reposted while the newest visible review is the same notice; one marked in progress gets its body back. `fetch_pr_comments.py` never treats a notice as the latest verdict, so re-review interdiffs (#202667) also start from the last verdict's commit.
- The command sits mid-line in a code span. pytorch-bot only runs commands that start a line (`cliParser.ts`), and the label text is validated, so the notice cannot trigger the bot.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes (654 tests). New tests cover the notice body and its bot-command safety, dedupe (including marked and defused notices), head move, opt-out, change-request handling, the interdiff base, and the workflow wiring.

Known limit: if a smaller commit's review fails, the old notice is put back with the command defused until the next too-large run replaces it. Dr.CI shows that run's failure.
Pull Request resolved: #203136
Approved by: https://github.com/huydhn
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…rch#203051)

Go through the following checklist
- [x] Passes lint (checked `ruff` and the PYFMT adapter directly, not through `lintrunner`)
- [ ] Added/updated tests
- [ ] Updated documentation (if applicable)
- [ ] Included benchmark results (for PRs impacting perf)

---

## Linked issue or supporting maintainer

Follow-up to pytorch#202271 / pytorch#202273, which raised `requires-python` to `>=3.11` and (via pytorch#202303 on `release/2.15`) pinned ruff to 3.10 until this cleanup.

## BC-breaking?

No. Lint configuration and Python 3.11-only syntax/imports only. Behaviour is unchanged: the rewritten `sys.version_info >= (3, 11)` branches were already the live ones.

## Summary (human written only)

Removes `target-version = "py310"` from `[tool.ruff]` so ruff takes its target from `requires-python` (3.11) again, and applies the findings that turns on.

## Agent details (if applicable)

Drafted with Claude Code; diff reviewed by hand. The commit message follows.

Without the pin, `ruff check .` (ruff 0.14.4, the version lintrunner pins) goes from 941 to 1115 findings: 174 new, in 143 files, from five rules.

| Rule | Count | What | Fix |
|---|---|---|---|
| UP035 | 103 | `typing_extensions` imports that are in `typing` / `collections.abc` on 3.11 | safe |
| UP044 | 30 | `Unpack[...]` | unsafe |
| UP017 | 20 | `timezone.utc` -> `UTC` | safe |
| UP036 | 19 | obsolete `sys.version_info` checks | unsafe |
| UP041 | 2 | aliased errors | safe |

Changes:

- Delete the pin.
- `ruff check --fix --unsafe-fixes` for those five rules. I read the UP036 rewrites (e.g. `torch/_inductor/await_utils.py`, the `bisect_left` paths in `torch/fx/proxy.py` and `symbolic_shapes.py`); each keeps the 3.11 branch.
- Clean up what the fixes leave behind (27 unused imports and similar, all safe fixes), then `usort` + `ruff format` on the 94 files where moving imports changed their order. One `import tomllib` in `test/spincli/test_spin.py` was left out of order and is moved by hand.
- Python 3.11 across the lint tooling, instead of carving out the adapters. lintrunner runs 15 adapters with `uv run --python 3.10`, where the autofix's `import tomllib` and `typing.Self` would not exist. Rather than pin them to a 3.10 ruff target, the second commit moves those 15 `--python 3.10` entries in `.lintrunner.toml` and their `requires-python` script headers to 3.11, drops the `tomli ; python_version < '3.11'` dependency markers, and applies the same fixes to `tools/linter/adapters/**`. `mypy-strict.ini` moves from `python_version = 3.10` to 3.11 too.

Not changed: `pyrefly.toml` (`python-version = "3.12"`), and the `B905` entry in `[tool.ruff.lint] ignore`, whose comment says "TODO: Remove Python-3.10 specific suppressions". I did not check what removing it would change; it is a separate cleanup.

This touches 161 files (+294/-427) across `torch/`, `torchgen/`, `test/`, `.github/scripts` and `tools`, so it will conflict with in-flight PRs; the sooner it lands the fewer rebases.

## Testing

With `ruff==0.14.4` and the repo config, on the tree at this PR's base:

- Before the change (pin in place): 941 findings.
- With the pin removed and no fixes: 1115 findings (174 new).
- This PR: 939 findings, none beyond the 941 baseline.
- `pyfmt_linter.py` (usort + ruff format) on the changed `.py` files introduces nothing new; it flags only `torch/utils/checkpoint.py`, which it also flags without this change.
- Smoke-tested under `uv run --python 3.11 --script`: `pyfmt_linter`, `pyproject_linter` and `cmake_minimum_required_linter` (clean on `pyproject.toml`), and `license_files_linter` starts. The other moved adapters were not run individually.
- All 139 changed `.py`/`.pyi` files parse on CPython 3.11.

Not run: `lintrunner` end to end, `mypy --config-file mypy-strict.ini` on 3.11 (used by `test/test_type_hints.py`), and the test suites. CI is the verification for those.

Authored with an AI assistant; the diff was reviewed by hand.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull Request resolved: pytorch#203051
Approved by: https://github.com/williamwen42, https://github.com/justinchuby, https://github.com/d4l3k
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
… 300 (pytorch#203217)

Raise `MAX_CHANGED_FILES` in `hardened-pr-review-run.yml` from 100 to 300.

PRs that touch many files with small per-file edits (lint autofixes, renames, version-pin bumps) were being recorded as `skipped_too_large` even though their diffs are small. For example, pytorch#203051 changes 161 files with a 106 KB diff.

- `MAX_DIFF_BYTES` is unchanged at 400000, so a large diff is still skipped whatever its file count, and the context/cost bound on a single review is the same as before.
- `MAX_CHANGED_FILES` is one workflow-level env read by both `prepare` and `review`, so the early gate and the real-diff gate move together.
- No test pins the number: `scripts/pr_review/test_workflow_contract.py` only requires a single numeric workflow-level value (its `"100"` at line 831 is a stub input to a unit test).

Tested: `python3 -m unittest scripts.pr_review.test_workflow_contract` — 183 tests, OK.

Created with Claude

Pull Request resolved: pytorch#203217
Approved by: https://github.com/huydhn
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…ew (pytorch#203136)

✴️ iz2: When a PR is over the automated review's size gate (300 changed files or 400 KB of diff), the review only wrote an S3 telemetry row and Dr.CI showed a collapsed "Skipped, PR too large" line with no next step. Authors read that as the review being broken (pytorch#203051: 162 files, skipped under the earlier 100-file cap that pytorch#203217 raised to 300).

The skip now posts a COMMENT review that says the PR is over the limit, suggests splitting it, and gives the opt-out command (`@pytorchbot label "no automated review"`). The bot never applies the label itself; that stays the author's call.

- File-count path (decided in `prepare`): `announce` posts the notice with a new `post_review.py --too-large` mode. It already has the right token: `pull-requests: write`, no AWS, no environment, no PR code.
- Diff-bytes path (decided in `review`): `publish` posts the same notice from the `skipped_too_large` row.
- The notice hides earlier automated reviews like any new review. It dismisses no standing change request, since the large PR was not evaluated; after an opt-out that request stays until a maintainer dismisses it. It is not reposted while the newest visible review is the same notice; one marked in progress gets its body back. `fetch_pr_comments.py` never treats a notice as the latest verdict, so re-review interdiffs (pytorch#202667) also start from the last verdict's commit.
- The command sits mid-line in a code span. pytorch-bot only runs commands that start a line (`cliParser.ts`), and the label text is validated, so the notice cannot trigger the bot.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes (654 tests). New tests cover the notice body and its bot-command safety, dedupe (including marked and defused notices), head move, opt-out, change-request handling, the interdiff base, and the workflow wiring.

Known limit: if a smaller commit's review fails, the old notice is put back with the command defused until the next too-large run replaces it. Dr.CI shows that run's failure.
Pull Request resolved: pytorch#203136
Approved by: https://github.com/huydhn
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…rch#203051)

Go through the following checklist
- [x] Passes lint (checked `ruff` and the PYFMT adapter directly, not through `lintrunner`)
- [ ] Added/updated tests
- [ ] Updated documentation (if applicable)
- [ ] Included benchmark results (for PRs impacting perf)

---

## Linked issue or supporting maintainer

Follow-up to pytorch#202271 / pytorch#202273, which raised `requires-python` to `>=3.11` and (via pytorch#202303 on `release/2.15`) pinned ruff to 3.10 until this cleanup.

## BC-breaking?

No. Lint configuration and Python 3.11-only syntax/imports only. Behaviour is unchanged: the rewritten `sys.version_info >= (3, 11)` branches were already the live ones.

## Summary (human written only)

Removes `target-version = "py310"` from `[tool.ruff]` so ruff takes its target from `requires-python` (3.11) again, and applies the findings that turns on.

## Agent details (if applicable)

Drafted with Claude Code; diff reviewed by hand. The commit message follows.

Without the pin, `ruff check .` (ruff 0.14.4, the version lintrunner pins) goes from 941 to 1115 findings: 174 new, in 143 files, from five rules.

| Rule | Count | What | Fix |
|---|---|---|---|
| UP035 | 103 | `typing_extensions` imports that are in `typing` / `collections.abc` on 3.11 | safe |
| UP044 | 30 | `Unpack[...]` | unsafe |
| UP017 | 20 | `timezone.utc` -> `UTC` | safe |
| UP036 | 19 | obsolete `sys.version_info` checks | unsafe |
| UP041 | 2 | aliased errors | safe |

Changes:

- Delete the pin.
- `ruff check --fix --unsafe-fixes` for those five rules. I read the UP036 rewrites (e.g. `torch/_inductor/await_utils.py`, the `bisect_left` paths in `torch/fx/proxy.py` and `symbolic_shapes.py`); each keeps the 3.11 branch.
- Clean up what the fixes leave behind (27 unused imports and similar, all safe fixes), then `usort` + `ruff format` on the 94 files where moving imports changed their order. One `import tomllib` in `test/spincli/test_spin.py` was left out of order and is moved by hand.
- Python 3.11 across the lint tooling, instead of carving out the adapters. lintrunner runs 15 adapters with `uv run --python 3.10`, where the autofix's `import tomllib` and `typing.Self` would not exist. Rather than pin them to a 3.10 ruff target, the second commit moves those 15 `--python 3.10` entries in `.lintrunner.toml` and their `requires-python` script headers to 3.11, drops the `tomli ; python_version < '3.11'` dependency markers, and applies the same fixes to `tools/linter/adapters/**`. `mypy-strict.ini` moves from `python_version = 3.10` to 3.11 too.

Not changed: `pyrefly.toml` (`python-version = "3.12"`), and the `B905` entry in `[tool.ruff.lint] ignore`, whose comment says "TODO: Remove Python-3.10 specific suppressions". I did not check what removing it would change; it is a separate cleanup.

This touches 161 files (+294/-427) across `torch/`, `torchgen/`, `test/`, `.github/scripts` and `tools`, so it will conflict with in-flight PRs; the sooner it lands the fewer rebases.

## Testing

With `ruff==0.14.4` and the repo config, on the tree at this PR's base:

- Before the change (pin in place): 941 findings.
- With the pin removed and no fixes: 1115 findings (174 new).
- This PR: 939 findings, none beyond the 941 baseline.
- `pyfmt_linter.py` (usort + ruff format) on the changed `.py` files introduces nothing new; it flags only `torch/utils/checkpoint.py`, which it also flags without this change.
- Smoke-tested under `uv run --python 3.11 --script`: `pyfmt_linter`, `pyproject_linter` and `cmake_minimum_required_linter` (clean on `pyproject.toml`), and `license_files_linter` starts. The other moved adapters were not run individually.
- All 139 changed `.py`/`.pyi` files parse on CPython 3.11.

Not run: `lintrunner` end to end, `mypy --config-file mypy-strict.ini` on 3.11 (used by `test/test_type_hints.py`), and the test suites. CI is the verification for those.

Authored with an AI assistant; the diff was reviewed by hand.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull Request resolved: pytorch#203051
Approved by: https://github.com/williamwen42, https://github.com/justinchuby, https://github.com/d4l3k
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
… 300 (pytorch#203217)

Raise `MAX_CHANGED_FILES` in `hardened-pr-review-run.yml` from 100 to 300.

PRs that touch many files with small per-file edits (lint autofixes, renames, version-pin bumps) were being recorded as `skipped_too_large` even though their diffs are small. For example, pytorch#203051 changes 161 files with a 106 KB diff.

- `MAX_DIFF_BYTES` is unchanged at 400000, so a large diff is still skipped whatever its file count, and the context/cost bound on a single review is the same as before.
- `MAX_CHANGED_FILES` is one workflow-level env read by both `prepare` and `review`, so the early gate and the real-diff gate move together.
- No test pins the number: `scripts/pr_review/test_workflow_contract.py` only requires a single numeric workflow-level value (its `"100"` at line 831 is a stub input to a unit test).

Tested: `python3 -m unittest scripts.pr_review.test_workflow_contract` — 183 tests, OK.

Created with Claude

Pull Request resolved: pytorch#203217
Approved by: https://github.com/huydhn
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…ew (pytorch#203136)

✴️ iz2: When a PR is over the automated review's size gate (300 changed files or 400 KB of diff), the review only wrote an S3 telemetry row and Dr.CI showed a collapsed "Skipped, PR too large" line with no next step. Authors read that as the review being broken (pytorch#203051: 162 files, skipped under the earlier 100-file cap that pytorch#203217 raised to 300).

The skip now posts a COMMENT review that says the PR is over the limit, suggests splitting it, and gives the opt-out command (`@pytorchbot label "no automated review"`). The bot never applies the label itself; that stays the author's call.

- File-count path (decided in `prepare`): `announce` posts the notice with a new `post_review.py --too-large` mode. It already has the right token: `pull-requests: write`, no AWS, no environment, no PR code.
- Diff-bytes path (decided in `review`): `publish` posts the same notice from the `skipped_too_large` row.
- The notice hides earlier automated reviews like any new review. It dismisses no standing change request, since the large PR was not evaluated; after an opt-out that request stays until a maintainer dismisses it. It is not reposted while the newest visible review is the same notice; one marked in progress gets its body back. `fetch_pr_comments.py` never treats a notice as the latest verdict, so re-review interdiffs (pytorch#202667) also start from the last verdict's commit.
- The command sits mid-line in a code span. pytorch-bot only runs commands that start a line (`cliParser.ts`), and the label text is validated, so the notice cannot trigger the bot.

Test plan: `python3 -m unittest discover -s scripts/pr_review -t .` passes (654 tests). New tests cover the notice body and its bot-command safety, dedupe (including marked and defused notices), head move, opt-out, change-request handling, the interdiff base, and the workflow wiring.

Known limit: if a smaller commit's review fails, the old notice is put back with the command defused until the next too-large run replaces it. Dr.CI shows that run's failure.
Pull Request resolved: pytorch#203136
Approved by: https://github.com/huydhn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/docker ciflow/h100-symm-mem ciflow/inductor ciflow/torchtitan Run TorchTitan integration tests ciflow/trunk Trigger trunk jobs on your pull request GL/superseded GreenLight review is superseded by changes in progress PR is being worked on by the author, until the automated review accepts it Merged module: cpu CPU specific problem (e.g., perf, algorithm) module: dynamo module: inductor release notes: inductor (aoti) release notes: releng release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants