onnxruntime/onnxruntime/python
Adrian Lizarraga df28c7d73b
[Quant tool] Improve performance of int4 weight quantization (#20935)
### Description
- Uses our own quantization functions instead of the ONNX reference
implementation of QuantizeLinear when quantizing weights to int4.
- Uses a custom function that packs bytes into 4-bit elements.



### Motivation and Context
Running the quantization tool to create QDQ models with int4 weights
could take up to 7x longer. This PR uses our own quantization and byte
packing utilities to improve performance.

#### Measurements
Model with ~5M parameters to quantize to int4.

- Current implementation: **84.5s**
- Only replace ONNX QuantizeLinear implementation: **50.3s** (1.68x
speedup)
- This PR (replace onnx Q impl, custom packing func): **13.5s** (6.26x
speedup)

---------

Signed-off-by: adrianlizarraga <adlizarraga@microsoft.com>
2024-06-05 16:48:40 -07:00
..
backend Bump linter versions (#18341) 2023-11-08 13:04:40 -08:00
datasets Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
providers/tvm Bump ruff in CI (#15533) 2023-04-17 10:11:44 -07:00
tools [Quant tool] Improve performance of int4 weight quantization (#20935) 2024-06-05 16:48:40 -07:00
torch_cpp_extensions remove const cast for DLManagedTensor (#20015) 2024-03-22 10:39:19 -07:00
training
__init__.py
_ld_preload.py
_pybind_state.py.in Fix invalid escape sequence (#17145) 2023-08-15 10:29:54 -07:00
exported_symbols.lst
numpy_helper.h
onnxruntime_collect_build_info.py Adopt linrtunner as the linting tool - take 2 (#15085) 2023-03-24 15:29:03 -07:00
onnxruntime_inference_collection.py Implement numpy array over CPU OrtValues on return values (#20539) 2024-05-08 10:56:36 -07:00
onnxruntime_pybind.h
onnxruntime_pybind_exceptions.cc Run clang-format in CI (#15524) 2023-04-18 09:26:58 -07:00
onnxruntime_pybind_exceptions.h
onnxruntime_pybind_iobinding.cc Implement numpy array over CPU OrtValues on return values (#20539) 2024-05-08 10:56:36 -07:00
onnxruntime_pybind_mlvalue.cc [CPU EP] Int4 support for QuantizeLinear, DequantizeLinear, and Transpose (#20362) 2024-05-30 18:56:24 -07:00
onnxruntime_pybind_mlvalue.h Implement numpy array over CPU OrtValues on return values (#20539) 2024-05-08 10:56:36 -07:00
onnxruntime_pybind_module.cc Fix warning C4003 in ORT python binding code (#18612) 2023-11-30 08:07:47 -08:00
onnxruntime_pybind_ortvalue.cc Implement numpy array over CPU OrtValues on return values (#20539) 2024-05-08 10:56:36 -07:00
onnxruntime_pybind_quant.cc Block-wise 4b quantization matmul operator change (#18172) 2023-11-03 15:29:43 -07:00
onnxruntime_pybind_schema.cc [DML EP] Improve python API perf (#20331) 2024-04-17 17:33:37 -07:00
onnxruntime_pybind_sparse_tensor.cc Implement numpy array over CPU OrtValues on return values (#20539) 2024-05-08 10:56:36 -07:00
onnxruntime_pybind_state.cc [VitisAI] add new api for models (#20899) 2024-06-04 22:48:04 -07:00
onnxruntime_pybind_state.h
onnxruntime_pybind_state_common.cc
onnxruntime_pybind_state_common.h OpenVINO EP Rel 1.18 Changes (#20337) 2024-04-19 00:31:38 -07:00
onnxruntime_validation.py fix: "UserWarning: Unsupported Windows version (11). ONNX Runtime sup… (#19845) 2024-03-15 12:41:44 -07:00
pybind.def
version_script.lds
version_script_expose_onnx_protobuf.lds