Skip to content

Commit 250b9b7

Browse files
authored
refactor: Address some issues with enums and overhaul documentation (#2974)
1 parent 5eb33e4 commit 250b9b7

File tree

77 files changed

+1809
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1809
-376
lines changed

Diff for: .pre-commit-config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ repos:
5151
hooks:
5252
- id: black
5353
exclude: ^examples/custom_converters/elu_converter/setup.py|^docs
54+
- repo: https://github.com/crate-ci/typos
55+
rev: v1.22.9
56+
hooks:
57+
- id: typos
5458
- repo: local
5559
hooks:
5660
- id: dont-commit-upstream

Diff for: CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
66
contributors and maintainers pledge to make participation in our project and
77
our community a harassment-free experience for everyone, regardless of age, body
88
size, disability, ethnicity, sex characteristics, gender identity and expression,
9-
level of experience, education, socio-economic status, nationality, personal
9+
level of experience, education, socioeconomic status, nationality, personal
1010
appearance, race, religion, or sexual identity and orientation.
1111

1212
## Our Standards

Diff for: CONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
Do try to fill an issue with your feature or bug before filling a PR (op support is generally an exception as long as you provide tests to prove functionality). There is also a backlog (https://github.com/pytorch/TensorRT/issues) of issues which are tagged with the area of focus, a coarse priority level and whether the issue may be accessible to new contributors. Let us know if you are interested in working on a issue. We are happy to provide guidance and mentorship for new contributors. Though note, there is no claiming of issues, we prefer getting working code quickly vs. addressing concerns about "wasted work".
66

7-
#### Development enviornment
7+
#### Development environment
88

9-
Our build system relies on `bazel` (https://bazel.build/). Though there are many ways to install `bazel`, the prefered method is to use `bazelisk` (https://github.com/bazelbuild/bazelisk) which makes it simple to set up the correct version of bazel on the fly. Additional developement dependencies can be installed via the `requirements-dev.txt` file.
9+
Our build system relies on `bazel` (https://bazel.build/). Though there are many ways to install `bazel`, the preferred method is to use `bazelisk` (https://github.com/bazelbuild/bazelisk) which makes it simple to set up the correct version of bazel on the fly. Additional development dependencies can be installed via the `requirements-dev.txt` file.
1010

1111
#### Communication
1212

@@ -27,7 +27,7 @@ We use the PyTorch Slack for communication about core development, integration w
2727

2828
- Avoid introducing unnecessary complexity into existing code so that maintainability and readability are preserved
2929

30-
- Try to avoid commiting commented out code
30+
- Try to avoid committing commented out code
3131

3232
- Minimize warnings (and no errors) from the compiler
3333

Diff for: cmake/paths.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(ARCHIVE_OUTPUT_DIRECTORY "lib")
66
set(RUNTIME_OUTPUT_DIRECTORY "bin")
77
set(HEADERS_OUTPUT_DIRECTORY "include")
88

9-
#Set target ouput directory in the build directory
9+
#Set target output directory in the build directory
1010
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ARCHIVE_OUTPUT_DIRECTORY}")
1111
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${LIBRARY_OUTPUT_DIRECTORY}")
1212
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${RUNTIME_OUTPUT_DIRECTORY}")

Diff for: dev_dep_versions.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
__version__: "2.5.0.dev0"
21
__cuda_version__: "12.4"
32
__tensorrt_version__: "10.0.1"

Diff for: docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ RUN TENSORRT_MAJOR_VERSION=`echo ${TENSORRT_VERSION} | cut -d '.' -f 1` && \
5050
RUN wget -q https://github.com/bazelbuild/bazelisk/releases/download/v1.17.0/bazelisk-linux-amd64 -O /usr/bin/bazel &&\
5151
chmod a+x /usr/bin/bazel
5252

53-
# Build Torch-TensorRT in an auxillary container
53+
# Build Torch-TensorRT in an auxiliary container
5454
FROM base as torch-tensorrt-builder-base
5555

5656
ARG ARCH="x86_64"

Diff for: docker/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ nvidia-docker run --gpus all -it --shm-size=8gb --env="DISPLAY" --volume="/tmp/.
3535
Test:
3636

3737

38-
You can run any converter test to verify if Torch-TRT built sucessfully inside the container. Once you launch the container, you can run
38+
You can run any converter test to verify if Torch-TRT built successfully inside the container. Once you launch the container, you can run
3939
```
4040
bazel test //tests/core/conversion/converters:test_activation --compilation_mode=opt --test_output=summary --config use_precompiled_torchtrt --config pre_cxx11_abi
4141
```

Diff for: docsrc/RELEASE_CHECKLIST.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ While Torch-TensorRT is in alpha, patch versions are bumped sequentially on brea
99
In beta Torch-TensorRT will get a minor version bump on breaking changes, or upgrade to the next version of PyTorch, patch version will be incremented based on significant bug fixes, or siginficant new functionality in the compiler.
1010

1111
Once Torch-TensorRT hits version 1.0.0, major versions are bumped on breaking API changes, breaking changes or significant new functionality in the compiler
12-
will result in a minor version bump and sigificant bug fixes will result in a patch version change.
12+
will result in a minor version bump and significant bug fixes will result in a patch version change.
1313

1414
## Steps to Packaging a Release
1515

@@ -50,7 +50,7 @@ will result in a minor version bump and sigificant bug fixes will result in a pa
5050
- `[3, 1920, 1080]` (P2)
5151
- Batch Sizes: 1, 4, 8, 16, 32
5252
- Frameworks: PyTorch, Torch-TensorRT, ONNX + TRT
53-
- If any models do not convert to ONNX / TRT, that is fine. Mark them as failling / no result
53+
- If any models do not convert to ONNX / TRT, that is fine. Mark them as failing / no result
5454
- Devices:
5555
- A100 (P0)
5656
- A30 / A30 MIG (P1) (same batches as T4

Diff for: docsrc/conf.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# -- Project information -----------------------------------------------------
2626

2727
project = "Torch-TensorRT"
28-
copyright = "2022, NVIDIA Corporation"
28+
copyright = "2024, NVIDIA Corporation"
2929
author = "NVIDIA Corporation"
3030

3131
version = f"v{torch_tensorrt.__version__}"
@@ -151,6 +151,9 @@
151151
"master_doc": True,
152152
"version_info": {
153153
"main": "https://pytorch.org/TensorRT/",
154+
"v2.3.0": "https://pytorch.org/TensorRT/v2.3.0",
155+
"v2.2.0": "https://pytorch.org/TensorRT/v2.2.0",
156+
"v2.1.0": "https://pytorch.org/TensorRT/v2.1.0",
154157
"v1.4.0": "https://pytorch.org/TensorRT/v1.4.0",
155158
"v1.3.0": "https://pytorch.org/TensorRT/v1.3.0",
156159
"v1.2.0": "https://pytorch.org/TensorRT/v1.2.0",
@@ -186,6 +189,8 @@
186189

187190
nbsphinx_execute = "never"
188191

192+
autodoc_member_order = "groupwise"
193+
189194
# -- A patch that prevents Sphinx from cross-referencing ivar tags -------
190195
# See http://stackoverflow.com/a/41184353/3343043
191196

Diff for: docsrc/contributors/conversion.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Conversion Phase
44
==================
55

6-
Once the graph has be simplified to a form thats easy to convert, we then set up a conversion context
6+
Once the graph has be simplified to a form that's easy to convert, we then set up a conversion context
77
to manage the construction of a TensorRT ``INetworkDefinition`` from the blocks nodes. The conversion context
88
records the set of converted nodes, block inputs and outputs and other information about the conversion
99
of the graph. This data is then used to help converters link together layers and also hold build time

Diff for: docsrc/contributors/dynamo_converters.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The decorator takes a number of arguments:
3636
All that is required for a converter is the key.
3737

3838
The function body is responsible for taking the current state of the network and adding the next subgraph to perform the op specified in the decorator with TensorRT operations.
39-
The function is provided arguments as the native PyTorch op would be provided with the added case of numpy arrays for frozen Tensor attributes or TensorRT ITensors which are ouput Tensors of previous nodes, correspoding to edges/output Tensors of intermediate operations in the graph.
39+
The function is provided arguments as the native PyTorch op would be provided with the added case of numpy arrays for frozen Tensor attributes or TensorRT ITensors which are output Tensors of previous nodes, corresponding to edges/output Tensors of intermediate operations in the graph.
4040
To determine the types expected as well as the return type of the converter, look at the definition of the op being converted. In the case of ``aten`` operations, this file will be the source of truth: https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/native_functions.yaml
4141
Since many converters a developer may write are a composition of lower level operators, instead of needing to implement the converter in raw TensorRT, the ``torch_tensorrt.dynamo.conversion.impl`` subpackage contains many implementations of operations that can be chained to create a TensorRT subgraph.
4242

@@ -53,14 +53,14 @@ Capability Validation
5353

5454
There are some converters which have special cases to be accounted for. In those cases, one should use ``capability_validators`` to register the converter using ``@dynamo_tensorrt_converter``
5555
We illustrate this through ``torch.ops.aten.embedding.default``. It has parameters - ``scale_grad_by_freq`` and ``sparse`` which are not currently supported by the implementation.
56-
In such cases we can write validator ``embedding_param_validator`` which implements that given those paramters the converter is not supported and register the converter by
56+
In such cases we can write validator ``embedding_param_validator`` which implements that given those parameters the converter is not supported and register the converter by
5757

5858

5959
Type Contract
6060
^^^^^^^^^^^^^^^
6161

6262
The function is expected to follow the type contract established by the signature. This includes accepting the union of valid PyTorch types + numpy arrays for constant tensors and TensorRT ITensors.
63-
In the case that only a subset of types is supported in the converter, you can also add the ``torch_tensorrt.dynamo.conversion.converter_utils.enforce_tensor_types``, which allows you to specify a dictionary mapping between input positions and types that those inputs can take. Where possible the decorator will convert inputs to match these types prefering the order provided.
63+
In the case that only a subset of types is supported in the converter, you can also add the ``torch_tensorrt.dynamo.conversion.converter_utils.enforce_tensor_types``, which allows you to specify a dictionary mapping between input positions and types that those inputs can take. Where possible the decorator will convert inputs to match these types preferring the order provided.
6464
``int`` keys in the dictionary will refer to positional arguments in ``args``. ``str`` keys will refer to keyword arguments in ``kwargs``.
6565

6666

@@ -105,7 +105,7 @@ Some operations do not produce TensorRT subgraphs as a side-effect. These are te
105105
Operator Decomposition
106106
-----------------------
107107

108-
There are some converters which can be decomposed into suboperations in PyTorch and need not have seperate converter registration.
108+
There are some converters which can be decomposed into suboperations in PyTorch and need not have separate converter registration.
109109
Such converters can be implemented via a decomposition
110110

111111
Example: ``addmm``

Diff for: docsrc/contributors/lowering.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ Eliminate Dead Code
3030

3131
Dead code elimination will check if a node has side effects and not delete it if it does.
3232

33-
Eliminate Exeception Or Pass Pattern
33+
Eliminate Exception Or Pass Pattern
3434
***************************************
3535

3636
`Torch-TensorRT/core/lowering/passes/exception_elimination.cpp <https://github.com/pytorch/TensorRT/blob/master/core/lowering/passes/exception_elimination.cpp>`_
3737

38-
A common pattern in scripted modules are dimension gaurds which will throw execptions if
38+
A common pattern in scripted modules are dimension guards which will throw exceptions if
3939
the input dimension is not what was expected.
4040

4141
.. code-block:: none
@@ -48,9 +48,9 @@ the input dimension is not what was expected.
4848
block1():
4949
-> ()
5050
51-
Since we are resolving all of this at compile time and there are no execptions in the TensorRT graph, we just remove it.
51+
Since we are resolving all of this at compile time and there are no exceptions in the TensorRT graph, we just remove it.
5252

53-
Eliminate Redundant Gaurds
53+
Eliminate Redundant Guards
5454
***************************************
5555

5656
`torch/csrc/jit/passes/guard_elimination.h <https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/passes/guard_elimination.h>`_
@@ -63,15 +63,15 @@ Freeze Module
6363

6464
`torch/csrc/jit/passes/freeze_module.h <https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/passes/freeze_module.h>`_
6565

66-
Freeze attributes and inline constants and modules. Propogates constants in the graph.
66+
Freeze attributes and inline constants and modules. Propagates constants in the graph.
6767

6868
Fuse AddMM Branches
6969
***************************************
7070

7171
`Torch-TensorRT/core/lowering/passes/fuse_addmm_branches.cpp <https://github.com/pytorch/TensorRT/blob/master/core/lowering/passes/fuse_addmm_branches.cpp>`_
7272

7373
A common pattern in scripted modules is tensors of different dimensions use different constructions for implementing linear layers. We fuse these
74-
different varients into a single one that will get caught by the Unpack AddMM pass.
74+
different variants into a single one that will get caught by the Unpack AddMM pass.
7575

7676
.. code-block:: none
7777
@@ -103,7 +103,7 @@ Fuse Flatten Linear
103103

104104
`Torch-TensorRT/core/lowering/passes/fuse_flatten_linear.cpp <https://github.com/pytorch/TensorRT/blob/master/core/lowering/passes/fuse_flatten_linear.cpp>`_
105105

106-
TensorRT implicity flattens input layers into fully connected layers when they are higher than 1D. So when there is a
106+
TensorRT implicitly flattens input layers into fully connected layers when they are higher than 1D. So when there is a
107107
``aten::flatten`` -> ``aten::linear`` pattern we remove the ``aten::flatten``.
108108

109109
Lower Graph
@@ -147,7 +147,7 @@ Places delimiting nodes around module calls pre freezing to signify where in the
147147

148148
Looks for delimiters then marks all nodes between the delimiters to tell partitioning to run them in PyTorch
149149

150-
Peephole Optimze
150+
Peephole Optimize
151151
***************************************
152152

153153
`torch/csrc/jit/passes/peephole_optimze.h <https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/passes/ppeephole_optimze.h>`_
@@ -179,7 +179,7 @@ Remove To
179179

180180
`Torch-TensorRT/core/lowering/passes/remove_to.cpp <https://github.com/pytorch/TensorRT/blob/master/core/lowering/passes/remove_to.cpp>`_
181181

182-
Removes ``aten::to`` operators that do casting, since TensorRT mangages it itself. It is important that this is one of the last passes run so that
182+
Removes ``aten::to`` operators that do casting, since TensorRT manages it itself. It is important that this is one of the last passes run so that
183183
other passes have a change to move required cast operators out of the main namespace.
184184

185185
Unpack AddMM
@@ -204,7 +204,7 @@ Unroll Loops
204204

205205
`torch/csrc/jit/passes/loop_unrolling.h <https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/passes/loop_unrolling.h>`_
206206

207-
Unrolls the operations of compatable loops (e.g. sufficently short) so that you only have to go through the loop once.
207+
Unrolls the operations of compatible loops (e.g. sufficiently short) so that you only have to go through the loop once.
208208

209209
Replace Tile with Repeat
210210
***************************************

Diff for: docsrc/contributors/runtime.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Runtime Phase
66
The Runtime phase is responsible for constructing self standing TorchScript graphs with embedded TensorRT engines and serving as the runtime
77
when these engines are called. The main interface accepts a serialized TensorRT engine. The execution phase
88
will deserialize and wrap this engine in a class which maintains a execution context for each engine
9-
and some metadata about its inputs and outputs and is compatable with the TorchScript interpreter so that
9+
and some metadata about its inputs and outputs and is compatible with the TorchScript interpreter so that
1010
it can be moved around and used like other TorchScript IValues. The engine is run by providing it and inputs
11-
to the ``tensorrt::execute_engine`` operator which will take the engine and its inputs and return the results of engine exeuction.
11+
to the ``tensorrt::execute_engine`` operator which will take the engine and its inputs and return the results of engine execution.
1212

1313

1414
Background

Diff for: docsrc/dynamo/dynamo_export.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ usage of the dynamo frontend
2727
2828
.. note:: ``torch_tensorrt.dynamo.compile`` is the main API for users to interact with Torch-TensorRT dynamo frontend. The input type of the model should be ``ExportedProgram`` (ideally the output of ``torch.export.export`` or ``torch_tensorrt.dynamo.trace`` (discussed in the section below)) and output type is a ``torch.fx.GraphModule`` object.
2929

30-
Customizeable Settings
30+
Customizable Settings
3131
----------------------
3232

3333
There are lot of options for users to customize their settings for optimizing with TensorRT.

Diff for: docsrc/dynamo/torch_compile.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The primary goal of the Torch-TensorRT `torch.compile` backend is to enable Just
2626

2727
The backend can handle a variety of challenging model structures and offers a simple-to-use interface for effective acceleration of models. Additionally, it has many customization options to ensure the compilation process is fitting to the specific use case.
2828

29-
Customizeable Settings
29+
Customizable Settings
3030
-----------------
3131
.. autoclass:: CompilationSettings
3232

@@ -87,7 +87,7 @@ If key operators for your model are unsupported, see :ref:`dynamo_conversion` to
8787

8888
Feasibility of Serialization
8989
^^^^^^^^^^^^^^^^^
90-
Compilation can also be helpful in demonstrating graph breaks and the feasibility of serialization of a particular model. For instance, if a model has no graph breaks and compiles successfully with the Torch-TensorRT backend, then that model should be compileable and serializeable via the `torch_tensorrt` Dynamo IR, as discussed in :ref:`dynamic_shapes`. To determine the number of graph breaks in a model, the `torch._dynamo.explain` function is very useful:
90+
Compilation can also be helpful in demonstrating graph breaks and the feasibility of serialization of a particular model. For instance, if a model has no graph breaks and compiles successfully with the Torch-TensorRT backend, then that model should be compilable and serializeable via the `torch_tensorrt` Dynamo IR, as discussed in :ref:`dynamic_shapes`. To determine the number of graph breaks in a model, the `torch._dynamo.explain` function is very useful:
9191

9292
.. code-block:: python
9393

Diff for: docsrc/getting_started/getting_started_with_windows.rst

-34
This file was deleted.

0 commit comments

Comments
 (0)