Skip to content

vllm.distributed.pp_transport.rocm_sdma

The flag ops and peer copy of copy_engine.CopyEngineTransport on ROCm (gfx950): HIP stream memory ops and SDMA engines.

On HIP 7.16 a HIP peer copy runs as a blit kernel on the sender's CUs (hipMemcpyFlagExtPreferCE does not apply to device-to-device copies, and hipMemcpyDeviceToDeviceNoCU picks engines whose peer copy fails on MI355X while returning success). The copies therefore go through ROCr's hsa_amd_memory_async_copy_on_engine on explicit engines, kept in order with the side stream by HSA signals. Per step N:

  • the host queues the data copies behind a dependency signal, which the side stream opens (writes 0) after the transport's empty >= N - 1 wait;
  • two 8-byte copies of N, queued behind the data copies, publish full = N to the receiver and sent = N to this rank;
  • the side stream waits for sent >= N, so the transport's event recorded on it covers the copies, as on CUDA.

The copies sit on their engines' queues, blocked on the dependency signal, until the side stream opens it. ROCr gives each engine one queue per process, so only other SDMA peer copies from this GPU on the same engines would wait behind them: host copies run on engines 0 and 1, and HIP peer copies on blit kernels.

The shared buffers come from allocate_shared_buffer_and_handle, which on ROCm allocates uncached memory, so a stream wait never reads a stale L2 line.

Classes:

  • SdmaCopyEngines –

    ROCm's flag ops and, for a sender, its peer copy to the next stage.

SdmaCopyEngines

ROCm's flag ops and, for a sender, its peer copy to the next stage.

Methods:

  • __init__ –

    words: this rank's uncached shared-buffer bytes for sent and

  • copy –

    Queue, behind stream's work, the copy of each key's first rows

__init__(send_buf, peer_recv_buf, peer_full, words, peer_pci, cross_node)

words: this rank's uncached shared-buffer bytes for sent and the step-number sources; peer_pci: the next stage's PCI address. The peer must be on this node (cross_node false).

copy(stream, layout, rows, seq)

Queue, behind stream's work, the copy of each key's first rows rows into the peer's receive region and the publish of full = seq, and make stream wait for them.

_Hsa

The ROCr calls of an SDMA copy, over ctypes.

Methods:

  • copy –

    Queue a copy on engine that starts once every signal in deps is

  • free_engines –

    The mask of SDMA engines free for copies from src to dst.

copy(dst, dst_agent, src, src_agent, size, deps, done, engine)

Queue a copy on engine that starts once every signal in deps is 0 and decrements done when it finishes.

free_engines(dst, src)

The mask of SDMA engines free for copies from src to dst.

_agent(pci)

The HSA agent at PCI (domain, bus, device).