feat: custom binding names for out of runtime deployment#4309
Open
narendasan wants to merge 1 commit into
Open
feat: custom binding names for out of runtime deployment#4309narendasan wants to merge 1 commit into
narendasan wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/examples/dynamo/engine_converter_binding_names.py 2026-05-29 19:38:55.472711+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/dynamo/engine_converter_binding_names.py 2026-05-29 19:39:15.963114+00:00
@@ -302,11 +302,11 @@
try:
torch_tensorrt.dynamo.convert_exported_program_to_serialized_trt_engine(
exported,
arg_inputs=(x,),
- output_binding_names=("only_one",), # wrong arity for the 2-tuple return
+ output_binding_names=("only_one",), # wrong arity for the 2-tuple return
require_full_compilation=True,
min_block_size=1,
use_python_runtime=False,
immutable_weights=True,
)
--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py 2026-05-29 19:38:55.486463+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py 2026-05-29 19:39:17.826414+00:00
@@ -397,11 +397,10 @@
run_module_start_time = datetime.now()
super().run()
_LOGGER.info(
f"TRT INetwork construction elapsed time: {datetime.now() - run_module_start_time}"
)
-
@staticmethod
def find_weight(
weight_name: str,
weight_refit_map: dict[str, Any],
--- /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_engine_converter_binding_names.py 2026-05-29 19:38:55.514192+00:00
+++ /home/runner/work/TensorRT/TensorRT/tests/py/dynamo/conversion/test_engine_converter_binding_names.py 2026-05-29 19:39:21.059130+00:00
@@ -12,10 +12,11 @@
We ``tree_flatten`` each and verify spec equality against the exported
program's specs. On success the flat lists concatenate (args then
kwargs) into FX's flattened placeholder order; the interpreter just
indexes positionally.
"""
+
import unittest
import tensorrt as trt
import torch
import torch_tensorrt
@@ -361,10 +362,12 @@
(input_name,) = self._binding_names(engine, trt.TensorIOMode.INPUT)
outs = self._run_engine(engine, {input_name: x.contiguous()})
with torch.no_grad():
ref = model(x)
torch.testing.assert_close(outs["p_out"], ref["primary"], rtol=1e-2, atol=1e-2)
- torch.testing.assert_close(outs["s_out"], ref["secondary"], rtol=1e-2, atol=1e-2)
+ torch.testing.assert_close(
+ outs["s_out"], ref["secondary"], rtol=1e-2, atol=1e-2
+ )
if __name__ == "__main__":
run_tests()62c562d to
eb1ffee
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Allows users of the
convert_exported_program_to_serialized_engineAPI to specify binding names for all bindings utilizing the exported programs pytrees for i/o flattening to flatten the provided names and associate names to specific io positions.TODO: Add support for aliasing inputs and outputs through this method (see: #4251)
Fixes #4212
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: