Skip to content

[Feature] Add resource mapping for Huawei Ascend NPUs - #5071

Open
bakhovaddinov wants to merge 1 commit into
ray-project:masterfrom
bakhovaddinov:feat/huawei-npu-support
Open

[Feature] Add resource mapping for Huawei Ascend NPUs#5071
bakhovaddinov wants to merge 1 commit into
ray-project:masterfrom
bakhovaddinov:feat/huawei-npu-support

Conversation

@bakhovaddinov

@bakhovaddinov bakhovaddinov commented Aug 3, 2026

Copy link
Copy Markdown

This adds prefix-based resource mapping for Huawei Ascend NPUs to properly inject Ray NPU limits. Resolves #5039.

Why are these changes needed?

This PR adds native support for Huawei Ascend NPUs in KubeRay by mapping Kubernetes Ascend device resources to Ray's logical NPU resource.

Because Huawei device plugins and virtualization schedulers (like HAMi) expose several variations of resource names depending on the chip model and slicing (e.g., huawei.com/Ascend910B, huawei.com/ascend-1980, huawei.com/npu), this change introduces a case-insensitive prefix check (huawei.com/ascend) instead of hardcoding exact exact model names in the customAcceleratorToRayResourceMap.

This ensures that the operator correctly parses the limits and automatically injects --resources='{"NPU": X}' into the Ray worker startup parameters for all current and future Ascend hardware generations.

The refactor also unifies the accelerator resource mapping logic across both code paths that populate rayStartParams (top-level Resources field and container resources.limits). Previously, custom accelerators like google.com/tpu and aws.amazon.com/neuroncore could end up under different keys in --resources depending on which field was used. Both paths now go through getCustomAcceleratorRayResourceName, producing consistent Ray resource names (TPU, neuron_cores) regardless of the input field.

Related issue number

Closes #5039

Labels

  • If this PR has user-facing changes that require documentation updates at release time, I have added the doc-updates-required label.
  • If this PR contains breaking changes, I have added the breaking-change label.

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

Comment thread ray-operator/controllers/ray/common/pod_test.go Outdated
Comment thread ray-operator/controllers/ray/common/pod_test.go
@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch from 3d6a610 to 9f61605 Compare August 3, 2026 12:02

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 9f61605. Configure here.

Comment thread ray-operator/controllers/ray/common/pod.go
@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch from 9f61605 to 08a956e Compare August 3, 2026 12:29
Comment thread ray-operator/controllers/ray/common/pod.go Outdated
@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch from 08a956e to 7e18a52 Compare August 4, 2026 11:20
Comment thread ray-operator/controllers/ray/common/pod.go
Comment thread ray-operator/controllers/ray/common/pod.go Outdated
@bakhovaddinov
bakhovaddinov requested a review from win5923 August 4, 2026 14:39
@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch from 7e18a52 to dda4d17 Compare August 4, 2026 14:58
@bakhovaddinov

Copy link
Copy Markdown
Author

@win5923 @machichima I think the failed test in the pipeline is flaky or something. Any way to merge without it passing or trigger a new run?

@win5923

win5923 commented Aug 4, 2026

Copy link
Copy Markdown
Member

Have you rebase onto latest main branch? We recently fixed some flaky tests.

@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch from dda4d17 to ef5e735 Compare August 5, 2026 08:33
@bakhovaddinov

Copy link
Copy Markdown
Author

Have you rebase onto latest main branch? We recently fixed some flaky tests.

sorry, I was afk. I've rebased just now and now a new test fails

@win5923

win5923 commented Aug 5, 2026

Copy link
Copy Markdown
Member

Sorry for the inconvenience. We have a PR fixes this. You can rebase again once #5084 is merged.

@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch 2 times, most recently from 04eda9d to e87ca84 Compare August 6, 2026 09:10
@bakhovaddinov

Copy link
Copy Markdown
Author

@win5923 @machichima @rueian @andrewsykim can we merge this please?

Comment thread ray-operator/controllers/ray/common/pod.go
Comment thread ray-operator/controllers/ray/common/pod.go Outdated
Comment thread ray-operator/controllers/ray/common/pod.go
Comment thread ray-operator/controllers/ray/common/pod_test.go Outdated
Comment thread ray-operator/controllers/ray/utils/resources_test.go Outdated
Comment thread ray-operator/controllers/ray/common/pod_test.go Outdated
@machichima

Copy link
Copy Markdown
Collaborator

Overall LGTM, just few comments

This adds prefix-based resource mapping for Huawei Ascend NPUs to properly inject Ray NPU limits. Resolves ray-project#5039.

Signed-off-by: Iskandar Bahovaddinov <bakhovaddinov@gmail.com>
@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch from e87ca84 to 50a8692 Compare August 6, 2026 13:58

@machichima machichima left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! cc @rueian or @andrewsykim to merge. The CI failure is not related to this PR

@bakhovaddinov

Copy link
Copy Markdown
Author

LGTM! cc @rueian or @andrewsykim to merge. The CI failure is not related to this PR

is there an issue regarding the CI failure problem? It's quite annoying honestly, I could have a look at the weekends

@machichima

machichima commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

is there an issue regarding the CI failure problem? It's quite annoying honestly, I could have a look at the weekends

Yeah agree. There's an issue for this #4782 and someone is working on it

@bakhovaddinov
bakhovaddinov force-pushed the feat/huawei-npu-support branch from 86ed1cc to 50a8692 Compare August 7, 2026 10:25
@bakhovaddinov

bakhovaddinov commented Aug 7, 2026

Copy link
Copy Markdown
Author

@rueian @andrewsykim could we merge please?

@bakhovaddinov

bakhovaddinov commented Aug 10, 2026

Copy link
Copy Markdown
Author

@machichima @win5923 @rueian @andrewsykim I'm sorry to bother you again, guys. Is there anything I can do to make this PR closer to merge? Kinda confused if the problem is on my end or CI related. I've triggered CI a few times, something keeps failing. Does it prevent the merge?

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.

[Feature] Native support for Huawei Ascend NPUs ([huawei.com/Ascend](https://huawei.com/Ascend)*)

3 participants