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

add new format of quantization #41041

Merged
merged 17 commits into from
Apr 5, 2022

Conversation

yghstill
Copy link
Contributor

@yghstill yghstill commented Mar 28, 2022

PR types

New features

PR changes

APIs

Describe

Add new format of quantization.
image

补充说明:

  1. 新增量化新格式的原因:1)目前的量化格式动态图和静态图各一套,维护成本高,同时Intel部署模型还仍需转换一次,流程繁多。2)fake量化节点多而不统一,用户难以理解,比如fake_quantize_abs_maxfake_quantize_range_abs_max等,并且预测库需要解析多种fake op类型,并且量化时给模型原生op attr增加很多属性,适配起来比较复杂。 3)为了使得量化模型更加统一,同时对齐onnx量化模型标准,提升Paddle中模型量化易用性,易扩展,所以对量化模型格式做新的升级。
  2. 新格式和旧格式关系:二者互不影响,新格式在尚未全部模型推广时,模型量化默认还是旧格式,将来逐渐模型量化迁移至新格式。
  3. 新格式使用方法:1)静态图量化API中PostTrainingQuantization设置onnx_format=True即选择新格式。2)动态图量化API中save_quantized_model 接口中设置onnx_format=True即选择新格式。
  4. 兼容性:此PR支持了初版量化新格式,目前不影响当前量化流程,将来新格式会逐步优化量化过程、各平台各硬件预测部署流程,新格式会逐步替代旧格式,等方案成熟后,量化时会默认首选新格式。量化旧格式仍会保留,旧API及预测部署流程仍可使用。

paddle/fluid/operators/quantize_linear_op.cu Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.cu Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.cu Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.h Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.h Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.h Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.h Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.cu Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.h Outdated Show resolved Hide resolved
paddle/fluid/operators/quantize_linear_op.h Outdated Show resolved Hide resolved
wanghaoshuang
wanghaoshuang previously approved these changes Apr 1, 2022
ceci3
ceci3 previously approved these changes Apr 1, 2022
@yghstill yghstill dismissed stale reviews from ceci3 and wanghaoshuang via da5ddf7 April 2, 2022 01:59
ceci3
ceci3 previously approved these changes Apr 2, 2022
Aurelius84
Aurelius84 previously approved these changes Apr 4, 2022
Aurelius84
Aurelius84 previously approved these changes Apr 4, 2022
ceci3
ceci3 previously approved these changes Apr 4, 2022
@yghstill yghstill dismissed stale reviews from ceci3 and Aurelius84 via a3aeed9 April 4, 2022 04:02
Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yghstill yghstill merged commit b72a7eb into PaddlePaddle:develop Apr 5, 2022
@yghstill yghstill deleted the add_new_quant_format branch April 5, 2022 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants