Skip to content

add type annotations to torch.nn.modules.module#49045

Closed
guilhermeleobas wants to merge 7 commits intopytorch:masterfrom
guilhermeleobas:module
Closed

add type annotations to torch.nn.modules.module#49045
guilhermeleobas wants to merge 7 commits intopytorch:masterfrom
guilhermeleobas:module

Conversation

@guilhermeleobas
Copy link
Copy Markdown
Collaborator

Fixes #49044

@guilhermeleobas guilhermeleobas added the module: typing Related to mypy type annotations label Dec 8, 2020
@guilhermeleobas guilhermeleobas self-assigned this Dec 8, 2020
@facebook-github-bot facebook-github-bot added cla signed oncall: distributed Add this issue/PR to distributed oncall triage queue fx labels Dec 8, 2020
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Dec 8, 2020

💊 CI failures summary and remediations

As of commit b9382f2 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

This comment has been revised 33 times.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 9, 2020

Codecov Report

Merging #49045 (b9382f2) into master (4774c68) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #49045      +/-   ##
==========================================
- Coverage   80.72%   80.72%   -0.01%     
==========================================
  Files        1904     1904              
  Lines      206764   206764              
==========================================
- Hits       166908   166907       -1     
- Misses      39856    39857       +1     

@guilhermeleobas guilhermeleobas marked this pull request as ready for review December 9, 2020 15:38
@H-Huang H-Huang added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Dec 10, 2020
@rgommers
Copy link
Copy Markdown
Collaborator

@guilhermeleobas could you also add comments here about the ignores you added? That helps both with review (reproducing the failures and using reveal_type is my alternative), and when the next person has to touch that bit of code.

@rgommers
Copy link
Copy Markdown
Collaborator

Also, in your next commit message, can you add that it closes gh-48640?

@guilhermeleobas
Copy link
Copy Markdown
Collaborator Author

Hi @rgommers, thanks for the review. I've addressed your comments

Copy link
Copy Markdown
Collaborator

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

Looks good now, thanks @guilhermeleobas.

CI notifications seem stuck, but CI is done - see https://app.circleci.com/pipelines/github/pytorch/pytorch?branch=pull%2F49045. Failures are unrelated.

@rgommers rgommers requested review from ezyang and malfet December 19, 2020 19:16
Comment thread torch/fx/symbolic_trace.py Outdated
Comment on lines 91 to 93
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why cant we just use different variable names?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that works too

Comment thread torch/nn/modules/module.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not python expert. but cant we use del load to remove the function reference itself? (after all the load has been done, yes?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes!

@guilhermeleobas
Copy link
Copy Markdown
Collaborator Author

Do not merge this PR until one checks if the annotations introduce any regression. See:
#49564 (comment)

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@walterddr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

picky back on this PR - i dont think there's any additional item that needs to be test with JIT-ability for this change. am I missing any? @malfet

@@ -279,7 +279,7 @@ def parameters(self, recurse: bool = True) -> Iterator[Parameter]:

def named_parameters( # type: ignore[return]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't we remove this type ignore as well since we fixed the return Parameter

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

torch/distributed/nn/api/remote_module.py:280: error: Missing return statement  [return]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lol. Got it.

@guilhermeleobas guilhermeleobas marked this pull request as ready for review January 8, 2021 16:50
Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@walterddr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

looks good. I dont see any additional JIT test required.

@walterddr
Copy link
Copy Markdown
Contributor

actually please rebase master --> seems like merge conflict is preventing fb internal CI to run

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@walterddr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@walterddr merged this pull request in 5f8e1a1.

@guilhermeleobas guilhermeleobas deleted the module branch January 12, 2021 02:33
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Fixes pytorch#49044

Pull Request resolved: pytorch#49045

Reviewed By: malfet

Differential Revision: D25767092

Pulled By: walterddr

fbshipit-source-id: a81ba96f3495943af7bb9ee3e5fc4c94c690c405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: typing Related to mypy type annotations oncall: distributed Add this issue/PR to distributed oncall triage queue open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable torch.nn.modules.module typechecks during CI

6 participants