vllm.distributed.weight_transfer.sharded_rdt_trainer
¶
Trainer side of the sharded-RDT (pull-based NIXL) backend.
Every trainer rank owns a producer server: an internal Ray actor that shares
the rank's GPU over CUDA IPC and serves the workers' pulls, each packed into
a block of an arena registered with NIXL. Each sync, the rank gathers its
owned names unit by unit and publishes each unit to its server; the sender
also drives the inference-side start/update/finish calls. The protocol is in
sharded_rdt_common.
Classes:
-
ShardedRDTTrainerInitInfo–Trainer init info for the sharded-RDT backend; the same on every rank
-
ShardedRDTTrainerWeightTransferEngine–Trainer-side engine for the sharded-RDT backend, on every trainer rank.
ShardedRDTTrainerInitInfo
dataclass
¶
Bases: TrainerInitInfo
Trainer init info for the sharded-RDT backend; the same on every rank
except rank (rank 0 is the sender).
Attributes:
-
buffer_bytes(int) –Most bytes one pull moves, and the size of a gather unit.
-
buffer_presize_gb(float | None) –Deprecated and ignored: the arena is sized from
buffer_bytes. -
gather_lookahead(int) –Units the gather loop runs ahead of the consumers.
-
num_buffers(int) –Pulls each worker keeps in flight.
-
num_consumers(int) –Inference workers across the whole fleet.
-
num_rdt_buffers(int | None) –Deprecated and ignored: use
num_buffers. -
stall_timeout_s(float) –Seconds without progress before a producer fails the sync; the first
-
trainer_actor_namespace(str | None) –Ray namespace of the producer actors; the workers resolve them there.
-
workers_per_replica(int) –Inference workers per deployment, for the M:N routing; 0 means one
buffer_bytes = DEFAULT_BUFFER_BYTES
class-attribute
instance-attribute
¶
Most bytes one pull moves, and the size of a gather unit.
buffer_presize_gb = None
class-attribute
instance-attribute
¶
Deprecated and ignored: the arena is sized from buffer_bytes.
gather_lookahead = DEFAULT_GATHER_LOOKAHEAD
class-attribute
instance-attribute
¶
Units the gather loop runs ahead of the consumers.
num_buffers = DEFAULT_NUM_BUFFERS
class-attribute
instance-attribute
¶
Pulls each worker keeps in flight.
num_consumers
instance-attribute
¶
Inference workers across the whole fleet.
num_rdt_buffers = None
class-attribute
instance-attribute
¶
Deprecated and ignored: use num_buffers.
stall_timeout_s = DEFAULT_STALL_TIMEOUT_S
class-attribute
instance-attribute
¶
Seconds without progress before a producer fails the sync; the first sync's planning on the workers counts too.
trainer_actor_namespace = None
class-attribute
instance-attribute
¶
Ray namespace of the producer actors; the workers resolve them there.
workers_per_replica = 0
class-attribute
instance-attribute
¶
Inference workers per deployment, for the M:N routing; 0 means one deployment.
ShardedRDTTrainerWeightTransferEngine
¶
Bases: TrainerWeightTransferEngine[ShardedRDTTrainerInitInfo]
Trainer-side engine for the sharded-RDT backend, on every trainer rank.
send_weights gathers this rank's names unit by unit from the source,
publishes each to the rank's producer server, and on the sender drives
the inference-side calls. Ownership comes from ParamMeta.owners, the
same on every rank, so no exchange is needed to plan who serves what.
Methods:
-
get_worker_init_payload–The worker-side init payload, from retained state; no collective,
-
send_weights–Gather this rank's weights and serve them to the consumers.
_all_gather_server_names(world, rank)
¶
Server names by rank; a metadata digest rides along, since every rank plans units and ownership from its own metadata.
_arena_bytes()
¶
arena_bytes for this rank, over the workers of one deployment that
may pull from it: the others share their blocks.
_drop_inflight(released)
¶
Drop released units' tensors and return their export slots.
_export(unit, names, tensors, handle_cache)
¶
Share one unit's tensors over CUDA IPC: each large storage once,
the small ones packed into an export slot. Returns the entries for
publish_unit, the tensors to keep alive, and the event that marks
them written.
_fail_producers(message)
¶
Fail this sync on every producer.
_fail_producers_on_error(update_future)
¶
A failed update_weights (a worker's pull failed) fails the sync
on every producer at once, so no rank waits out the stall watchdog
for releases that will not come.
_iter_owned_units()
¶
This rank's units in order, as (names, tensors).
_pack_for_export(held, slot_idx)
¶
Copy held into export slot slot_idx and describe them as views
of its one storage, the way publish_unit rebuilds them. A slot is
handed back only when its unit is released (_drop_inflight).
_plan(world, rank)
¶
Owner table, gather units, and this rank's share of both.
_pullers()
¶
Consumers that may pull from this rank.
_remote(method, *args)
¶
Call a server method; return its ref. The seam tests replace.
_run_gather_loop(update_future, live)
¶
Gather and publish this rank's units in order, holding at most
gather_lookahead + 1 unreleased ones. Runs on every rank.
get_worker_init_payload()
¶
The worker-side init payload, from retained state; no collective, so a restarted inference engine can rejoin between syncs.
Raises:
-
RuntimeError–before
trainer_initgathered the server names.
send_weights(live_consumer_ids=None)
¶
Gather this rank's weights and serve them to the consumers.
live_consumer_ids restricts the sync to the consumers still alive
(every rank must get the same set); None serves all of them.
_Block
dataclass
¶
An arena block packed once for every replica's worker that shares its bucket; freed once each has pulled and freed it, or its sync is over.
_Published
dataclass
¶
One unit's last publish; gen changes only when its tensors move.
_RDTProducerServer
¶
One trainer rank's serve surface: an internal Ray actor on the rank's GPU. The engine publishes gathered units into it over CUDA IPC; workers register their buckets and pull them.
A plain class; the engine wraps it with ray.remote at spawn.
Methods:
-
begin_sync–Open sync
sync_idxfor the given live consumers. -
bucket–Serve one registered bucket of sync
sync_idxonce its unit is -
end_sync–Block until every published unit is released and Ray freed every
-
publish_unit–Rebuild one gathered unit's CUDA-IPC tensors and make them
-
register_consumer–Record the buckets
consumer_idpulls from here, in pull order, -
set_gather_error–Fail sync
sync_idx(default: the current one) on this producer. -
wait_freed–Block until a published unit is released; return the released ones.
-
warmup_nixl–Create the NIXL agent and register the arena now, while the rank's
_carve(nbytes, *, dry_run=False)
¶
First fit for nbytes in the arena: its offset, or -1 (no room).
Caller holds _lock.
_check_first_pull(consumer_id, seq, sync_idx)
¶
Refuse a second pull of a bucket in a sync: two workers share the
consumer id. Caller holds _lock.
_drop_import(unit)
¶
Drop a unit's CUDA-IPC import but for its kept storages. Caller
holds _lock.
_freed_bucket(offset)
¶
Ray freed a served copy of the block at offset.
_maybe_free(block)
¶
Free block once Ray holds no copy and no live sharer will pull it
(or its sync is over). Caller holds _lock.
_notify_all()
¶
Wake every wait (an error or a new sync). Caller holds _lock.
_pack_bucket(sources, seq, spec, offset, tensors, gen, ready)
¶
Pack bucket seq into its arena block with one fused copy per kind
of box (words, bytes, strided runs), and wait for the copies.
_publish(unit, tensors, signature=None, bases=None, exports=None, keep=frozenset())
¶
_release_if_done(unit)
¶
Release unit once every live consumer registered and all its
buckets of it are packed: nothing reads the unit after that. Caller
holds _lock.
_share_key(consumer_id)
¶
The worker index consumer_id has in its deployment.
_track_free(flat, offset)
¶
Release this copy of the block at offset once Ray drops its last
reference to flat (the consumer's read is done).
_unit_cond(unit)
¶
The condition a pull for unit waits on. Caller holds _lock.
_wait_for(cond, blocked, what, sync_idx=None)
¶
Wait on cond while blocked(), returning early on an error of
sync sync_idx (default: the current one); fail the sync when nothing
on this producer progressed for the stall timeout. Caller holds _lock.
begin_sync(live_consumer_ids, sync_idx)
¶
Open sync sync_idx for the given live consumers.
bucket(consumer_id, seq, sync_idx)
¶
Serve one registered bucket of sync sync_idx once its unit is
gathered and the arena has room: its boxes packed, with one fused
copy, into an arena block at flat_layout. The same worker of every
deployment gets the same block, packed once.
Raises:
-
ValueError–an unregistered bucket, or a sync this producer left.
end_sync()
¶
Block until every published unit is released and Ray freed every served block (workers may still read them); return the released.
publish_unit(unit, entries)
¶
Rebuild one gathered unit's CUDA-IPC tensors and make them
servable; never blocks. entries is (storages, views, event, keep),
as _export returns them.
Raises:
-
ValueError–a tensor does not match its metadata.
register_consumer(consumer_id, buckets)
¶
Record the buckets consumer_id pulls from here, in pull order,
replacing its earlier registration. A re-plan to other buckets is
refused while the same worker of another deployment holds the old ones.
Raises:
-
ValueError–a bucket names a tensor this rank does not serve, spans two units or is larger than the arena; or the same worker of another deployment registered other buckets.
set_gather_error(message, sync_idx=None)
¶
Fail sync sync_idx (default: the current one) on this producer.
wait_freed()
¶
Block until a published unit is released; return the released ones.
warmup_nixl()
¶
Create the NIXL agent and register the arena now, while the rank's GPU is idle and before any rank enters a collective: creating the agent lazily deadlocks on EFA-class fabrics.
_Sources
dataclass
¶
One bucket's source boxes for one generation of its unit: the
contiguous ones as 8-byte words where aligned, else as bytes, each with
the split sizes (in words or bytes) whose odd chunks of the bucket are
the pieces they fill; and the strided ones as runs (first piece,
count), each one strided view.
_reduce_storage(ust, device)
¶
CUDA-IPC reduce args for the whole storage ust.
_sources(gen, views, layout, nbytes)
¶
Split a bucket's source boxes into contiguous ones (as 8-byte words where aligned) and runs of evenly spaced strided ones, each run copied as one view.
_splits(idx, layout, nbytes, unit)
¶
Split sizes, in unit bytes, cutting a bucket of nbytes into gaps
and pieces idx, so that its odd chunks are those pieces.