-
Notifications
You must be signed in to change notification settings - Fork 372
Feat: Pre-quantized LLM model support #3740
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
base: main
Are you sure you want to change the base?
Conversation
62cb0f2
to
1f1cf7f
Compare
return model | ||
|
||
|
||
class TensorRTQuantizedLinear(torch.nn.Module): |
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.
@peri044 Is this something we might want to upstream to ModelOpt in the future?
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.
Or pull into main torch-tensorrt as a pass?
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.
I guess its somewhat HF specific, so remaining in this tool would make sense but are there some parts we could make generic for any sort of quantization workflow (e.g. torchao)?
|
||
hf_quant_algo = hf_quant_config.pop("quant_algo", None) | ||
if hf_quant_algo != "FP8" and hf_quant_algo != "NVFP4": | ||
raise RuntimeError("Only FP8 or NVFP4 quantization is supported") |
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.
How would it be different for MXFP4?
) | ||
.eval() | ||
.cuda() | ||
) | ||
if args.pre_quantized: |
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.
Is this something we could determine automatically?
@@ -234,13 +239,36 @@ def measure_perf(trt_model, input_signature, backend_name): | |||
arg_parser.add_argument( | |||
"--benchmark", action="store_true", help="Enable benchmark (default: False)" | |||
) | |||
|
|||
arg_parser.add_argument( | |||
"--qformat", |
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.
For the sake of clarity, this should be something like quant-[scheme/format]
Description
Support pre-quantized HF models and post-training quantization (PTQ) option for run_llm.py
Fixes # (issue)
Type of change
Checklist: