Skip to content

fix: Fix PTQ export #3447

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

Merged
merged 1 commit into from
Mar 19, 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
4 changes: 1 addition & 3 deletions examples/dynamo/vgg16_ptq.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ def calibrate_loop(model):
with export_torch_mode():
# Compile the model with Torch-TensorRT Dynamo backend
input_tensor = images.cuda()
# torch.export.export() failed due to RuntimeError: Attempting to use FunctionalTensor on its own. Instead, please use it with a corresponding FunctionalTensorMode()
from torch.export._trace import _export

exp_program = _export(model, (input_tensor,))
exp_program = torch.export.export(model, (input_tensor,), strict=False)
if args.quantize_type == "int8":
enabled_precisions = {torch.int8}
elif args.quantize_type == "fp8":
Expand Down
3 changes: 1 addition & 2 deletions tests/py/dynamo/models/test_models_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def test_resnet18_half(ir):
def test_base_fp8(ir):
import modelopt.torch.quantization as mtq
from modelopt.torch.quantization.utils import export_torch_mode
from torch.export._trace import _export

class SimpleNetwork(torch.nn.Module):
def __init__(self):
Expand Down Expand Up @@ -234,7 +233,7 @@ def calibrate_loop(model):

with torch.no_grad():
with export_torch_mode():
exp_program = _export(model, (input_tensor,))
exp_program = torch.export.export(model, (input_tensor,), strict=False)
trt_model = torchtrt.dynamo.compile(
exp_program,
inputs=[input_tensor],
Expand Down