Skip to content

Commit 93ee116

Browse files
committed
common: tighten peer-handle docstrings
Signed-off-by: Phuong Nguyen <phuonguyen@nvidia.com>
1 parent e4cfa62 commit 93ee116

4 files changed

Lines changed: 17 additions & 40 deletions

File tree

transformer_engine/common/comm_handle.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66

77
#include "transformer_engine/comm_handle.h"
88

9-
#include "transformer_engine/nccl_comm.h"
10-
119
#include "common.h"
10+
#include "transformer_engine/nccl_comm.h"
1211
#include "util/logging.h"
1312

1413
using transformer_engine::convertNVTETensor;

transformer_engine/common/common.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,11 @@ struct Tensor {
180180
*/
181181
bool row_scaled_nvfp4 = false;
182182

183-
/*! \brief Optional peer-handle annotation for zero-copy comm fast paths.
184-
*
185-
* Borrowed reference to a comm-backend-specific resource (NCCL window,
186-
* NVSHMEM pointer, CUDA IPC handle, etc.) that lets a consumer initiate
187-
* one-sided remote-memory ops against this tensor's storage. The kind tag
188-
* selects which backend owns ``peer_handle_data``; the tensor never owns
189-
* the resource — the caller keeps it valid for the tensor's lifetime.
190-
* Code paths that don't issue cross-rank ops ignore these fields. */
183+
/*! \brief Optional borrowed peer handle for one-sided RMA against this tensor.
184+
* ``peer_handle_kind`` selects the backend owning ``peer_handle_data``;
185+
* the caller keeps the resource valid for the tensor's lifetime. */
191186
NVTEPeerHandleKind peer_handle_kind = NVTE_PEER_HANDLE_NONE;
192-
void* peer_handle_data = nullptr;
187+
void *peer_handle_data = nullptr;
193188
uint64_t peer_handle_offset = 0;
194189

195190
/*! Map from NVTETensorParam to parameter sizes */

transformer_engine/common/include/transformer_engine/comm_handle.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@
55
************************************************************************/
66

77
/*! \file comm_handle.h
8-
* \brief Generic peer-handle annotation on NVTETensor.
8+
* \brief Generic peer-handle annotation on NVTETensor for one-sided RMA.
99
*
10-
* A peer handle is an opaque, comm-backend-specific reference that lets a
11-
* consumer initiate one-sided remote-memory operations against a peer's
12-
* buffer (e.g. NCCL symmetric-memory window, NVSHMEM pointer, CUDA-IPC
13-
* handle). The annotation is borrowed; the resource outlives the call and
14-
* the tensor never owns it.
15-
*
16-
* Backends register their setter/getter under a dedicated header (e.g.
17-
* ``nccl_comm.h`` for NCCL windows). This header exposes only the kind tag
18-
* and detach, both of which are payload-agnostic.
10+
* The annotation is borrowed; the tensor never owns the underlying resource.
11+
* Per-backend setters/getters live in dedicated headers (e.g. ``nccl_comm.h``).
1912
*/
2013

2114
#ifndef TRANSFORMER_ENGINE_COMM_HANDLE_H_
@@ -27,17 +20,16 @@
2720
extern "C" {
2821
#endif
2922

30-
/*! \brief Kind tag identifying which comm backend owns a tensor's peer handle. */
23+
/*! \brief Comm backend that owns a tensor's peer handle. */
3124
typedef enum {
3225
NVTE_PEER_HANDLE_NONE = 0,
3326
NVTE_PEER_HANDLE_NCCL_WINDOW = 1,
34-
/* Reserved for future backends: NVSHMEM_PTR, CUDA_IPC, UCX_RKEY, ... */
3527
} NVTEPeerHandleKind;
3628

37-
/*! \brief Return the peer-handle kind currently attached to ``t``. */
29+
/*! \brief Peer-handle kind attached to ``t``. */
3830
NVTEPeerHandleKind nvte_tensor_peer_handle_kind(const NVTETensor t);
3931

40-
/*! \brief Clear any peer handle attached to ``t``; no-op when none is set. */
32+
/*! \brief Clear any peer handle attached to ``t``. */
4133
void nvte_tensor_detach_peer_handle(NVTETensor t);
4234

4335
#ifdef __cplusplus

transformer_engine/common/include/transformer_engine/nccl_comm.h

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
************************************************************************/
66

77
/*! \file nccl_comm.h
8-
* \brief NCCL-backed peer-handle setter/getter for NVTETensor.
8+
* \brief Attach a registered NCCL symmetric-memory window to an NVTETensor.
99
*
10-
* Attaches a registered NCCL symmetric-memory window + byte offset onto a
11-
* tensor so consumers (e.g. the EP backend) can issue one-sided put/get over
12-
* the window instead of staging through the raw data pointer. The window is
13-
* caller-owned; ``attach`` does not register or rendezvous it.
10+
* The window is caller-owned and must outlive the tensor; ``attach`` does
11+
* not register or rendezvous it.
1412
*/
1513

1614
#ifndef TRANSFORMER_ENGINE_NCCL_COMM_H_
@@ -23,23 +21,16 @@
2321
extern "C" {
2422
#endif
2523

26-
/*! \brief Attach an NCCL window + byte offset to ``t``.
27-
*
28-
* Sets the tensor's peer-handle kind to ``NVTE_PEER_HANDLE_NCCL_WINDOW``. The
29-
* window must stay registered for the tensor's lifetime. Pass ``window=NULL``
30-
* to detach (equivalent to ``nvte_tensor_detach_peer_handle``).
24+
/*! \brief Attach an NCCL window + byte offset to ``t``. Pass ``window=NULL`` to detach.
3125
*
3226
* \param[in,out] t Tensor to annotate.
3327
* \param[in] window Opaque ncclWindow_t (caller-owned), or NULL to clear.
3428
* \param[in] offset Byte offset into the window where this tensor starts.
3529
*/
3630
void nvte_tensor_attach_nccl_window(NVTETensor t, void* window, uint64_t offset);
3731

38-
/*! \brief Read the NCCL window + offset attached to ``t``.
39-
*
40-
* ``*window`` is set to ``NULL`` and ``*offset`` to 0 when no NCCL window is
41-
* attached (including when the tensor carries a different peer-handle kind).
42-
* Either out-pointer may be ``NULL`` to skip that field.
32+
/*! \brief Read the NCCL window + offset attached to ``t``; yields (NULL, 0) when unset.
33+
* Either out-pointer may be NULL to skip that field.
4334
*/
4435
void nvte_tensor_nccl_window(const NVTETensor t, void** window, uint64_t* offset);
4536

0 commit comments

Comments
 (0)