Skip to content

[docs] Improve API reference documentation#65

Merged
tianyi-ge merged 2 commits into
Ascend:masterfrom
Artimislyy:doc/improve-api-reference
Jun 4, 2026
Merged

[docs] Improve API reference documentation#65
tianyi-ge merged 2 commits into
Ascend:masterfrom
Artimislyy:doc/improve-api-reference

Conversation

@Artimislyy

@Artimislyy Artimislyy commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

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

@ascend-robot

Copy link
Copy Markdown

CLA Signature Guide

@Artimislyy , thanks for your pull request.

The following commit(s) are not associated with a signed Contributor License Agreement (CLA).

Commit Reason
cb8f1583 docs: modify API reference docum... the email used in the commit is not linked to a signed CLA!
please verify that it matches the email you used when signing the CLA.

To sign CLA, click here.

To check if your email is configured correctly, refer to the FAQs.

Once you've signed the CLA or updating your email, please comment /check-cla to revalidate CLA status.

2 similar comments
@ascend-robot

Copy link
Copy Markdown

CLA Signature Guide

@Artimislyy , thanks for your pull request.

The following commit(s) are not associated with a signed Contributor License Agreement (CLA).

Commit Reason
cb8f1583 docs: modify API reference docum... the email used in the commit is not linked to a signed CLA!
please verify that it matches the email you used when signing the CLA.

To sign CLA, click here.

To check if your email is configured correctly, refer to the FAQs.

Once you've signed the CLA or updating your email, please comment /check-cla to revalidate CLA status.

@ascend-robot

Copy link
Copy Markdown

CLA Signature Guide

@Artimislyy , thanks for your pull request.

The following commit(s) are not associated with a signed Contributor License Agreement (CLA).

Commit Reason
cb8f1583 docs: modify API reference docum... the email used in the commit is not linked to a signed CLA!
please verify that it matches the email you used when signing the CLA.

To sign CLA, click here.

To check if your email is configured correctly, refer to the FAQs.

Once you've signed the CLA or updating your email, please comment /check-cla to revalidate CLA status.

@dpj135

dpj135 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Add cleanup_yr_resources()

Comment thread docs/user_guide/api_reference.md Outdated
Comment thread docs/user_guide/api_reference.md Outdated
- `["npu"]` for NPU tensors only
- `["npu", "cpu"]` for NPU and CPU tensors
- `["cpu"]` for CPU tensors only
- `None` (default) for both `["npu", "cpu"]`

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.

now the default value is ["npu", "cpu"]. check ray_ascend/__init__.py


**Notes:**

- Must be called in both the driver process and each actor's `__init__`

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.

Requires Ray >= 2.55

Comment thread docs/user_guide/api_reference.md Outdated
| Variable | Default | Description |
| --- | --- | --- |
| `YR_DS_INIT_MODE` | `metastore` | Initialization mode (`metastore` or `etcd`) |
| `YR_DS_WORKER_PORT` | `31501` | YR DS worker port |

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.

YR DS worker port -> openYuanrong Datasystem worker port

@ray.method(tensor_transport="YR")
def transfer_cpu_tensor_via_rdma(self):
return torch.zeros(1024)
```

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.

add a real use case e.g. driver calls transfer_cpu_tensor_via_rdma or transfer_npu_tensor_via_hccs and ray.get

backend="HCCL",
group_name="my_group",
)
```

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.

add a real case e.g. call allreduce on each actor


- Must be called in both the driver process and each actor's `__init__`
- Environment variables should be set in the driver process before calling
- YR backend initialization happens once across the cluster via a named actor

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.

note that tensor_transport is case-insensitive. YR/yr both work; HCCL/hccl both work.

@tianyi-ge

Copy link
Copy Markdown
Collaborator

@ascend-robot

Copy link
Copy Markdown

CLA Signature Guide

@Artimislyy , thanks for your pull request.

The following commit(s) are not associated with a signed Contributor License Agreement (CLA).

Commit Reason
cb8f1583 docs: modify API reference docum... the email used in the commit is not linked to a signed CLA!
please verify that it matches the email you used when signing the CLA.

To sign CLA, click here.

To check if your email is configured correctly, refer to the FAQs.

Once you've signed the CLA or updating your email, please comment /check-cla to revalidate CLA status.

@dpj135

dpj135 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Please add signature to commit info.

