Skip to content

Conversation

@ckmadhira
Copy link
Contributor

@ckmadhira ckmadhira commented Nov 8, 2024

…, dequantize, cat, layer norm, softmax to backends/cadence folder. Added operators to backends/cadence folder

Summary

Added kernels and operators related to

  1. Add
  2. Mul,
  3. Quantize
  4. Dequatize
  5. Cat
  6. Layernorm
  7. Softmax
    to Fusion G3. The Kernels part of Fusion G3 NN library which is a submodule.

…, dequantize, cat, layer norm, softmax to backends/cadence folder. Added operators to backends/cadence folder
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 8, 2024

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 92b58ef with merge base 43555d2 (image):

NEW FAILURE - The following job has failed:

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

@facebook-github-bot
Copy link
Contributor

Hi @ckmadhira!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@ckmadhira
Copy link
Contributor Author

Fusion G3 NN library is added with kernels related to add, mul, quantize, dequantize, cat, layernorm and softmax. Operators which use these kernels are also added to backends/cadence folder

Copy link
Contributor

@zonglinpeng zonglinpeng left a comment

Choose a reason for hiding this comment

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

Thanks for the change! Had one comment on the op namespace


namespace impl {
namespace FusionG3 {
namespace native {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the name spaces of all the G3 ops build as

namespace cadence {
namespace impl {
namespace G3 {
namespace native {

To align with other ops? HiFi example: https://github.com/pytorch/executorch/blob/main/backends/cadence/hifi/operators/op_add.cpp#L25

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated as per review comment

- op: _softmax.out
kernels:
- arg_meta: null
kernel_name: impl::FusionG3::softmax_out
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment on the namespace

Copy link
Contributor

Choose a reason for hiding this comment

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

Per @hsharma35 's comment above, please use cadence::impl::G3::native::<OP_NAME> namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the operator name as cadence::impl::G3::<OP_NAME>. native is not explicitly mentioned. As per kernel-library-custom-aten-kernel.md, native is automatically appended to the operators.

@@ -0,0 +1,119 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change the kernel_name here to match cadence::impl::G3::native::OP_NAME. For example: cadence::impl::G3::native::add_out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the operator name as cadence::impl::G3::add_out. native is not explicitly mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

With the change to operator namespace, I think this would now fail to compile. Can you please check on your end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are able to compile and verify the operator with toy model. Are you having any issue with this name space?

@hsharma35
Copy link
Contributor

Nit: Can we rename the folder FuG3 to FusionG3 instead?

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 11, 2024
@facebook-github-bot
Copy link
Contributor

@zonglinpeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@zonglinpeng
Copy link
Contributor

please make nnlib a standalone repository @ckmadhira

Copy link
Contributor

@zonglinpeng zonglinpeng left a comment

Choose a reason for hiding this comment

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

comment as above

@ckmadhira
Copy link
Contributor Author

please make nnlib a standalone repository @ckmadhira

The decision is not to make the Fusion G3 NN library opensource. We are looking for a space where we can put the repo and provide exclusive access to Meta

@zonglinpeng
Copy link
Contributor

zonglinpeng commented Nov 19, 2024

@ckmadhira thanks for driving nnlib to a public repo! Can you remake this PR with just the kernel updates (i.e. everything except thirdparty nnlib) so that I can import as a clean change? Thank you
cc @mcremon-meta

@ckmadhira
Copy link
Contributor Author

@ckmadhira thanks for driving nnlib to a public repo! Can you remake this PR with just the kernel updates (i.e. everything except thirdparty nnlib) so that I can import as a clean change? Thank you cc @mcremon-meta

Updated Fusion G3 NN library as a submodule from opensource.

Copy link
Contributor

@hsharma35 hsharma35 left a comment

Choose a reason for hiding this comment

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

LGTM, just needs one change:
Please make the operators in op_*.cpp consistent with the operators in functions_fusion_g3.yaml.

Thanks!

Comment on lines +25 to +28
- op: add.out
kernels:
- arg_meta: null
kernel_name: cadence::impl::G3::add_out
Copy link
Contributor

Choose a reason for hiding this comment

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

@ckmadhira the name used here (kernel_name: cadence::impl::G3::add_out) does not match the actual kernel in op_add.cpp (cadence::impl::G3::native::add_out). Is this compiling on your end?

Copy link
Contributor Author

@ckmadhira ckmadhira Nov 21, 2024

Choose a reason for hiding this comment

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

This got compiled for us and we are able to test it. We should not add "native" in the functions_fusion_g3.yaml file. The word "native" implicitly gets appended. If we try to add "native", we get build errors saying, native is added twice.

@@ -0,0 +1,119 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
Copy link
Contributor

Choose a reason for hiding this comment

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

With the change to operator namespace, I think this would now fail to compile. Can you please check on your end?

@zonglinpeng
Copy link
Contributor

zonglinpeng commented Nov 20, 2024

Please resolve the merge conflict in .gitmodules, and update the PR summary

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice this is awesome!

@facebook-github-bot
Copy link
Contributor

@zonglinpeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@ckmadhira
Copy link
Contributor Author

This is done

@mcremon-meta
Copy link
Contributor

@ckmadhira there are a lot of linter errors, see https://github.com/pytorch/executorch/actions/runs/11950614633/job/33350989488?pr=6738. @zonglinpeng can you share instructions on how to run the linter?

@zonglinpeng
Copy link
Contributor

@facebook-github-bot
Copy link
Contributor

@zonglinpeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link
Contributor

@zonglinpeng zonglinpeng left a comment

Choose a reason for hiding this comment

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

there are still some lint errors, please try lintrunner -a
https://github.com/pytorch/executorch/actions/runs/12009466002/job/33489114504?pr=6738

zonglinpeng

This comment was marked as outdated.

@zonglinpeng zonglinpeng dismissed hsharma35’s stale review November 25, 2024 19:22

Ok to merge, we can likely fix issues on our end

@facebook-github-bot
Copy link
Contributor

@zonglinpeng has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mcremon-meta mcremon-meta merged commit d778627 into pytorch:main Nov 25, 2024
40 of 41 checks passed
- op: native_layer_norm.out
kernels:
- arg_meta: null
kernel_name: cadence::impl::G3::native_layer_norm_out No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

missing quant dequant per tensor func definition. fixed in #7061

- op: _softmax.out
kernels:
- arg_meta: null
kernel_name: cadence::impl::G3::softmax_out
Copy link
Contributor

Choose a reason for hiding this comment

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

need to be _softmax to be consistent, fixed in #7061

namespace G3 {
namespace native {

Tensor& softmax_out(
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment, _softmax, fixed in #7061

*/
namespace cadence {
namespace impl {
namespace FusionG3 {
Copy link
Contributor

Choose a reason for hiding this comment

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

namespace needs to be G3. fixed in #7061



/* Local function which calls the kernels based on the input datatype */
void Dequantize_impl(Tensor& out,
Copy link
Contributor

Choose a reason for hiding this comment

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

please use all lower case fixed in #7061

@zonglinpeng zonglinpeng changed the title Added Fusion G3 NN library with kernels related to add, mul, quantize… Milestone 1: Added Fusion G3 NN library with kernels related to add, mul, quantize… Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants