You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
🐛 [Bug] dynamo.compile silently ignores kwarg_inputs entries the program does not take #5031
torch_tensorrt.dynamo.compile accepts kwarg_inputs entries that the exported program does not take, and ignores them with no error and no warning. Two cases:
a name that forward() does not have (for example a typo);
a name that duplicates a positional input, with a different shape.
So a typo in a kwarg_inputs key, or a stale shape, changes nothing and goes unnoticed. Eager PyTorch rejects both calls with a TypeError.
To Reproduce
importtorchimporttorch_tensorrtclassM(torch.nn.Module):
defforward(self, x):
returnx*2+1x=torch.ones(3, device="cuda")
ep=torch.export.export(M().cuda().eval(), (x,))
# 1. a name forward() does not taketorch_tensorrt.dynamo.compile(
ep, arg_inputs=[x], kwarg_inputs={"bogus": torch.ones(7, device="cuda")}, min_block_size=1
)
# 2. a duplicate of the positional input, with a different shapetorch_tensorrt.dynamo.compile(
ep, arg_inputs=[x], kwarg_inputs={"x": torch.ones(5, device="cuda")}, min_block_size=1
)
Both calls compile, and the resulting modules run and return [3.0, 3.0, 3.0].
Expected behavior
An error (or at least a warning) for both, matching eager PyTorch:
From reading the code (not traced in a debugger): in py/torch_tensorrt/dynamo/_compiler.py, _build_user_symbol_bounds falls back, when in_spec.flatten_up_to raises, to looping over user_input_names[len(sample_arg_inputs):] and reading only the keys that match. Keys that match no remaining user input are dropped silently. The multi-profile path (top_level_inputs.extend(sample_kwarg_inputs.values())) also takes the values without checking the names. compile_and_save passes the same arguments, so it behaves the same way.
Environment
Torch-TensorRT: 2.15.0 (Python package files identical to the v2.15.0 tag)
PyTorch: 2.15.0+cu132
Seen on Linux x86_64 with an H100, and on Jetson AGX Thor (aarch64) with the PyPI torch_tensorrt 2.15.0 wheel.
Activity