vllm.distributed.weight_transfer.sharded_rdt_common
¶
Sharded RDT: the wire protocol, and what both sides compute from it.
Each inference worker (consumer) pulls, over NIXL through Ray Direct Transport
(RDT), the boxes of each checkpoint tensor its load plan names from the
trainer ranks (producers) that own them. Both sides cut the metadata into the
same gather units, route each name the same way (RdtRouter), and lay a
bucket out the same way (flat_layout). The protocol is described in
docs/training/weight_updates/engines/sharded_rdt.md.
Classes:
-
RdtRouter–Which producer serves each name to each consumer; both sides derive
Functions:
-
arena_bytes–The NIXL arena one producer registers:
num_buffersbuckets of at most -
check_ray_rdt_version–Refuse an installed Ray older than
RDT_MIN_RAY_VERSION, which would -
deregister_nixl_memory–Drop one registration
register_nixl_memorytook ontensor's storage. -
flat_layout–The pieces of a flat bucket, in order, each starting on 16 B, so the
-
flat_view–One piece of a flat byte tensor, shaped like its box.
-
gather_units–The gather unit of each name: consecutive names, in order, of at most
-
meta_nbytes–A full tensor's bytes.
-
piece_nbytes–A piece's bytes in a flat bucket, counting its 16 B alignment.
-
register_nixl_memory–Register
tensor's whole storage with NIXL (reference counted). -
validate_int–Reject a non-int (bools included) or an int below
minimum.
Attributes:
-
FlatPiece–Where a piece sits in a flat bucket: byte offset, bytes, dtype, shape.
FlatPiece = tuple[int, int, torch.dtype, tuple[int, ...]]
module-attribute
¶
Where a piece sits in a flat bucket: byte offset, bytes, dtype, shape.
RdtRouter
¶
Which producer serves each name to each consumer; both sides derive the same answers from the same wire tables.
Methods:
-
__init__–Build the routing tables.
-
components–Per producer, its coupling component: producers that co-own a name
-
consumers_of–Consumers that may pull from
producer: the bound on its fan-in. -
owners–Every producer holding
name. -
producer_for–The producer
consumer_idpullsnamefrom. -
validate–Raises:
__init__(num_producers, num_consumers, owner_sets=None, name_owner_class=None, names=None, workers_per_replica=0)
¶
Build the routing tables.
Parameters:
-
(num_producers¶int) –Trainer ranks.
-
(num_consumers¶int) –Inference workers across the whole fleet.
-
(owner_sets¶list[list[int]] | None, default:None) –The distinct owner sets, one per owner class; empty means one class owning every producer.
-
(name_owner_class¶list[int] | None, default:None) –Per name of
names, its index intoowner_sets; a name without one is class 0. -
(names¶list[str] | None, default:None) –The metadata names.
-
(workers_per_replica¶int, default:0) –Consumers per inference deployment. The M:N carve spreads one deployment over an owner set and every deployment reuses it; 0 means one deployment.
Raises:
-
ValueError–workers_per_replicadoes not dividenum_consumers.
_block(num_owners, consumer_id)
¶
The owner indices consumer_id binds under M:N.
components()
¶
Per producer, its coupling component: producers that co-own a name may gather it collectively, so they progress through units together.
consumers_of(producer)
¶
Consumers that may pull from producer: the bound on its fan-in.
owners(name)
¶
Every producer holding name.
producer_for(consumer_id, name, unit)
¶
The producer consumer_id pulls name from.
Spreads one deployment's consumers over the name's owners, then rotates by gather unit, so a consumer spreads its units over the owners it binds instead of loading one NIC.
validate()
¶
ValueError: an owner set is empty or out of range, or a class index does not resolve.
arena_bytes(*, buffer_bytes, num_buffers, num_consumers)
¶
The NIXL arena one producer registers: num_buffers buckets of at most
buffer_bytes for each consumer that may pull from it, plus one of slack
for a free still on its way and for fragmentation.
check_ray_rdt_version()
¶
Refuse an installed Ray older than RDT_MIN_RAY_VERSION, which would
otherwise fail deep in the first pull.
Raises:
-
ValueError–the installed Ray is too old.
deregister_nixl_memory(tensor)
¶
Drop one registration register_nixl_memory took on tensor's storage.
flat_layout(boxes, dtypes)
¶
The pieces of a flat bucket, in order, each starting on 16 B, so the
bucket is sum(piece_nbytes) long. Producer and consumer derive it from
the same (name, box) list.
flat_view(flat, piece)
¶
One piece of a flat byte tensor, shaped like its box.
gather_units(nbytes, budget)
¶
The gather unit of each name: consecutive names, in order, of at most
budget bytes together; a name larger than budget is a unit alone.
meta_nbytes(meta)
¶
A full tensor's bytes.
piece_nbytes(box, dtype)
¶
A piece's bytes in a flat bucket, counting its 16 B alignment.
register_nixl_memory(tensor)
¶
Register tensor's whole storage with NIXL (reference counted).
validate_int(name, value, *, minimum)
¶
Reject a non-int (bools included) or an int below minimum.