Custom AscendC op support in vllm_ascend#371
Custom AscendC op support in vllm_ascend#371wangxiyuan merged 12 commits intovllm-project:v0.7.3-devfrom
Conversation
b760c43 to
e0ce409
Compare
| ROPE_CUSTOM_KERNEL(half) | ||
| ROPE_CUSTOM_KERNEL(bfloat16_t) | ||
|
|
||
| enum struct TurboTypes { |
There was a problem hiding this comment.
Is this repeated with AscendTypes?
There was a problem hiding this comment.
Yes, this part should be removed
| }; | ||
|
|
||
| template <typename scalar_t> | ||
| __aicore__ inline void smem2smem(AscendC::LocalTensor<scalar_t> dst, AscendC::LocalTensor<scalar_t> src, int size) |
There was a problem hiding this comment.
If my understanding is correct, this method is used to copy tensor. Maybe we can give it a more understandable name, like tensorCopy?
BTW, just curious, why we use AscendC::Copy, instead of AscendC::DataCopy here?
There was a problem hiding this comment.
DataCopy indicate HBM to on-chip-memory, but Copy stands for on-chip-memory to on-chip-memory
There was a problem hiding this comment.
tensorCopy is bit of confusing actually, its more related to the memory location, I adopt the name of shared memory here, but maybe I should use another name
|
Please merge this PR sooner, "sleep mode" feature depends on this. @wangxiyuan @MengqingCao |
36dc29c to
aff6e58
Compare
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
fc1aebe to
c907e07
Compare
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
| fe::PlatformInfoManager::GeInstance().GetRuntimePlatformInfosByDevice(device_id, platform_infos); | ||
| uint32_t aivNum = platform_infos.GetCoreNumByType("aiv"); | ||
| uint32_t loop_cnt = (num_tokens + aivNum - 1) / aivNum; | ||
| rotary_embedding_kernel(dtype_num, is_neox, stream, position_ids_ptr, query_ptr, key_ptr, query_ptr, |
There was a problem hiding this comment.
For any case the kernel does not support, please fallback to the native implementation. so can we add the native implementation here, like what we do in torch.
There was a problem hiding this comment.
Maybe we can add a fallback path in next PR in python?
c5985a8 to
cc5d840
Compare
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Add custom ascendc kernel support in vllm-ascend, this PR mainly include 3 parts: - AscendC implementation of rotary_embedding, and its unitest. - CMakeLists.txt to compile AscendC kernel and related torch library binding to this kernel. - Build and pack all the compiled so into the vllm_ascend's package. For now, this rotary embedding kernel dose not support the scenario with `neoxStyle=False`, So its not used in the actual modeling parts. We will soon add this implements into the vllm-ascend and integrate it into the modeling parts. No change at all --------- Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
Add custom ascendc kernel support in vllm-ascend, this PR mainly include 3 parts: - AscendC implementation of rotary_embedding, and its unitest. - CMakeLists.txt to compile AscendC kernel and related torch library binding to this kernel. - Build and pack all the compiled so into the vllm_ascend's package. For now, this rotary embedding kernel dose not support the scenario with `neoxStyle=False`, So its not used in the actual modeling parts. We will soon add this implements into the vllm-ascend and integrate it into the modeling parts. No change at all --------- Signed-off-by: ganyi <pleaplusone.gy@gmail.com>
### What this PR does / why we need it? This PR adds sleep mode feature for vllm-ascend, when sleeps, we do mainly two things: - offload model weights - discard kv cache RLHF tools(such as https://github.com/volcengine/verl and https://github.com/OpenRLHF/OpenRLHF) have a strong need of sleep mode to accelerate the training process. This PR may solve #375 and #320 . ### Does this PR introduce _any_ user-facing change? No existing user interfaces changed. Users will have two new methods(`sleep()` and `wake_up()`) to use. ### How was this patch tested? This PR is tested with Qwen/Qwen2.5-0.5B-Instruct. At first, we have free NPU memory M1. After `llm = LLM("Qwen/Qwen2.5-0.5B-Instruct", enable_sleep_mode=True)` executed, we have free NPU memory M2. M2 < M1. Then we call `llm.sleep(level=1)`, we have free NPU memory M3. We have M3 > M2, M3 is very close to M1. Plus, we have the same output tokens before sleep and after wake up, with the config of `SamplingParams(temperature=0, max_tokens=10)` and with the same input tokens of course. This PR is utilizing the CMake procedure of #371 , thanks a lot. Signed-off-by: Shuqiao Li <celestialli@outlook.com>
### What this PR does / why we need it? This PR adds sleep mode feature for vllm-ascend, when sleeps, we do mainly two things: - offload model weights - discard kv cache RLHF tools(such as https://github.com/volcengine/verl and https://github.com/OpenRLHF/OpenRLHF) have a strong need of sleep mode to accelerate the training process. This PR may solve #375 and #320 . ### Does this PR introduce _any_ user-facing change? No existing user interfaces changed. Users will have two new methods(`sleep()` and `wake_up()`) to use. ### How was this patch tested? This PR is tested with Qwen/Qwen2.5-0.5B-Instruct. At first, we have free NPU memory M1. After `llm = LLM("Qwen/Qwen2.5-0.5B-Instruct", enable_sleep_mode=True)` executed, we have free NPU memory M2. M2 < M1. Then we call `llm.sleep(level=1)`, we have free NPU memory M3. We have M3 > M2, M3 is very close to M1. Plus, we have the same output tokens before sleep and after wake up, with the config of `SamplingParams(temperature=0, max_tokens=10)` and with the same input tokens of course. This PR is utilizing the CMake procedure of #371 , thanks a lot. Signed-off-by: Shuqiao Li <celestialli@outlook.com>
### What this PR does / why we need it? This PR adds sleep mode feature for vllm-ascend, when sleeps, we do mainly two things: - offload model weights - discard kv cache RLHF tools(such as https://github.com/volcengine/verl and https://github.com/OpenRLHF/OpenRLHF) have a strong need of sleep mode to accelerate the training process. This PR may solve vllm-project#375 and vllm-project#320 . ### Does this PR introduce _any_ user-facing change? No existing user interfaces changed. Users will have two new methods(`sleep()` and `wake_up()`) to use. ### How was this patch tested? This PR is tested with Qwen/Qwen2.5-0.5B-Instruct. At first, we have free NPU memory M1. After `llm = LLM("Qwen/Qwen2.5-0.5B-Instruct", enable_sleep_mode=True)` executed, we have free NPU memory M2. M2 < M1. Then we call `llm.sleep(level=1)`, we have free NPU memory M3. We have M3 > M2, M3 is very close to M1. Plus, we have the same output tokens before sleep and after wake up, with the config of `SamplingParams(temperature=0, max_tokens=10)` and with the same input tokens of course. This PR is utilizing the CMake procedure of vllm-project#371 , thanks a lot. Signed-off-by: Shuqiao Li <celestialli@outlook.com>
### What this PR does / why we need it? As plus of #1070, this patch adds `Nominating and Removing Maintainers` section (reference some design from [PyTorch Governance](https://docs.pytorch.org/docs/stable/community/governance.html)) Below are key info about existing maintainers: ## @wangxiyuan: - Super active code and high quality reviewer [450+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3Awangxiyuan). - One of the top contributors, he also active contribute [50+ commits ](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3Awangxiyuan+) with good quality, he dares to [refactor the code](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+author%3Awangxiyuan+is%3Aclosed+refactor), which also shows his deep understanding of vllm and vllm ascend. - He leads the [[RFC]: Hardware pluggable](vllm-project/vllm#11162) feature, this make vllm-ascend project become true. - Active community involved cross wechat group, slack, github issue. Involved on [150+ issue](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3Awangxiyuan) and help users. He is also the spearker of vLLM Beijing meetup help more users understand vLLM Ascend. - Relase manager of [v0.7.1rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.1rc1), [v0.7.3rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3rc1), [v0.7.3rc2](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3rc2), [v0.8.4rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.4rc1), [v0.7.3.post1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3.post1). ## @Yikun: - High active code reviewer: [190+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3AYikun), especially for new developers to help them onboarding. - One of the top contributors with sustained contributions: [50+ commits](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3AYikun+) since the first day of vLLM Ascend. - High quality contributions around vLLM compatibility guarantee and also maintain [CI ](#1040) and [test Framework](#730). - Active community involved cross local group, github issue Involved on [170+ issue](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3AYikun). He is also main organizer of vLLM Beijing Meetup and speaker of [PyTorch Day China 2025](https://pytorchdaychina2025.sched.com/event/2401V/poster-session) to help vLLM Ascend growth. - Relase manager of [v0.8.4rc2](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.4rc2), [v0.8.5rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.5rc1), [v0.7.3](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3). ## @ganyi1996ppo - High active code and high quality reviewer: [90+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3Aganyi1996ppo), he has a deep understanding of Ascend operators can always find some key issues, has deeply understand of the codebase, good code quality and qualified judgement. - Major and high quality contributions: [10+ commits](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3Aganyi1996ppo) with high quality. - He is the main contributor of [Custom AscendC op support](#371), [Deepseekv3 performance optimization](#598). - Community Involvement: Involved on [11+ issue and help users](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3Aganyi1996ppo), share [custom ops topic](https://www.bilibili.com/video/BV1Z25az3EqS/?share_source=copy_web&vd_source=72ef9c665af5f2f1370abe26ce1f719f&t=1342) on vLLM Ascend Weekly meeting. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Preview Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
### What this PR does / why we need it? As plus of vllm-project#1070, this patch adds `Nominating and Removing Maintainers` section (reference some design from [PyTorch Governance](https://docs.pytorch.org/docs/stable/community/governance.html)) Below are key info about existing maintainers: ## @wangxiyuan: - Super active code and high quality reviewer [450+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3Awangxiyuan). - One of the top contributors, he also active contribute [50+ commits ](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3Awangxiyuan+) with good quality, he dares to [refactor the code](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+author%3Awangxiyuan+is%3Aclosed+refactor), which also shows his deep understanding of vllm and vllm ascend. - He leads the [[RFC]: Hardware pluggable](vllm-project/vllm#11162) feature, this make vllm-ascend project become true. - Active community involved cross wechat group, slack, github issue. Involved on [150+ issue](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3Awangxiyuan) and help users. He is also the spearker of vLLM Beijing meetup help more users understand vLLM Ascend. - Relase manager of [v0.7.1rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.1rc1), [v0.7.3rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3rc1), [v0.7.3rc2](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3rc2), [v0.8.4rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.4rc1), [v0.7.3.post1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3.post1). ## @Yikun: - High active code reviewer: [190+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3AYikun), especially for new developers to help them onboarding. - One of the top contributors with sustained contributions: [50+ commits](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3AYikun+) since the first day of vLLM Ascend. - High quality contributions around vLLM compatibility guarantee and also maintain [CI ](vllm-project#1040) and [test Framework](vllm-project#730). - Active community involved cross local group, github issue Involved on [170+ issue](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3AYikun). He is also main organizer of vLLM Beijing Meetup and speaker of [PyTorch Day China 2025](https://pytorchdaychina2025.sched.com/event/2401V/poster-session) to help vLLM Ascend growth. - Relase manager of [v0.8.4rc2](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.4rc2), [v0.8.5rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.5rc1), [v0.7.3](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3). ## @ganyi1996ppo - High active code and high quality reviewer: [90+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3Aganyi1996ppo), he has a deep understanding of Ascend operators can always find some key issues, has deeply understand of the codebase, good code quality and qualified judgement. - Major and high quality contributions: [10+ commits](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3Aganyi1996ppo) with high quality. - He is the main contributor of [Custom AscendC op support](vllm-project#371), [Deepseekv3 performance optimization](vllm-project#598). - Community Involvement: Involved on [11+ issue and help users](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3Aganyi1996ppo), share [custom ops topic](https://www.bilibili.com/video/BV1Z25az3EqS/?share_source=copy_web&vd_source=72ef9c665af5f2f1370abe26ce1f719f&t=1342) on vLLM Ascend Weekly meeting. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Preview Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
### What this PR does / why we need it? This PR adds sleep mode feature for vllm-ascend, when sleeps, we do mainly two things: - offload model weights - discard kv cache RLHF tools(such as https://github.com/volcengine/verl and https://github.com/OpenRLHF/OpenRLHF) have a strong need of sleep mode to accelerate the training process. This PR may solve vllm-project#375 and vllm-project#320 . ### Does this PR introduce _any_ user-facing change? No existing user interfaces changed. Users will have two new methods(`sleep()` and `wake_up()`) to use. ### How was this patch tested? This PR is tested with Qwen/Qwen2.5-0.5B-Instruct. At first, we have free NPU memory M1. After `llm = LLM("Qwen/Qwen2.5-0.5B-Instruct", enable_sleep_mode=True)` executed, we have free NPU memory M2. M2 < M1. Then we call `llm.sleep(level=1)`, we have free NPU memory M3. We have M3 > M2, M3 is very close to M1. Plus, we have the same output tokens before sleep and after wake up, with the config of `SamplingParams(temperature=0, max_tokens=10)` and with the same input tokens of course. This PR is utilizing the CMake procedure of vllm-project#371 , thanks a lot. Signed-off-by: Shuqiao Li <celestialli@outlook.com>
### What this PR does / why we need it? As plus of vllm-project#1070, this patch adds `Nominating and Removing Maintainers` section (reference some design from [PyTorch Governance](https://docs.pytorch.org/docs/stable/community/governance.html)) Below are key info about existing maintainers: ## @wangxiyuan: - Super active code and high quality reviewer [450+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3Awangxiyuan). - One of the top contributors, he also active contribute [50+ commits ](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3Awangxiyuan+) with good quality, he dares to [refactor the code](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+author%3Awangxiyuan+is%3Aclosed+refactor), which also shows his deep understanding of vllm and vllm ascend. - He leads the [[RFC]: Hardware pluggable](vllm-project/vllm#11162) feature, this make vllm-ascend project become true. - Active community involved cross wechat group, slack, github issue. Involved on [150+ issue](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3Awangxiyuan) and help users. He is also the spearker of vLLM Beijing meetup help more users understand vLLM Ascend. - Relase manager of [v0.7.1rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.1rc1), [v0.7.3rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3rc1), [v0.7.3rc2](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3rc2), [v0.8.4rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.4rc1), [v0.7.3.post1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3.post1). ## @Yikun: - High active code reviewer: [190+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3AYikun), especially for new developers to help them onboarding. - One of the top contributors with sustained contributions: [50+ commits](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3AYikun+) since the first day of vLLM Ascend. - High quality contributions around vLLM compatibility guarantee and also maintain [CI ](vllm-project#1040) and [test Framework](vllm-project#730). - Active community involved cross local group, github issue Involved on [170+ issue](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3AYikun). He is also main organizer of vLLM Beijing Meetup and speaker of [PyTorch Day China 2025](https://pytorchdaychina2025.sched.com/event/2401V/poster-session) to help vLLM Ascend growth. - Relase manager of [v0.8.4rc2](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.4rc2), [v0.8.5rc1](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.8.5rc1), [v0.7.3](https://github.com/vllm-project/vllm-ascend/releases/tag/v0.7.3). ## @ganyi1996ppo - High active code and high quality reviewer: [90+ PR reviewed](https://github.com/vllm-project/vllm-ascend/pulls?q=commenter%3Aganyi1996ppo), he has a deep understanding of Ascend operators can always find some key issues, has deeply understand of the codebase, good code quality and qualified judgement. - Major and high quality contributions: [10+ commits](https://github.com/vllm-project/vllm-ascend/pulls?q=is%3Apr+is%3Aclosed+review%3Aapproved+author%3Aganyi1996ppo) with high quality. - He is the main contributor of [Custom AscendC op support](vllm-project#371), [Deepseekv3 performance optimization](vllm-project#598). - Community Involvement: Involved on [11+ issue and help users](https://github.com/vllm-project/vllm-ascend/issues?q=is%3Aissue%20state%3Aopen%20commenter%3Aganyi1996ppo), share [custom ops topic](https://www.bilibili.com/video/BV1Z25az3EqS/?share_source=copy_web&vd_source=72ef9c665af5f2f1370abe26ce1f719f&t=1342) on vLLM Ascend Weekly meeting. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Preview Signed-off-by: Yikun Jiang <yikunkero@gmail.com>
What this PR does / why we need it?
Add custom ascendc kernel support in vllm-ascend, this PR mainly include 3 parts:
For now, this rotary embedding kernel dose not support the scenario with
neoxStyle=False, So its not used in the actual modeling parts. We will soon add this implements into the vllm-ascend and integrate it into the modeling parts.Does this PR introduce any user-facing change?
No change at all