vllm.distributed.weight_transfer.sharded_rdt_fake ¶
Op-chain recording for the sharded-RDT backend.
The consumer asks the trainer for the exact slice a worker consumes, described as an op chain replayed on the trainer's live tensor. FakeRDTTensor builds the chain by intercepting the model's own weight loaders; copy_ is its data sink, BakeSink — the dry run records how each slice would be fetched and where it lands.
Chains are built against meta tensors, so nothing here touches Ray or a GPU.
Classes:
-
BakeSink–copy_sink for the dry-run bake: record how each slice would be fetched -
FakeRDTTensor–Zero-storage tensor that records how to fetch a weight slice.
BakeSink dataclass ¶
copy_ sink for the dry-run bake: record how each slice would be fetched and where it would land, and move nothing.
_install_recording_stamps sets current = (leaf_module, param_name) around each loader so accept_copy can attribute the copy. An unstamped copy_ cannot be attributed and stays unrecorded, so its module fails the coverage gate and takes the plain load. copies_by_layer is keyed by module object, so iterating it yields each leaf module once.
Source code in vllm/distributed/weight_transfer/sharded_rdt_fake.py
FakeRDTTensor ¶
Bases: Tensor
Zero-storage tensor that records how to fetch a weight slice.
_make_wrapper_subclass gives it shape/dtype/device without storage. Every op in SUPPORTED_OPS returns a child with the spec appended; copy_ delegates to the installed sink. Anything else reaches __torch_dispatch__ and raises _UnsupportedFakeOp, so failures are loud rather than silently fetching the wrong bytes.
Source code in vllm/distributed/weight_transfer/sharded_rdt_fake.py
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 | |
_intercept(self_, func, op_name, args, kwargs) classmethod ¶
Append the op and return a child, or a tuple of children for multi-return ops. Each child's geometry comes from running the op on a meta tensor.
Source code in vllm/distributed/weight_transfer/sharded_rdt_fake.py
_make_child(new_shape, new_dtype, *new_ops) ¶
Append one or more ops to the chain and return a fresh child.
Variadic so multi-return ops (e.g. chunk) can append both the base op and an indexing op in a single call.
Source code in vllm/distributed/weight_transfer/sharded_rdt_fake.py
_meta() ¶
A zero-storage meta tensor of this fake's shape/dtype, so PyTorch itself computes post-op geometry rather than us reimplementing it.
Source code in vllm/distributed/weight_transfer/sharded_rdt_fake.py
_Scatter dataclass ¶
One recorded scatter: pull src, copy it into layer's param_name at the recorded strided region. The bake's output unit; see the engine module's Data flow.
Self-contained so replay needs no lookups. Destination geometry is read off the meta view and rebuilt each sync as as_strided(shape, stride, offset) -- layer is resolved to a param at replay time, never baked, since every sync re-materializes fresh tensors.
shape and dtype also size the slice ON THE WIRE, so dtype is the PRODUCED dtype (the fake's after its op chain), not the source name's: view(dtype) is allowlisted, and taking the source's would size the slice with the wrong itemsize and carve the packed blob differently on the two sides.
Source code in vllm/distributed/weight_transfer/sharded_rdt_fake.py
_UnsupportedFakeOp ¶
Bases: NotImplementedError
Raised when a weight loader does something to a FakeRDTTensor that cannot be expressed as a slice request.
Surfaced as NotImplementedError so callers can distinguish "this backend can't handle this loader" from genuine bugs.
Source code in vllm/distributed/weight_transfer/sharded_rdt_fake.py
_freeze_kwargs(kwargs) ¶
Sort kwargs into a tuple of items for hashable storage in OpSpec.
_meta_copy_(dest, src) ¶
Fire dest.copy_ from a zero-storage meta source of src's geometry.
Moves no data but still counts against the layer's loaded numel, which drives _layerwise_process; skipping it would leave the layer looking unloaded forever.
A non-meta dest is one the layerwise reload never moved there (the SKIP_LOAD_TENSORS set, e.g. GLM's router bias). Torch forbids real.copy_(meta), and skipping the count is consistent -- get_layer_size excludes the same set. The caller still RECORDS the copy, so the replay writes the real param.