vllm.v1.utils
ConstantList
¶
Source code in vllm/v1/utils.py
CoreEngineProcManager
¶
Utility class to handle creation, readiness, and shutdown of background processes used by the AsyncLLM and LLMEngine.
Source code in vllm/v1/utils.py
__init__
¶
__init__(
target_fn: Callable,
local_engine_count: int,
start_index: int,
local_start_index: int,
vllm_config: VllmConfig,
on_head_node: bool,
input_address: str,
executor_class: type[Executor],
log_stats: bool,
)
Source code in vllm/v1/utils.py
close
¶
finished_procs
¶
Returns dict of proc name -> exit code for any finished procs.
join_first
¶
bind_kv_cache
¶
bind_kv_cache(
kv_caches: dict[str, Tensor],
forward_context: dict[str, Attention],
runner_kv_caches: list[Tensor],
) -> None
Bind the allocated KV cache to both ModelRunner and forward context so that the KV cache can be used in the forward pass.
This function
1) Fills the ModelRunner's kv cache list (runner_kv_caches) with
kv_caches.
2) Associates each attention layer in the forward_context with its
corresponding KV cache in kv_caches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kv_caches
|
dict[str, Tensor]
|
The allocated kv_caches with layer names as keys. |
required |
forward_context
|
dict[str, Attention]
|
The global forward context containing all Attention |
required |
runner_kv_caches
|
list[Tensor]
|
The kv_cache declared by ModelRunner. |
required |
Source code in vllm/v1/utils.py
copy_slice
¶
Copy the first length elements of a tensor into another tensor in a non-blocking manner.
Used to copy pinned CPU tensor data to pre-allocated GPU tensors.
Returns the sliced target tensor.
Source code in vllm/v1/utils.py
report_usage_stats
¶
report_usage_stats(
vllm_config,
usage_context: UsageContext = ENGINE_CONTEXT,
) -> None
Report usage statistics if enabled.