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

[CANN] Support cpu offload optimizer for Ascend NPU #4568

Merged
merged 4 commits into from
Nov 14, 2023

Conversation

hipudding
Copy link
Contributor

@hipudding hipudding commented Oct 26, 2023

Support cpu_adam, cpu_adagrad and cpu_lion optimizer for Ascend NPU. All these optimizer are running on host, the difference between each backend is the way to copy params back to device. This commit add a new symbol called "ENABLE_CANN". This symbol can compile code adapted to NPU.
The NPU builder adds the required header files and libraries for compiling, according to CANN's compilation manual.
Note that there's no FusedLion implementation for NPU, test_cpu_lion test case should disabled until FusedLion optimizer implemented.

Besides, when NPU is selected as the accelerator, ds_report will show torch_npu and CANN informations.

With this PR, deepspeed test cases in huggingface/accelerate are all passed.

It's a part of feature list for Ascend NPU support, @see #4567

@hipudding hipudding marked this pull request as draft October 26, 2023 02:35
@hipudding hipudding force-pushed the cpu_adam branch 2 times, most recently from f572373 to 07916e0 Compare October 27, 2023 07:02
@hipudding hipudding changed the title [WIP][CANN] Support cpu_adam optimizer for NPU [CANN] Support cpu offload optimizer for NPU Oct 27, 2023
@hipudding hipudding changed the title [CANN] Support cpu offload optimizer for NPU [CANN] Support cpu offload optimizer for Ascend NPU Oct 27, 2023
@hipudding hipudding force-pushed the cpu_adam branch 2 times, most recently from 4deb6f6 to 11d61cb Compare November 9, 2023 02:22
Support cpu_adam, cpu_adagrad and cpu_lion optimizer for Ascend NPU. All
these optimizer are running on host, the difference between each backend
is the way to copy params back to device. This commit add a new symbol
called __ENABLE_CANN__. This symbol can compile code adapted to NPU.
The NPU builder adds the required header files and libraries for
compiling, according to CANN's compilation manual.
Note that there's no FusedLion implementation for NPU, test_cpu_lion
test case should disabled until FusedLion optimizer implemented.

Besides, when NPU is selected as the accelerator, ds_report will show
torch_npu and CANN informations.
@hipudding hipudding marked this pull request as ready for review November 9, 2023 02:33
@ji-huazhong
Copy link
Contributor

ji-huazhong commented Nov 11, 2023

Hi @tjruwase, please take a look at this PR. 🤗 Deepspeed test cases in huggingface/transformers are also passed. See:huggingface/transformers#27342 (comment)

@hipudding
Copy link
Contributor Author

@tjruwase Format and spell issue has fixed. Please re-trigger checks, Thanks.

@hipudding
Copy link
Contributor Author

All checks are passed. Is it ready to merge now?

@tjruwase tjruwase added this pull request to the merge queue Nov 14, 2023
Merged via the queue into microsoft:master with commit c1ba6a1 Nov 14, 2023
15 checks passed
mauryaavinash95 pushed a commit to mauryaavinash95/DeepSpeed that referenced this pull request Feb 17, 2024
Support cpu_adam, cpu_adagrad and cpu_lion optimizer for Ascend NPU. All
these optimizer are running on host, the difference between each backend
is the way to copy params back to device. This commit add a new symbol
called "__ENABLE_CANN__". This symbol can compile code adapted to NPU.
The NPU builder adds the required header files and libraries for
compiling, according to CANN's compilation manual.
Note that there's no FusedLion implementation for NPU, test_cpu_lion
test case should disabled until FusedLion optimizer implemented.

Besides, when NPU is selected as the accelerator, ds_report will show
torch_npu and CANN informations.

With this PR, deepspeed test cases in
[huggingface/accelerate](https://github.com/huggingface/accelerate/tree/main/tests/deepspeed)
are all passed.

It's a part of feature list for Ascend NPU support, @see microsoft#4567

---------

Co-authored-by: Olatunji Ruwase <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants