protocol.py 2.92 KB
Newer Older
1
from typing import (AsyncGenerator, List, Mapping, Optional, Protocol,
2
3
4
5
6
7
                    runtime_checkable)

from vllm.config import DecodingConfig, ModelConfig
from vllm.core.scheduler import SchedulerOutputs
from vllm.inputs.data import PromptInputs
from vllm.lora.request import LoRARequest
8
from vllm.model_executor.layers.sampler import SamplerOutput
9
10
11
12
from vllm.outputs import EmbeddingRequestOutput, RequestOutput
from vllm.pooling_params import PoolingParams
from vllm.prompt_adapter.request import PromptAdapterRequest
from vllm.sampling_params import SamplingParams
13
from vllm.transformers_utils.tokenizer import AnyTokenizer
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


@runtime_checkable
class AsyncEngineClient(Protocol):
    """Protocol class for Clients to AsyncLLMEngine"""

    @property
    def is_running(self) -> bool:
        ...

    @property
    def is_stopped(self) -> bool:
        ...

    @property
    def errored(self) -> bool:
        ...

32
33
34
35
    @property
    def limit_concurrency(self) -> Optional[int]:
        """Maximum number of concurrently running requests."""

36
    def generate(
37
38
39
40
41
42
43
        self,
        inputs: PromptInputs,
        sampling_params: SamplingParams,
        request_id: str,
        lora_request: Optional[LoRARequest] = None,
        trace_headers: Optional[Mapping[str, str]] = None,
        prompt_adapter_request: Optional[PromptAdapterRequest] = None
44
    ) -> AsyncGenerator[RequestOutput, None]:
45
        """Generates outputs for a request"""
46
        ...
47

48
    def encode(
49
50
51
52
53
54
        self,
        inputs: PromptInputs,
        pooling_params: PoolingParams,
        request_id: str,
        lora_request: Optional[LoRARequest] = None,
        trace_headers: Optional[Mapping[str, str]] = None,
55
    ) -> AsyncGenerator[EmbeddingRequestOutput, None]:
56
        """Generate outputs for a request from an embedding model."""
57
        ...
58
59
60
61
62
63
64
65
66
67

    async def abort(self, request_id: str) -> None:
        """Abort a request.

        Args:
            request_id: The unique id of the request.
        """

    async def get_model_config(self) -> ModelConfig:
        """Get the model configuration of the vLLM engine."""
68
        ...
69
70

    async def get_decoding_config(self) -> DecodingConfig:
71
        ...
72
73
74
75
76
        """Get the decoding configuration of the vLLM engine."""

    async def get_tokenizer(
        self,
        lora_request: Optional[LoRARequest] = None,
77
78
79
    ) -> AnyTokenizer:
        """Get the appropriate tokenizer for the request"""
        ...
80
81

    async def is_tracing_enabled(self) -> bool:
82
        ...
83
84
85
86
87
88

    async def do_log_stats(
        self,
        scheduler_outputs: Optional[SchedulerOutputs] = None,
        model_output: Optional[List[SamplerOutput]] = None,
    ) -> None:
89
        ...
90
91
92

    async def check_health(self) -> None:
        """Raise if unhealthy"""
93
        ...
94
95
96
97
98
99
100
101

    async def start_profile(self) -> None:
        """Start profiling the engine"""
        ...

    async def stop_profile(self) -> None:
        """Start profiling the engine"""
        ...