vllm.executor.executor_base
DistributedExecutorBase
¶
Bases: ExecutorBase
Abstract superclass of distributed executor implementations.
Source code in vllm/executor/executor_base.py
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 |
|
parallel_worker_tasks
instance-attribute
¶
__init__
¶
Source code in vllm/executor/executor_base.py
_driver_execute_model
abstractmethod
¶
_driver_execute_model(
execute_model_req: Optional[ExecuteModelRequest],
) -> Optional[List[SamplerOutput]]
Run execute_model in the driver worker.
Passing None will cause the driver to stop the model execution loop running in each of the remote workers. In this case, this method returns None. Otherwise, this method returns the model output.
Source code in vllm/executor/executor_base.py
_driver_execute_model_async
abstractmethod
async
¶
_driver_execute_model_async(
execute_model_req: Optional[ExecuteModelRequest] = None,
) -> List[SamplerOutput]
Execute the model asynchronously in the driver worker.
Passing None will cause the driver to stop the model execution loop running in each of the remote workers.
Source code in vllm/executor/executor_base.py
_run_workers
abstractmethod
¶
_run_workers(
method: Union[str, Callable],
*args,
async_run_tensor_parallel_workers_only: bool = False,
max_concurrent_workers: Optional[int] = None,
**kwargs,
) -> Any
Runs the given method on all workers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
async_run_tensor_parallel_workers_only
|
bool
|
If True the method will be run only in the remote TP workers, not the driver worker. It will also be run asynchronously and return a list of futures rather than blocking on the results. |
False
|
TODO: simplify and merge with collective_rpc¶
Source code in vllm/executor/executor_base.py
_start_worker_execution_loop
abstractmethod
async
¶
Run execution loop on all workers. It guarantees all workers run
the loop or None of them is running the loop. Loop can be stopped by
stop_remote_worker_execution_loop
.
The API is idempotent (guarantee only 1 loop run at any moment).
Source code in vllm/executor/executor_base.py
_wait_for_tasks_completion
abstractmethod
¶
_wait_for_tasks_completion(
parallel_worker_tasks: Any,
) -> None
Wait for futures returned from _run_workers() with async_run_remote_workers_only to complete.
collective_rpc
¶
execute_model
¶
execute_model(
execute_model_req: ExecuteModelRequest,
) -> List[SamplerOutput]
Source code in vllm/executor/executor_base.py
execute_model_async
async
¶
execute_model_async(
execute_model_req: ExecuteModelRequest,
) -> List[SamplerOutput]
Source code in vllm/executor/executor_base.py
stop_remote_worker_execution_loop
¶
Source code in vllm/executor/executor_base.py
stop_remote_worker_execution_loop_async
async
¶
Source code in vllm/executor/executor_base.py
ExecutorBase
¶
Bases: ABC
Base class for all executors.
An executor is responsible for executing the model on one device, or it can be a distributed executor that can execute the model on multiple devices.
Source code in vllm/executor/executor_base.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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 |
|
__del__
¶
__init__
¶
__init__(vllm_config: VllmConfig) -> None
Source code in vllm/executor/executor_base.py
_init_executor
abstractmethod
¶
add_lora
¶
add_lora(lora_request: LoRARequest) -> bool
add_prompt_adapter
¶
add_prompt_adapter(
prompt_adapter_request: PromptAdapterRequest,
) -> bool
Source code in vllm/executor/executor_base.py
apply_model
¶
Run a function directly on the model inside each worker, returning the result for each of them.
Source code in vllm/executor/executor_base.py
check_health
abstractmethod
¶
check_health_async
async
¶
collective_rpc
abstractmethod
¶
collective_rpc(
method: Union[str, Callable[..., _R]],
timeout: Optional[float] = None,
args: Tuple = (),
kwargs: Optional[Dict[str, Any]] = None,
) -> List[_R]
Execute an RPC call on all workers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
Union[str, Callable[..., _R]]
|
Name of the worker method to execute, or a callable that is serialized and sent to all workers to execute. If the method is a callable, it should accept an additional
|
required |
timeout
|
Optional[float]
|
Maximum time in seconds to wait for execution. Raises a
|
None
|
args
|
Tuple
|
Positional arguments to pass to the worker method. |
()
|
kwargs
|
Optional[Dict[str, Any]]
|
Keyword arguments to pass to the worker method. |
None
|
Returns:
Type | Description |
---|---|
List[_R]
|
A list containing the results from each worker. |
Note
It is recommended to use this API to only pass control messages, and set up data-plane communication to pass data.
Source code in vllm/executor/executor_base.py
determine_num_available_blocks
¶
Determine the number of available blocks for the GPU KV cache and swappable CPU KV cache.
Normally, this should simply delegate to the underlying Worker. Some ExecutorBase may require modification of the result, e.g. to ensure the selected cache sizes are compatible with all workers.
Returns a Tuple[num_gpu_blocks, num_cpu_blocks], where num_gpu_blocks are blocks that are "active" on the device and can be appended to. num_cpu_blocks refers to "swapped" blocks in CPU memory and cannot be appended to.
Source code in vllm/executor/executor_base.py
execute_model
¶
execute_model(
execute_model_req: ExecuteModelRequest,
) -> Optional[List[Union[SamplerOutput, PoolerOutput]]]
execute_model_async
async
¶
execute_model_async(
execute_model_req: ExecuteModelRequest,
) -> List[SamplerOutput]
Executes one model step on the given sequences.
Source code in vllm/executor/executor_base.py
initialize_cache
¶
initialize_cache(
num_gpu_blocks: int, num_cpu_blocks
) -> None
Initialize the KV cache by invoking the underlying worker.
Source code in vllm/executor/executor_base.py
list_loras
¶
list_prompt_adapters
¶
pin_lora
¶
pin_prompt_adapter
¶
remove_lora
¶
remove_prompt_adapter
¶
save_sharded_state
¶
save_sharded_state(
path: str,
pattern: Optional[str] = None,
max_size: Optional[int] = None,
) -> None
Source code in vllm/executor/executor_base.py
shutdown
¶
sleep
¶
sleep(level: int = 1)