Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cherry-pick] Deprecate torchscript frontend #3376

Merged
merged 1 commit into from
Jan 31, 2025
Merged
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: ^.github/actions/assigner/dist
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: trailing-whitespace
Expand Down Expand Up @@ -32,7 +32,7 @@ repos:
hooks:
- id: validate-pyproject
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 6.0.0
hooks:
- id: isort
name: isort (python)
Expand All @@ -52,7 +52,7 @@ repos:
- id: black
exclude: ^examples/custom_converters/elu_converter/setup.py|^docs
- repo: https://github.com/crate-ci/typos
rev: v1.22.9
rev: typos-dict-v0.12.4
hooks:
- id: typos
- repo: https://github.com/astral-sh/uv-pre-commit
Expand Down
3 changes: 3 additions & 0 deletions cpp/include/torch_tensorrt/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
STR(TORCH_TENSORRT_MAJOR_VERSION) \
"." STR(TORCH_TENSORRT_MINOR_VERSION) "." STR(TORCH_TENSORRT_PATCH_VERSION)

#define TORCH_TENSORRT_PTQ_DEPRECATION \
[[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")]]
// Setup namespace aliases for ease of use
namespace torch_tensorrt {
namespace torchscript {}
Expand Down
6 changes: 3 additions & 3 deletions cpp/include/torch_tensorrt/ptq.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ class Int8CacheCalibrator : Algorithm {
* @param use_cache: bool - use calibration cache
* @return Int8Calibrator<Algorithm, DataLoader>
*/

template <typename Algorithm = nvinfer1::IInt8EntropyCalibrator2, typename DataLoader>
inline Int8Calibrator<Algorithm, DataLoader> make_int8_calibrator(
TORCH_TENSORRT_PTQ_DEPRECATION inline Int8Calibrator<Algorithm, DataLoader> make_int8_calibrator(
DataLoader dataloader,
const std::string& cache_file_path,
bool use_cache) {
Expand Down Expand Up @@ -344,7 +343,8 @@ inline Int8Calibrator<Algorithm, DataLoader> make_int8_calibrator(
* @return Int8CacheCalibrator<Algorithm>
*/
template <typename Algorithm = nvinfer1::IInt8EntropyCalibrator2>
inline Int8CacheCalibrator<Algorithm> make_int8_cache_calibrator(const std::string& cache_file_path) {
TORCH_TENSORRT_PTQ_DEPRECATION inline Int8CacheCalibrator<Algorithm> make_int8_cache_calibrator(
const std::string& cache_file_path) {
return Int8CacheCalibrator<Algorithm>(cache_file_path);
}

Expand Down
13 changes: 13 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,12 @@ 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',
DeprecationWarning,
stacklevel=2,
)

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 +247,12 @@ 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',
DeprecationWarning,
stacklevel=2,
)

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
11 changes: 11 additions & 0 deletions py/torch_tensorrt/ts/ptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing_extensions import Self

import os
import warnings
from enum import Enum

import torch
Expand Down Expand Up @@ -88,6 +89,11 @@ 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",
DeprecationWarning,
stacklevel=2,
)
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 +181,11 @@ 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",
DeprecationWarning,
stacklevel=2,
)
cache_file = args[0]
algo_type = kwargs.get("algo_type", CalibrationAlgo.ENTROPY_CALIBRATION_2)

Expand Down
Loading