-
Notifications
You must be signed in to change notification settings - Fork 414
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 fix for CPU Inference #385
Conversation
@fxmarty, need your review on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think you don't need to hardcode the dtype - wdyt?
A safe approach would be to modify https://github.com/PanQiWei/AutoGPTQ/blob/518617b8d682aaa95796f622d788e014ee882869/auto_gptq/modeling/_utils.py#L70 to pass the dtype to QuantLinear init, and to default to fp16 (ugly, but for backward compatibility). This may not work for transformers integration though - maybe |
a71beb1
to
f500ff1
Compare
@fxmarty, can you please review it now? I think we need to make the changes here https://github.com/huggingface/optimum/blob/8e7588b09df2f15c47e9b92f81ec2b05f7ae6957/optimum/gptq/quantizer.py#L242-L246 as well? |
Refer: AutoGPTQ/AutoGPTQ#385 Signed-Off By: Vivek Khandelwal <vivek@nod-labs.com>
I have added a PR here: huggingface/optimum#1496 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, can you make sure the tests pass?
CUDA_VISIBLE_DEVICES=0 pytest tests/ -s -vvvvv
Refer: AutoGPTQ/AutoGPTQ#385 Signed-Off By: Vivek Khandelwal <vivek@nod-labs.com>
@fxmarty I have updated the PR with the required changes. |
f500ff1
to
21f973e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Could you confirm that tests pass?
The following 2 tests failed:
Edit:
|
The above failure doesn't seem to be occurring because of the changes made in this PR. @fxmarty |
Yes it was fixed by #387. Thank you! |
Refer: AutoGPTQ/AutoGPTQ#385 Signed-Off By: Vivek Khandelwal <vivek@nod-labs.com>
Thanks, @fxmarty, for your support in getting these patches in. |
out = torch.matmul(x.to(weights.dtype), weights) | ||
out = out.half().reshape(out_shape) | ||
out = torch.matmul(x, weights) | ||
out = out.to(dtype=weights.dtype).reshape(out_shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems broken in master at the moment:
File "/opt/miniconda3/envs/text-gen-gptq/lib/python3.10/site-packages/auto_gptq/nn_modules/qlinear/qlinear_cuda.py", line 272, in forward
out = out.to(dtype=weights.dtype).reshape(out_shape)
UnboundLocalError: local variable 'weights' referenced before assignment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes: AutoGPTQ#385 (comment) Signed-Off By: Vivek Khandelwal <vivek@nod-labs.com>
Signed-Off By: Vivek Khandelwal vivek@nod-labs.com