KEMBAR78
[Quantization][PrivateUse1] Adding more support QuantizedPrivateuse1 backends by fmo-mt · Pull Request #139860 · pytorch/pytorch · GitHub
Skip to content

Conversation

@fmo-mt
Copy link
Contributor

@fmo-mt fmo-mt commented Nov 6, 2024

Here's are some explanations of this PR.

  1. Changes in aten/src/ATen/core/Tensor.cpp and c10/core/DispatchKey.cpp: Support toString method for QuantizedPrivateUse1 backend, make pytorch print out correct backend string for it.
  2. Add header DispatchStub.h in aten/src/ATen/native/quantized/IndexKernel.h: If this header is not included, we can't utilize masked_fill_kernel_quantized_stub even we include this IndexKernel.h header, it would throw an error during compilation.
  3. Add multiple TORCH_APIs in aten/src/ATen/native/quantized/AffineQuantizer.h: these functions is useful for other privateuse1 backends supporting quantization functions, if these TORCH_API are missed, it would throw an error during runtime (undefined symbol)

@pytorch-bot
Copy link

pytorch-bot bot commented Nov 6, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/139860

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit bbde42a with merge base c19c384 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the release notes: quantization release notes category label Nov 6, 2024
@bdhirsh bdhirsh requested a review from albanD November 8, 2024 15:48
@bdhirsh bdhirsh added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Nov 8, 2024
namespace native {

Tensor& quantize_tensor_per_tensor_affine(
TORCH_API Tensor& quantize_tensor_per_tensor_affine(
Copy link
Contributor

Choose a reason for hiding this comment

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

@jerryzh168 you might be a better reviewer here - do we want these API's to get public symbols?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we do, and it would throw an error of undefined symbol if we don't.
PTAL @jerryzh168

Copy link
Contributor

@jerryzh168 jerryzh168 Nov 15, 2024

Choose a reason for hiding this comment

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

this is not a public function I think, what does "getting public symbols" entail here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not a public function I think, what does "getting public symbols" entail here?

it's not, but it should be if privateuse1 user like to implement quantization functions like torch.quantize_per_tensor, so we can reuse this native common functions.

@@ -1,4 +1,5 @@
#pragma once
#include <ATen/native/DispatchStub.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Contributor Author

@fmo-mt fmo-mt Nov 10, 2024

Choose a reason for hiding this comment

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

Well, as I comment, it's because that during implementing some operators for privateuse1 backend, If DispatchStub.h is not included, we can't use the two stubs in this header, like masked_fill_kernel_quantized_stub and index_put_kernel_quantized_stub, which would throw an error during compilation.

@fmo-mt
Copy link
Contributor Author

fmo-mt commented Nov 15, 2024

@bdhirsh @jerryzh168 Hi, can we make this proceed? I believe that many other privateuse1 users could gain benefits from these changes.

Copy link
Contributor

@bdhirsh bdhirsh left a comment

Choose a reason for hiding this comment

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

Sounds good to me!

@bdhirsh
Copy link
Contributor

bdhirsh commented Nov 18, 2024

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 18, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
…backends (pytorch#139860)

Here's are some explanations of this PR.

1. Changes in `aten/src/ATen/core/Tensor.cpp` and `c10/core/DispatchKey.cpp`: Support toString method for `QuantizedPrivateUse1` backend, make pytorch print out correct backend string for it.
2. Add  header `DispatchStub.h` in `aten/src/ATen/native/quantized/IndexKernel.h`: If this header is not included, we can't utilize `masked_fill_kernel_quantized_stub` even we include this `IndexKernel.h` header, it would throw an error during compilation.
3. Add multiple `TORCH_API`s in `aten/src/ATen/native/quantized/AffineQuantizer.h`: these functions is useful for other privateuse1 backends supporting quantization functions, if these `TORCH_API` are missed, it would throw an error during runtime (undefined symbol)
Pull Request resolved: pytorch#139860
Approved by: https://github.com/bdhirsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: quantization release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants