vllm.engine.multiprocessing.client
MQClientClosedError
¶
Bases: Exception
Exception class raised when the client is used post-close.
The client can be closed, which closes the ZMQ context. This normally happens on server shutdown. In some cases, methods like abort and do_log_stats will still be called and then try to open a socket, which causes a ZMQError and creates a huge stack trace. So, we throw this error such that we can suppress it.
Source code in vllm/engine/multiprocessing/client.py
MQLLMEngineClient
¶
Bases: EngineClient
A client wrapper for MQLLMEngine that conforms to the EngineClient protocol.
MQLLMEngine and MQLLMEngineClient are intended to run in separate processes communicating via zeromq ipc sockets.
The entrypoint to MQLLMEngineClient is through the generate() method. On generate() MQLLMEngine does three things: - Creates an asyncio output queue - Sends a RPCGenerateRequest to the MQLLMEngine via zmq - Pulls RequestOutputs from its queue and yields them
MQLLMEngine runs two background loops
- output_loop: the output loop pulls List[RequestOutput] from the MQLLMEngine via zmq (each list is the output of one engine_step in the LLMEngine). It then parses the list and pushes individual request_outputs into the corresponding output_queue such that they can be consumed by the .generate() method.
- health_loop: the health loop queries the health socket every N seconds, confirming the engine is healthy
Source code in vllm/engine/multiprocessing/client.py
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 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 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
|
input_preprocessor
instance-attribute
¶
input_preprocessor = InputPreprocessor(
model_config, tokenizer
)
tokenizer
instance-attribute
¶
tokenizer = init_tokenizer_from_configs(
model_config=model_config,
scheduler_config=scheduler_config,
lora_config=lora_config,
)
__init__
¶
__init__(
ipc_path: str,
engine_config: VllmConfig,
engine_pid: int,
)
Source code in vllm/engine/multiprocessing/client.py
_add_output
¶
_add_output(
request_output: Union[
RequestOutput,
RPCAdapterLoadedResponse,
RPCIsSleepingResponse,
],
)
_await_ack
async
¶
_await_ack(error_message: str, socket: Socket)
Await acknowledgement that a request succeeded.
Source code in vllm/engine/multiprocessing/client.py
_check_success
async
staticmethod
¶
_check_success(error_message: str, socket: Socket)
Confirm that socket has a VLLM_RPC_SUCCESS_STR message
Source code in vllm/engine/multiprocessing/client.py
_process_request
async
¶
_process_request(
prompt: PromptType,
params: Union[SamplingParams, PoolingParams],
request_id: str,
lora_request: Optional[LoRARequest] = None,
trace_headers: Optional[Mapping[str, str]] = None,
prompt_adapter_request: Optional[
PromptAdapterRequest
] = None,
priority: int = 0,
) -> Union[
AsyncGenerator[RequestOutput, None],
AsyncGenerator[PoolingRequestOutput, None],
]
Send an RPCGenerateRequest to the RPCServer and stream responses.
Source code in vllm/engine/multiprocessing/client.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
|
_send_get_data_rpc_request
async
staticmethod
¶
_send_get_data_rpc_request(
request: RPCStartupRequest,
expected_type: Any,
error_message: str,
socket: Socket,
) -> Any
Send an RPC request that is expecting data back.
Source code in vllm/engine/multiprocessing/client.py
_send_one_way_rpc_request
async
staticmethod
¶
_send_one_way_rpc_request(
request: RPC_REQUEST_T, socket: Socket
)
Send one-way RPC request to trigger an action.
Source code in vllm/engine/multiprocessing/client.py
_set_errored
¶
_set_errored(e: BaseException)
_wait_for_server_rpc
async
¶
_wait_for_server_rpc(socket: Socket) -> RPCStartupResponse
Wait for the RPCServer to start up.
Source code in vllm/engine/multiprocessing/client.py
abort
async
¶
abort(request_id: str)
Send an ABORT_REQUEST signal to the RPC Server
Source code in vllm/engine/multiprocessing/client.py
add_lora
async
¶
add_lora(lora_request: LoRARequest) -> None
Load a new LoRA adapter into the engine for future requests.
Source code in vllm/engine/multiprocessing/client.py
check_health
async
¶
The check health loop probes the health status of the Engine's health every N seconds and sets _errored_with if the engine is unhealthy.
Source code in vllm/engine/multiprocessing/client.py
close
¶
Destroy the ZeroMQ Context.
Source code in vllm/engine/multiprocessing/client.py
do_log_stats
async
¶
do_log_stats(
scheduler_outputs: Optional[SchedulerOutputs] = None,
model_output: Optional[List[SamplerOutput]] = None,
) -> None
Ignore do_log_stats (handled on MQLLMEngine polling)
Source code in vllm/engine/multiprocessing/client.py
encode
¶
encode(
prompt: PromptType,
pooling_params: PoolingParams,
request_id: str,
lora_request: Optional[LoRARequest] = None,
trace_headers: Optional[Mapping[str, str]] = None,
priority: int = 0,
) -> AsyncGenerator[PoolingRequestOutput, None]
Generate outputs for a request from a pooling model.
Generate outputs for a request. This method is a coroutine. It adds the request into the waiting queue of the LLMEngine and streams the outputs from the LLMEngine to the caller.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
PromptType
|
The prompt to the LLM. See
|
required |
pooling_params
|
PoolingParams
|
The pooling parameters of the request. |
required |
request_id
|
str
|
The unique id of the request. |
required |
lora_request
|
Optional[LoRARequest]
|
LoRA request to use for generation, if any. |
None
|
trace_headers
|
Optional[Mapping[str, str]]
|
OpenTelemetry trace headers. |
None
|
Yields:
Type | Description |
---|---|
AsyncGenerator[PoolingRequestOutput, None]
|
The output |
AsyncGenerator[PoolingRequestOutput, None]
|
for the request. |
Source code in vllm/engine/multiprocessing/client.py
generate
¶
generate(
prompt: PromptType,
sampling_params: SamplingParams,
request_id: str,
lora_request: Optional[LoRARequest] = None,
trace_headers: Optional[Mapping[str, str]] = None,
prompt_adapter_request: Optional[
PromptAdapterRequest
] = None,
priority: int = 0,
) -> AsyncGenerator[RequestOutput, None]
Generate outputs for a request.
Generate outputs for a request. This method is a coroutine. It adds the request into the waiting queue of the LLMEngine and streams the outputs from the LLMEngine to the caller.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt
|
PromptType
|
The prompt to the LLM. See
|
required |
sampling_params
|
SamplingParams
|
The sampling parameters of the request. |
required |
request_id
|
str
|
The unique id of the request. |
required |
lora_request
|
Optional[LoRARequest]
|
LoRA request to use for generation, if any. |
None
|
trace_headers
|
Optional[Mapping[str, str]]
|
OpenTelemetry trace headers. |
None
|
prompt_adapter_request
|
Optional[PromptAdapterRequest]
|
Prompt Adapter request to use for generation, if any. |
None
|
priority
|
int
|
Priority of the request (lower means earlier handling). Any priority other than 0 will lead to an error if the scheduling policy is not "priority". |
0
|
Source code in vllm/engine/multiprocessing/client.py
get_decoding_config
async
¶
get_decoding_config() -> DecodingConfig
get_input_preprocessor
async
¶
get_input_preprocessor() -> InputPreprocessor
get_model_config
async
¶
get_model_config() -> ModelConfig
get_tokenizer
async
¶
get_tokenizer(lora_request: Optional[LoRARequest] = None)
get_vllm_config
async
¶
get_vllm_config() -> VllmConfig
is_sleeping
async
¶
is_sleeping() -> bool
Check whether the engine is sleeping
Source code in vllm/engine/multiprocessing/client.py
is_unsupported_config
staticmethod
¶
is_unsupported_config(vllm_config: VllmConfig)
reset_mm_cache
async
¶
reset_prefix_cache
async
¶
Reset the prefix cache
run_heartbeat_loop
async
¶
run_heartbeat_loop(timeout: int)
Background loop that continually checks to ensure the engine process is still alive.
Source code in vllm/engine/multiprocessing/client.py
run_output_handler_loop
async
¶
Get RequestOutputs from Engine and stream to Request Queues
Source code in vllm/engine/multiprocessing/client.py
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 |
|
setup
async
¶
Setup the client before it starts sending server requests.