-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Add Ascend NPU support #975
Conversation
Why NPU cannot use the bfloat16 data type? |
Support for bfloat16 is still in the works and will likely be available by the end of the year 😃 |
I have added |
if is_torch_npu_available(): | ||
infer_dtype = torch.float16 | ||
else: | ||
infer_dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16 # detect cuda capability |
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.
Here is an if statement to evaluate the compatibility of the bf16 data type of the current computing environment.
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.
torch.cuda.is_bf16_supported
will cause a runtime error on an NPU environment.
FYI, to use PyTorch on NPU, users need to install both torch-cpu and torch-npu. As a result, cuda-related code is not included.
accelerate选MULTI_NPU就可以直接使用npu训练吗,不需要修改代码吗,我这边训练报超时错误。 npuSynchronizeDevice:/usr1/02/workspace/j_vqN6BFvg/pytorch/torch_npu/csrc/core/npu/NPUStream.cpp:370 NPU error, error code is 107020. |
@shirwy 建议先试试单卡 |
What does this PR do?
This PR integrates Ascend NPU hardware capabilities into the LLaMA-Efficient-Tuning, and enables users to leverage the NPUs for training, inference and serving of LLMs.
Ascend NPU is an AI processor that support AI frameworks like PyTorch, TensorFlow, which has already integrated by huggingface, deepspeed and others popular LLM related software and tools.
As mentioned above, Ascend NPU already supports libraries such as Transformers/Accelerate, so you can refer to the fine-tuning instructions in the README to perform LLM fine-tuning tasks directly on Ascend NPU.
The model export phase requires adding Ascend NPU adaptation logic, which is addressed in this patch.