-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[quant] Support quantization of embedding lookup operators #44207
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
Summary: Use existing embedding_bag operator but set offsets to [0, 1, .. len(indices)] Test Plan: python test/test_quantization.py TestEmbeddingOps.test_embedding_byte Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit 3e137ea (more details on the Dr. CI page):
ci.pytorch.org: 1 failedThis comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 12 times. |
Summary: Use existing embedding_bag operator but set offsets to [0, 1, .. len(indices)] Test Plan: python test/test_quantization.py TestEmbeddingOps.test_embedding_byte Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
| qresult = quant_op(packed_weight, indices, sparse=False) | ||
|
|
||
| ref = torch.embedding(weights, indices, padding_idx=-1, scale_grad_by_freq=False, sparse=False) | ||
| torch.testing.assert_allclose(ref, qresult, atol=0.005, rtol=1e-3) |
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.
are the modified atol and rtol values only because of quantization error?
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.
Yes
| packed_weight = prepack_op(qweight) | ||
| qresult = quant_op(packed_weight, indices, sparse=False) | ||
|
|
||
| ref = torch.embedding(weights, indices, padding_idx=-1, scale_grad_by_freq=False, sparse=False) |
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.
If you use qweight.dequantize(), this should be an exact match
Summary: Use existing embedding_bag operator but set offsets to [0, 1, .. len(indices)] Test Plan: python test/test_quantization.py TestEmbeddingOps.test_embedding_byte Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D23547385](https://our.internmc.facebook.com/intern/diff/D23547385) [ghstack-poisoned]
Codecov Report
@@ Coverage Diff @@
## gh/supriyar/173/base #44207 +/- ##
=====================================================
Coverage 69.24% 69.24%
=====================================================
Files 381 381
Lines 47573 47573
=====================================================
Hits 32943 32943
Misses 14630 14630 Continue to review full report at Codecov.
|
Summary: Use existing embedding_bag operator but set offsets to [0, 1, .. len(indices)] Test Plan: python test/test_quantization.py TestEmbeddingOps.test_embedding_byte Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D23547385](https://our.internmc.facebook.com/intern/diff/D23547385) [ghstack-poisoned]
|
This pull request has been merged in 6013a29. |
Stack from ghstack:
Summary:
Use existing embedding_bag operator but set offsets to [0, 1, .. len(indices)]
Test Plan:
python test/test_quantization.py TestEmbeddingOps.test_embedding_byte
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D23547385