Skip to content

[BE][Ez]: Fully type nn.utils.clip_grad #154801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Skylion007
Copy link
Collaborator

@Skylion007 Skylion007 commented May 31, 2025

Full types clip_grad and exposed typing annotations that were hidden by a bad decorator

cc @ezyang @malfet @xuzhao9 @gramster @albanD

Copy link

pytorch-bot bot commented May 31, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit f302434 with merge base f88d7a7 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@Skylion007 Skylion007 requested a review from aorenste May 31, 2025 16:49
@Skylion007 Skylion007 added module: typing Related to mypy type annotations module: python frontend For issues relating to PyTorch's Python frontend labels May 31, 2025
@@ -23,19 +21,22 @@
]


_tensor_or_tensors = Union[
_TensorOrTensors: TypeAlias = Union[
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruff complained about the name of this once I exposed it as a TypeAlias, and it's an internal only TypeAlias

@Skylion007 Skylion007 added release notes: python_frontend python frontend release notes category suppress-bc-linter Suppresses the failures of API backward-compatibility linter (Lint/bc_linter) labels May 31, 2025
@Skylion007 Skylion007 added the better-engineering Relatively self-contained tasks for better engineering contributors label May 31, 2025
@Skylion007 Skylion007 requested a review from jansel May 31, 2025 17:12
@Skylion007 Skylion007 changed the title [BE]: Fully type nn.utils.clip_grad [BE][Ez]: Fully type nn.utils.clip_grad May 31, 2025
@Skylion007
Copy link
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 31, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

nWEIdia pushed a commit to nWEIdia/pytorch that referenced this pull request Jun 2, 2025
Full types clip_grad and exposed typing annotations that were hidden by a bad decorator

Pull Request resolved: pytorch#154801
Approved by: https://github.com/jansel
@facebook-github-bot
Copy link
Contributor

@pytorchbot revert -m="Diff reverted internally" -c="ghfirst"

This Pull Request has been reverted by a revert inside Meta. To re-land this change, please open another pull request, assign the same reviewers, fix the CI failures that caused the revert and make sure that the failing CI runs on the PR by applying the proper ciflow label (e.g., ciflow/trunk).)

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Jun 4, 2025
This reverts commit 9ce2732.

Reverted #154801 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](#154801 (comment)))
@pytorchmergebot
Copy link
Collaborator

@Skylion007 your PR has been successfully reverted.

iupaikov-amd pushed a commit to ROCm/pytorch that referenced this pull request Jun 4, 2025
Full types clip_grad and exposed typing annotations that were hidden by a bad decorator

Pull Request resolved: pytorch#154801
Approved by: https://github.com/jansel
iupaikov-amd pushed a commit to ROCm/pytorch that referenced this pull request Jun 4, 2025
@Skylion007
Copy link
Collaborator Author

Skylion007 commented Jun 4, 2025

@aorenste Looks like this uncovered more typing errors inside of Meta. Not sure if the input args need to be more flexible or if the private type alias was actually used somewhere else or what, but if you could help land, that would be super helpful.

@Skylion007
Copy link
Collaborator Author

Looking at torch_tune, it looks like the alias is actually used...

@Skylion007
Copy link
Collaborator Author

@nathan-az If the internal issue is just the internal typing, feel free to revert that change and keep the decorator typing.

@aorenste
Copy link
Contributor

aorenste commented Jun 4, 2025

I can help - but I have to wait for our internal tooling to be fixed. Without that there's no way to run all the tests that could have fallout - so it lands and then tests start failing.

angelayi pushed a commit to angelayi/pytorch that referenced this pull request Jun 5, 2025
@Skylion007
Copy link
Collaborator Author

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Rebase failed due to Command git -C /home/runner/work/pytorch/pytorch rebase refs/remotes/origin/viable/strict pull/154801/head returned non-zero exit code 1

warning: skipped previously applied commit da780b97500
hint: use --reapply-cherry-picks to include skipped commits
hint: Disable this message with "git config set advice.skippedCherryPicks false"
Rebasing (1/1)
Auto-merging torch/nn/utils/clip_grad.py
CONFLICT (content): Merge conflict in torch/nn/utils/clip_grad.py
error: could not apply e17cc8767c6... Revert private TypeAlias rename
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Could not apply e17cc8767c6... Revert private TypeAlias rename

Raised by https://github.com/pytorch/pytorch/actions/runs/15519092514

vijayabhaskar-ev pushed a commit to vijayabhaskar-ev/pytorch that referenced this pull request Jun 22, 2025
@aorenste
Copy link
Contributor

aorenste commented Jul 7, 2025

@pytorchbot rebase

@pytorchmergebot
Copy link
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Rebase failed due to Command git -C /home/runner/work/pytorch/pytorch rebase refs/remotes/origin/viable/strict pull/154801/head returned non-zero exit code 1

warning: skipped previously applied commit da780b97500
hint: use --reapply-cherry-picks to include skipped commits
hint: Disable this message with "git config set advice.skippedCherryPicks false"
Rebasing (1/1)
Auto-merging torch/nn/utils/clip_grad.py
CONFLICT (content): Merge conflict in torch/nn/utils/clip_grad.py
error: could not apply e17cc8767c6... Revert private TypeAlias rename
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Could not apply e17cc8767c6... Revert private TypeAlias rename

Raised by https://github.com/pytorch/pytorch/actions/runs/16126456689

@Skylion007 Skylion007 force-pushed the skylion007/type-clip-grad-2025-05-31 branch from e17cc87 to 77976cc Compare July 8, 2025 15:40
@Skylion007
Copy link
Collaborator Author

@aorenste Rebased

@Skylion007 Skylion007 force-pushed the skylion007/type-clip-grad-2025-05-31 branch from 42e535d to f302434 Compare July 8, 2025 15:46
@facebook-github-bot
Copy link
Contributor

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

@albanD albanD removed their request for review July 9, 2025 07:55
@aorenste
Copy link
Contributor

aorenste commented Jul 9, 2025

Imported internally and it passes all tests.
I also manually ran it on a bunch of internal typechecking tests that I know failed on other typechecking diffs and it passed there (our internal "full check" tool is still not working yet :( ).
Looking at the original land attempt it actually looked fine to me - I suspect it actually got caught up paired with another PR that did actually have issues at the same time.
@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

vijayabhaskar-ev pushed a commit to vijayabhaskar-ev/pytorch that referenced this pull request Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
better-engineering Relatively self-contained tasks for better engineering contributors ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request Merged module: python frontend For issues relating to PyTorch's Python frontend module: typing Related to mypy type annotations open source release notes: python_frontend python frontend release notes category Reverted suppress-bc-linter Suppresses the failures of API backward-compatibility linter (Lint/bc_linter)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy