From 0b8736d845942acdc089ab7ed7fa7aa78693cde3 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 21 Oct 2025 11:04:16 -0700 Subject: [PATCH 1/7] fix coverage report tool issue --- docker/Dockerfile | 6 ++--- .../dynamo/conversion/impl/deconv.py | 22 ++++++++++--------- py/torch_tensorrt/dynamo/utils.py | 4 ++-- .../fx/converters/converter_utils.py | 5 ++++- .../fx/tools/timing_cache_utils.py | 4 ++-- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 2138c94100..9052992015 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -55,9 +55,9 @@ FROM base as torch-tensorrt-builder-base ARG ARCH="x86_64" ARG TARGETARCH="amd64" -RUN apt-get update -RUN apt-get install -y python3-setuptools -RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub +RUN apt-get update && \ + apt-get install -y python3-setuptools && \ + apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub RUN apt-get update &&\ apt-get install -y --no-install-recommends locales ninja-build &&\ diff --git a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py index b9ee582d26..444ce8ec51 100644 --- a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py +++ b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py @@ -116,6 +116,7 @@ def deconvNd( kernel=trt.Weights() if isinstance(weight, TRTTensor) else weight, bias=trt.Weights() if isinstance(bias, TRTTensor) else bias, ) + assert deconv_layer is not None, "Deconvolution layer is None" set_layer_name(deconv_layer, target, name, source_ir) # If the weight is a TRTTensor, set it as an input of the layer @@ -156,19 +157,20 @@ def deconvNd( if groups is not None: deconv_layer.num_groups = groups - ndims = len(padding) - pre_padding_values = [] - post_padding_values = [] + if padding is not None: + ndims = len(padding) + pre_padding_values = [] + post_padding_values = [] - for dim in range(ndims): - pre_padding = padding[dim] - post_padding = padding[dim] - output_padding[dim] + for dim in range(ndims): + pre_padding = padding[dim] + post_padding = padding[dim] - output_padding[dim] - pre_padding_values.append(pre_padding) - post_padding_values.append(post_padding) + pre_padding_values.append(pre_padding) + post_padding_values.append(post_padding) - deconv_layer.pre_padding = tuple(pre_padding_values) - deconv_layer.post_padding = tuple(post_padding_values) + deconv_layer.pre_padding = tuple(pre_padding_values) + deconv_layer.post_padding = tuple(post_padding_values) result = deconv_layer.get_output(0) diff --git a/py/torch_tensorrt/dynamo/utils.py b/py/torch_tensorrt/dynamo/utils.py index 97328acd6d..f822e40e1b 100644 --- a/py/torch_tensorrt/dynamo/utils.py +++ b/py/torch_tensorrt/dynamo/utils.py @@ -826,13 +826,13 @@ def get_output_metadata( return [node.meta for node in nodes] -def get_output_dtypes(output: Any, truncate_doulbe: bool = False) -> List[dtype]: +def get_output_dtypes(output: Any, truncate_double: bool = False) -> List[dtype]: output_dtypes = [] if isinstance(output, torch.fx.node.Node): if "val" in output.meta: output_meta = output.meta["val"] if isinstance(output_meta, (FakeTensor, torch.Tensor)): - if truncate_doulbe and output_meta.dtype == torch.float64: + if truncate_double and output_meta.dtype == torch.float64: output_dtypes.append(dtype.float32) else: output_dtypes.append(dtype._from(output_meta.dtype)) diff --git a/py/torch_tensorrt/fx/converters/converter_utils.py b/py/torch_tensorrt/fx/converters/converter_utils.py index 78ea125424..a63c7cde00 100644 --- a/py/torch_tensorrt/fx/converters/converter_utils.py +++ b/py/torch_tensorrt/fx/converters/converter_utils.py @@ -173,7 +173,10 @@ def to_numpy( """ output = None - if value is None or isinstance(value, np.ndarray): + if value is None: + return None + + elif isinstance(value, np.ndarray): output = value elif isinstance(value, torch.Tensor): diff --git a/py/torch_tensorrt/fx/tools/timing_cache_utils.py b/py/torch_tensorrt/fx/tools/timing_cache_utils.py index 4580843e98..dcd9bd0f50 100644 --- a/py/torch_tensorrt/fx/tools/timing_cache_utils.py +++ b/py/torch_tensorrt/fx/tools/timing_cache_utils.py @@ -28,12 +28,12 @@ def get_timing_cache_trt(self, timing_cache_file: str) -> bytearray: return None def update_timing_cache( - self, timing_cache_file: str, serilized_cache: bytearray + self, timing_cache_file: str, serialized_cache: bytearray ) -> None: if not self.save_timing_cache: return timing_cache_file = self.get_file_full_name(timing_cache_file) with open(timing_cache_file, "wb") as local_cache: local_cache.seek(0) - local_cache.write(serilized_cache) + local_cache.write(serialized_cache) local_cache.truncate() From 3ff78bf8432aa47f8774573ca17221545ff1742f Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 21 Oct 2025 11:34:34 -0700 Subject: [PATCH 2/7] fix report issue --- .../dynamo/conversion/converter_utils.py | 80 +++++++++---------- .../dynamo/lowering/_decompositions.py | 2 +- .../fx/converters/acc_ops_converters.py | 29 ++++--- tests/py/dynamo/models/test_engine_cache.py | 7 +- 4 files changed, 61 insertions(+), 57 deletions(-) diff --git a/py/torch_tensorrt/dynamo/conversion/converter_utils.py b/py/torch_tensorrt/dynamo/conversion/converter_utils.py index 094de488ec..175979ccf9 100644 --- a/py/torch_tensorrt/dynamo/conversion/converter_utils.py +++ b/py/torch_tensorrt/dynamo/conversion/converter_utils.py @@ -446,53 +446,47 @@ def create_constant( else: shape = list(torch_value.shape) - if torch_value is not None: - - if torch_value.dtype == torch.uint8: - if is_tensorrt_version_supported("10.8.0"): - if ( - target_quantized_type is None - or target_quantized_type != trt.DataType.FP4 - ): - # Iconstant layer does not support Uint8, it only support that FP4 data packed in uint8 - raise ValueError( - "Currently supported target_quantized_type for uint8 is FP4, got {target_quantized_type=}" - ) - shape[-1] = shape[-1] * 2 - weights = to_trt_weights( - ctx, - torch_value, - name, - "CONSTANT", - "CONSTANT", - dtype=trt.DataType.FP4, - count=torch_value.numel() * 2, - ) - constant = ctx.net.add_constant( - shape, - weights, - ) - constant.name = name - return constant.get_output(0) - else: + if torch_value.dtype == torch.uint8: + if is_tensorrt_version_supported("10.8.0"): + if ( + target_quantized_type is None + or target_quantized_type != trt.DataType.FP4 + ): + # Iconstant layer does not support Uint8, it only support that FP4 data packed in uint8 raise ValueError( - "Currently FP4 is only supported in TensorRT 10.8.0 and above" + "Currently supported target_quantized_type for uint8 is FP4, got {target_quantized_type=}" ) - # Record the weight in ctx for refit and cpu memory reference + shape[-1] = shape[-1] * 2 + weights = to_trt_weights( + ctx, + torch_value, + name, + "CONSTANT", + "CONSTANT", + dtype=trt.DataType.FP4, + count=torch_value.numel() * 2, + ) + constant = ctx.net.add_constant( + shape, + weights, + ) + constant.name = name + return constant.get_output(0) + else: + raise ValueError( + "Currently FP4 is only supported in TensorRT 10.8.0 and above" + ) + # Record the weight in ctx for refit and cpu memory reference - # Convert the torch.Tensor to a trt.Weights object - trt_weights = to_trt_weights(ctx, torch_value, name, "CONSTANT", "CONSTANT") - constant = ctx.net.add_constant( - shape, - trt_weights, - ) - constant.name = name + # Convert the torch.Tensor to a trt.Weights object + trt_weights = to_trt_weights(ctx, torch_value, name, "CONSTANT", "CONSTANT") + constant = ctx.net.add_constant( + shape, + trt_weights, + ) + constant.name = name - return constant.get_output(0) - else: - raise ValueError( - f"Cannot convert tensor '{name}' to a TensorRT constant because its value is None." - ) + return constant.get_output(0) def get_trt_tensor( diff --git a/py/torch_tensorrt/dynamo/lowering/_decompositions.py b/py/torch_tensorrt/dynamo/lowering/_decompositions.py index 7d68ea0d93..68e276d432 100644 --- a/py/torch_tensorrt/dynamo/lowering/_decompositions.py +++ b/py/torch_tensorrt/dynamo/lowering/_decompositions.py @@ -331,7 +331,7 @@ def reduce_operation_with_scatter( scatter_tensor = initial_tensor else: # This case would not be encountered from torch itself - print("Invalid Operation for Reduce op!!") + raise ValueError(f"Invalid Operation for Reduce op: {self}!!") operation_rhs = torch.scatter(scatter_tensor, dim, index_tensor, src_tensor) device = to_torch_device(scatter_tensor.device) diff --git a/py/torch_tensorrt/fx/converters/acc_ops_converters.py b/py/torch_tensorrt/fx/converters/acc_ops_converters.py index f998ddb27a..048d17d2cd 100644 --- a/py/torch_tensorrt/fx/converters/acc_ops_converters.py +++ b/py/torch_tensorrt/fx/converters/acc_ops_converters.py @@ -143,7 +143,9 @@ def acc_ops_conv_transposend( kwargs: Dict[str, Argument], name: str, ) -> Union[TRTTensor, Sequence[TRTTensor]]: - input_val = kwargs["input"] + input_val = kwargs.get("input", None) + if input_val is None: + raise ValueError(f"conv_transpose received input as None") if not isinstance(input_val, TRTTensor): raise RuntimeError( @@ -159,12 +161,17 @@ def acc_ops_conv_transposend( # for now we'll assume bias is constant Tensor or None, # and bias being ITensor is not supported in TensorRT api # right now - if kwargs["bias"] is not None and not isinstance(kwargs["bias"], torch.Tensor): + if kwargs.get("bias", None) is not None and not isinstance( + kwargs["bias"], torch.Tensor + ): raise RuntimeError( f"ConvTranspose {name} has bias of type {type(kwargs['bias'])}, Expect Optional[Tensor]" ) - bias = to_numpy(kwargs["bias"]) # type: ignore[arg-type] - + bias = to_numpy(kwargs.get("bias", None)) # type: ignore[arg-type] + if kwargs.get("weight", None) is None: + raise ValueError(f"conv_transpose received weight as None") + if kwargs.get("groups", None) is None: + raise ValueError(f"conv_transpose received groups as None") if network.has_explicit_precision or isinstance(kwargs["weight"], TRTTensor): weight = get_trt_tensor(network, kwargs["weight"], f"{name}_weight") weight_shape = tuple(kwargs["weight"].shape) # type: ignore[union-attr] @@ -201,8 +208,7 @@ def acc_ops_conv_transposend( layer.stride_nd = kwargs["stride"] layer.padding_nd = kwargs["padding"] layer.dilation_nd = kwargs["dilation"] - if kwargs["groups"] is not None: - layer.num_groups = kwargs["groups"] + layer.num_groups = kwargs["groups"] return layer.get_output(0) @@ -215,10 +221,13 @@ def acc_ops_pad_with_padding_layer( kwargs: Dict[str, Argument], name: str, ) -> Union[TRTTensor, Sequence[TRTTensor]]: - input_val = kwargs["input"] - pad = cast(Sequence[int], kwargs["pad"]) - mode = kwargs["mode"] - value = kwargs["value"] if kwargs["value"] is not None else 0 + + input_val = kwargs.get("input", None) + if input_val is None: + raise ValueError(f"pad received input as None") + pad = cast(Sequence[int], kwargs.get("pad", 0)) + mode = kwargs.get("mode", None) + value = kwargs.get("value", 0) rank = len(input_val.shape) # type: ignore[union-attr] if not isinstance(input_val, TRTTensor): diff --git a/tests/py/dynamo/models/test_engine_cache.py b/tests/py/dynamo/models/test_engine_cache.py index 5e310900aa..f1aa5313b6 100644 --- a/tests/py/dynamo/models/test_engine_cache.py +++ b/tests/py/dynamo/models/test_engine_cache.py @@ -755,9 +755,10 @@ def remove_timing_cache(path=TIMING_CACHE_PATH): strip_engine_weights=strip_engine_weights, refit_identical_engine_weights=refit_identical_engine_weights, ) - - if strip_engine_weights: - trt_gm = refit_module_weights(trt_gm, exp_program) + # currently, strip_engine_weights is not supported in torch_tensorrt, enable it when we support it + # commenting out for now, so that coverage report will not report this line as 10012 Logically dead code + # if strip_engine_weights: + # trt_gm = refit_module_weights(trt_gm, exp_program) end.record() torch.cuda.synchronize() From 4d4ceefde6c06025c60b533e6d525125a74588e9 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 28 Oct 2025 08:17:18 -0700 Subject: [PATCH 3/7] fix 10003 error --- py/torch_tensorrt/dynamo/conversion/impl/deconv.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py index 444ce8ec51..3cd7203a93 100644 --- a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py +++ b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py @@ -109,9 +109,11 @@ def deconvNd( assert len(kernel_shape) > 0, "Deconvolution kernel shape must be non-empty" # add deconv layer + if groups is not None: + num_output_maps = num_output_maps * groups deconv_layer = ctx.net.add_deconvolution_nd( input=input, - num_output_maps=num_output_maps * groups, + num_output_maps=num_output_maps, kernel_shape=kernel_shape, kernel=trt.Weights() if isinstance(weight, TRTTensor) else weight, bias=trt.Weights() if isinstance(bias, TRTTensor) else bias, From 4720953fa4a914fa0aa82a21632f05baaf8b89d1 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 28 Oct 2025 10:53:28 -0700 Subject: [PATCH 4/7] 10019 --- docker/Dockerfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 9052992015..739e0aecc1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,8 +16,7 @@ ENV PYTHON_VERSION=${PYTHON_VERSION} ENV DEBIAN_FRONTEND=noninteractive # Install basic dependencies -RUN apt-get update -RUN apt install -y build-essential manpages-dev wget zlib1g software-properties-common git libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget ca-certificates curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev mecab-ipadic-utf8 +RUN apt-get update && apt-get install -y build-essential manpages-dev wget zlib1g software-properties-common git libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget ca-certificates curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev mecab-ipadic-utf8 # Install PyEnv and desired Python version ENV HOME="/root" @@ -34,8 +33,7 @@ RUN pyenv global ${PYTHON_VERSION} # Install TensorRT + dependencies RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub RUN add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /" -RUN apt-get update -RUN TENSORRT_MAJOR_VERSION=`echo ${TENSORRT_VERSION} | cut -d '.' -f 1` && \ +RUN apt-get update && TENSORRT_MAJOR_VERSION=`echo ${TENSORRT_VERSION} | cut -d '.' -f 1` && \ apt-get install -y libnvinfer${TENSORRT_MAJOR_VERSION}=${TENSORRT_VERSION}.* \ libnvinfer-plugin${TENSORRT_MAJOR_VERSION}=${TENSORRT_VERSION}.* \ libnvinfer-dev=${TENSORRT_VERSION}.* \ From b734e478d67491dffa1a6feb3c4ac2e2b2b403d8 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Tue, 28 Oct 2025 11:22:51 -0700 Subject: [PATCH 5/7] fix for 10015 --- py/torch_tensorrt/dynamo/conversion/impl/deconv.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py index 3cd7203a93..9d1d738adf 100644 --- a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py +++ b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py @@ -133,6 +133,8 @@ def deconvNd( padding = (padding,) if isinstance(padding, int) else padding stride = (stride,) if isinstance(stride, int) else stride dilation = (dilation,) if isinstance(dilation, int) else dilation + if output_padding is None: + output_padding = 0 output_padding = ( (output_padding,) if isinstance(output_padding, int) else output_padding ) From af4f2247035d894cb8e06312f38944043d1a2862 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Wed, 29 Oct 2025 10:25:28 -0700 Subject: [PATCH 6/7] fix 100020 --- py/torch_tensorrt/dynamo/conversion/impl/deconv.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py index 9d1d738adf..ff4d1730e3 100644 --- a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py +++ b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py @@ -145,12 +145,7 @@ def deconvNd( # stride in deconv1d is (2,) -> need to change to (2, 1) in deconv2d stride = (stride[0], 1) if stride is not None else stride dilation = (dilation[0], 1) if dilation is not None else dilation - output_padding = ( - (tuple(output_padding) + (0,)) - if output_padding is not None - else output_padding - ) - + output_padding = tuple(output_padding) + (0,) # Set relevant attributes of deconvolution layer if padding is not None: deconv_layer.padding_nd = padding From 8fcc948db0e90ec09e18e4244bf416194bbe0f26 Mon Sep 17 00:00:00 2001 From: lanluo-nvidia Date: Fri, 31 Oct 2025 11:26:50 -0700 Subject: [PATCH 7/7] resolve comments --- .../dynamo/conversion/impl/deconv.py | 8 +++-- .../dynamo/lowering/_decompositions.py | 2 +- .../fx/converters/acc_ops_converters.py | 29 +++++++------------ tests/py/dynamo/models/test_engine_cache.py | 7 ++--- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py index ff4d1730e3..9653bdf9f8 100644 --- a/py/torch_tensorrt/dynamo/conversion/impl/deconv.py +++ b/py/torch_tensorrt/dynamo/conversion/impl/deconv.py @@ -133,8 +133,6 @@ def deconvNd( padding = (padding,) if isinstance(padding, int) else padding stride = (stride,) if isinstance(stride, int) else stride dilation = (dilation,) if isinstance(dilation, int) else dilation - if output_padding is None: - output_padding = 0 output_padding = ( (output_padding,) if isinstance(output_padding, int) else output_padding ) @@ -145,7 +143,11 @@ def deconvNd( # stride in deconv1d is (2,) -> need to change to (2, 1) in deconv2d stride = (stride[0], 1) if stride is not None else stride dilation = (dilation[0], 1) if dilation is not None else dilation - output_padding = tuple(output_padding) + (0,) + output_padding = ( + (tuple(output_padding) + (0,)) + if output_padding is not None + else output_padding + ) # Set relevant attributes of deconvolution layer if padding is not None: deconv_layer.padding_nd = padding diff --git a/py/torch_tensorrt/dynamo/lowering/_decompositions.py b/py/torch_tensorrt/dynamo/lowering/_decompositions.py index 68e276d432..2372635a40 100644 --- a/py/torch_tensorrt/dynamo/lowering/_decompositions.py +++ b/py/torch_tensorrt/dynamo/lowering/_decompositions.py @@ -331,7 +331,7 @@ def reduce_operation_with_scatter( scatter_tensor = initial_tensor else: # This case would not be encountered from torch itself - raise ValueError(f"Invalid Operation for Reduce op: {self}!!") + raise ValueError(f"Invalid Operation for Reduce op: {self}") operation_rhs = torch.scatter(scatter_tensor, dim, index_tensor, src_tensor) device = to_torch_device(scatter_tensor.device) diff --git a/py/torch_tensorrt/fx/converters/acc_ops_converters.py b/py/torch_tensorrt/fx/converters/acc_ops_converters.py index 048d17d2cd..f998ddb27a 100644 --- a/py/torch_tensorrt/fx/converters/acc_ops_converters.py +++ b/py/torch_tensorrt/fx/converters/acc_ops_converters.py @@ -143,9 +143,7 @@ def acc_ops_conv_transposend( kwargs: Dict[str, Argument], name: str, ) -> Union[TRTTensor, Sequence[TRTTensor]]: - input_val = kwargs.get("input", None) - if input_val is None: - raise ValueError(f"conv_transpose received input as None") + input_val = kwargs["input"] if not isinstance(input_val, TRTTensor): raise RuntimeError( @@ -161,17 +159,12 @@ def acc_ops_conv_transposend( # for now we'll assume bias is constant Tensor or None, # and bias being ITensor is not supported in TensorRT api # right now - if kwargs.get("bias", None) is not None and not isinstance( - kwargs["bias"], torch.Tensor - ): + if kwargs["bias"] is not None and not isinstance(kwargs["bias"], torch.Tensor): raise RuntimeError( f"ConvTranspose {name} has bias of type {type(kwargs['bias'])}, Expect Optional[Tensor]" ) - bias = to_numpy(kwargs.get("bias", None)) # type: ignore[arg-type] - if kwargs.get("weight", None) is None: - raise ValueError(f"conv_transpose received weight as None") - if kwargs.get("groups", None) is None: - raise ValueError(f"conv_transpose received groups as None") + bias = to_numpy(kwargs["bias"]) # type: ignore[arg-type] + if network.has_explicit_precision or isinstance(kwargs["weight"], TRTTensor): weight = get_trt_tensor(network, kwargs["weight"], f"{name}_weight") weight_shape = tuple(kwargs["weight"].shape) # type: ignore[union-attr] @@ -208,7 +201,8 @@ def acc_ops_conv_transposend( layer.stride_nd = kwargs["stride"] layer.padding_nd = kwargs["padding"] layer.dilation_nd = kwargs["dilation"] - layer.num_groups = kwargs["groups"] + if kwargs["groups"] is not None: + layer.num_groups = kwargs["groups"] return layer.get_output(0) @@ -221,13 +215,10 @@ def acc_ops_pad_with_padding_layer( kwargs: Dict[str, Argument], name: str, ) -> Union[TRTTensor, Sequence[TRTTensor]]: - - input_val = kwargs.get("input", None) - if input_val is None: - raise ValueError(f"pad received input as None") - pad = cast(Sequence[int], kwargs.get("pad", 0)) - mode = kwargs.get("mode", None) - value = kwargs.get("value", 0) + input_val = kwargs["input"] + pad = cast(Sequence[int], kwargs["pad"]) + mode = kwargs["mode"] + value = kwargs["value"] if kwargs["value"] is not None else 0 rank = len(input_val.shape) # type: ignore[union-attr] if not isinstance(input_val, TRTTensor): diff --git a/tests/py/dynamo/models/test_engine_cache.py b/tests/py/dynamo/models/test_engine_cache.py index f1aa5313b6..5e310900aa 100644 --- a/tests/py/dynamo/models/test_engine_cache.py +++ b/tests/py/dynamo/models/test_engine_cache.py @@ -755,10 +755,9 @@ def remove_timing_cache(path=TIMING_CACHE_PATH): strip_engine_weights=strip_engine_weights, refit_identical_engine_weights=refit_identical_engine_weights, ) - # currently, strip_engine_weights is not supported in torch_tensorrt, enable it when we support it - # commenting out for now, so that coverage report will not report this line as 10012 Logically dead code - # if strip_engine_weights: - # trt_gm = refit_module_weights(trt_gm, exp_program) + + if strip_engine_weights: + trt_gm = refit_module_weights(trt_gm, exp_program) end.record() torch.cuda.synchronize()