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

Fix TypeError in MutableTorchTensorRTModule on Python 3.9 #3094

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

HolyWu
Copy link
Contributor

@HolyWu HolyWu commented Aug 17, 2024

Description

    import torch_tensorrt as torchtrt
/__w/_temp/conda_environment_10423996349/lib/python3.9/site-packages/torch_tensorrt/__init__.py:137: in <module>
    from torch_tensorrt.dynamo.runtime._MutableTorchTensorRTModule import (
/__w/_temp/conda_environment_10423996349/lib/python3.9/site-packages/torch_tensorrt/dynamo/runtime/_MutableTorchTensorRTModule.py:40: in <module>
    class MutableTorchTensorRTModule(object):
/__w/_temp/conda_environment_10423996349/lib/python3.9/site-packages/torch_tensorrt/dynamo/runtime/_MutableTorchTensorRTModule.py:61: in MutableTorchTensorRTModule
    Set[torch.dtype | dtype] | Tuple[torch.dtype | dtype]
E   TypeError: unsupported operand type(s) for |: 'type' and 'EnumMeta'

Type union operator was not supported on Python 3.9 since it's introduced on Python 3.10. Additionally, the allowed type for enabled_precisions should only be Set, not Tuple.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@github-actions github-actions bot added component: api [Python] Issues re: Python API component: runtime component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Aug 17, 2024
@github-actions github-actions bot requested a review from peri044 August 17, 2024 03:51
Copy link
Collaborator

@narendasan narendasan left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks!

@narendasan narendasan merged commit 3eb1141 into pytorch:main Aug 19, 2024
46 of 68 checks passed
@HolyWu HolyWu deleted the fix_type_error branch August 19, 2024 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed component: api [Python] Issues re: Python API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants