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 quant_linear #57852

Merged
merged 29 commits into from
Oct 31, 2023
Merged

add quant_linear #57852

merged 29 commits into from
Oct 31, 2023

Conversation

YSF-A
Copy link
Contributor

@YSF-A YSF-A commented Sep 28, 2023

PR types

New features

PR changes

OPs

Description

add quant_linear
输入input、bias与in8的w,以及quant scale、round_type、max_bound、min_bound等量化相关的参数,可以计算获得output。其中,input量化为layer_wise,w量化为channel_wise。
应用场景是用于需要量化的Linear的场景。

@paddle-bot
Copy link

paddle-bot bot commented Sep 28, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Sep 28, 2023
phi::QuantLinearKernel,
float,
double,
phi::dtype::float16) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

也需要支持bfloat16

int in_num_col_dims,
const std::string& activation_type,
bool padding_weights,
bool is_quant,
Copy link
Contributor

Choose a reason for hiding this comment

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

算子名称已经是QuantLinear 这个参数是否有必要保留

Copy link
Contributor Author

Choose a reason for hiding this comment

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

那后续删掉这个参数,算子改为只支持quant。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@vivienfanghuagood
Copy link
Contributor

PR types

New features

PR changes

OPs

Description

add quant fc

麻烦在PR描述里写上op的运行方式以及应用场景吧~

case 4:
QuantKernelWithVecSize<<<grid, block, 0, stream>>>(
input,
(char4*)output, // NOLINT
Copy link
Contributor

Choose a reason for hiding this comment

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

是不是还是用reinterpret_cast好一些

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

float quant_max_bound,
float quant_min_bound,
DenseTensor* y) {
bool with_relu = activation_type == "relu" ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

对于给入非relu的激活, 好像没有做处理?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

目前是只支持relu激活,在InferMeta里对activation_type 非relu的情况做了检查。

be created according to ParamAttr. For detailed information, please refer
to :attr:`paddle.ParamAttr`. The default value is None and the bias will be
initialized to zero.
activation (str, optional): Activation to be applied to the output of
Copy link
Contributor

Choose a reason for hiding this comment

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

文档这里可能需要写明给出已支持的activation方法列表

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@wwbitejotunn wwbitejotunn 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

@RichardWooSJTU RichardWooSJTU 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

@qili93 qili93 left a comment

Choose a reason for hiding this comment

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

LGTM for unittest.skipIf

@phlrain phlrain self-requested a review October 30, 2023 06:57
@YSF-A YSF-A changed the title add quant fc add quant_linear Oct 30, 2023
Copy link
Collaborator

@phlrain phlrain left a comment

Choose a reason for hiding this comment

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

LGTM for check_dygaph

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.

考虑到API后续可能会被修改,建议先作为内部API

Copy link
Contributor

@Ligoml Ligoml left a comment

Choose a reason for hiding this comment

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

LGTM for docs

@heavengate heavengate merged commit 040ecd4 into PaddlePaddle:develop Oct 31, 2023
zeroRains pushed a commit to zeroRains/Paddle that referenced this pull request Nov 8, 2023
@luotao1
Copy link
Contributor

luotao1 commented Nov 8, 2023

hi, @YSF-A

  • 非常感谢你对飞桨框架的贡献,我们正在运营一个PFCC组织,会通过定期分享技术知识与发布开发者主导任务的形式持续为飞桨框架做贡献,详情可见 https://github.com/luotao1 主页说明。
  • 如果你对PFCC有兴趣,请发送邮件至 ext_paddle_oss@baidu.com,我们会邀请你加入~

danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.