Repository navigation
[pyrefly] Add type annotations to torch/fx/experimental/migrate_gradu… - #180070
Lucaskabela wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/180070
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: ❌ 2 New Failures, 2 Unrelated FailuresAs of commit af20acf with merge base ce68080 ( NEW FAILURES - The following jobs have failed:
UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
820e6c1 to
796bf6c
Compare
|
@claude review this PR - be specific on Any usage |
|
Claude finished @Lucaskabela's task in 1m 56s —— View job Review of PR #180070
Overall: Good progress removing
|
1c730bf to
ec89ad8
Compare
|
@claude can you review this PR - focus on the BC related changes |
|
Claude finished @Lucaskabela's task in 4m 20s —— View job Review of PR #180070 — Focus on Backward Compatibility
Note: All classes in BC Issue 1 (Behavioral change):
|
| Change | Type | Risk |
|---|---|---|
Conj/Disj/Prod constructors copy input |
Behavioral | Low — all callers pass literals |
transform_index_select deepcopy moved |
Bug fix | Low — fixes UnboundLocalError |
New else branches in generate_binconstraint_t/d |
Bug fix | Low — fixes None return |
_DynType import in constraint.py |
Annotation-only | None |
TensorType.__args__ annotation |
Annotation-only | None |
TensorType removed from constraint allowlist |
API surface | Low — __all__ now controls this |
Sequence added to transformation allowlist |
API surface leak | Low — add __all__ to fix |
elif → else in transform_to_z3 |
Cleanup | None — conditions were exhaustive |
| Explicit raises in transform_var/dimension | Bug fix | Low — replaces None returns |
Overall, the BC risk of this PR is low. The changed module is experimental and explicitly marked as not backward compatible. The behavioral changes are all improvements (bug fixes or defensive copies). The main actionable suggestion is adding __all__ to constraint_transformation.py to prevent Sequence from leaking into the public API surface.
ec89ad8 to
f268226
Compare
|
@pytorchbot fix-lint |
|
Successfully applied lint patches in https://github.com/pytorch/pytorch/actions/runs/24369126278. Please pull locally before pushing more changes. |
…al_types Remove mypy suppressions. Add return type and parameter type annotations to constraint classes, generator, transformation, and z3 transform. Authored with Claude.
a4cba81 to
af20acf
Compare
| from torch.fx.tensor_type import _DynType, Dyn, TensorType | ||
|
|
||
|
|
||
| __all__ = [ |
There was a problem hiding this comment.
Why these changes to all?
test_correct_module_names test enforces a rule: for every module, either
- No all — then every non-_ name in the module is considered public, and each must have a module that matches the module it lives in. Imported names like Sequence, Graph, Any fail this check because their module points elsewhere (e.g., typing, torch.fx.graph).
- Has all — then only names in all are public, and only those are checked. Imported names not in all are ignored.
Before our changes, these modules had no all, so every imported name leaked as "public". The type annotation work added new imports (_DynType, Sequence) which made this worse.
Adding all with the module's own function names solves both directions: imported names no longer leak, and the module's own functions are properly declared as public.
| + [BinConstraintD(1, new_dim, op_leq) for new_dim in new_dims] | ||
| ) | ||
| return Conj(new_dim_constraints), counter | ||
| else: |
There was a problem hiding this comment.
BUG - without this, we would fall through and return None!
This is why type checking rules :)
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 2 checks: pull / linux-docs / build-docs-cpp-false, pull / linux-docs / build-docs-python-false Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
#180070) …al_types Remove mypy suppressions. Add return type and parameter type annotations to constraint classes, generator, transformation, and z3 transform. Authored with Claude. Pull Request resolved: #180070 Approved by: https://github.com/Skylion007
pytorch#180070) …al_types Remove mypy suppressions. Add return type and parameter type annotations to constraint classes, generator, transformation, and z3 transform. Authored with Claude. Pull Request resolved: pytorch#180070 Approved by: https://github.com/Skylion007
pytorch#180070) …al_types Remove mypy suppressions. Add return type and parameter type annotations to constraint classes, generator, transformation, and z3 transform. Authored with Claude. Pull Request resolved: pytorch#180070 Approved by: https://github.com/Skylion007
pytorch#180070) …al_types Remove mypy suppressions. Add return type and parameter type annotations to constraint classes, generator, transformation, and z3 transform. Authored with Claude. Pull Request resolved: pytorch#180070 Approved by: https://github.com/Skylion007
…al_types
Remove mypy suppressions. Add return type and parameter type annotations to constraint classes, generator, transformation, and z3 transform.
Authored with Claude.