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

weight_quantize/weight_only_linear support Volta Arch #58082

Merged
merged 12 commits into from Nov 22, 2023
Merged

weight_quantize/weight_only_linear support Volta Arch #58082

merged 12 commits into from Nov 22, 2023

Conversation

MARD1NO
Copy link
Contributor

@MARD1NO MARD1NO commented Oct 13, 2023

PR types

New features

PR changes

OPs

Description

  1. when in volta arch, weightonly needs Row major, we do not need to transpose it.
  2. And we do not write rowmajor gemv, so when M=1 and arch=70, it still use Weightonly Gemm.
  3. Since the layout has changed in sm70, weightonly linear grad maynot suit for sm70, here we just force arch==80 when using weightonly linear grad operator.

Pcard-72603

@paddle-bot
Copy link

paddle-bot bot commented Oct 13, 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.

@MARD1NO MARD1NO marked this pull request as ready for review October 13, 2023 08:55
@MARD1NO MARD1NO marked this pull request as draft October 13, 2023 09:15
@@ -3846,7 +3846,13 @@ void WeightOnlyLinearInferMeta(const MetaTensor& x,
const MetaTensor& bias,
const MetaTensor& weight_scale,
const std::string& weight_dtype,
const int32_t arch,
Copy link
Contributor

Choose a reason for hiding this comment

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

int类型的值传递就不需要const修饰了

python/paddle/nn/quant/quantized_linear.py Show resolved Hide resolved
@MARD1NO MARD1NO marked this pull request as ready for review October 13, 2023 09:59
@@ -2807,7 +2807,7 @@
backward: weight_only_linear_grad

- op : weight_quantize
args : (Tensor x, str algo="weight_only_int8")
args : (Tensor x, str algo = "weight_only_int8", int arch = -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

改为默认是80

@@ -146,9 +159,24 @@ def weight_only_linear(
... print(out.shape)
[1, 2, 32]
"""
if arch is None:
# Get SMVersion from device.
cuda_version = version.cuda()
Copy link
Contributor

Choose a reason for hiding this comment

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

这块代码封装成一个函数给这两个api调用

@MARD1NO MARD1NO changed the title Fix volta arch weight quantize error weight_quantize/weight_only_linear support Volta Arch Oct 20, 2023
@MARD1NO MARD1NO marked this pull request as draft November 1, 2023 05:33
@MARD1NO MARD1NO marked this pull request as ready for review November 1, 2023 05:33
Copy link

paddle-ci-bot bot commented Nov 9, 2023

Sorry to inform you that f744bcb's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@CLAassistant
Copy link

CLAassistant commented Nov 21, 2023

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ MARD1NO
❌ paddle


paddle seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Contributor

@yuanlehome yuanlehome left a comment

Choose a reason for hiding this comment

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

LGGGTM

Copy link
Contributor

@sunzhongkai588 sunzhongkai588 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~

Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

weight_quantize and weight_only_linear have added default value parameters arch=Nonewhich belongs to compatibility upgrade, so approve.

@yuanlehome yuanlehome merged commit b391825 into PaddlePaddle:develop Nov 22, 2023
28 checks passed
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
…8082)

* fix volta arch weight quantize error

* set default arch as 0 and use getSMVersion to get device's arch automatically

* move getSmVersion to python api
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.

None yet

7 participants