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:
python -m vllm.model_executor.model_loader.weight_cache.daemon \
--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
Only tensor and expert parallelism are supported; pipeline and data parallelism are rejected at launch.
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)
python -m vllm.model_executor.model_loader.weight_cache.daemon \
--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)
python -m vllm.model_executor.model_loader.weight_cache.daemon \
--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.
Classes:
-
WeightCacheDaemon–Per-GPU process that loads one TP shard and serves CUDA IPC handles.
Functions:
-
export_entries–Export a model's tensors, preserving tied-parameter aliases.
-
get_daemon_model–Load the daemon's model, composed from the configured loader.
WeightCacheDaemon ¶
Per-GPU process that loads one TP shard and serves CUDA IPC handles.
Methods:
-
serve_forever–Serve requests until terminated.
Source code in vllm/model_executor/model_loader/weight_cache/daemon.py
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 | |
_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
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 parallelism modes other than tensor/expert parallelism.
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_daemon_model(vllm_config) ¶
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.