From 11dcf5f0e7bcc18432c7584e1384b5aa6cbec51b Mon Sep 17 00:00:00 2001 From: apbose Date: Fri, 28 Aug 2026 17:41:42 -0700 Subject: [PATCH] Short-circuit index_put with a statically-empty index An empty index means no positions to scatter into, so index_put is a no-op. Building the scatter path anyway (reshaping an index tensor to a shape containing a 0) trips a TensorRT-internal squeezeDims assertion at build time on DGX Spark (GB10, SM 12.1) -- Error Code 2, "Assertion inputDims != nullptr failed" in validationUtils.cpp. Other platforms don't hit it, but the operation is a no-op regardless of platform, so avoid building it at all. --- py/torch_tensorrt/dynamo/conversion/impl/select.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/py/torch_tensorrt/dynamo/conversion/impl/select.py b/py/torch_tensorrt/dynamo/conversion/impl/select.py index 945a5f19d2..f380eb2302 100644 --- a/py/torch_tensorrt/dynamo/conversion/impl/select.py +++ b/py/torch_tensorrt/dynamo/conversion/impl/select.py @@ -772,6 +772,13 @@ def index_put_converter( else: N = 1 + if isinstance(N, int) and N == 0: + # Empty index -> no-op. Building the scatter path anyway trips a + # TensorRT squeezeDims assertion on DGX Spark (GB10, SM 12.1). + identity_layer = ctx.net.add_identity(input_tensor) + set_layer_name(identity_layer, target, f"{name}_empty_index_noop", source_ir) + return identity_layer.get_output(0) + # Compute shapes and volume for the free dimensions. # F_shapes: static ints (-1 for dynamic dims), used where static ints are required. # F_shape_values: per-free-dim size as int (static) or ITensor (dynamic).