-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[Quant] Add fused linear-leaky_relu op for onednn backend #88478
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
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/88478
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit c74af6a: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
|
This is part of replacement of #76424 which is too big to land. |
cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
I have added summary and test plan. |
**Summary** Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused `linear-leaky_relu` op for `onednn` backend, which will be used for int8 inference with `onednn` backend. Cannot call this op with other quantization backends otherwise an error is thrown. **Test Plan** python test_quantization.py TestQuantizedLinear cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
jerryzh168
left a comment
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.
looks good to me
|
btw the Summary and Test Plan should appear after the stack.. |
**Summary** Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused `linear-leaky_relu` op for `onednn` backend, which will be used for int8 inference with `onednn` backend. Cannot call this op with other quantization backends otherwise an error is thrown. **Test Plan** python test_quantization.py TestQuantizedLinear cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 2 additional jobs have failed, first few of them are: trunk ,trunk / cuda11.6-py3.10-gcc7-sm86 / test (default, 1, 4, linux.g5.4xlarge.nvidia.gpu) Details for Dev Infra teamRaised by workflow job |
|
Hi @jerryzh168. The separated |
**Summary** Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused `linear-leaky_relu` op for `onednn` backend, which will be used for int8 inference with `onednn` backend. Cannot call this op with other quantization backends otherwise an error is thrown. **Test Plan** python test_quantization.py TestQuantizedLinear cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
**Summary** Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused `linear-leaky_relu` op for `onednn` backend, which will be used for int8 inference with `onednn` backend. Cannot call this op with other quantization backends otherwise an error is thrown. **Test Plan** python test_quantization.py TestQuantizedLinear cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
**Summary** Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused `linear-leaky_relu` op for `onednn` backend, which will be used for int8 inference with `onednn` backend. Cannot call this op with other quantization backends otherwise an error is thrown. **Test Plan** python test_quantization.py TestQuantizedLinear cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
Hi, @jerryzh168. It was due to some weird rounding errors, I think.
It has been good before we separated test_qlinear and test_qlinear_relu but the issue occurred after the separation.To avoid the issue and keep the test cases reasonable, I changed the scale value to 12.34. Now all checks have passed. How does that sound to you?
|
**Summary** Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused `linear-leaky_relu` op for `onednn` backend, which will be used for int8 inference with `onednn` backend. Cannot call this op with other quantization backends otherwise an error is thrown. **Test Plan** python test_quantization.py TestQuantizedLinear cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo jgong5 leslie-fang-intel VitalyFedyunin mingfeima XiaobingSuper sanchitintel ashokei jingxu10 [ghstack-poisoned]
|
Hi @jerryzh168 It's been a while since your last review. Could you take a look again? Do you have more comments on this PR and others? Thanks! |
| m.def(TORCH_SELECTIVE_SCHEMA("quantized::linear_relu_dynamic(Tensor X, __torch__.torch.classes.quantized.LinearPackedParamsBase W_prepack, bool reduce_range=False) -> Tensor Y")); | ||
| m.def(TORCH_SELECTIVE_SCHEMA("quantized::linear_dynamic_fp16(Tensor X, __torch__.torch.classes.quantized.LinearPackedParamsBase W_prepack) -> Tensor Y")); | ||
| m.def(TORCH_SELECTIVE_SCHEMA("quantized::linear_relu_dynamic_fp16(Tensor X, __torch__.torch.classes.quantized.LinearPackedParamsBase W_prepack) -> Tensor Y")); | ||
| m.def(TORCH_SELECTIVE_SCHEMA("quantized::linear_leaky_relu(Tensor X, __torch__.torch.classes.quantized.LinearPackedParamsBase W_prepack, float Y_scale_i, int Y_zero_point_i, float negative_slope) -> Tensor Y")); |
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.
nit: what does i in Y_scale_i mean?
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.
nit: what does
iinY_scale_imean?
Good question. I don't know. I just copied the arg name from above to look aligned
| m.def(TORCH_SELECTIVE_SCHEMA("quantized::linear_relu(Tensor X, __torch__.torch.classes.quantized.LinearPackedParamsBase W_prepack, float Y_scale_i, int Y_zero_point_i) -> Tensor Y")); |
Shall I keep it or remove it?
|
yeah LGTM |
what is the error? is it a numerical error or something else? |
Yes, it's a numerical error of fbgemm. There was only one mismatched value with absolute difference = 1. So, it was probably about rounding. |
Thanks. Please also review other PRs at your convenience. |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
) **Summary** Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused `linear-leaky_relu` op for `onednn` backend, which will be used for int8 inference with `onednn` backend. Cannot call this op with other quantization backends otherwise an error is thrown. **Test Plan** python test_quantization.py TestQuantizedLinear Pull Request resolved: pytorch#88478 Approved by: https://github.com/jgong5, https://github.com/jerryzh168
ghstack-source-id: 2d1f2b2 Pull Request resolved: pytorch/pytorch#88478
Stack from ghstack (oldest at bottom):
Summary
Post op fusion can reduce data movement overhead and improve inference performance. This PR adds fused
linear-leaky_reluop foronednnbackend, which will be used for int8 inference withonednnbackend. Cannot call this op with other quantization backends otherwise an error is thrown.Test Plan
python test_quantization.py TestQuantizedLinear
cc @jerryzh168 @jianyuh @raghuramank100 @jamesr66a @vkuzo @jgong5 @leslie-fang-intel @VitalyFedyunin @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10