Skip to content
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

[Experimental] Enable kleidi AI examples to run on graviton3 #1721

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akote123
Copy link

@akote123 akote123 commented Feb 17, 2025

Enable kleidi AI int4 experimental features to run in graviton3.

cc: @metascroy

Copy link

pytorch-bot bot commented Feb 17, 2025

🔗 Helpful Links

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

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

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

@facebook-github-bot
Copy link
Contributor

Hi @akote123!

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!

@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 Feb 17, 2025
@metascroy
Copy link
Contributor

Hi @akote123, thanks for the PR!

Can you tell me more about which kernels you're trying to run on graviton3?

@akote123
Copy link
Author

akote123 commented Feb 24, 2025

Hi @akote123, thanks for the PR!

Can you tell me more about which kernels you're trying to run on graviton3?

@metascroy ,
I wanted to use torch ao experimental features to quantize the model with int4 kleidi kernels and run quantized model in pytorch.

@akote123 akote123 force-pushed the aruna/aarch64_kleidi branch from 59511cd to 456fecc Compare February 24, 2025 05:39
@akote123 akote123 requested a review from metascroy February 24, 2025 05:41
@metascroy
Copy link
Contributor

metascroy commented Mar 4, 2025

Hi @akote123, thanks for the PR!
Can you tell me more about which kernels you're trying to run on graviton3?

@metascroy , I wanted to use torch ao experimental features to quantize the model with int4 kleidi kernels and run quantized model in pytorch.

Hi @akote123, so there are two kinds of KleidiAI int4 kernels available. One kind is availble in PyTorch itself and models with it can be quantized like this: https://github.com/pytorch/ao/blob/main/torchao/experimental/tests/test_packed_linear_int8_dynamic_activation_intx_weight_layout_target_aten.py#L48-L60

The other belongs in torchao experimental kernels (#1826) and can be built by running:

USE_CPP=1 TORCHAO_BUILD_CPU_AARCH64=1 TORCHAO_BUILD_KLEIDIAI=1 pip install .

from the ao directory (Note that TORCHAO_BUILD_CPU_AARCH64 is automatically set on Arm-based Mac machines).

You can see how to quantize a model using these kernels here: https://github.com/pytorch/ao/blob/main/torchao/experimental/tests/test_int8_dynamic_activation_intx_weight.py#L62-L72 (KleidiAI kernels will only be used with int4, has_weight_zeros=false; otherwise our "universal" kernels will be used. If you build with TORCHAO_BUILD_KLEIDIAI=0, our universal kernels will be used instead of KleidiAI for int4/has_weight_zeros=false, too).

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.

3 participants