Skip to content

feat: add convert_method_to_trt_engine() for dynamo #2467

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

Conversation

zewenli98
Copy link
Collaborator

Description

Add a function convert_method_to_trt_engine() for dynamo.

I'm not familiar with this part, so detailed reviews and suggestions are greatly welcome.

Fixes #2410

Type of change

  • New feature (non-breaking change which adds functionality)

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: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Nov 14, 2023
@github-actions github-actions bot requested a review from peri044 November 14, 2023 22:01
@zewenli98 zewenli98 requested review from narendasan and gs-olive and removed request for peri044 November 14, 2023 22:01
@zewenli98
Copy link
Collaborator Author

@gs-olive @narendasan Another question - Regarding testing, how to invoke this function like directly calling torchtrt.dynamo.convert_method_to_trt_engine? and where should I put the test cases?

@gs-olive
Copy link
Collaborator

I think it could potentially go in tests/py/dynamo/runtime? Then, you can directly call the function to generate the TRT engine which can be run directly in Python for inference purposes.

@github-actions github-actions bot added component: conversion Issues re: Conversion stage component: tests Issues re: Tests labels Nov 17, 2023
@zewenli98 zewenli98 force-pushed the torch_tensorrt.dynamo.convert_method_to_trt_engine branch 2 times, most recently from a6ba374 to 9df10a4 Compare November 17, 2023 21:34
@zewenli98
Copy link
Collaborator Author

zewenli98 commented Nov 17, 2023

@gs-olive Got a Python package import error:

==================================== ERRORS ====================================
_ ERROR collecting tests/py/dynamo/runtime/test_convert_method_to_trt_engine.py _
ImportError while importing test module '/__w/TensorRT/TensorRT/pytorch/tensorrt/tests/py/dynamo/runtime/test_convert_method_to_trt_engine.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/python/cp38-cp38/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
runtime/test_convert_method_to_trt_engine.py:4: in <module>
    import pycuda.driver as cuda
E   ModuleNotFoundError: No module named 'pycuda'

Can we add pycuda in CI?

@gs-olive
Copy link
Collaborator

Hi @zewenli98 - sure, I think we can add this dependency at the path tests/modules/requirements.txt, and it should be reflected in the CI afterward.

@zewenli98 zewenli98 force-pushed the torch_tensorrt.dynamo.convert_method_to_trt_engine branch from a0053c5 to 7e94305 Compare November 29, 2023 22:02
@zewenli98
Copy link
Collaborator Author

Hi @zewenli98 - sure, I think we can add this dependency at the path tests/modules/requirements.txt, and it should be reflected in the CI afterward.

Thanks! Naren suggested that PythonTorchTensorRTModule should be used instead of directly calling native functions, so I modified accordingly.

@zewenli98 zewenli98 force-pushed the torch_tensorrt.dynamo.convert_method_to_trt_engine branch from 7e94305 to 38caf26 Compare December 12, 2023 23:39
Copy link
Collaborator

@gs-olive gs-olive left a comment

Choose a reason for hiding this comment

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

Overall looks good. Added one suggestion and needs a rebase.

@zewenli98 zewenli98 force-pushed the torch_tensorrt.dynamo.convert_method_to_trt_engine branch from e5a8d62 to 4cbad77 Compare January 14, 2024 16:37
@zewenli98 zewenli98 requested a review from gs-olive January 14, 2024 16:41
@zewenli98 zewenli98 merged commit 5f66ade into pytorch:main Jan 17, 2024
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: conversion Issues re: Conversion stage component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: tests Issues re: Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implenting torch_tensorrt.dynamo.convert_method_to_trt_engine
4 participants