Skip to content

Commit

Permalink
Deprecate torchscript frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
narendasan committed Jan 31, 2025
1 parent 52227da commit 48ec3cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cpp/include/torch_tensorrt/ptq.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Int8Calibrator : Algorithm {
* calibration cache
* @param use_cache : bool - Whether to use the cache (if it exists)
*/
Int8Calibrator(DataLoaderUniquePtr dataloader, const std::string& cache_file_path, bool use_cache)
Int8Calibrator(DataLoaderUniquePtr dataloader, const std::string& cache_file_path, bool use_cache)
: dataloader_(dataloader.get()), cache_file_path_(cache_file_path), use_cache_(use_cache) {
for (auto batch : *dataloader_) {
batched_data_.push_back(batch.data);
Expand Down Expand Up @@ -308,8 +308,8 @@ class Int8CacheCalibrator : Algorithm {
* @param use_cache: bool - use calibration cache
* @return Int8Calibrator<Algorithm, DataLoader>
*/

template <typename Algorithm = nvinfer1::IInt8EntropyCalibrator2, typename DataLoader>
[[deprecated("Int8 PTQ Calibrator has been deprecated by TensorRT, please plan on porting to a NVIDIA Model Optimizer Toolkit based workflow. See: https://pytorch.org/TensorRT/tutorials/_rendered_examples/dynamo/vgg16_ptq.html for more details")]]
inline Int8Calibrator<Algorithm, DataLoader> make_int8_calibrator(
DataLoader dataloader,
const std::string& cache_file_path,
Expand Down Expand Up @@ -344,6 +344,7 @@ inline Int8Calibrator<Algorithm, DataLoader> make_int8_calibrator(
* @return Int8CacheCalibrator<Algorithm>
*/
template <typename Algorithm = nvinfer1::IInt8EntropyCalibrator2>
[[deprecated("Int8 PTQ Calibrator has been deprecated by TensorRT, please plan on porting to a NVIDIA Model Optimizer Toolkit based workflow. See: https://pytorch.org/TensorRT/tutorials/_rendered_examples/dynamo/vgg16_ptq.html for more details")]]
inline Int8CacheCalibrator<Algorithm> make_int8_cache_calibrator(const std::string& cache_file_path) {
return Int8CacheCalibrator<Algorithm>(cache_file_path);
}
Expand Down
9 changes: 9 additions & 0 deletions py/torch_tensorrt/ts/_compiler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import warnings
from typing import Any, List, Optional, Sequence, Set, Tuple

import torch
Expand Down Expand Up @@ -102,6 +103,10 @@ def compile(
torch.jit.ScriptModule: Compiled TorchScript Module, when run it will execute via TensorRT
"""

warnings.warn(
'The torchscript frontend for Torch-TensorRT has been deprecated, please plan on porting to the dynamo frontend (torch_tensorrt.compile(..., ir="dynamo"). Torchscript will continue to be a supported deployment format via post compilation torchscript tracing, see: https://pytorch.org/TensorRT/user_guide/saving_models.html for more details'
)

input_list = list(inputs) if inputs is not None else []
enabled_precisions_set = (
enabled_precisions if enabled_precisions is not None else set()
Expand Down Expand Up @@ -240,6 +245,10 @@ def convert_method_to_trt_engine(
Returns:
bytes: Serialized TensorRT engine, can either be saved to a file or deserialized via TensorRT APIs
"""
warnings.warn(
'The torchscript frontend for Torch-TensorRT has been deprecated, please plan on porting to the dynamo frontend (torch_tensorrt.convert_method_to_trt_engine(..., ir="dynamo"). Torchscript will continue to be a supported deployment format via post compilation torchscript tracing, see: https://pytorch.org/TensorRT/user_guide/saving_models.html for more details'
)

input_list = list(inputs) if inputs is not None else []
enabled_precisions_set = (
enabled_precisions if enabled_precisions is not None else {torch.float}
Expand Down
8 changes: 8 additions & 0 deletions py/torch_tensorrt/ts/ptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from torch_tensorrt import _C
from torch_tensorrt.ts.logging import Level, log

import warnings


class CalibrationAlgo(Enum):
ENTROPY_CALIBRATION = _C.CalibrationAlgo.ENTROPY_CALIBRATION
Expand Down Expand Up @@ -88,6 +90,9 @@ def __init__(self, **kwargs: Any):
pass

def __new__(cls, *args: Any, **kwargs: Any) -> Self:
warnings.warn(
"Int8 PTQ Calibrator has been deprecated by TensorRT, please plan on porting to a NVIDIA Model Optimizer Toolkit based workflow. See: https://pytorch.org/TensorRT/tutorials/_rendered_examples/dynamo/vgg16_ptq.html for more details"
)
dataloader = args[0]
algo_type = kwargs.get("algo_type", CalibrationAlgo.ENTROPY_CALIBRATION_2)
cache_file = kwargs.get("cache_file", None)
Expand Down Expand Up @@ -175,6 +180,9 @@ def __init__(self, **kwargs: Any):
pass

def __new__(cls, *args: Any, **kwargs: Any) -> Self:
warnings.warn(
"Int8 PTQ Calibrator has been deprecated by TensorRT, please plan on porting to a NVIDIA Model Optimizer Toolkit based workflow. See: https://pytorch.org/TensorRT/tutorials/_rendered_examples/dynamo/vgg16_ptq.html for more details"
)
cache_file = args[0]
algo_type = kwargs.get("algo_type", CalibrationAlgo.ENTROPY_CALIBRATION_2)

Expand Down

0 comments on commit 48ec3cb

Please sign in to comment.