Skip to content

Add Ascend NPU Support #1521

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

Merged
merged 9 commits into from
Apr 21, 2025
Merged

Add Ascend NPU Support #1521

merged 9 commits into from
Apr 21, 2025

Conversation

xuedinge233
Copy link
Contributor

@xuedinge233 xuedinge233 commented Apr 2, 2025

This PR introduces native support for Huawei Ascend NPU acceleration in generative AI tasks and chat applications. The implementation leverages Ascend's CANN computing architecture to optimize tensor operations for large language models.

Compatibility Matrix:
Python 3.10.15
torch 2.7.0+cpu
torch_npu 2.7.0+git36b5d8c (nightly)
torchvision 0.22.0
torchtune 0.6.0

The following is the result generated using Llama3.1.
image

Copy link

pytorch-bot bot commented Apr 2, 2025

🔗 Helpful Links

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

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 c4aba33 with merge base f7c4f14 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot
Copy link

Hi @xuedinge233!

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 Meta Open Source bot. label Apr 3, 2025
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@xuedinge233 xuedinge233 changed the title Add Ascend NPU device support for generate Add Huawei Ascend NPU Support for Generative & Chat Workloads Apr 3, 2025
@xuedinge233 xuedinge233 changed the title Add Huawei Ascend NPU Support for Generative & Chat Workloads Add Ascend NPU Support Apr 3, 2025
@xuedinge233 xuedinge233 marked this pull request as ready for review April 8, 2025 09:48
@xuedinge233
Copy link
Contributor Author

xuedinge233 commented Apr 11, 2025

@Jack-Khuu @mikekgfb Hello,can you help review this PR?

Copy link
Contributor

@Jack-Khuu Jack-Khuu 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 addition!

Looking good, just a question about the pytorch install source

@@ -71,6 +71,9 @@ then
elif [[ -x "$(command -v xpu-smi)" ]];
then
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/nightly/xpu"
elif [[ -x "$(command -v npu-smi)" ]]
then
TORCH_NIGHTLY_URL="https://download.pytorch.org/whl/test/cpu"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we using a test wheel?

Copy link

Choose a reason for hiding this comment

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

Hey @Jack-Khuu thanks for your review. IMO, we should use nightly pytorch wheels like other backends. What do you think? @hipudding @xuedinge233

Copy link

Choose a reason for hiding this comment

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

But, we usually use pytorch RC versions, not sure if everything works fine on nightly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Torch_npu is currently released following the test version of the PyTorch wheels. but after testing, nightly is also effective, so following the source code, modify it to the nightly version.

The latest version of torch_npu is 2.7.0, so torch has been fixed at version 2.7.0

Copy link
Contributor

@Jack-Khuu Jack-Khuu left a comment

Choose a reason for hiding this comment

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

Please rebase

@xuedinge233
Copy link
Contributor Author

Please rebase

done.

@Jack-Khuu Jack-Khuu merged commit 701d826 into pytorch:main Apr 21, 2025
72 checks passed
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 Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants