Skip to content
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

[release] Add warning to stateless.functional_call for deprecated behavior #87079

Merged
merged 6 commits into from Oct 20, 2022

Conversation

samdow
Copy link
Contributor

@samdow samdow commented Oct 17, 2022

We need to deprecate this behavior in 1.13 for silent correctness errors (current version gives unexpected results for users, but it is BC-breaking so we need a deprecation cycle)

@pytorch-bot
Copy link

pytorch-bot bot commented Oct 17, 2022

🔗 Helpful Links

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

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

✅ No Failures

As of commit 1eb4332:
💚 Looks good so far! There are no failures yet. 💚

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

def _named_members(mod, get_members_fn, prefix='', recurse=True, remove_duplicate=True):
r"""Helper method for yielding various names + members of modules."""
memo = set()
modules = mod.named_modules(prefix=prefix) if recurse else [(prefix, mod)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will fix the issue with the test but does mean that we won't warn on the case where we have a recursive module (i.e. module = SomeModule(); module.m = module) and a user passes in values for multiple of the recursive values

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

It would be good to use similar script as the ones in #68969 (comment) to see what is the impact of this.

@@ -0,0 +1,32 @@
# Polyfilled from pytorch core while we figure out the `remove_duplicate` issues.
def _named_members(mod, get_members_fn, prefix='', recurse=True, remove_duplicate=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

These are not needed. We have them in core.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually didn't make it into the release (source)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ho I though that landed a while back. So much happened in one week :p

yield name, v


def _named_parameters(mod, prefix: str = '', recurse: bool = True, remove_duplicate: bool = True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is still needed but we should really just add it to core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was going to leave that for post-release since it's BC-breaking and probably requires codevelopment

@samdow
Copy link
Contributor Author

samdow commented Oct 18, 2022

It would be good to use similar script as the ones in #68969 (comment) to see what is the impact of this.

Just used that script and got some numbers:

% of parameters passed CPU Time (us) GPU Time (us)
Vanilla model 13428 93666
functorch (for comparison) 20957 97661
This PR with 100% of params changed 22610 100051
Pre-PR with 100% of params changed 19343 97172

So this is incurring ~15% regression on resnet

@samdow
Copy link
Contributor Author

samdow commented Oct 18, 2022

Talked offline and per Alban's suggestion, moved the code to check to happen during the traversal. This reduced overhead to 5% on resnet

Raw numbers

% of parameters passed CPU Time (us) GPU Time (us)
Vanilla model 13233 91789
functorch (for comparison) 20617 95866
This PR with 100% of params changed 20545 96493
Pre-PR with 100% of params changed 19513 95570

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Needs a test and this is good to go I think!

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

SGTM!

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 19, 2022
Copy link
Contributor

@atalman atalman left a comment

Choose a reason for hiding this comment

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

LGTM

@atalman atalman merged commit ca0ee92 into pytorch:release/1.13 Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants