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

[Quant tool] Handle input models with pre-quantized weights #22633

Merged
merged 13 commits into from
Nov 14, 2024

Conversation

adrianlizarraga
Copy link
Contributor

@adrianlizarraga adrianlizarraga commented Oct 28, 2024

Description

Allows the QDQ quantizer to handle input models that already have some pre-quantized weights. In this case, the qdq quantizer will properly skip/handle the pre-quantized weights.

Also handles an operator (e.g., Conv) with a pre-quantized weight and a float bias. The tool will read the pre-quantized weight's quantization scale to compute the bias's scale (bias_scale = input_scale * weight_scale).

Input model (pre-quantized Conv weight):
image

Output QDQ model (everything is quantized):
image

Motivation and Context

Customers may use external tools to quantize some weights (e.g., int4 for Conv/MatMul). The qdq quantizer should still be able to quantize the rest of the model (float weights and activations) in this case.

@adrianlizarraga
Copy link
Contributor Author

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, Linux QNN CI Pipeline

@adrianlizarraga adrianlizarraga marked this pull request as ready for review October 29, 2024 00:34
@adrianlizarraga
Copy link
Contributor Author

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, Linux QNN CI Pipeline

@sophies927 sophies927 added release:1.20.1 triage:approved Approved for cherrypicks for release release:1.20.0 and removed triage:approved Approved for cherrypicks for release release:1.20.1 labels Nov 5, 2024
@adrianlizarraga adrianlizarraga merged commit 0733733 into main Nov 14, 2024
128 checks passed
@adrianlizarraga adrianlizarraga deleted the adrianl/quant-tool-handle-prequantized-weights branch November 14, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants