advanced25 min studyLesson 487 in Engineering

Peer-to-peer transfer and ordering

Separate device addressability, matched communication, stream dependencies, and buffer ownership before treating accelerator-to-accelerator movement as complete.

On this page

What you’ll understand

  • Distinguish peer-access capability from synchronization and completion.
  • Specify producer-transfer-consumer dependencies.
  • Budget transfer payload and buffer lifetime with consistent units.

Accelerators can sometimes access or transfer data directly between peers, avoiding a particular host-staging path. That capability is not a synchronization protocol. A producer must finish the data that a transfer reads, a consumer must wait for the relevant transfer completion, and the application must preserve buffer ownership throughout. A valid pointer or a successful enqueue does not establish any of those temporal facts by itself.

Addressability is a supported direction, not a completed transfer

The CUDA Runtime 13.4 peer-access interface distinguishes whether one device can access another's memory and whether that access has been enabled. The documented enablement is directional; the reverse direction requires its own supported setup. Platform, topology, allocation, and runtime constraints still apply. A capability result does not mean every possible device pair has the same bandwidth, that a remote allocation is immortal, or that every cross-device atomic operation has the desired semantics. Use the supported access and synchronization contracts of the deployed architecture.

NCCL 2.32.3 two-sided point-to-point communication uses matching sends and receives with compatible peer ranks, counts, and datatypes. Its grouping interface can express sets of operations that need concurrent progress. Those rank-based communication calls are distinct from merely enabling CUDA peer memory access. A transport may use different supported physical paths based on topology. Validate the actual selected route rather than inferring that a high-level peer operation necessarily uses one particular local link or never touches host resources.

Ttransfer≥DBT_{\rm transfer}\ge\frac{D}{B}
D is payload bytes traversing a specified bottleneck and B its sustained usable bytes/s in the counted direction. The bound is seconds and excludes startup, synchronization, staging, and contention. It says nothing about whether the destination is safe to consume before an actual completion dependency.↔ Scroll wide equations horizontally.

Three ownership transitions form the real protocol

First establish producer completion before the communication stream or device reads the source. Then establish transfer completion before a consumer reads the destination. Finally, allow source or destination reuse only after all operations that still reference the corresponding storage have finished. Supported stream ordering, events, waits, or communication requests provide those dependencies. A host-side flag set immediately after an asynchronous submission does not automatically order device work across unrelated streams. An incorrect dependency can produce intermittent old data instead of a clean error.

Avoid inferring correctness from one successful transfer of a zero-filled array. Use identifiable values and vary producer timing, streams, buffer reuse, and iteration sequence while retaining the documented contracts. A stream wait can order later work without a global device synchronization, but the event must refer to the intended operation and revision. Cancellation and timeout need special care: software deciding to stop waiting does not prove that a device or peer stopped accessing the buffer. Teardown must quiesce the applicable operations before storage is freed or recycled.

treuse(b)≥max⁡o∈Users⁡(b)tcomplete(o)t_{\rm reuse}(b)\ge\max_{o\in\operatorname{Users}(b)}t_{\rm complete}(o)
For buffer b, every referencing operation o must complete before reuse. All t values use one consistent logical timeline in seconds; actual devices need supported dependency mechanisms rather than subtraction of unsynchronized clocks. Users includes producers, transfers, and consumers that still retain the storage.↔ Scroll wide equations horizontally.

Pipelining retains more than one payload

Double buffering can let one transfer proceed while another buffer is produced or consumed, but it doubles the retained slots for that particular buffer category. Count source and destination pools separately and include other outstanding iterations. A pipeline that reuses slot i modulo a small ring needs evidence that the earlier use of that slot is complete. Increasing slot count can hide latency until another resource binds, but it also consumes memory and can make a stalled peer retain more state. Bound in-flight work instead of treating unlimited asynchronous submissions as free overlap.

The Markov instrument is useful as a contrast to real completion evidence. Reset, set both p=0.5 and q=0, predict modeled completion-state probability 0.75 after two Steps, then Step twice. Separately Reset, set both p=0.9 and q=0, predict 0.99 after two Steps, then Step twice. These are exact probabilities for an assumed two-state chain, not observations from a CUDA transfer. Even a high modeled completion probability does not authorize consuming or recycling a real buffer without the required event or request completion.

A transfer estimate does not release a buffer

A hypothetical peer path transfers 4,000,000 four-byte values at a sustained twenty billion bytes/s, with an additional fixed ten-microsecond startup. Count one source-pool category with two equally sized retained buffer slots.

  1. The payload is 4,000,000×4=16,000,000 bytes. Its bandwidth-only lower term is 16,000,000/20,000,000,000 s=0.0008 s, or 0.8 ms.

  2. Adding the stipulated startup gives a modeled 0.81 ms. This estimate does not establish that any particular asynchronous call completed after a host sleep of that duration.

  3. Two source slots retain 2×16,000,000=32,000,000 payload bytes. Destination slots and implementation buffers add separate memory, and every slot still needs its own correct completion-before-reuse dependency.

The result

Capacity and timing estimates support design, while documented synchronization establishes when a particular buffer may be consumed or reused.

Explore the model

Interactive lab

Interactive lab · markov

Likelihood is not a device completion event

Reset, set both p=0.5 and q=0, predict state-one probability 0.75 after two Steps, then Step twice. Separately Reset, set both p=0.9 and q=0, predict 0.99, then Step twice. This exact two-state probability model performs no peer transfer or synchronization and cannot release an actual buffer.

Likelihood is not a device completion eventExact finite-step probabilities for a two-state chain starting in state 0, not sampled trajectories. Playback advances two transitions per second. When p = q = 0 every distribution is stationary; when p = q = 1 the chain alternates forever. A single zero transition creates an absorbing state. Current readings: P(state 1) at step 0: 0%; Stationary P(state 1): 60%; Chain behavior: Monotone convergence. All parameters are adjustable with the labeled controls below.Two-state Markov distribution after 0 steps: state zero probability 1, state one probability 0.Initial distribution (1, 0) · step 0p = 0.3q = 0.201100%0%1−p1−qP(0)P(1)Monotone convergence
P(state 0)P(state 1)Stationary distribution
P(state 1) at step 0
0%
Stationary P(state 1)
60%
Chain behavior
Monotone convergence
t = 0 s

Exact finite-step probabilities for a two-state chain starting in state 0, not sampled trajectories. Playback advances two transitions per second. When p = q = 0 every distribution is stationary; when p = q = 1 the chain alternates forever. A single zero transition creates an absorbing state. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA predicted short transfer time or high completion probability never replaces the required ordering and completion evidence.

Check your understanding

CUDA peer access from device A to device B has been enabled. What additional fact is still required before a consumer uses newly produced data?

Try it yourself

A pipeline has four source slots and four destination slots, each holding 16 MiB. What is the combined payload reservation? What does increasing the slot count fail to prove?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Count both endpoint categories, then separate capacity from ordering.

Compare with the solution

Eight slots hold 8×16=128 MiB of payload. More slots can provide room for in-flight work but do not prove any producer, transfer, or consumer has completed, guarantee a faster path, or remove buffer-lifetime rules. Additional implementation scratch memory and stalled iterations need separate budgets.

Take it with you

  • Peer addressability, matched communication, and completion are separate contracts.
  • Order producer, transfer, consumer, and eventual reuse explicitly.
  • Count retained endpoint buffers as well as the payload of one transfer.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.