Repository navigation
[pyrefly] Add type annotations to torch/fx/passes - #179731
Lucaskabela wants to merge 2 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/179731
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ You can merge normally! (2 Unrelated Failures)As of commit bfd4c4b with merge base c5acdfb ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following job failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
BC suppression because |
b06f865 to
f22383a
Compare
aorenste
left a comment
There was a problem hiding this comment.
There are a few minor behavior changes mixed in (RuntimeError in split_utils.py, bool return in _needs_inductor_compile in regional_inductor.py). Should we split those into a separate PR for easier landing/tracking?
aorenste
left a comment
There was a problem hiding this comment.
There are a LOT of Anys here. Maybe do a pass with Claude to have it guess at some of those types?
I had the same thought and already gave it a pass with claude - let me try again but with a bit more manual oversight |
| # If input is a get_attr node, copy it to current component's graph. | ||
| # Returns the get_attr node in current component's graph. | ||
| if x.op == "get_attr": | ||
| if not isinstance(x.target, str): |
There was a problem hiding this comment.
cc @aorenste this is not truly a change - this is to make pyrefly happy as opposed to asserts doing type narrowing.
This is the new preferred way to do this as Alban has landed a series of PRs enabling S101 (no asserts in code)
There was a problem hiding this comment.
We can remove this and just throw a pyrefly suppression if you are concerned about the correctness here though
There was a problem hiding this comment.
Yeah - I dislike S101 enforcement. Sometimes assertions are actually useful as a concept of something that disappears w/ optimization turned on.
This is a behavior change - but a reasonable change.
| def _needs_inductor_compile(node: torch.fx.Node): | ||
| return ( | ||
| def _needs_inductor_compile(node: torch.fx.Node) -> bool: | ||
| return bool( |
There was a problem hiding this comment.
This is also a "make pyrefly happy" change - just explicitly narrowing and returning bool as opposed to implicit (no behavior change)
There was a problem hiding this comment.
But it IS a behavior change - previously we sometimes returned None (which is "falsy" - but the type was a lie). But I'm okay with the change.
173cb54 to
fee6ec9
Compare
| const_mod_name, non_const_mod_name = "submod_0", "submod_1" | ||
| # Safely get submod_1 in case there are no non-const nodes | ||
| const_gm, non_const_gm = split.submod_0, getattr(split, non_const_mod_name, None) | ||
| const_gm = getattr(split, const_mod_name) |
There was a problem hiding this comment.
These are purely to support pyrefly - I can remove these and just silent the error if we are concerned about correctness (cc @aorenste )
fee6ec9 to
360b347
Compare
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
@pytorchmergebot merge |
e8f50ff to
8b22b5c
Compare
|
@pytorchmergebot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
This reverts commit 8c49f56. Reverted #180251 on behalf of https://github.com/jeanschmidt due to sorry, need to revert in order to revert #179731, feel free to resolve conflicts and merge into main after that ([comment](#180251 (comment)))
This reverts commit a55d045. Reverted #179731 on behalf of https://github.com/jeanschmidt due to Breaks internal static tests, see D100718848 ([comment](#179731 (comment)))
|
@pytorchmergebot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: pull / linux-jammy-py3.10-gcc11 / test (distributed, 3, 3, linux.2xlarge.amx) Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10-mi355 / test (default, 3, 6, linux.rocm.gpu.gfx950.1) Details for Dev Infra teamRaised by workflow job |
|
@pytorchmergebot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Remove mypy suppressions. Add return type, parameter type, and generic type annotations. Backward-compatible APIs use pyrefly ignore comments. Authored with Claude. Pull Request resolved: pytorch#179731 Approved by: https://github.com/aorenste
)" This reverts commit 8c49f56. Reverted pytorch#180251 on behalf of https://github.com/jeanschmidt due to sorry, need to revert in order to revert pytorch#179731, feel free to resolve conflicts and merge into main after that ([comment](pytorch#180251 (comment)))
…9731)" This reverts commit a55d045. Reverted pytorch#179731 on behalf of https://github.com/jeanschmidt due to Breaks internal static tests, see D100718848 ([comment](pytorch#179731 (comment)))
Remove mypy suppressions. Add return type, parameter type, and generic type annotations. Backward-compatible APIs use pyrefly ignore comments. Authored with Claude. Pull Request resolved: pytorch#179731 Approved by: https://github.com/aorenste
Remove mypy suppressions. Add return type, parameter type, and generic type annotations. Backward-compatible APIs use pyrefly ignore comments. Authored with Claude. Pull Request resolved: pytorch#179731 Approved by: https://github.com/aorenste
)" This reverts commit 8c49f56. Reverted pytorch#180251 on behalf of https://github.com/jeanschmidt due to sorry, need to revert in order to revert pytorch#179731, feel free to resolve conflicts and merge into main after that ([comment](pytorch#180251 (comment)))
…9731)" This reverts commit a55d045. Reverted pytorch#179731 on behalf of https://github.com/jeanschmidt due to Breaks internal static tests, see D100718848 ([comment](pytorch#179731 (comment)))
Remove mypy suppressions. Add return type, parameter type, and generic type annotations. Backward-compatible APIs use pyrefly ignore comments. Authored with Claude. Pull Request resolved: pytorch#179731 Approved by: https://github.com/aorenste
Remove mypy suppressions. Add return type, parameter type, and generic type annotations. Backward-compatible APIs use pyrefly ignore comments.
Authored with Claude.