-
Notifications
You must be signed in to change notification settings - Fork 87
Add Ascend NPU CANN backend support #307
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 of ChangesHello @leo-pony, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates comprehensive support for the Ascend NPU CANN backend, allowing the application to utilize Huawei's Ascend processors for accelerated AI model execution. The changes encompass updates to the command-line interface for GPU selection, enhanced GPU runtime detection, dynamic mounting of necessary Ascend driver paths within Docker containers, and modifications to the build process for CANN-specific controller images. This significantly broadens the application's hardware compatibility for AI workloads. Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- In tryGetBindAscendMounts, you’re calling fmt.Errorf but not using the returned error—switch to log.Printf or handle the error so the failure is actually reported.
- Currently only libraries and version.info are mounted; you may also need to detect and bind relevant Ascend device nodes (e.g. /dev/ascend*, sockets, etc.) so the container can access the hardware.
- In the Dockerfile’s build stage, make sure uname -m is defined before use and remove trailing whitespace on line-continuation backslashes to avoid unexpected shell parsing issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In tryGetBindAscendMounts, you’re calling fmt.Errorf but not using the returned error—switch to log.Printf or handle the error so the failure is actually reported.
- Currently only libraries and version.info are mounted; you may also need to detect and bind relevant Ascend device nodes (e.g. /dev/ascend*, sockets, etc.) so the container can access the hardware.
- In the Dockerfile’s build stage, make sure uname -m is defined before use and remove trailing whitespace on line-continuation backslashes to avoid unexpected shell parsing issues.
## Individual Comments
### Comment 1
<location> `llamacpp/native/cann.Dockerfile:43-51` </location>
<code_context>
+RUN --mount=type=cache,target=/root/.ccache \
+ cann_in_sys_path=/usr/local/Ascend/ascend-toolkit; \
+ cann_in_user_path=$HOME/Ascend/ascend-toolkit; \
+ if [ -f "${cann_in_sys_path}/set_env.sh" ]; then \
+ source ${cann_in_sys_path}/set_env.sh; \
+ export LD_LIBRARY_PATH=${cann_in_sys_path}/latest/lib64:${cann_in_sys_path}/latest/${uname_m}-linux/devlib:${LD_LIBRARY_PATH} ; \
+ elif [ -f "${cann_in_user_path}/set_env.sh" ]; then \
+ source "$HOME/Ascend/ascend-toolkit/set_env.sh"; \
+ export LD_LIBRARY_PATH=${cann_in_user_path}/latest/lib64:${cann_in_user_path}/latest/${uname_m}-linux/devlib:${LD_LIBRARY_PATH}; \
+ else \
+ echo "No Ascend Toolkit found"; \
+ exit 1; \
+ fi && \
+ cmake --build build --config Release && \
</code_context>
<issue_to_address>
**issue (bug_risk):** Potential issue with undefined variable 'uname_m'.
Please define 'uname_m' before using it in LD_LIBRARY_PATH to prevent runtime errors.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
d75798c to
a997f19
Compare
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.
Code Review
This pull request adds support for Ascend NPU CANN backend. The changes are comprehensive, touching CLI commands, documentation, GPU detection, and container setup. Overall, the implementation is solid, but I've identified a few issues. There are inconsistencies in the updated documentation, a bug in the new Dockerfile that would cause the build to fail, an unhandled error, and a test log file that appears to have been committed by mistake. My review includes specific suggestions to address these points.
9f029ad to
a70a6c2
Compare
|
@ericcurtin I tested it on my local Ascend NPU host and everything seems to be working fine. Could you please help review the code? |
ericcurtin
left a comment
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.
There are conflicts and a build to fix.
But looks great to me! Worth comparing against the recent MUSA PR to see if we forgot anything
@ericcurtin Thank you for your review! However, as I need to attend meetings all day these days, I'll address the CI issue this Thursday or Friday. |
a70a6c2 to
7cc66ca
Compare
@ericcurtin
Others: |
It looks great, hopefully CI goes green |
60f0954 to
0a66d2f
Compare
|
@leo-pony there's a minor conflict (again 😢 ), but once we fix that, I think it's merge time |
Signed-off-by: leo-pony <nengjunma@outlook.com>
Signed-off-by: leo-pony <nengjunma@outlook.com>
0a66d2f to
b10f108
Compare
@ericcurtin Thanks for you quickly review! Please help trigger the CI once more.
|

Add Ascend NPU CANN backend support
In my local host, i test with my build command cann.Dockerfile could been succesfully builded, and started, as following see:
Test running successfully,
Build and start modelrunner
On another terminal run LLM model and inference job:
Start model_runner successfully:
Inference successfully with Ascend NPU:

Ascend NPU resource using:
