vllm.distributed.weight_transfer.sharded_rdt_engine
¶
Sharded Ray Direct Transport (RDT) weight transfer engine (consumer side).
Each worker pulls only the boxes of each checkpoint tensor that its load plan
names, from the trainer ranks that own them, and writes them where the plan
says. The protocol is described in sharded_rdt_common.
Classes:
-
ShardedRDTWeightTransferEngine–Pull-based RDT/NIXL backend that moves only the boxes each worker's
-
ShardedRDTWeightTransferInitInfo–Initialization info for the sharded RDT backend, built by the trainer
-
ShardedRDTWeightTransferUpdateInfo–Update info for the sharded RDT backend.
ShardedRDTWeightTransferEngine
¶
Bases: WeightTransferEngine[ShardedRDTWeightTransferInitInfo, ShardedRDTWeightTransferUpdateInfo]
Pull-based RDT/NIXL backend that moves only the boxes each worker's
load plan needs. Requires direct reload (VLLM_RELOAD_MODE auto or direct),
distributed_executor_backend="ray" and nixl.
Every inference deployment must call start_weight_update before any
calls update_weights: the first one plans and registers with the
trainer, which frees a gathered unit only once every live worker has.
Methods:
-
finish_weight_update–Rerun post-load processing on the received weights.
-
init_transfer_engine–Check the configuration and bind the producers. Touches no model
-
receive_weights–Pull every bucket of the plan,
num_buffersin flight, and apply -
start_weight_update–Begin a direct reload; the first one after an init also plans and
_apply(bucket, slot)
¶
Copy a bucket landed in receive slot slot into its destinations,
the contiguous ones with one fused byte copy, and load its
fallbacks.
_bucket_cap(groups)
¶
The size every bucket is cut to: the largest bucket the pieces
within buffer_bytes make, raised to hold one row of every larger one.
Raises:
-
RuntimeError–one row of a piece is over
buffer_bytes.
_build_buckets(plan)
¶
Route, split and order this worker's pieces into pulls.
_pin_arena(buckets)
¶
Allocate and register the receive arena: per pull in flight, one
slot of the largest bucket (at most buffer_bytes). Each bucket
lands at the start of a slot, so its targets and copy-out sources
are views built here, once.
_send_buckets(buckets)
¶
Tell every producer, including those this worker pulls nothing from, which buckets it will pull: a producer releases a unit only once every live worker has registered.
_source_views(bucket, flat)
staticmethod
¶
Where each copy of bucket reads in flat.
finish_weight_update()
¶
Rerun post-load processing on the received weights.
init_transfer_engine(init_info)
¶
Check the configuration and bind the producers. Touches no model
state; the plan is built at the next start_weight_update.
Raises:
-
ValueError–invalid settings or metadata.
-
RuntimeError–the model cannot be planned (
check_plannable: e.g. the model does not reload directly), or a producer cannot be found.
receive_weights(update_info)
¶
Pull every bucket of the plan, num_buffers in flight, and apply
each as it lands.
Raises:
-
RuntimeError–no plan (call
start_weight_updatefirst).
start_weight_update()
¶
Begin a direct reload; the first one after an init also plans and sends each producer its buckets.
Raises:
-
RuntimeError–not initialized.
ShardedRDTWeightTransferInitInfo
dataclass
¶
Bases: WeightTransferInitInfo
Initialization info for the sharded RDT backend, built by the trainer
(ShardedRDTTrainerWeightTransferEngine).
Attributes:
-
buffer_bytes(int) –Most bytes one pull moves, and the size of a gather unit.
-
dtype_names(list[str]) –Dtype name (e.g. 'bfloat16') for each entry of
names. -
name_owner_class(list[int]) –Per name, its index into
owner_sets. -
names(list[str]) –Every checkpoint tensor name, in the trainer's gather order.
-
num_buffers(int) –Pulls each worker keeps in flight.
-
num_consumers(int) –Workers across the fleet; 0 infers it from the parallel config.
-
num_replicas(int) –Independent inference deployments in the fleet (uniform); must match
-
owner_sets(list[list[int]]) –The distinct sets of trainer ranks that hold a name. Empty means every
-
replica_rank(int) –This inference deployment's index in a fleet of independent ones,
-
shapes(list[list[int]]) –Full shape for each entry of
names. -
trainer_actor_names(list[str]) –Producer actor names, ordered by trainer rank.
-
trainer_actor_namespace(str | None) –Ray namespace the producer actors live in.
-
workers_per_replica(int) –Workers per inference deployment, from the trainer; 0 means one.
buffer_bytes = DEFAULT_BUFFER_BYTES
class-attribute
instance-attribute
¶
Most bytes one pull moves, and the size of a gather unit.
dtype_names = field(default_factory=list)
class-attribute
instance-attribute
¶
Dtype name (e.g. 'bfloat16') for each entry of names.
name_owner_class = field(default_factory=list)
class-attribute
instance-attribute
¶
Per name, its index into owner_sets.
names = field(default_factory=list)
class-attribute
instance-attribute
¶
Every checkpoint tensor name, in the trainer's gather order.
num_buffers = DEFAULT_NUM_BUFFERS
class-attribute
instance-attribute
¶
Pulls each worker keeps in flight.
num_consumers = 0
class-attribute
instance-attribute
¶
Workers across the fleet; 0 infers it from the parallel config.
num_replicas = 1
class-attribute
instance-attribute
¶
Independent inference deployments in the fleet (uniform); must match
the trainer's workers_per_replica.
owner_sets = field(default_factory=list)
class-attribute
instance-attribute
¶
The distinct sets of trainer ranks that hold a name. Empty means every rank holds every name.
replica_rank = 0
class-attribute
instance-attribute
¶
This inference deployment's index in a fleet of independent ones, whose worker indices each restart at 0; set per deployment.
shapes = field(default_factory=list)
class-attribute
instance-attribute
¶
Full shape for each entry of names.
trainer_actor_names = field(default_factory=list)
class-attribute
instance-attribute
¶
Producer actor names, ordered by trainer rank.
trainer_actor_namespace = None
class-attribute
instance-attribute
¶
Ray namespace the producer actors live in.
workers_per_replica = 0
class-attribute
instance-attribute
¶
Workers per inference deployment, from the trainer; 0 means one.
ShardedRDTWeightTransferUpdateInfo
dataclass
¶
Bases: WeightTransferUpdateInfo
Update info for the sharded RDT backend.
Attributes:
sync_idx = 0
class-attribute
instance-attribute
¶
The trainer's count of this sync; producers serve a pull only in the sync it names.
_Bucket
dataclass
¶
One pull: the pieces one producer serves to this worker, and where
they go. It lands as one flat byte tensor (pieces at flat_layout) in a
slot of the receive arena.
Methods:
-
prepare–Build the copy-out from each piece's sent dtype and destinations.
_PullHooks
dataclass
¶
The transport, injected so tests can run the engine without Ray.
_Staging
dataclass
¶
A fallback's whole tensor name, allocated when its first piece lands
and loaded through load_weights (then freed) once all count have.
_by_destination(piece, storages)
¶
Sort key: a piece with one contiguous destination of its dtype by its storage's first-use rank and byte offset; every other piece after them, in plan order.
_component_unit_rank(metas, units, router, components)
¶
Per coupling component, each unit's index in its ranks' gather order, so pulls follow the gathers and independent stages pull side by side.
_cut(pieces, budget)
¶
Consecutive runs of at most budget bytes; a larger piece goes alone.
_resolve_producers(init_info)
¶
Producer actor handles, by trainer rank.
_rows(piece, cap)
¶
A piece over cap cut along dim 0 into segments of whole rows that
fit cap, each a view on both sides.
Raises:
-
RuntimeError–a destination's rows are not rows of the box.