vllm.distributed.engram_pool.rdma
¶
Table rows from every peer's shard over RDMA, gathered by the owner's NIC.
A READ per row would cap a NIC at its message rate (~45M/s here, a fraction of
line rate for small rows). Instead each owner's NIC gathers a packet's worth of
rows per RDMA WRITE (one SGE per row) and writes them into the requester's
landing buffer. The requester's GPU builds those WRs and hands each owner its
share itself; owner proxy processes (proxy.py) post them.
A fetch is two stream-ordered kernels, so it captures into CUDA graphs, needs
no host thread, and no SM touches a row until it has landed. start:
1. _plan_kernel numbers live rows within their (table, gatherer) group.
2. _wr_kernel writes each group's gathering WRs and SGEs, in the gatherer
proxy's addresses, into this GPU's descriptor buffer. Its last program
bumps the device-side sequence number and posts, per group, an RDMA
WRITE_WITH_IMM that copies them into the gatherer's mailbox: it writes the
mlx5 WQE into the send queue of this GPU's QP to that gatherer and rings
the doorbell (GPU-initiated, as IBGDA).
Then, before the layer that needs a table, wait_landed (in the consumer's
kernel, or _place_kernel) spins until the flag of every QP that gathered the
table's rows says they have landed.
Shards live in host memory, or in dmabuf-registered HBM.
Classes:
-
RdmaTransport–QPs to every peer's owner proxy (requests) and from this GPU's to every
Functions:
-
node_id–This machine's identity: GPUs with the same one share host memory.
-
pick_device–This GPU's RDMA device: the active one closest to it (see
_nearest).
RdmaTransport
¶
QPs to every peer's owner proxy (requests) and from this GPU's to every peer's (gathers), and the buffers fetches go through.
Methods:
-
landed–Where table
table's rows land: the landing buffer, each row's slot -
rows_per_wr–Rows one WRITE gathers: a packet's worth, within every NIC's SGEs.
-
shard–Allocate and register this GPU's shard; returns it (host memory for
-
start–Start gathering rows
ids([..., TABLES, K]) of the tables inmeta -
wait–Hold the current stream until table
table's rows (slots, as
_fail()
¶
Fail every wait. A copy engine copies the flag in, so it lands even while waiting kernels hold every SM.
_launch(kernel, grid, args, consts)
¶
Launch kernel on the current stream, compiled once per constexprs
and tensor dtype and alignment: Triton's per-call dispatch costs ~20 us
here.
_map_queues(qps)
staticmethod
¶
Map QPs' send queues and doorbells for this GPU; returns rows of send queue, WQEs, doorbell record and register, QPN and WQEs posted.
_register(memory, access)
¶
Register host memory or HBM with the owner proxy; returns its address for the NIC, lkey and rkey.
_watch(cq, channel, peers)
¶
Flag the first failed request. Requests are unsignaled: only failed ones complete, as when a peer's engine is gone.
landed(slots, table)
¶
Where table table's rows land: the landing buffer, each row's slot
in it, and the descriptor wait_landed reads.
rows_per_wr(row_bytes)
¶
Rows one WRITE gathers: a packet's worth, within every NIC's SGEs.
shard(num_bytes, name)
¶
Allocate and register this GPU's shard; returns it (host memory for
host shards), its meta arrays and what keeps them alive. Collective.
start(meta, ids, fetch)
¶
Start gathering rows ids ([..., TABLES, K]) of the tables in meta
on the current stream; the NICs move them while the stream goes on.
wait(slots, table, out)
¶
Hold the current stream until table table's rows (slots, as
start returned) have landed, and place them into out.
_RequestWQE
¶
Bases: Structure
The mlx5 WQE of a request: an RDMA WRITE_WITH_IMM of its WRs and of their SGEs (a data segment each) into a mailbox.
_be32(x)
¶
The low 32 bits of x, big-endian, as stored by a little-endian GPU.
_last_program(ticket)
¶
Whether this program is the last of its launch to get here.
_nearest(devices, gpu)
¶
The devices closest to gpu: those sharing the longest sysfs PCIe
path with it (the NIC behind its PCIe switch), then those on its NUMA node
(for GPUs not on the NICs' PCIe tree, as with C2C-attached GPUs).
_place_kernel(owner_pos, starts, landing, out, num_words, table, ready, TABLES, K, HOST, WORDS, BLOCK)
¶
Once table table's rows have landed, copy them to their places in
out (its [..., K] rows), zeroing dead rows; one word per lane.
_plan_kernel(ids, meta, counts, owner_pos, remote_addr, keys, num_items, world, ticket, starts, wr_starts, wr_counts, used, TABLES, K, WORDS, ROWS_PER_WR, QPS, VG_P2, BLOCK)
¶
Number live rows within their (table, gatherer) group into owner_pos
(-1 if dead); the last program lays out each group's slots, WRs and QPs.
_post_requests(vg, active, imm_wrs, sizes, group_first, group_first_wr, group_wrs, world, boxes, box_rkeys, desc_at, desc_lkey, queues, BOX_BYTES, MAX_WRS)
¶
Post each active group's _RequestWQE on its gatherer's QP and ring
the doorbell; queues rows are those _map_queues returns.
_rdma_wr(word, wr_id, next, sg_list, num_sge, opcode, send_flags, addr, rkey)
¶
An RDMA WRITE or READ ibv_send_wr, as 8-byte words (word).
_with_be64(value, word, at, x)
¶
value (32-bit words) with big-endian x at word at.
_with_data_seg(value, word, at, length, lkey, addr)
¶
value (32-bit words) with an mlx5_wqe_data_seg at word at.
_with_sge(value, word, at, addr, length, lkey)
¶
value (8-byte words) with an ibv_sge at word at.
_word(struct, field, word_bytes)
¶
The word_bytes-byte word of struct where field (dotted) starts.
_wr_kernel(owner_pos, counts, remote_addr, keys, boxes, box_keys, desc, seq_ptr, landing, landing_rkey, flags, flags_rkey, num_items, world, rank, ticket, starts, wr_starts, wr_counts, used, box_rkeys, desc_lkey, queues, slots, BOX_BYTES, MAX_WRS, ROWS_PER_WR, QPS, VG_P2, WORDS, TABLES, K, BLOCK)
¶
Write each group's gathering WRs and SGEs (in its gatherer's mailbox layout) and each row's slot; the last program posts every group's request.
_wr_layout(rows, ROWS_PER_WR, QPS)
¶
Gathering WRs, WRs per chain and QPs used for rows rows of one
gatherer, chained as proxy.chain_length says.
node_id()
¶
This machine's identity: GPUs with the same one share host memory.
pick_device()
¶
This GPU's RDMA device: the active one closest to it (see _nearest).
GPUs with the same closest devices take them round-robin.