aitune.torch.backend.torch_tensorrt_aot_backend
aitune.torch.backend.torch_tensorrt_aot_backend
TorchTensorRT backend with AOT compilation and intermediate model save.
Module Contents
Classes
Functions
Data
API
Bases: Backend
Backend that compiles model using TensorRT.
Load compiled module.
Build the model with TensorRT.
Exports the module via torch.export.export with shared Dim instances
across inputs, then hands the resulting ExportedProgram to
torch_tensorrt.dynamo.compile. This replaces the previous flow that called
torch_tensorrt.compile and let it run its own export, which built one
independent Dim per Input and raised ConstraintViolationError
whenever two inputs had to share a runtime axis (e.g. HF encoders’ shared
batch on input_ids and attention_mask).
Workaround pending a dynamic_shapes passthrough on torch_tensorrt.compile;
revert to torch_tensorrt.compile(...) once that lands upstream.
Create path to exported model.
In order to avoid name clashes we create a unique path for each model and graph spec.
Deactivate backend and cleanup.
Deploys the backend.
Run inference with TensorRT engine.
Parameters:
Inference arguments
Inference keyword arguments
Returns: Any
Model outputs
Store the backend configuration to a file.
Returns the description of the backend.
Creates a backend from a state_dict.
Returns the key of the backend.
Returns the state_dict of the backend.
Bases: BackendConfig
Configuration for TorchTensorRTAotBackend.
See torch_tensorrt/dynamo/_settings.py CompilationSettings for compile_config(TorchTensorRTConfig)
Describe the backend configuration. Display only changed fields.
Initialise config from a plain dict (e.g. parsed from YAML).
compile_config may be passed as a nested dict and will be
reconstructed into a TorchTensorRTConfig instance automatically.
Saves the backend configuration to a file.
Bases: BackendBuildStep
Identifiers for discrete sub-steps of a TorchTensorRTAot backend build.
Fallback settings matching upstream defaults when torch_tensorrt is unavailable.
Check if a value is a primitive type (int, float, str, bool).
Check if torch_tensorrt is installed.