vllm.model_executor.model_loader.weight_cache.daemon
¶
Weight cache daemon for fast engine restarts.
One daemon process per GPU holds the post-quantized, TP-sharded weights of its rank in GPU memory and serves CUDA IPC handles to vLLM engines over a Unix domain socket. Restarting engines map the weights via zero-copy IPC instead of reloading from disk.
Launch one daemon per TP rank with a single command:
vllm preload \
--model /path/to/model --tensor-parallel-size 4
Engines then load from the daemons with:
vllm serve /path/to/model --tensor-parallel-size 4 \
--load-format ipc_cache
Tensor, expert, data and pipeline parallelism are supported.
For multi-node tensor parallelism, run one launcher per node with a shared
rendezvous so the global TP group forms across nodes (CUDA IPC handles are
node-local, so each node serves only its local GPUs' shards). Reuse the same
--nnodes/--node-rank/--master-addr flags you pass the engine, plus a
--weight-cache-master-port distinct from the engine's --master-port:
# node 0 (8 local GPUs)
vllm preload \
--model /path/to/model --tensor-parallel-size 16 \
--nnodes 2 --node-rank 0 --master-addr 10.0.0.1 \
--weight-cache-master-port 29600
# node 1 (8 local GPUs)
vllm preload \
--model /path/to/model --tensor-parallel-size 16 \
--nnodes 2 --node-rank 1 --master-addr 10.0.0.1 \
--weight-cache-master-port 29600
The global TP rank of local GPU i on node r is
r * (tp_size // nnodes) + i, matching vLLM's contiguous per-node rank
assignment, so each engine worker maps its shard from the daemon on its own
node. With pipeline parallelism each node additionally runs one daemon per PP
stage; the global rank is pp_rank * tp_size + tp_rank.
For data parallelism (e.g. a TP1 x DP16 x EP decode fleet) run one launcher per
node with the engine's DP placement flags. Local GPU i serves DP rank
start_rank + i // tp_size and TP rank i % tp_size, and all
dp_size * tp_size daemons form one world group on
--data-parallel-address/--weight-cache-master-port so the expert
shards are laid out exactly as in the engine:
# node r (4 local GPUs)
vllm preload \
--model /path/to/model --tensor-parallel-size 1 --enable-expert-parallel \
--data-parallel-size 16 --data-parallel-size-local 4 \
--data-parallel-start-rank 4r --data-parallel-address 10.0.0.1 \
--weight-cache-master-port 29600
Data parallelism also combines with multi-node tensor parallelism: pass both
flag sets (--nnodes/--node-rank/--master-addr and the DP flags with
a reachable --data-parallel-address). Each node then serves a contiguous
block of the dp_size * tp_size global ranks, e.g. TP8 x DP2 on 4 nodes:
# node r (4 local GPUs)
vllm preload \
--model /path/to/model --tensor-parallel-size 8 --enable-expert-parallel \
--nnodes 4 --node-rank r --master-addr 10.0.0.1 \
--data-parallel-size 2 --data-parallel-address 10.0.0.1 \
--weight-cache-master-port 29600
With MTP, EAGLE or EAGLE3 speculative decoding the launcher additionally
starts a draft daemon group that caches the draft model. It uses its own cache
key, Unix sockets (*_draft.sock) and rendezvous port
(--weight-cache-draft-master-port, default --weight-cache-master-port +
1), so each process serves exactly one model role. Other draft types are not
cached and keep loading from disk in the engine.
Classes:
-
WeightCacheDaemon–Per-GPU process that loads one TP/PP shard and serves CUDA IPC handles.
Functions:
-
export_entries–Export a model's tensors, preserving tied-parameter aliases.
-
get_draft_daemon_config–VllmConfig for the draft daemon group
-
plan_local_ranks–(local_rank, dp_rank, pp_rank, tp_rank)for every local daemon.
WeightCacheDaemon
¶
Per-GPU process that loads one TP/PP shard and serves CUDA IPC handles.
Methods:
-
get_model–Load the daemon's model, composed from the configured loader.
-
serve_forever–Serve requests until terminated.
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
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 | |
_acquire_gpu_lock(socket_path)
¶
Take an exclusive lock guarding this GPU's socket path.
The lock is advisory and released automatically when the daemon exits (or crashes), so a stale socket is only ever removed by whoever owns the lock. A running daemon holding it makes a second daemon fail fast instead of clobbering the live socket.
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
get_model()
¶
Load the daemon's model, composed from the configured loader.
Runs the quantization check after model creation but before the slow weight load, so an unsupported method fails fast. Online quantization always fails the check, so load_model's finalize step for it is unnecessary here.
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
serve_forever(ready_callback=None)
¶
Serve requests until terminated.
The socket is only bound once the model is fully cached, so clients get a connection error (and fall back to disk) until the daemon is ready.
Parameters:
-
(ready_callback¶Callable[[], None] | None, default:None) –Invoked once the socket is bound and listening, so the launcher can report overall readiness.
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
_reject_unsupported_parallelism(parallel_config)
¶
Reject placements the daemon cannot map.
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
export_entries(model)
¶
Export a model's tensors, preserving tied-parameter aliases.
named_parameters/named_buffers are iterated with
remove_duplicate=False so tied weights (e.g. lm_head.weight sharing
storage with embed_tokens.weight) are not silently dropped. Each unique
tensor is exported once per call; every additional name that refers to the same
tensor object is recorded in the returned alias map so the client can
re-establish the shared identity instead of allocating uninitialized
memory for it.
CUDA reduction arguments must be exported separately for each consumer so that PyTorch registers a reference for each IPC mapping's lifetime.
Returns:
-
dict[str, TensorEntry]–A
(entries, aliases)pair whereentriesmaps a canonical name to -
dict[str, str]–its
TensorEntryandaliasesmaps each duplicate name to its -
tuple[dict[str, TensorEntry], dict[str, str]]–canonical name.
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
get_draft_daemon_config(vllm_config)
¶
VllmConfig for the draft daemon group
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
plan_local_ranks(parallel_config)
¶
(local_rank, dp_rank, pp_rank, tp_rank) for every local daemon.
Global ranks enumerate DP, PP, then TP: global = dp_rank * pp_size *
tp_size + pp_rank * tp_size + tp_rank.
With --nnodes the engine hands each node a contiguous block of global
ranks, so node r serves node_rank * local + i; without it a
launcher's block starts at --data-parallel-start-rank * tp_size.