From 301d175b95accc0cf40963b662e755125318029c Mon Sep 17 00:00:00 2001 From: shoumikhin Date: Tue, 21 Jul 2026 19:35:08 -0700 Subject: [PATCH 1/2] fix: add missing serialized_aliased_io arg to no_op_placeholder op schema The serialized engine layout gained ALIASED_IO_IDX=12 (SERIALIZATION_LEN=13) in #4251, so _replace_execute_engine_with_no_op builds the tensorrt::no_op_placeholder_for_execute_engine node with 14 args (inputs + 13 serialized fields). The op and its fake kernel were never updated and still declared only 13 params, so any ExecuTorch .pte export hit: RuntimeError: no_op_placeholder_for_execute_engine() expected at most 13 argument(s) but received 14 argument(s) Add the trailing serialized_aliased_io: str param (ALIASED_IO_IDX) to both the custom op and its register_fake so the schema matches the builder. The fake still derives output shapes from serialized_metadata, so the new field is accepted but not otherwise used. Signed-off-by: shoumikhin --- py/torch_tensorrt/dynamo/runtime/meta_ops/register_meta_ops.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/torch_tensorrt/dynamo/runtime/meta_ops/register_meta_ops.py b/py/torch_tensorrt/dynamo/runtime/meta_ops/register_meta_ops.py index 3c2ea2180a..916c5dcf3f 100644 --- a/py/torch_tensorrt/dynamo/runtime/meta_ops/register_meta_ops.py +++ b/py/torch_tensorrt/dynamo/runtime/meta_ops/register_meta_ops.py @@ -321,6 +321,7 @@ def no_op_placeholder_for_execute_engine( serialized_require_output_allocator: str, serialized_resource_allocation_strategy: str, serialized_requires_native_multidevice: str, + serialized_aliased_io: str, ) -> List[torch.Tensor]: raise RuntimeError( "The saved model is cross compiled for windows in Linux, should only be loadded in Windows via torch_tensorrt.load_cross_compiled_exported_program() api." @@ -342,6 +343,7 @@ def fake_no_op_placeholder_for_execute_engine( serialized_require_output_allocator: str, serialized_resource_allocation_strategy: str, serialized_requires_native_multidevice: str, + serialized_aliased_io: str, ) -> List[torch.Tensor]: """Fake kernel for no_op_placeholder_for_execute_engine. From b2c8dd62d3677e486b2b241c3973385a182cdbbd Mon Sep 17 00:00:00 2001 From: shoumikhin Date: Tue, 21 Jul 2026 21:17:21 -0700 Subject: [PATCH 2/2] test: cover no-op placeholder schema layout --- tests/py/dynamo/executorch/test_backend.py | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/py/dynamo/executorch/test_backend.py b/tests/py/dynamo/executorch/test_backend.py index 3afe50a2b1..1c070f318e 100644 --- a/tests/py/dynamo/executorch/test_backend.py +++ b/tests/py/dynamo/executorch/test_backend.py @@ -1,3 +1,5 @@ +import ast +from pathlib import Path from types import SimpleNamespace import pytest @@ -7,6 +9,7 @@ import torch # noqa: E402 from torch.export.graph_signature import InputKind # noqa: E402 from torch_tensorrt.dynamo.runtime._TorchTensorRTModule import ( # noqa: E402 + ALIASED_IO_IDX, DEVICE_IDX, ENGINE_IDX, INPUT_BINDING_NAMES_IDX, @@ -109,6 +112,32 @@ def _engine_tensor(payload: bytes) -> torch.Tensor: return torch.frombuffer(bytearray(payload), dtype=torch.uint8) +@pytest.mark.unit +def test_no_op_placeholder_schema_matches_serialized_engine_layout(): + meta_ops_path = ( + Path(__file__).parents[4] + / "py/torch_tensorrt/dynamo/runtime/meta_ops/register_meta_ops.py" + ) + module = ast.parse(meta_ops_path.read_text()) + signatures = { + node.name: [arg.arg for arg in node.args.args] + for node in module.body + if isinstance(node, ast.FunctionDef) + and node.name + in { + "no_op_placeholder_for_execute_engine", + "fake_no_op_placeholder_for_execute_engine", + } + } + + expected_arg_count = SERIALIZATION_LEN + 1 + for args in signatures.values(): + assert len(args) == expected_arg_count + assert args[ALIASED_IO_IDX + 1] == "serialized_aliased_io" + assert len(signatures) == 2 + assert len({tuple(args) for args in signatures.values()}) == 1 + + @pytest.mark.unit def test_get_engine_info_rejects_multiple_engine_nodes(): engine_info = [""] * SERIALIZATION_LEN