vllm.engine.protocol
¶
Classes:
-
EngineClient–Protocol class for Clients to Engine.
-
StreamingInput–Input data for a streaming generation request.
EngineClient
¶
Bases: ABC
Protocol class for Clients to Engine.
Methods:
-
abort–Abort a request.
-
add_lora–Load a new LoRA adapter into the engine for future requests.
-
check_admission–Reject the request up front if it would exceed queue limits.
-
check_health–Raise if unhealthy.
-
check_health_generate–Raise if the engine is not ready to execute model work.
-
checkpoint_prepare–Drain with
mode, then release what a checkpoint must not contain. -
checkpoint_restore–Bring back what preparing released, in the restored process or in place.
-
checkpoint_state–Return the checkpoint lifecycle state and the error that failed it.
-
collective_rpc–Perform a collective RPC call to the given path.
-
compute_weight_checksums–Return rank-qualified weight digests from every worker of every engine.
-
encode–Generate outputs for a request from a pooling model.
-
finish_weight_update–Finish the weight update and set its version if provided.
-
generate–Generate outputs for a request.
-
get_external_elastic_ep_status–Return shared external Elastic EP operation status, if enabled.
-
get_kv_event_sources–KV-event publisher config of each engine, keyed by DP rank.
-
get_status–Get fault tolerance status of all engines.
-
get_supported_tasks–Get supported tasks.
-
get_weight_version–Return the latest committed weight version.
-
handle_fault–Send fault tolerance instruction to the engine.
-
init_weight_transfer_engine–Initialize weight transfer for RL training.
-
is_paused–Return whether the engine is currently paused.
-
is_sleeping–Check whether the engine is sleeping.
-
notify_kv_transfer_request_rejected–Notify the engine that a KV-transfer request was rejected before
-
pause_generation–Pause new generation/encoding requests.
-
release_kv_cache_memory–Discard KV cache physical GPU memory. Requires a completed pause.
-
reset_encoder_cache–Reset the encoder cache.
-
reset_mm_cache–Reset the multi-modal cache.
-
reset_prefix_cache–Reset the prefix cache and optionally any configured connector cache.
-
resume_generation–Resume accepting generation/encoding requests.
-
scale_elastic_ep–Scale the engine.
-
shutdown–Shutdown the engine with optional timeout.
-
shutdown_weight_transfer_engine–Release the trainer connection without shutting down inference.
-
sleep–Sleep the engine.
-
start_draft_weight_update–Start a new weight update targeting the speculative draft model.
-
start_profile–Start profiling with optional per-session overrides.
-
start_weight_update–Start a new weight update.
-
stop_profile–Stop profiling the engine.
-
update_weight_version–Set the weight version without updating weights.
-
update_weights–Batched weight update for RL training.
-
wake_up–Wake the tagged resources; return whether every engine is fully awake.
abort(request_id)
abstractmethod
async
¶
add_lora(lora_request)
abstractmethod
async
¶
Load a new LoRA adapter into the engine for future requests.
check_admission(n=1, request_id=None)
¶
Reject the request up front if it would exceed queue limits.
Called before a response is started so that overload rejections can carry an HTTP status, which is not possible once a streaming response has begun. Engines without admission control accept everything.
Parameters:
-
(n¶int, default:1) –Number of sequences the request will occupy.
-
(request_id¶str | None, default:None) –Request id, used for logging only.
Raises:
-
GracefulHTTPError–If the request cannot be admitted.
check_health()
abstractmethod
async
¶
Raise if unhealthy.
check_health_generate(timeout_s)
async
¶
Raise if the engine is not ready to execute model work.
checkpoint_prepare(mode='wait')
abstractmethod
async
¶
Drain with mode, then release what a checkpoint must not contain.
Returns why the engine cannot prepare, with nothing changed, or None.
checkpoint_restore()
abstractmethod
async
¶
Bring back what preparing released, in the restored process or in place.
checkpoint_state()
abstractmethod
async
¶
Return the checkpoint lifecycle state and the error that failed it.
collective_rpc(method, timeout=None, args=(), kwargs=None)
async
¶
Perform a collective RPC call to the given path.
compute_weight_checksums()
async
¶
Return rank-qualified weight digests from every worker of every engine.
encode(prompt, pooling_params, request_id, lora_request=None, trace_headers=None, priority=0, tokenization_kwargs=None, reasoning_ended=None)
abstractmethod
¶
Generate outputs for a request from a pooling model.
finish_weight_update(weight_version=None)
async
¶
Finish the weight update and set its version if provided.
generate(prompt, sampling_params, request_id, *, prompt_text=None, lora_request=None, tokenization_kwargs=None, trace_headers=None, priority=0, data_parallel_rank=None, session_id=None, kv_hints=None, reasoning_ended=None, reasoning_parser_kwargs=None)
abstractmethod
¶
Generate outputs for a request.
get_external_elastic_ep_status()
async
¶
Return shared external Elastic EP operation status, if enabled.
get_kv_event_sources()
¶
KV-event publisher config of each engine, keyed by DP rank.
get_status()
async
¶
Get fault tolerance status of all engines.
get_supported_tasks()
async
¶
Get supported tasks.
get_weight_version()
async
¶
Return the latest committed weight version.
handle_fault(fault_tolerance_request)
async
¶
Send fault tolerance instruction to the engine.
init_weight_transfer_engine(init_request)
async
¶
Initialize weight transfer for RL training.
is_paused()
abstractmethod
async
¶
Return whether the engine is currently paused.
is_sleeping()
abstractmethod
async
¶
Check whether the engine is sleeping.
notify_kv_transfer_request_rejected(request_id, kv_transfer_params, *, data_parallel_rank=None)
abstractmethod
async
¶
Notify the engine that a KV-transfer request was rejected before engine admission, so connector-side cleanup can run (e.g. free prefill blocks pinned on the P node).
pause_generation(*, mode='abort', clear_cache=True)
abstractmethod
async
¶
Pause new generation/encoding requests.
Parameters:
-
(mode¶PauseMode, default:'abort') –How to handle in-flight requests: -
"abort": Abort all in-flight requests immediately and return partial results with "abort" reason (default). -"wait": Wait for in-flight requests to complete. -"keep": Freeze requests in queue; they resume onresume_generation. -
(clear_cache¶bool, default:True) –DEPRECATED. Whether to clear KV and prefix caches after draining.
release_kv_cache_memory(reset_connector=True)
abstractmethod
async
¶
Discard KV cache physical GPU memory. Requires a completed pause.
reset_encoder_cache()
abstractmethod
async
¶
Reset the encoder cache.
reset_mm_cache()
abstractmethod
async
¶
Reset the multi-modal cache.
reset_prefix_cache(reset_running_requests=False, reset_connector=False)
abstractmethod
async
¶
Reset the prefix cache and optionally any configured connector cache.
resume_generation()
abstractmethod
async
¶
Resume accepting generation/encoding requests.
scale_elastic_ep(new_data_parallel_size, drain_timeout=300)
async
¶
Scale the engine.
shutdown(timeout=None)
abstractmethod
¶
Shutdown the engine with optional timeout.
shutdown_weight_transfer_engine()
async
¶
Release the trainer connection without shutting down inference.
sleep(level=1, mode='abort', reset_connector=True)
abstractmethod
async
¶
Sleep the engine.
start_draft_weight_update()
async
¶
Start a new weight update targeting the speculative draft model.
start_profile(profile_prefix=None, *, delay_iterations=None, max_iterations=None, profiler_kwargs=None)
abstractmethod
async
¶
Start profiling with optional per-session overrides.
start_weight_update()
async
¶
Start a new weight update.
stop_profile()
abstractmethod
async
¶
Stop profiling the engine.
update_weight_version(new_version)
async
¶
Set the weight version without updating weights.
update_weights(request)
async
¶
Batched weight update for RL training.
wake_up(tags=None)
abstractmethod
async
¶
Wake the tagged resources; return whether every engine is fully awake.
StreamingInput
dataclass
¶
Input data for a streaming generation request.
This is used with generate() to support multi-turn streaming sessions where inputs are provided via an async generator.