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

Add deprecation messages for functorch.* function transforms #92279

Closed
wants to merge 5 commits into from

Conversation

zou3519
Copy link
Contributor

@zou3519 zou3519 commented Jan 17, 2023

Stack from ghstack (oldest at bottom):

This PR:

  • adds deprecation warnings when calling the functorch APIs
  • adds documentation saying that those APIs are deprecated

It does this by creating thin wrappers around the original APIs that (1)
raise deprecation warnings and (2) have an additional line in their
documentation that they are deprecated.

NB:

  • Python surpresses DeprecationWarning, so we use UserWarning instead.

Test Plan:

  • New tests
  • the functorch.* APIs are still tested for correctness because that's
    what test/functorch/* use (as opposed to directly calling the
    torch.func.* APIs)

This PR:
- adds deprecation warnings when calling the functorch APIs
- adds documentation saying that those APIs are deprecated

It does this by creating thin wrappers around the original APIs that (1)
raise deprecation warnings and (2) have an additional line in their
documentation that they are deprecated.

NB:
- PyTorch actually suppresses all DeprecationWarning by default.
So the warnings themselves are less important than the docs.

Test Plan:
- New tests
- the functorch.* APIs are still tested for correctness because that's
what test/functorch/* use (as opposed to directly calling the
torch.func.* APIs)

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Jan 17, 2023

🔗 Helpful Links

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

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

✅ No Failures

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

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

@zou3519 zou3519 added the release notes: functorch release notes category; Pertaining to torch.func or pytorch/functorch label Jan 17, 2023
This PR:
- adds deprecation warnings when calling the functorch APIs
- adds documentation saying that those APIs are deprecated

It does this by creating thin wrappers around the original APIs that (1)
raise deprecation warnings and (2) have an additional line in their
documentation that they are deprecated.

NB:
- Python surpresses DeprecationWarning, so we use UserWarning instead.

Test Plan:
- New tests
- the functorch.* APIs are still tested for correctness because that's
what test/functorch/* use (as opposed to directly calling the
torch.func.* APIs)

[ghstack-poisoned]
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.

Sounds good to me, just small details


def warn_deprecated(api, new_api=None):
warning = get_warning(api, new_api, replace_newlines=True)
warnings.warn(warning)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You might want to pass in stacklevel=2 so that the line number in the warning points to functorch.vmap() call and not warn_deprecated('vmap', 'torch.vmap')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point

torch/_functorch/deprecated.py Outdated Show resolved Hide resolved
Copy link
Contributor

@soulitzer soulitzer left a comment

Choose a reason for hiding this comment

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

LGTM

This PR:
- adds deprecation warnings when calling the functorch APIs
- adds documentation saying that those APIs are deprecated

It does this by creating thin wrappers around the original APIs that (1)
raise deprecation warnings and (2) have an additional line in their
documentation that they are deprecated.

NB:
- Python surpresses DeprecationWarning, so we use UserWarning instead.

Test Plan:
- New tests
- the functorch.* APIs are still tested for correctness because that's
what test/functorch/* use (as opposed to directly calling the
torch.func.* APIs)

[ghstack-poisoned]
This PR:
- adds deprecation warnings when calling the functorch APIs
- adds documentation saying that those APIs are deprecated

It does this by creating thin wrappers around the original APIs that (1)
raise deprecation warnings and (2) have an additional line in their
documentation that they are deprecated.

NB:
- Python surpresses DeprecationWarning, so we use UserWarning instead.

Test Plan:
- New tests
- the functorch.* APIs are still tested for correctness because that's
what test/functorch/* use (as opposed to directly calling the
torch.func.* APIs)

[ghstack-poisoned]
This PR:
- adds deprecation warnings when calling the functorch APIs
- adds documentation saying that those APIs are deprecated

It does this by creating thin wrappers around the original APIs that (1)
raise deprecation warnings and (2) have an additional line in their
documentation that they are deprecated.

NB:
- Python surpresses DeprecationWarning, so we use UserWarning instead.

Test Plan:
- New tests
- the functorch.* APIs are still tested for correctness because that's
what test/functorch/* use (as opposed to directly calling the
torch.func.* APIs)

[ghstack-poisoned]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged release notes: functorch release notes category; Pertaining to torch.func or pytorch/functorch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants