Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions docsrc/user_guide/compilation/compilation_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,22 @@ Graph Partitioning
engine boundary. Only static shapes are rewritten. Fewer, larger engines can
need much more time and memory to build and to run, so measure it.
* - ``convert_antialiased_resize``
- ``False``
- Run antialiased bilinear and bicubic resize (``F.interpolate`` with
``antialias=True``) in TensorRT instead of PyTorch, so it does not split the
graph. Only static input and output heights and widths and floating-point
inputs are converted. Some sizes run slower than in PyTorch, so measure it.
- ``None``
- Which antialiased resizes (``F.interpolate`` with ``antialias=True``) run in
TensorRT instead of PyTorch, so they do not split the graph. ``None``
converts float32 bilinear downscales with at most 6 input pixels per output
pixel along each axis (up to about 3x); upscales stay in PyTorch. In our
measurements on A100, H100 and Jetson Orin GPUs with TensorRT 11.4 and a
PyTorch 2.16 build for CUDA 13.2, its output matched PyTorch's CUDA kernel bit
for bit. On other GPUs, on TensorRT-RTX or with other TensorRT versions it can
differ by a few float32 roundings, enough to change a value that is rounded to
an integer afterwards. ``True`` converts every bilinear and bicubic resize,
which can differ from PyTorch in the same way. ``False`` keeps them all in
PyTorch, as does listing the operator, such as
``torch.ops.aten._upsample_bilinear2d_aa.default``, in ``torch_executed_ops``;
use either to get PyTorch's exact output, for example before rounding to uint8.
Only static input and output heights and widths and floating-point inputs are
converted. Some sizes run slower than in PyTorch, so measure it.
* - ``replace_interleave_stack_with_cat``
- ``False``
- Write a stack whose only user is a reshape that merges the new axis into a
Expand Down
12 changes: 6 additions & 6 deletions py/torch_tensorrt/dynamo/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def cross_compile_for_windows(
fallback_data_dependent_ops: bool = _defaults.FALLBACK_DATA_DEPENDENT_OPS,
fallback_pytorch_plugin_ops: bool = _defaults.FALLBACK_PYTORCH_PLUGIN_OPS,
collapse_high_rank_permutes: bool = _defaults.COLLAPSE_HIGH_RANK_PERMUTES,
convert_antialiased_resize: bool = _defaults.CONVERT_ANTIALIASED_RESIZE,
convert_antialiased_resize: Optional[bool] = _defaults.CONVERT_ANTIALIASED_RESIZE,
replace_interleave_stack_with_cat: bool = _defaults.REPLACE_INTERLEAVE_STACK_WITH_CAT,
**kwargs: Any,
) -> torch.fx.GraphModule:
Expand Down Expand Up @@ -267,7 +267,7 @@ def cross_compile_for_windows(
fallback_data_dependent_ops (bool): If True, operators whose converters require a TensorRT output allocator (i.e. data-dependent output shapes, such as nonzero) are added to torch_executed_ops and run in PyTorch instead of being lowered into a TensorRT engine. This is useful when targeting runtimes that cannot consume a TensorRT output allocator. Default is False.
fallback_pytorch_plugin_ops (bool): If True, operators whose converters insert a TensorRT plugin that runs PyTorch (such as aten.index_put with accumulate=True, which uses Torch-TensorRT's ScatterAdd plugin, or a generated plugin without an AOT kernel) run in PyTorch instead of being lowered into a TensorRT engine. An accumulating aten.index_put with one 1-D index then stays in TensorRT through TensorRT's ScatterElements plugin, which needs no PyTorch. This needs float32, float16, bfloat16, int32 or int64 data. The input and the values it receives (the input's shape with the indexed dimension set to the index length) must stay under 2**31 elements, so every dynamic size needs an upper bound in the exported program, such as torch.export.Dim(max=...), that keeps them there. Otherwise the operator runs in PyTorch. Use it for runtimes without PyTorch, such as the ExecuTorch TensorRT runtime. Default is False.
collapse_high_rank_permutes (bool): Rewrite a reshape, permute, reshape chain over more than 8 dimensions, TensorRT's limit, as reshapes and permutes of at most 8 dimensions that give the same values. Window and patch layouts, such as neighborhood attention and the Qwen2-VL image patches, build such chains. Left in PyTorch, each one splits the graph, and the partitioner can then hand many large tensors across one engine boundary. Only static shapes are rewritten. Fewer, larger engines can need much more time and memory to build and to run, so measure it. Default is False.
convert_antialiased_resize (bool): Run antialiased bilinear and bicubic resize (F.interpolate with antialias=True) in TensorRT instead of PyTorch, so it does not split the graph. Only static input and output heights and widths and floating-point inputs are converted. Some sizes run slower than in PyTorch, so measure it. Default is False.
convert_antialiased_resize (Optional[bool]): Which antialiased resizes (F.interpolate with antialias=True) run in TensorRT instead of PyTorch, so they do not split the graph. None converts float32 bilinear downscales with at most 6 input pixels per output pixel along each axis (up to about 3x); upscales stay in PyTorch. In our measurements on Linux with A100, H100 and Jetson Orin GPUs with TensorRT 11.4 and a PyTorch 2.16 build for CUDA 13.2, its output matched PyTorch's CUDA kernel bit for bit. On other GPUs, on TensorRT-RTX or with other TensorRT versions it can differ by a few float32 roundings, enough to change a value that is rounded to an integer afterwards. True converts every bilinear and bicubic resize, which can differ from PyTorch in the same way. False keeps them all in PyTorch, as does listing the operator, such as torch.ops.aten._upsample_bilinear2d_aa.default, in torch_executed_ops; use either to get PyTorch's exact output, for example before rounding to uint8. Only static input and output heights and widths and floating-point inputs are converted. Some sizes run slower than in PyTorch, so measure it. Default is None.
replace_interleave_stack_with_cat (bool): Write a stack whose only user is a reshape that merges the new axis into a neighbor axis, as in torch.stack([even, odd], dim=3).flatten(2, 3) for a 2x upsample, as a concatenation of unsqueezed inputs. This can make large, image-sized interleaves faster on GPUs where TensorRT fuses the region around them, but slower where TensorRT runs them as separate layers and adds copies, so measure it. Only programs from torch.export are rewritten, not torch.compile graphs. Default is False.
**kwargs: Any,
Returns:
Expand Down Expand Up @@ -588,7 +588,7 @@ def compile(
fallback_data_dependent_ops: bool = _defaults.FALLBACK_DATA_DEPENDENT_OPS,
fallback_pytorch_plugin_ops: bool = _defaults.FALLBACK_PYTORCH_PLUGIN_OPS,
collapse_high_rank_permutes: bool = _defaults.COLLAPSE_HIGH_RANK_PERMUTES,
convert_antialiased_resize: bool = _defaults.CONVERT_ANTIALIASED_RESIZE,
convert_antialiased_resize: Optional[bool] = _defaults.CONVERT_ANTIALIASED_RESIZE,
replace_interleave_stack_with_cat: bool = _defaults.REPLACE_INTERLEAVE_STACK_WITH_CAT,
build_route: Optional[str] = _defaults.BUILD_ROUTE,
tune_build_routes: Optional[str] = _defaults.TUNE_BUILD_ROUTES,
Expand Down Expand Up @@ -719,7 +719,7 @@ def compile(
fallback_data_dependent_ops (bool): If True, operators whose converters require a TensorRT output allocator (i.e. data-dependent output shapes, such as nonzero) are added to torch_executed_ops and run in PyTorch instead of being lowered into a TensorRT engine. This is useful when targeting runtimes that cannot consume a TensorRT output allocator. Default is False.
fallback_pytorch_plugin_ops (bool): If True, operators whose converters insert a TensorRT plugin that runs PyTorch (such as aten.index_put with accumulate=True, which uses Torch-TensorRT's ScatterAdd plugin, or a generated plugin without an AOT kernel) run in PyTorch instead of being lowered into a TensorRT engine. An accumulating aten.index_put with one 1-D index then stays in TensorRT through TensorRT's ScatterElements plugin, which needs no PyTorch. This needs float32, float16, bfloat16, int32 or int64 data. The input and the values it receives (the input's shape with the indexed dimension set to the index length) must stay under 2**31 elements, so every dynamic size needs an upper bound in the exported program, such as torch.export.Dim(max=...), that keeps them there. Otherwise the operator runs in PyTorch. Use it for runtimes without PyTorch, such as the ExecuTorch TensorRT runtime. Default is False.
collapse_high_rank_permutes (bool): Rewrite a reshape, permute, reshape chain over more than 8 dimensions, TensorRT's limit, as reshapes and permutes of at most 8 dimensions that give the same values. Window and patch layouts, such as neighborhood attention and the Qwen2-VL image patches, build such chains. Left in PyTorch, each one splits the graph, and the partitioner can then hand many large tensors across one engine boundary. Only static shapes are rewritten. Fewer, larger engines can need much more time and memory to build and to run, so measure it. Default is False.
convert_antialiased_resize (bool): Run antialiased bilinear and bicubic resize (F.interpolate with antialias=True) in TensorRT instead of PyTorch, so it does not split the graph. Only static input and output heights and widths and floating-point inputs are converted. Some sizes run slower than in PyTorch, so measure it. Default is False.
convert_antialiased_resize (Optional[bool]): Which antialiased resizes (F.interpolate with antialias=True) run in TensorRT instead of PyTorch, so they do not split the graph. None converts float32 bilinear downscales with at most 6 input pixels per output pixel along each axis (up to about 3x); upscales stay in PyTorch. In our measurements on A100, H100 and Jetson Orin GPUs with TensorRT 11.4 and a PyTorch 2.16 build for CUDA 13.2, its output matched PyTorch's CUDA kernel bit for bit. On other GPUs, on TensorRT-RTX or with other TensorRT versions it can differ by a few float32 roundings, enough to change a value that is rounded to an integer afterwards. True converts every bilinear and bicubic resize, which can differ from PyTorch in the same way. False keeps them all in PyTorch, as does listing the operator, such as torch.ops.aten._upsample_bilinear2d_aa.default, in torch_executed_ops; use either to get PyTorch's exact output, for example before rounding to uint8. Only static input and output heights and widths and floating-point inputs are converted. Some sizes run slower than in PyTorch, so measure it. Default is None.
replace_interleave_stack_with_cat (bool): Write a stack whose only user is a reshape that merges the new axis into a neighbor axis, as in torch.stack([even, odd], dim=3).flatten(2, 3) for a 2x upsample, as a concatenation of unsqueezed inputs. This can make large, image-sized interleaves faster on GPUs where TensorRT fuses the region around them, but slower where TensorRT runs them as separate layers and adds copies, so measure it. Only programs from torch.export are rewritten, not torch.compile graphs. Default is False.
build_route (Optional[str]): TensorRT Global Performance Tuning build route string (space-separated "-knob=value" tokens). None uses the default route. This feature requires TensorRT with Global Performance Tuning enabled; currently unavailable on TensorRT-RTX / Windows.
tune_build_routes (Optional[str]): Build-route expression for an autotuning sweep that runs each candidate in a spawned child process (e.g. "-slice_fusion=[on|off] -kgen:codegen:cuda_tile=[0|1|2|3]"). None disables tuning.
Expand Down Expand Up @@ -2255,7 +2255,7 @@ def convert_exported_program_to_serialized_trt_engine(
deduplicate_weights: bool = _defaults.DEDUPLICATE_WEIGHTS,
fallback_pytorch_plugin_ops: bool = _defaults.FALLBACK_PYTORCH_PLUGIN_OPS,
collapse_high_rank_permutes: bool = _defaults.COLLAPSE_HIGH_RANK_PERMUTES,
convert_antialiased_resize: bool = _defaults.CONVERT_ANTIALIASED_RESIZE,
convert_antialiased_resize: Optional[bool] = _defaults.CONVERT_ANTIALIASED_RESIZE,
replace_interleave_stack_with_cat: bool = _defaults.REPLACE_INTERLEAVE_STACK_WITH_CAT,
lift_mutable_buffers: bool = False,
arg_input_binding_names: Any = None,
Expand Down Expand Up @@ -2374,7 +2374,7 @@ def convert_exported_program_to_serialized_trt_engine(
deduplicate_weights (bool): Add a weight that several layers read to the TensorRT network once instead of once per layer, and give the linear layers that share a weight one transposed copy of it. This cuts engine-build host memory for models that reuse weights, such as a denoising loop unrolled into one graph, most of all in float32 builds with disable_tf32=True and in refittable engines. TensorRT may pick other kernels, so results can round differently, and some models need more memory instead, so measure it. Default is False.
fallback_pytorch_plugin_ops (bool): If True, skip converters that insert a TensorRT plugin that runs PyTorch (such as aten.index_put with accumulate=True, which uses Torch-TensorRT's ScatterAdd plugin, or a generated plugin without an AOT kernel), so the engine runs without PyTorch. This function builds one engine for the whole program, so an operator that only such a converter supports fails to convert. An accumulating aten.index_put with one 1-D index then uses TensorRT's ScatterElements plugin, which needs no PyTorch. This needs float32, float16, bfloat16, int32 or int64 data. The input and the values it receives (the input's shape with the indexed dimension set to the index length) must stay under 2**31 elements, so every dynamic size needs an upper bound in the exported program, such as torch.export.Dim(max=...), that keeps them there. Default is False.
collapse_high_rank_permutes (bool): Rewrite a reshape, permute, reshape chain over more than 8 dimensions, TensorRT's limit, as reshapes and permutes of at most 8 dimensions that give the same values. Window and patch layouts, such as neighborhood attention and the Qwen2-VL image patches, build such chains. This function builds one engine, so without the rewrite such a chain makes the conversion fail. Only static shapes are rewritten. A large engine can need much more time and memory to build and to run, so measure it. Default is False.
convert_antialiased_resize (bool): Convert antialiased bilinear and bicubic resize (F.interpolate with antialias=True) to TensorRT. This function builds one engine, so without this setting such a resize makes the conversion fail. Only static input and output heights and widths and floating-point inputs are converted. Some sizes run slower than in PyTorch, so measure it. Default is False.
convert_antialiased_resize (Optional[bool]): Which antialiased resizes (F.interpolate with antialias=True) convert to TensorRT. None converts float32 bilinear downscales with at most 6 input pixels per output pixel along each axis (up to about 3x); upscales stay in PyTorch. In our measurements on A100, H100 and Jetson Orin GPUs with TensorRT 11.4 and a PyTorch 2.16 build for CUDA 13.2, its output matched PyTorch's CUDA kernel bit for bit. On other GPUs, on TensorRT-RTX or with other TensorRT versions it can differ by a few float32 roundings, enough to change a value that is rounded to an integer afterwards. True converts every bilinear and bicubic resize, which can differ from PyTorch in the same way. False converts none. This function builds one engine, so a resize that is not converted makes the conversion fail. Only static input and output heights and widths and floating-point inputs are converted. Some sizes run slower than in PyTorch, so measure it. Default is None.
replace_interleave_stack_with_cat (bool): Write a stack whose only user is a reshape that merges the new axis into a neighbor axis, as in torch.stack([even, odd], dim=3).flatten(2, 3) for a 2x upsample, as a concatenation of unsqueezed inputs. This can make large, image-sized interleaves faster on GPUs where TensorRT fuses the region around them, but slower where TensorRT runs them as separate layers and adds copies, so measure it. Only programs from torch.export are rewritten, not torch.compile graphs. Default is False.
**kwargs: Any,
Returns:
Expand Down
2 changes: 1 addition & 1 deletion py/torch_tensorrt/dynamo/_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
FALLBACK_DATA_DEPENDENT_OPS = False
FALLBACK_PYTORCH_PLUGIN_OPS = False
COLLAPSE_HIGH_RANK_PERMUTES = False
CONVERT_ANTIALIASED_RESIZE = False
CONVERT_ANTIALIASED_RESIZE = None
REPLACE_INTERLEAVE_STACK_WITH_CAT = False

# Global Performance Tuning (TensorRT build-route knobs)
Expand Down
Loading
Loading