vllm.model_executor.model_loader.weight_cache ¶
Modules:
-
daemon–Weight cache daemon for fast engine restarts.
-
ipc_loader–IPC model loader: maps post-quantized weights from a local weight cache
-
protocol–WeightCacheKey fingerprinting and socket protocol for the weight cache daemon.
Classes:
-
CacheConfigMismatchError–Raised when the daemon's cached weights don't match the engine.
-
IpcModelLoader–Loads a model by mapping the weight cache daemon's tensors via CUDA IPC.
-
TensorEntry–A single cached tensor.
-
UnsupportedPlatformForIPCError–Raised when the current platform cannot share CUDA IPC handles.
-
UnsupportedQuantForIPCError–Raised when a quantization method is not verified for IPC weight sharing.
-
WeightCacheKey–Fingerprint of the cached weights.
-
WeightCacheUnavailableError–Raised when no weight cache daemon is reachable or usable.
Functions:
-
check_ipc_platform_support–Hard-error unless the current platform can share CUDA IPC handles.
-
check_ipc_quant_support–Hard-error unless the model's quantization is verified for IPC sharing.
CacheConfigMismatchError ¶
IpcModelLoader ¶
Bases: BaseModelLoader
Loads a model by mapping the weight cache daemon's tensors via CUDA IPC.
The model is initialized on the meta device and every parameter/buffer is replaced by the daemon's post-quantized tensor, so process_weights_after_loading is skipped entirely. In "zero_copy" mode the engine shares the daemon's GPU memory; in "copy" mode the tensors are cloned into engine-owned memory and the daemon is asked to release its cache afterwards.
Extra config keys (via --model-loader-extra-config):
- socket_path: explicit daemon socket path. Defaults to a per-GPU path derived from the physical GPU id.
- socket_dir: directory containing the daemon sockets.
- mode: "zero_copy" (default) or "copy".
- fallback: fall back to disk loading when the daemon is unavailable or the fingerprints mismatch (default: True).
- connect_timeout_s: socket connect timeout (default: 5.0).
- state_timeout_s: timeout for the weight-transfer request (default: 300.0).
Note: in zero-copy mode the weights live in the daemon's CUDA IPC allocations, so sleep mode (CuMemAllocator weight offloading) must not be used with this loader.
Methods:
-
load_weights–Best-effort in-place reload for an already-initialized model.
Source code in vllm/model_executor/model_loader/weight_cache/ipc_loader.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 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 | |
load_weights(model, model_config) ¶
Best-effort in-place reload for an already-initialized model.
Copies daemon tensors into matching parameters/buffers. The model is expected to already be in the post-quantized layout (e.g. previously loaded through this loader).
Source code in vllm/model_executor/model_loader/weight_cache/ipc_loader.py
TensorEntry dataclass ¶
A single cached tensor.
CUDA tensors are exported as torch.multiprocessing reduction args (CUDA IPC handles); non-CUDA tensors are shipped by value.
Attributes:
Source code in vllm/model_executor/model_loader/weight_cache/protocol.py
kind instance-attribute ¶
Either "param" or "buffer".
UnsupportedPlatformForIPCError ¶
UnsupportedQuantForIPCError ¶
WeightCacheKey dataclass ¶
Fingerprint of the cached weights.
Any mismatch between the daemon's and the engine's fingerprint means the cached weights cannot be reused and the engine must load from disk.
Methods:
-
from_model_config–Build the fingerprint for a model configuration.
Source code in vllm/model_executor/model_loader/weight_cache/protocol.py
from_model_config(model_config, tp_size, tp_rank) classmethod ¶
Build the fingerprint for a model configuration.
Must be called before weight loading: process_weights_after_loading may mutate hf_config.quantization_config, which would change the hash between the daemon and the engine.
The checkpoint is identified by a hash of its safetensors metadata when the weights are available locally, so a daemon and engine referencing identical weights in different directories still match; otherwise it falls back to the model path.
Source code in vllm/model_executor/model_loader/weight_cache/protocol.py
WeightCacheUnavailableError ¶
check_ipc_platform_support(*, where) ¶
Hard-error unless the current platform can share CUDA IPC handles.
Only CUDA/ROCm tensors get a real IPC handle from TensorEntry; other platforms (e.g. XPU) would silently ship every tensor by value instead.
Parameters:
Raises:
-
UnsupportedPlatformForIPCError–If the current platform is not CUDA/ROCm.
Source code in vllm/model_executor/model_loader/weight_cache/protocol.py
check_ipc_quant_support(model_config, *, where) ¶
Hard-error unless the model's quantization is verified for IPC sharing.
Parameters:
-
(model_config¶ModelConfig) –Model configuration to inspect.
-
(where¶str) –Short tag ("daemon"/"engine") used in the error message.
Raises:
-
UnsupportedQuantForIPCError–If the quantization method is not on the verified allowlist.