Commit 06ec2fdcdd5ae96c39134c71eb04336310303c3c is missing Signed-off-by
Commit e3687f617e21f2aed65a0607d9e454ff8390c655 is missing Signed-off-by
Commit 45bb4bf871cdaca3e19cc511f11d6156012e9774 is missing Signed-off-by
Commit c902d162753dfd94a979f6ec3c9b87ab8f036a44 is missing Signed-off-by
Commit cb6812d9e9371fe6b680f3e5dcee0e1470eff0aa is missing Signed-off-by
Commit 11e5d5c404769e6a5cefa4d898bc2470d0e5c7ec is missing Signed-off-by

Comment thread docs/user_guide/api_reference.md Outdated
```

Must be called in both the driver process and each actor's `__init__`.
## cleanup_yr_resources

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.

cleanup_yr_resources is used to clean datasystem workers and single controller initialized by register_yr_tensor_transport. I think they should be together to decrible.

Comment thread docs/user_guide/api_reference.md Outdated
## cleanup_yr_resources

### Environment Variables
Clean up all YR resources. Delegates cleanup to coordinator, then kills the coordinator

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.

Users don't know what the coordinator is. Perhaps we need more popular description.

Comment thread docs/user_guide/api_reference.md Outdated

### Environment Variables
Clean up all YR resources. Delegates cleanup to coordinator, then kills the coordinator
actor.

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.

we can tell users like "ray stop can also clean yr worker".

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.

what may happen if users forgot cleanup yr

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.

YrDsCoordinary is detached. This actor process will continue to exist until ray shutdown

| `YR_DS_INIT_MODE` | `metastore` | Initialization mode (`metastore` or `etcd`) |
| `YR_DS_WORKER_PORT` | `31501` | openYuanRong Datasystem worker port |
| `YR_DS_METASTORE_PORT` | `2379` | Metastore service port |
| `YR_DS_ETCD_ADDRESS` | - | Etcd address (required for etcd mode) |

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.

if etcd mode but no etcd address is provided, is there any error message? @dpj135

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.

Raises error when os.getenv("YR_DS_ETCD_ADDRESS")

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.

image

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.

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.

raise RuntimeError("etcd mode requires etcd_address")

ok

Comment thread docs/user_guide/api_reference.md Outdated

### Environment Variables
Clean up all YR resources. Delegates cleanup to coordinator, then kills the coordinator
actor.

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.

what may happen if users forgot cleanup yr

Comment thread ray_ascend/__init__.py Outdated
- ["npu", "cpu"] for NPU and CPU tensors
- ["cpu"] for CPU tensors only
- None (default) for both ["npu", "cpu"]
- `None` (uses `["npu", "cpu"]` by default)

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.

None is not allowed, should raise error

Comment thread docs/user_guide/api_reference.md Outdated
def transfer_npu_tensor(self):
return torch.tensor([1, 2, 3]).npu()

actor = RayActor.remote()

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.

In order to use hccl in tensor transport, you need to create collective group first. see

@ascend-robot

Copy link
Copy Markdown

CLA Signature Guide

@Artimislyy , thanks for your pull request.

The following commit(s) are not associated with a signed Contributor License Agreement (CLA).

Commit Reason
cb8f1583 docs: modify API reference docum... the email used in the commit is not linked to a signed CLA!
please verify that it matches the email you used when signing the CLA.

To sign CLA, click here.

To check if your email is configured correctly, refer to the FAQs.

Once you've signed the CLA or updating your email, please comment /check-cla to revalidate CLA status.

@Artimislyy Artimislyy force-pushed the doc/improve-api-reference branch from aa0a8ae to 24b1605 Compare June 4, 2026 07:43
@ascend-robot

Copy link
Copy Markdown

CLA Signature Guide

@Artimislyy , thanks for your pull request.

The following commit(s) are not associated with a signed Contributor License Agreement (CLA).

Commit Reason
cb8f1583 docs: modify API reference docum... the email used in the commit is not linked to a signed CLA!
please verify that it matches the email you used when signing the CLA.

To sign CLA, click here.

To check if your email is configured correctly, refer to the FAQs.

Once you've signed the CLA or updating your email, please comment /check-cla to revalidate CLA status.

Signed-off-by: Artimislyy <2249614312@qq.com>
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

Artimislyy, thanks for your pull request. All authors of the commits have signed the CLA. 👍

Signed-off-by: Artimislyy <2249614312@qq.com>
@ascend-robot

Copy link
Copy Markdown

CLA Signature Pass

Artimislyy, thanks for your pull request. All authors of the commits have signed the CLA. 👍

return torch.zeros(1024, device="npu")

@ray.method(tensor_transport="YR")
def transfer_cpu_tensor_via_rdma(self):

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.

TODO: Support RDMA for cpu tensor transport

@dpj135 dpj135 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

@tianyi-ge tianyi-ge merged commit 084ed7d into Ascend:master Jun 4, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants