Skip to content

✨[Feature] Create Decorator for Python functions Incompatible with Legacy Torch Versions #1733

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
gs-olive opened this issue Mar 10, 2023 · 2 comments · Fixed by #1738
Closed
Assignees
Labels
feature request New feature or request

Comments

@gs-olive
Copy link
Collaborator

Context

Some functions in the code base are incompatible with certain versions of Torch such as 1.13.1. Adding a general-purpose utility decorator which detects whether the Torch version is incompatible with certain key functions could be helpful in notifying the user when such mismatches occur.

Desired Solution

A decorator of the form:

@req_torch_version(2)
def f(...):

This decorator would throw a clear error when the detected Torch version differs from that required to use the decorated function.

Temporary Alternative

A temporary alternative, which is already in use in PR #1731, is to add logic to each function with compatibility issues, raising an error if any versioning issues are detected. While this is a functional solution, it is difficult to scale and can lead to repetitive code.

Additional Context

Certain imports are also not compatible across Torch versions (as in import torchdynamo in Torch 1.13 versus import torch._dynamo in 2.0). To resolve this issue, the imports can be moved inside the functions using them so as to encapsulate all version-specific code within one area.

@gs-olive gs-olive added the feature request New feature or request label Mar 10, 2023
@gs-olive gs-olive assigned narendasan and gs-olive and unassigned narendasan Mar 10, 2023
@narendasan
Copy link
Collaborator

@gs-olive I was thinking about this, probably something to bring up with @ncomly-nvidia but spanning 1.13 and 2.0 makes dependencies complicated for dyanmo.

Also we could add some functionality to the @tensorrt_converter decorators similar to what is already there for TRT.

@narendasan
Copy link
Collaborator

Just to record the discussion. We decided not to support dynamo workflows in the 1.13 compatibility mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants