vllm.distributed.weight_transfer.sharded_rdt_common ¶
Shared pieces of the sharded-RDT backend: the op-chain allowlist, buffer sizing and the minimum Ray version, plus RdtRouter — consumer-only, since routing is a consumer decision.
The gather-group partition itself is base.layerwise_groups: it defines what a group index means for any WeightSource, not just this transport.
Classes:
-
RdtRouter–Decides which producer serves each weight name, and — once bound — sends.
Functions:
-
assign_producer_indices–Producers (global indices) that consumer
consumer_idxbinds. -
buffer_alloc_bytes–Size a NIXL buffer / ring slot for
nbytes: the max of the request, an -
check_ray_rdt_version–Refuse an installed Ray older than the one this backend is tested on.
RdtRouter ¶
Decides which producer serves each weight name, and — once bound — sends.
Ownership is per NAME. owner_sets holds the few distinct producer sets that occur, and name_owner_class[i] indexes it for names[i]; a name determines both its owner set and its gather group, so neither appears in the routing API. Empty tables mean every producer holds everything.
Any placement is expressible this way: a pipeline stage is a set of names sharing one owner set, an expert is a name whose owner set is a single rank, and a group produced by two stages is just two classes inside one group.
Both engines derive the same tables from the same wire data, so they agree on who serves what. Disagreement is not a wrong answer but a hang or a loud misroute: a pull sent to a producer that never gathered the name trips its served-names guard.
Routing is consumer-only. The trainer publishes what it holds and answers whatever arrives; it never asks who serves what.
Methods:
-
__init__–Build the routing tables from the wire data both engines receive.
-
bind–Attach this consumer's producer handles. Rebuilt wholesale per init,
-
class_of–The name's owner class — the planner's bucketing key, since all names
-
free_group–Signal the group done at every producer holding any of its names.
-
group_owners–Every producer holding any name of
group_idx. -
owners–Every producer holding
name. -
producer_for–The single producer
consumer_idpullsnamefrom. -
pull–Issue one packed pull to
owner. -
reserve_serve_buffers–Ask each producer to pre-register a serve ring sized to the most this
-
validate–Check the ownership tables can be served.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
__init__(num_producers, num_consumers, owner_sets=None, name_owner_class=None, names=None, group_lens=None, workers_per_replica=0) ¶
Build the routing tables from the wire data both engines receive.
The four table arguments travel together and default together: with all of them empty the router degrades to "every producer holds everything".
Parameters:
-
(num_producers¶int) –Trainer ranks. Owner indices are positions in this range, and
validaterejects any that fall outside it. -
(num_consumers¶int) –Inference workers across the whole fleet. Fixes the id space; the block carve uses
workers_per_replicaof it. -
(owner_sets¶list[list[int]] | None, default:None) –The distinct producer sets that occur, one row per owner class; each row is deduplicated and sorted here. Empty means a single class owning every producer.
-
(name_owner_class¶list[int] | None, default:None) –Parallel to
names—name_owner_class[i]indexesowner_setsfornames[i]. A name with no entry falls back to class 0. -
(names¶list[str] | None, default:None) –Every parameter name, in group-major order: concatenating the gather groups reproduces this list exactly. The other two tables are keyed by this order.
-
(group_lens¶list[int] | None, default:None) –Length of each gather group, consecutive over
names, so they sum tolen(names). Fixes name -> group and the per-group owner union the free barrier fans out to. -
(workers_per_replica¶int, default:0) –Consumers per inference DEPLOYMENT. The block carve spreads this many consumers over an owner set and every deployment reuses that carve, so the same worker of each deployment resolves one producer (see
producer_for). 0 means one deployment: carve over the whole fleet.
Raises:
-
ValueError–workers_per_replicadoes not dividenum_consumers, so the deployments are not uniform and two workers of one deployment would share a block index.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
bind(actors, produce_methods, consumer_id) ¶
Attach this consumer's producer handles. Rebuilt wholesale per init, never appended to: every owner index is a position in these lists, so a rejoining engine that re-inits must not shift them.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
class_of(name) ¶
The name's owner class — the planner's bucketing key, since all names of a chunk must share one producer.
free_group(group_idx) ¶
Signal the group done at every producer holding any of its names.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
group_owners(group_idx) ¶
Every producer holding any name of group_idx.
The one group-keyed rule, because the free barrier is per group: a consumer signals free_group(gi) at each of these and the producer counts signals against its live-consumer total. Names route; groups free.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
owners(name) ¶
producer_for(consumer_id, name) ¶
The single producer consumer_id pulls name from.
Blocks consumers across the name's owner set with the same rule that binds producers globally, then rotates by the name's GROUP index so a consumer spreads its groups over its block instead of hammering one NIC. Rotating per group (not per name) keeps every name of a chunk on one producer, which is what lets a chunk be a single pull.
The carve is over ONE DEPLOYMENT (this consumer's index within its own deployment, over workers_per_replica of them), so the same worker of every deployment resolves the same producer for every name. Carving over the whole fleet instead spreads the multi-owner names of different deployments onto different producers while single-owner names still route by ownership, so a producer serves several distinct worker indices, each needing its own serve ring, and none of them can share a slot. With one deployment the width is the fleet, so this is the plain block rule.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
pull(owner, keys, seq) ¶
Issue one packed pull to owner.
The consumer id keys the producer's serve ring; without it every worker is served out of ring 0 and concurrent pulls overwrite each other's blob. seq is this call's index in the stream to owner (see _Chunk): it selects the serve slot in ISSUE order, so a slot is never repacked while the read of its previous contents is still in flight.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
reserve_serve_buffers(bytes_by_producer, plan_digests=None) ¶
Ask each producer to pre-register a serve ring sized to the most this consumer will pull from it.
plan_digests[p] describes the chunks this consumer pulls from producer p, in pull order. A producer that shares one serve ring across the consumers of several deployments compares it across them, so a fleet whose deployments are not identical fails at init instead of stalling mid-sync. A producer that shares nothing ignores it.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
validate() ¶
Check the ownership tables can be served.
Raises:
-
ValueError–an owner set is empty or out of range, or a class index does not resolve.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
assign_producer_indices(num_producers, num_consumers, consumer_idx) ¶
Producers (global indices) that consumer consumer_idx binds.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
buffer_alloc_bytes(nbytes, presize=0) ¶
Size a NIXL buffer / ring slot for nbytes: the max of the request, an optional presize floor, and a coarse 256MB round-up, so the buffer is allocated ONCE and never regrows. Regrowth is a correctness hazard, not just a perf one -- see buffer_presize_gb. Shared by the consumer's receive buffers and the producer's serve rings.
Source code in vllm/distributed/weight_transfer/sharded_rdt_common.py
check_ray_rdt_version() ¶
Refuse an installed Ray older than the one this backend is tested on.
vLLM does not depend on Ray, so there is no pin to carry this. Without the check the failure is an opaque option-validation error out of .options(enable_tensor_transport=True) (below 2.49) or an ImportError raised deep in the first pull, long after init reported success (below 2.55).
Raises:
-
ValueError–the installed Ray predates
RDT_MIN_RAY_VERSION.