-
Notifications
You must be signed in to change notification settings - Fork 371
Add a testcase for ts compile -> saving with torch_tensorrt.save #3778
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/_compile.py 2025-08-14 15:59:14.216704+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/_compile.py 2025-08-14 15:59:39.529516+00:00
@@ -578,11 +578,13 @@
def save(
module: Any,
file_path: str = "",
*,
- output_format: Literal["exported_program", "torchscript", "aot_inductor"] = "exported_program",
+ output_format: Literal[
+ "exported_program", "torchscript", "aot_inductor"
+ ] = "exported_program",
inputs: Optional[Sequence[torch.Tensor]] = None,
arg_inputs: Optional[Sequence[torch.Tensor]] = None,
kwarg_inputs: Optional[dict[str, Any]] = None,
retrace: bool = False,
pickle_protocol: int = 2,
--- /home/runner/work/TensorRT/TensorRT/tests/py/ts/api/test_export_serde.py 2025-08-14 15:59:14.249704+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/ts/api/test_export_serde.py 2025-08-14 15:59:46.067071+00:00
@@ -12,10 +12,11 @@
cosine_similarity,
get_model_device,
)
assertions = unittest.TestCase()
+
@pytest.mark.unit
def test_save_load_ts(ir):
"""
This tests save/load API on Torchscript format (model still compiled using ts workflow)
b753f47
to
b5ab1ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/tests/py/ts/api/test_export_serde.py 2025-08-14 20:24:49.095701+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/ts/api/test_export_serde.py 2025-08-14 20:25:20.385752+00:00
@@ -12,10 +12,11 @@
cosine_similarity,
get_model_device,
)
assertions = unittest.TestCase()
+
@pytest.mark.unit
def test_save_load_ts(ir):
"""
This tests save/load API on Torchscript format (model still compiled using ts workflow)
torchtrt.save(trt_gm, "./trt.ts", output_format="torchscript", inputs=[input]) | ||
|
||
trt_ts_module = torchtrt.load("./trt.ts") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to use the pytest's tmp_path
fixture here, so that pytest could automatically cleanup the file once the tests are finished.
@pytest.mark.unit
def test_save_load_ts(ir, tmp_path):
...
trt_file = tmp_path / "trt.ts"
torchtrt.save(trt_gm, trt_file, output_format="torchscript", inputs=[input])
trt_ts_module = torchtrt.load(trt_file)
Description
Adds a testcase to cover #3775
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: