Ascend-native hardware plugin for ray
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[ci] Fix publish version update in container (#63) ## Summary Fix the publish workflow version update step in the container environment. ## Changes - Pass the release version from GITHUB_REF directly to ci/update_version.py. - Pass the commit SHA from GITHUB_SHA instead of calling git rev-parse HEAD inside the container. ## Why The self-hosted container runner can fail when running git commands inside the container. Using GitHub Actions environment variables avoids that dependency. ## Validation - Locally verified that ci/update_version.py writes the expected version and commit when given GITHUB_REF and GITHUB_SHA values. Signed-off-by: tianyi-huawei <[email protected]> Co-authored-by: tianyi-huawei <[email protected]> | 1 个月前 | |
[ci] add basic ci for pre-commit/build/test/doc/publish (#23) * 1. add github workflow: dco check, pre-commit, ci (build, tests), publish to github release/pypi 2. support versioning when publish Signed-off-by: tianyi-huawei <[email protected]> * fix pre-commit check Signed-off-by: tianyi-huawei <[email protected]> * trigger build and test on each push Signed-off-by: tianyi-huawei <[email protected]> * 1. support manually-triggered workflow with publish version 2. support full installation in ci.yml Signed-off-by: tianyi-huawei <[email protected]> * 1. enforce ray version >= 2.54.0 to use register tensor transport 2. merge build and test to one job 3. fix yr tensor transport Signed-off-by: tianyi-huawei <[email protected]> * fix doc build ci Signed-off-by: tianyi-huawei <[email protected]> * update ascend runner name Signed-off-by: tianyi-huawei <[email protected]> * fix copilot nit Signed-off-by: tianyi-huawei <[email protected]> * modify ci container image Signed-off-by: tianyi-huawei <[email protected]> * 1. fix cann version 2. add pytest-cov to pyproject Signed-off-by: tianyi-huawei <[email protected]> * pip install requirements Signed-off-by: tianyi-huawei <[email protected]> --------- Signed-off-by: tianyi-huawei <[email protected]> Co-authored-by: tianyi-huawei <[email protected]> | 4 个月前 | |
[docs] Improve API reference documentation (#65) # Description - **Standardized format** for each API with clear sections: Description, Parameters, Returns, Raises, Notes, and Examples - **Added complete code examples** with proper imports and realistic usage patterns - **Improved clarity** on when and where each function should be called # Fix - #58 --------- Signed-off-by: Artimislyy <[email protected]> | 1 个月前 | |
Unify the style of type annotations (#64) ## Description - Add type annotations to function signatures - Add Adjust function annotations style and complete functions that lack annotations - Add pydoclint to _.pre-commit-config.yaml_ --------- Signed-off-by: dpj135 <[email protected]> | 1 个月前 | |
[feat] Add HCCL tensor transport for RDT (#21) ## Description - Implement HCCLTensorTransport to integrate HCCL with RDT tensor transport flow and enable explicit registration - Add HCCL collective backend tests by using register_collective_backend API - Add tests covering HCCL tensor transport usage in RDT - Provide register_hccl_collective_backend, register_hccl_tensor_transport, and register_yr_tensor_transport API - Update the usage doc ## Self-Check Result - HCCL collective backend tests by using register_collective_backend API: bash [root@devserver-bms-54 ray-ascend]# pytest -v /home/hhc/ray_wp/ray-ascend/tests/collective/test_hccl_via_registry.py ====================================================================== test session starts ======================================================================= platform linux -- Python 3.10.16, pytest-8.3.4, pluggy-1.5.0 -- /usr/bin/python cachedir: .pytest_cache Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type> rootdir: /home/hhc/ray_wp/ray-ascend configfile: pyproject.toml plugins: cov-6.2.1, hydra-core-1.3.2, jaxtyping-0.3.2, anyio-4.8.0, random-order-1.2.0, mock-3.14.1, typeguard-4.3.0 collected 6 items tests/collective/test_hccl_via_registry.py::test_allreduce PASSED [ 16%] tests/collective/test_hccl_via_registry.py::test_broadcast PASSED [ 33%] tests/collective/test_hccl_via_registry.py::test_allgather PASSED [ 50%] tests/collective/test_hccl_via_registry.py::test_reduce PASSED [ 66%] tests/collective/test_hccl_via_registry.py::test_reducescatter PASSED [ 83%] tests/collective/test_hccl_via_registry.py::test_send_recv PASSED [100%] ======================================================================== warnings summary ======================================================================== tests/collective/test_hccl_via_registry.py::test_allreduce /usr/local/python3.10.16/lib/python3.10/site-packages/ray/_private/worker.py:2052: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0 warnings.warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ========================================================================= tests coverage ========================================================================= ________________________________________________________ coverage: platform linux, python 3.10.16-final-0 ________________________________________________________ Name Stmts Miss Cover Missing --------------------------------------------------------------------------------------- ray_ascend/__init__.py 0 0 100% ray_ascend/_version.py 13 13 0% 4-34 ray_ascend/collective/__init__.py 2 0 100% ray_ascend/collective/hccl_collective_group.py 334 259 22% 30, 34-36, 65-83, 94-102, 118-119, 122-123, 126-130, 136-146, 150-162, 167, 173-181, 197-222, 241-274, 291-315, 326-333, 347-374, 393-426, 441-461, 476-496, 499-512, 524-554, 558-560, 572-585, 589-615, 625-636, 640-642, 647-653, 668-677 ray_ascend/direct_transport/__init__.py 3 3 0% 1-8 ray_ascend/direct_transport/hccl_tensor_transport.py 9 9 0% 1-22 ray_ascend/direct_transport/yr_tensor_transport.py 116 116 0% 1-253 ray_ascend/direct_transport/yr_tensor_transport_util.py 44 44 0% 1-91 --------------------------------------------------------------------------------------- TOTAL 521 444 15% Coverage HTML written to dir htmlcov Coverage XML written to file coverage.xml ============================================================ 6 passed, 1 warning in 60.06s (0:01:00) ============================================================= - HCCL tensor transport tests: bash [root@devserver-bms-54 ray-ascend]# pytest -v /home/hhc/ray_wp/ray-ascend/tests/direct_transport/test_hccl_tensor_transport.py ====================================================================== test session starts ======================================================================= platform linux -- Python 3.10.16, pytest-8.3.4, pluggy-1.5.0 -- /usr/bin/python cachedir: .pytest_cache Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type> rootdir: /home/hhc/ray_wp/ray-ascend configfile: pyproject.toml plugins: cov-6.2.1, hydra-core-1.3.2, jaxtyping-0.3.2, anyio-4.8.0, random-order-1.2.0, mock-3.14.1, typeguard-4.3.0 collected 1 item tests/direct_transport/test_hccl_tensor_transport.py::test_hccl_tensor_transport PASSED [100%] ======================================================================== warnings summary ======================================================================== tests/direct_transport/test_hccl_tensor_transport.py::test_hccl_tensor_transport /usr/local/python3.10.16/lib/python3.10/site-packages/ray/_private/worker.py:2052: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0 warnings.warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ========================================================================= tests coverage ========================================================================= ________________________________________________________ coverage: platform linux, python 3.10.16-final-0 ________________________________________________________ Name Stmts Miss Cover Missing --------------------------------------------------------------------------------------- ray_ascend/__init__.py 0 0 100% ray_ascend/_version.py 13 13 0% 4-34 ray_ascend/collective/__init__.py 2 0 100% ray_ascend/collective/hccl_collective_group.py 334 259 22% 30, 34-36, 65-83, 94-102, 118-119, 122-123, 126-130, 136-146, 150-162, 167, 173-181, 197-222, 241-274, 291-315, 326-333, 347-374, 393-426, 441-461, 476-496, 499-512, 524-554, 558-560, 572-585, 589-615, 625-636, 640-642, 647-653, 668-677 ray_ascend/direct_transport/__init__.py 3 0 100% ray_ascend/direct_transport/hccl_tensor_transport.py 9 2 78% 21-22 ray_ascend/direct_transport/yr_tensor_transport.py 116 82 29% 47-49, 52, 56, 60, 66-104, 107-125, 140-152, 160-173, 185, 194-220, 238-248 ray_ascend/direct_transport/yr_tensor_transport_util.py 44 22 50% 9-10, 22-23, 46, 49, 53-55, 58-59, 62-63, 66, 71, 79, 82-83, 86-87, 90-91 --------------------------------------------------------------------------------------- TOTAL 521 378 27% Coverage HTML written to dir htmlcov Coverage XML written to file coverage.xml ============================================================ 1 passed, 1 warning in 68.25s (0:01:08) ============================================================= ## Related issues Closes #9 #3 --------- Signed-off-by: Haichuan Hu <[email protected]> | 1 个月前 | |
re-commit lost commits Signed-off-by: dpj135 <[email protected]> | 4 个月前 | |
Unify the style of type annotations (#64) ## Description - Add type annotations to function signatures - Add Adjust function annotations style and complete functions that lack annotations - Add pydoclint to _.pre-commit-config.yaml_ --------- Signed-off-by: dpj135 <[email protected]> | 1 个月前 | |
[docs] Developers guide document (#19) ## Description - Complete the developer guide documentation: developer_guide/ |-- index.md |-- setup.md |-- contributing.md - Add the markdown format check to pre-commit. --------- Signed-off-by: dpj135 <[email protected]> | 3 个月前 | |
[chore] add copyright to LISCENSE and unused import check to pre-commit (#27) ## Description - add copyright to LISCENSE - add unused import check to pre-commit <img width="1380" height="684" alt="image" src="https://github.com/user-attachments/assets/e6c0d04b-078a-4026-840a-cb8a24ee0cb5" /> ## Related issues - Fixed #18 , #24 --------- Signed-off-by: dpj135 <[email protected]> | 4 个月前 | |
[feat] Add HCCL tensor transport for RDT (#21) ## Description - Implement HCCLTensorTransport to integrate HCCL with RDT tensor transport flow and enable explicit registration - Add HCCL collective backend tests by using register_collective_backend API - Add tests covering HCCL tensor transport usage in RDT - Provide register_hccl_collective_backend, register_hccl_tensor_transport, and register_yr_tensor_transport API - Update the usage doc ## Self-Check Result - HCCL collective backend tests by using register_collective_backend API: bash [root@devserver-bms-54 ray-ascend]# pytest -v /home/hhc/ray_wp/ray-ascend/tests/collective/test_hccl_via_registry.py ====================================================================== test session starts ======================================================================= platform linux -- Python 3.10.16, pytest-8.3.4, pluggy-1.5.0 -- /usr/bin/python cachedir: .pytest_cache Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type> rootdir: /home/hhc/ray_wp/ray-ascend configfile: pyproject.toml plugins: cov-6.2.1, hydra-core-1.3.2, jaxtyping-0.3.2, anyio-4.8.0, random-order-1.2.0, mock-3.14.1, typeguard-4.3.0 collected 6 items tests/collective/test_hccl_via_registry.py::test_allreduce PASSED [ 16%] tests/collective/test_hccl_via_registry.py::test_broadcast PASSED [ 33%] tests/collective/test_hccl_via_registry.py::test_allgather PASSED [ 50%] tests/collective/test_hccl_via_registry.py::test_reduce PASSED [ 66%] tests/collective/test_hccl_via_registry.py::test_reducescatter PASSED [ 83%] tests/collective/test_hccl_via_registry.py::test_send_recv PASSED [100%] ======================================================================== warnings summary ======================================================================== tests/collective/test_hccl_via_registry.py::test_allreduce /usr/local/python3.10.16/lib/python3.10/site-packages/ray/_private/worker.py:2052: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0 warnings.warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ========================================================================= tests coverage ========================================================================= ________________________________________________________ coverage: platform linux, python 3.10.16-final-0 ________________________________________________________ Name Stmts Miss Cover Missing --------------------------------------------------------------------------------------- ray_ascend/__init__.py 0 0 100% ray_ascend/_version.py 13 13 0% 4-34 ray_ascend/collective/__init__.py 2 0 100% ray_ascend/collective/hccl_collective_group.py 334 259 22% 30, 34-36, 65-83, 94-102, 118-119, 122-123, 126-130, 136-146, 150-162, 167, 173-181, 197-222, 241-274, 291-315, 326-333, 347-374, 393-426, 441-461, 476-496, 499-512, 524-554, 558-560, 572-585, 589-615, 625-636, 640-642, 647-653, 668-677 ray_ascend/direct_transport/__init__.py 3 3 0% 1-8 ray_ascend/direct_transport/hccl_tensor_transport.py 9 9 0% 1-22 ray_ascend/direct_transport/yr_tensor_transport.py 116 116 0% 1-253 ray_ascend/direct_transport/yr_tensor_transport_util.py 44 44 0% 1-91 --------------------------------------------------------------------------------------- TOTAL 521 444 15% Coverage HTML written to dir htmlcov Coverage XML written to file coverage.xml ============================================================ 6 passed, 1 warning in 60.06s (0:01:00) ============================================================= - HCCL tensor transport tests: bash [root@devserver-bms-54 ray-ascend]# pytest -v /home/hhc/ray_wp/ray-ascend/tests/direct_transport/test_hccl_tensor_transport.py ====================================================================== test session starts ======================================================================= platform linux -- Python 3.10.16, pytest-8.3.4, pluggy-1.5.0 -- /usr/bin/python cachedir: .pytest_cache Test order randomisation NOT enabled. Enable with --random-order or --random-order-bucket=<bucket_type> rootdir: /home/hhc/ray_wp/ray-ascend configfile: pyproject.toml plugins: cov-6.2.1, hydra-core-1.3.2, jaxtyping-0.3.2, anyio-4.8.0, random-order-1.2.0, mock-3.14.1, typeguard-4.3.0 collected 1 item tests/direct_transport/test_hccl_tensor_transport.py::test_hccl_tensor_transport PASSED [100%] ======================================================================== warnings summary ======================================================================== tests/direct_transport/test_hccl_tensor_transport.py::test_hccl_tensor_transport /usr/local/python3.10.16/lib/python3.10/site-packages/ray/_private/worker.py:2052: FutureWarning: Tip: In future versions of Ray, Ray will no longer override accelerator visible devices env var if num_gpus=0 or num_gpus=None (default). To enable this behavior and turn off this error message, set RAY_ACCEL_ENV_VAR_OVERRIDE_ON_ZERO=0 warnings.warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ========================================================================= tests coverage ========================================================================= ________________________________________________________ coverage: platform linux, python 3.10.16-final-0 ________________________________________________________ Name Stmts Miss Cover Missing --------------------------------------------------------------------------------------- ray_ascend/__init__.py 0 0 100% ray_ascend/_version.py 13 13 0% 4-34 ray_ascend/collective/__init__.py 2 0 100% ray_ascend/collective/hccl_collective_group.py 334 259 22% 30, 34-36, 65-83, 94-102, 118-119, 122-123, 126-130, 136-146, 150-162, 167, 173-181, 197-222, 241-274, 291-315, 326-333, 347-374, 393-426, 441-461, 476-496, 499-512, 524-554, 558-560, 572-585, 589-615, 625-636, 640-642, 647-653, 668-677 ray_ascend/direct_transport/__init__.py 3 0 100% ray_ascend/direct_transport/hccl_tensor_transport.py 9 2 78% 21-22 ray_ascend/direct_transport/yr_tensor_transport.py 116 82 29% 47-49, 52, 56, 60, 66-104, 107-125, 140-152, 160-173, 185, 194-220, 238-248 ray_ascend/direct_transport/yr_tensor_transport_util.py 44 22 50% 9-10, 22-23, 46, 49, 53-55, 58-59, 62-63, 66, 71, 79, 82-83, 86-87, 90-91 --------------------------------------------------------------------------------------- TOTAL 521 378 27% Coverage HTML written to dir htmlcov Coverage XML written to file coverage.xml ============================================================ 1 passed, 1 warning in 68.25s (0:01:08) ============================================================= ## Related issues Closes #9 #3 --------- Signed-off-by: Haichuan Hu <[email protected]> | 1 个月前 | |
[ci] Update publish workflow and dependency ranges (#60) ## Summary This PR updates the release workflow and relaxes optional dependency requirements. ## Changes - Remove manual workflow_dispatch publishing so releases are triggered only by v* tags. - Fix artifact download paths by enabling merge-multiple before GitHub Release and PyPI publishing. - Explicitly use the pushed tag name for GitHub Release creation. - Relax torch and torch-npu optional dependency pins to minimum supported versions. - Update README and user guide dependency docs for CANN, torch, and torch-npu. --------- Signed-off-by: tianyi-huawei <[email protected]> Co-authored-by: tianyi-huawei <[email protected]> | 1 个月前 | |
[chore]: Upgrade base Ray version to 2.55 (#48) ## Description Upgrade base Ray version to 2.55 to adapt to the new RDT API breaking changes. Ray 2.55 introduced breaking changes including the register_tensor_transport function now requiring a data_type parameter, the TensorTransportManager interface changes with new parameters for recv_multiple_tensors and garbage_collect, and the module path change from ray.experimental.gpu_object_manager to ray.experimental.rdt. ## Changes - Updated import path in YRTensorTransport.actor_has_tensor_transport: ray.experimental.gpu_object_manager.util →ray.experimental.rdt.util - Added target_buffers: Optional[List[Any]] parameter to recv_multiple_tensors method signature - Added tensors: Optional[List[Any]] parameter to garbage_collect method signature with proper type annotation - Changed tensor_device from torch.device object to device type string (device.type) to match Ray's device_match_transport check - Added torch.Tensor as data_type to all register_tensor_transport calls across the codebase - Removed unused yr_is_available_in_actor function that referenced deprecated module - Fixed reducescatter stream synchronization in HCCL collective group with event-based synchronization before and after HCCL operations - Updated tests to expect string device type instead of torch.device object ## Related issues Fixes #47 #37 Signed-off-by: Haichuan Hu <[email protected]> | 2 个月前 |
以下内容由 AI 翻译,如有问题请 点此提交 issue 反馈
Ray Ascend 插件
概述
ray-ascend 是一个社区维护的硬件插件,支持在昇腾 NPU 加速器上运行高级 Ray 功能。
默认情况下,Ray 原生支持将昇腾 NPU 作为预定义资源类型,用于绑定 actor 和任务(详见 Ray 加速器支持)。作为增强工具,ray-ascend 提供了 Ray 上的昇腾原生功能,例如通过 华为集合通信库(HCCL) 实现的集合通信、Ray 直接传输(RDT) 等。
性能基准测试详见 性能基准测试报告。
前提条件
- 架构:aarch64、x86
- 操作系统内核:Linux
- Python 依赖:
- python >= 3.10,<= 3.11
- CANN >= 8.2.rc1
- torch >= 2.7.1;torch-npu >= 2.7.1.post2
- torch 与 torch-npu 版本需相互兼容。
- ray >= 2.55.0
快速开始
安装
pip install "ray-ascend[yr]"
Ray Actor 间的 HCCL 集合通信
import ray
from ray.util import collective
from ray_ascend import register_hccl_collective_backend
register_hccl_collective_backend()
@ray.remote(resources={"NPU": 1})
class RayActor:
def __init__(self):
register_hccl_collective_backend()
collective.create_collective_group(
actors,
len(actors),
list(range(0, len(actors))),
backend="HCCL",
group_name="my_group",
)
# Each actor broadcasts in SPMD manner
collective.broadcast(tensor, src_rank=0, group_name="my_group")
通过HCCS传输昇腾NPU张量
import ray
import torch
from ray.util.collective import create_collective_group
from ray_ascend import register_hccl_tensor_transport
register_hccl_tensor_transport()
@ray.remote(resources={"NPU": 1})
class RayActor:
def __init__(self):
register_hccl_tensor_transport()
@ray.method(tensor_transport="HCCL")
def random_tensor(self):
return torch.zeros(1024, device="npu")
def sum(self, tensor: torch.Tensor):
return torch.sum(tensor)
sender, receiver = RayActor.remote(), RayActor.remote()
group = create_collective_group([sender, receiver], backend="HCCL")
tensor = sender.random_tensor.remote()
result = receiver.sum.remote(tensor)
ray.get(result)
通过 HCCS 传输昇腾 NPU 张量,通过 RDMA 传输 CPU 张量
开放元融数据系统
(YR)允许用户使用 Ray 对象传输 NPU 张量(通过 HCCS)和 CPU 张量(若提供,则通过 RDMA)。
import ray
from ray_ascend import register_yr_tensor_transport
register_yr_tensor_transport(["npu", "cpu"])
@ray.remote(resources={"NPU": 1})
class RayActor:
def __init__(self):
register_yr_tensor_transport(["npu", "cpu"])
@ray.method(tensor_transport="YR")
def transfer_npu_tensor_via_hccs(self):
return torch.zeros(1024, device="npu")
@ray.method(tensor_transport="YR")
def transfer_cpu_tensor_via_rdma(self):
return torch.zeros(1024)
sender = RayActor.remote()
npu_tensor = ray.get(sender.transfer_npu_tensor_via_hccs.remote())
cpu_tensor = ray.get(sender.transfer_cpu_tensor_via_rdma.remote())
Ray 版本兼容性
| Ray 版本 | YR 传输 | HCCL 集合通信 | HCCL 张量传输(RDT) |
|---|---|---|---|
| >=2.55, <2.56 | ✅ | ❌ | ❌ |
| >= 2.56 | ✅ | ✅ | ✅ |
贡献指南
有关详细信息,请参见 CONTRIBUTING 和 开发者指南——这是一份逐步指南,可帮助您设置开发环境、构建和测试。如果您发现错误或需要新功能,请通过 提交 issue 告知我们。
许可证
Apache License 2.0。详见 LICENSE 文件。