add int8 quantization support for llm models#4086
Open
lanluo-nvidia wants to merge 3 commits intomainfrom
Open
add int8 quantization support for llm models#4086lanluo-nvidia wants to merge 3 commits intomainfrom
lanluo-nvidia wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/tools/llm/quantize_utils.py 2026-02-19 21:27:32.249942+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/llm/quantize_utils.py 2026-02-19 21:28:16.257493+00:00
@@ -57,16 +57,20 @@
device="cuda:0",
)
if args.quant_format == "int8":
if args.quant_algo == "smoothquant":
if args.weight_only:
- raise RuntimeError("SmoothQuant is supported for weight-and-activation quantization, weight-only flag should not be set")
+ raise RuntimeError(
+ "SmoothQuant is supported for weight-and-activation quantization, weight-only flag should not be set"
+ )
quant_cfg = mtq.INT8_SMOOTHQUANT_CFG
elif args.weight_only:
quant_cfg = mtq.INT8_WEIGHT_ONLY_CFG
else:
- raise RuntimeError(f"Unsupported args.quant_algo: {args.quant_algo} and args.weight_only: {args.weight_only} for int8 quantization")
+ raise RuntimeError(
+ f"Unsupported args.quant_algo: {args.quant_algo} and args.weight_only: {args.weight_only} for int8 quantization"
+ )
elif args.quant_format == "fp8":
quant_cfg = mtq.FP8_DEFAULT_CFG
elif args.quant_format == "nvfp4":
quant_cfg = mtq.NVFP4_DEFAULT_CFG
else:
--- /home/runner/work/TensorRT/TensorRT/tools/llm/run_llm.py 2026-02-19 21:27:32.249942+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/llm/run_llm.py 2026-02-19 21:28:16.328324+00:00
@@ -269,11 +269,11 @@
default="max",
)
arg_parser.add_argument(
"--weight_only",
help=("Apply weight only quantization. True (default: False)"),
- action="store_true",
+ action="store_true",
)
args = arg_parser.parse_args()
with torch.inference_mode():
model = get_model(args)There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/tools/llm/quantize_utils.py 2026-02-20 00:10:03.446101+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/llm/quantize_utils.py 2026-02-20 00:10:48.765198+00:00
@@ -57,16 +57,20 @@
device="cuda:0",
)
if args.quant_format == "int8":
if args.quant_algo == "smoothquant":
if args.weight_only:
- raise RuntimeError("SmoothQuant is supported for weight-and-activation quantization, weight-only flag should not be set")
+ raise RuntimeError(
+ "SmoothQuant is supported for weight-and-activation quantization, weight-only flag should not be set"
+ )
quant_cfg = mtq.INT8_SMOOTHQUANT_CFG
elif args.weight_only:
quant_cfg = mtq.INT8_WEIGHT_ONLY_CFG
else:
- raise RuntimeError(f"Unsupported args.quant_algo: {args.quant_algo} and args.weight_only: {args.weight_only} for int8 quantization")
+ raise RuntimeError(
+ f"Unsupported args.quant_algo: {args.quant_algo} and args.weight_only: {args.weight_only} for int8 quantization"
+ )
elif args.quant_format == "fp8":
quant_cfg = mtq.FP8_DEFAULT_CFG
elif args.quant_format == "nvfp4":
quant_cfg = mtq.NVFP4_DEFAULT_CFG
else:
--- /home/runner/work/TensorRT/TensorRT/tools/llm/run_llm.py 2026-02-20 00:10:03.446101+00:00
+++ /home/runner/work/TensorRT/TensorRT/tools/llm/run_llm.py 2026-02-20 00:10:49.258692+00:00
@@ -269,11 +269,11 @@
default="max",
)
arg_parser.add_argument(
"--weight_only",
help=("Apply weight only quantization. True (default: False)"),
- action="store_true",
+ action="store_true",
)
args = arg_parser.parse_args()
with torch.inference_mode():
model = get_model(args)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: