-
Notifications
You must be signed in to change notification settings - Fork 350
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
add int8 quantization support #3058
Conversation
consider adding modelopt as optional dependency with the correct version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/examples/dynamo/simple_int8_ptq.py 2024-08-21 23:27:44.130840+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/dynamo/simple_int8_ptq.py 2024-08-21 23:28:02.118758+00:00
@@ -14,13 +14,15 @@
x = self.linear1(x)
x = torch.nn.ReLU()(x)
x = self.linear2(x)
return x
+
def calibrate_loop(model):
"""Simple calibration function for testing."""
model(input_tensor)
+
input_tensor = torch.randn(1, 6).cuda()
model = SimpleNetwork().eval().cuda()
print(f"model before quantize: {model}")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/examples/dynamo/simple_int8_ptq.py 2024-08-21 23:28:32.341283+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/dynamo/simple_int8_ptq.py 2024-08-21 23:28:50.802608+00:00
@@ -14,13 +14,15 @@
x = self.linear1(x)
x = torch.nn.ReLU()(x)
x = self.linear2(x)
return x
+
def calibrate_loop(model):
"""Simple calibration function for testing."""
model(input_tensor)
+
input_tensor = torch.randn(1, 6).cuda()
model = SimpleNetwork().eval().cuda()
print(f"model before quantize: {model}")
@dheerajperi @narendasan ready for review however in the testcase I has to change from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/examples/dynamo/simple_int8_ptq.py 2024-08-22 00:07:47.982949+00:00
+++ /home/runner/work/TensorRT/TensorRT/examples/dynamo/simple_int8_ptq.py 2024-08-22 00:08:05.777701+00:00
@@ -14,13 +14,15 @@
x = self.linear1(x)
x = torch.nn.ReLU()(x)
x = self.linear2(x)
return x
+
def calibrate_loop(model):
"""Simple calibration function for testing."""
model(input_tensor)
+
input_tensor = torch.randn(1, 6).cuda()
model = SimpleNetwork().eval().cuda()
print(f"model before quantize: {model}")
from torch.export._trace import _export | ||
|
||
exp_program = _export(model, (input_tensor,)) | ||
if args.quantize_type == "int8": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldnt these be joined with a default set like enabled_precisions = {torch.float, torch.half}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me, one small optional idea for the docs
Description
Add int8 quantization support
Fixes # (issue)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: