vllm.distributed.ec_transfer.ec_connector.cpu.worker ¶
Worker-side of the ECCPUConnector.
Thin, stateless across steps: opens the shared mmap region and uses the per-step connector metadata (ECCPUConnectorMetadata) to decide which blocks to copy in each direction.
Modules:
-
descriptor_buffers–Reusable pool of (src_ptrs, dst_ptrs, sizes) tensor triples.
Classes:
-
ECCPUWorker–Worker-side delegate for the ECCPUConnector.
-
Transfer–A batched copy in flight on a dedicated GPU stream.
ECCPUWorker ¶
Worker-side delegate for the ECCPUConnector.
- Producer role: copies
encoder_cache[mm_hash]→mmap[block_ids]for each entry inmetadata.saves. Descriptor buffers are filled directly insave_caches; the actual DMA is issued as a single batched call inflush_saves. - Consumer role: copies
mmap[block_ids]→encoder_cache[mm_hash]for all entries inmetadata.loadsvia a singleswap_blocks_batchcall on a dedicated stream. - On
ec_bothnodes both paths run back-to-back in a single step.
Every batched copy runs on a stream drawn from a pool so it overlaps the compute stream, bracketed by a start/end event pair. The stream, events, and descriptor buffers are recycled once the end event fires.
Both paths move memory between the two streams, so each buffer is registered against the stream that is not its own: save sources against the save stream, load destinations against the compute stream. Without that, the caching allocator would be free to reissue memory a copy or a queued read still needs, since it only tracks the stream a buffer was allocated on.
Methods:
-
build_connector_worker_meta–Report the GPU copies that completed on this rank this step: saved
-
flush_saves–Flush all accumulated saves in a single swap_blocks_batch call.
-
save_caches–Fill descriptor buffers directly for batched flush.
-
start_load_caches–Consumer path: single batched copy of all loads from mmap→GPU.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
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 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 | |
_collect_finished(inflight, direction) ¶
Pop transfers whose end event has fired, recycle their stream, events, and buffers, and return their completions.
The front check is conservative: a transfer is reported only once its own end event fires, so completions are always genuinely done, and each is reported exactly once because the transfer is popped as it is reported. A later transfer that happens to finish first simply waits behind the front and is reported on a subsequent poll.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
_pin_shared_region() ¶
_shutdown_transfer_backend() ¶
_submit_transfer(bufs, count, direction) ¶
Submit a transfer on the current backend stream.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
build_connector_worker_meta() ¶
Report the GPU copies that completed on this rank this step: saved mm_hashes and loaded transfer ids.
Returns None when nothing finished, so the scheduler sees no payload.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
flush_saves() ¶
Flush all accumulated saves in a single swap_blocks_batch call.
Runs the copy on the stream the batch acquired when it opened, gated behind the compute stream that produced the encoder outputs, brackets it with start/end events, and enqueues the batch as in-flight. The stream, events, and descriptor buffers are recycled once the end event fires (see _collect_finished), which is also when the saved mm_hashes become safe to mark ready.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
save_caches(encoder_cache, mm_hash, connector_metadata) ¶
Fill descriptor buffers directly for batched flush.
Registers encoder_cache[mm_hash] against the stream the copy will run on, so the caching allocator will not hand that memory to another allocation before the copy has read it. The descriptor buffers hold raw addresses, and the caller is free to evict the entry as soon as this step's saves are dispatched.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
start_load_caches(encoder_cache, connector_metadata) ¶
Consumer path: single batched copy of all loads from mmap→GPU.
The destination is registered against the compute stream that consumes it, so the caching allocator will not hand that memory to a later load while reads of it are still queued there.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
Transfer dataclass ¶
A batched copy in flight on a dedicated GPU stream.
Its descriptor buffers and stream are held until end_event fires; only then are the buffers and stream safe to recycle and the completions safe to report. start_event/end_event bracket the copy so its elapsed time can be measured on completion.
completions is what the scheduler is told about this copy: mm_hashes for saves, transfer ids for loads.
Source code in vllm/distributed/ec_transfer/ec_connector/cpu/worker/__init__.py
_coalesce_runs(block_ids) ¶
Split block ids into runs that are consecutive in the region.
Returns (slots, first_blocks, num_blocks), one element per run, where slots is the run's offset in the flat block sequence. Per-descriptor overhead dominates these copies, so describing a run with one descriptor rather than one per block is worth an order of magnitude.
Both callers derive the non-region side of a run from its slot, so that side advances in lockstep with the region and only the region has to be split. EmbeddingCache hands out ascending ids, which is what makes runs findable at all.