[Docs] optimize and supplement docs system (#86)
Signed-off-by: Gaohan123 <gaohan19@huawei.com>
This commit is contained in:
1 parent
38f58064eb
commit
db81ee9f69
75 files changed
+2452
-512
No files matched your search
@@ -53,6 +53,38 @@ logger = init_logger(__name__)
|
||||
|
||||
|
||||
class AsyncOmniLLM(EngineClient):
|
||||
"""Async entry point for vLLM-omni inference.
|
||||
|
||||
This class provides an asynchronous interface for running multi-modal
|
||||
comprehension and generation models. It orchestrates multiple
|
||||
stages in a pipeline, where each stage runs in a separate process.
|
||||
Designed for use with async/await patterns and streaming generation.
|
||||
|
||||
Args:
|
||||
model: Model name or path to load
|
||||
stage_configs_path: Optional path to YAML file containing stage
|
||||
configurations. If None, configurations are loaded from the model.
|
||||
log_stats: Whether to enable statistics logging
|
||||
log_file: Optional path prefix for log files. If provided, logs will
|
||||
be written to files with stage-specific suffixes.
|
||||
init_sleep_seconds: Number of seconds to sleep between starting
|
||||
each stage process during initialization
|
||||
shm_threshold_bytes: Threshold in bytes for using shared memory
|
||||
for IPC. Objects larger than this threshold will use shared memory.
|
||||
batch_timeout: Timeout in seconds for batching requests within a stage
|
||||
init_timeout: Timeout in seconds for waiting for all stages to initialize
|
||||
**kwargs: Additional keyword arguments passed to stage engines
|
||||
|
||||
Example:
|
||||
>>> async_llm = AsyncOmniLLM(model="Qwen/Qwen2.5-Omni-7B")
|
||||
>>> async for output in async_llm.generate(
|
||||
... prompt="Hello",
|
||||
... request_id="req-1",
|
||||
... sampling_params_list=[SamplingParams(), SamplingParams()]
|
||||
... ):
|
||||
... print(output)
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
model: str,
|
||||
@@ -63,7 +95,7 @@ class AsyncOmniLLM(EngineClient):
|
||||
shm_threshold_bytes: int = 65536,
|
||||
batch_timeout: int = 10,
|
||||
init_timeout: int = 300,
|
||||
**kwargs,
|
||||
**kwargs: Any,
|
||||
):
|
||||
self.batch_timeout = batch_timeout
|
||||
self._enable_stats: bool = bool(log_stats)
|
||||
@@ -140,6 +172,12 @@ class AsyncOmniLLM(EngineClient):
|
||||
time.sleep(self._init_sleep_seconds)
|
||||
|
||||
def close(self) -> None:
|
||||
"""Close all stage processes and clean up resources.
|
||||
|
||||
Sends shutdown signals to all stage input queues and stops
|
||||
all stage worker processes. This method should be called
|
||||
when done using the AsyncOmniLLM instance.
|
||||
"""
|
||||
for q in self._stage_in_queues:
|
||||
try:
|
||||
q.put_nowait(None)
|
||||
@@ -162,7 +200,11 @@ class AsyncOmniLLM(EngineClient):
|
||||
logger.debug("[Orchestrator] __del__ close() raised: %s", e, exc_info=True)
|
||||
|
||||
def shutdown(self):
|
||||
"""Shutdown, cleaning up the background proc and IPC."""
|
||||
"""Shutdown, cleaning up the background proc and IPC.
|
||||
|
||||
Alias for close() method. Cleans up all stage processes
|
||||
and inter-process communication resources.
|
||||
"""
|
||||
try:
|
||||
self.close()
|
||||
except Exception as e:
|
||||
@@ -178,6 +220,33 @@ class AsyncOmniLLM(EngineClient):
|
||||
priority: int = 0,
|
||||
data_parallel_rank: Optional[int] = None,
|
||||
) -> AsyncGenerator[OmniRequestOutput, None]:
|
||||
"""Generate outputs for the given prompt asynchronously.
|
||||
|
||||
Processes the prompt through all stages in the pipeline and yields
|
||||
outputs as they become available. Each stage uses its corresponding
|
||||
sampling parameters from the sampling_params_list.
|
||||
|
||||
Args:
|
||||
prompt: Prompt to process. Can be a text string, token IDs,
|
||||
or multimodal prompt.
|
||||
request_id: Unique identifier for this request
|
||||
sampling_params_list: List of SamplingParams, one for each stage.
|
||||
Must have the same length as the number of stages.
|
||||
If None, uses default sampling params for each stage.
|
||||
lora_request: Optional LoRA adapter request for this generation
|
||||
trace_headers: Optional tracing headers for observability
|
||||
priority: Request priority (higher values processed first)
|
||||
data_parallel_rank: Optional data parallel rank for distributed
|
||||
inference
|
||||
|
||||
Yields:
|
||||
OmniRequestOutput objects as they are produced by each stage.
|
||||
Each output contains the stage_id, final_output_type, and
|
||||
the request_output from that stage.
|
||||
|
||||
Raises:
|
||||
ValueError: If sampling_params_list has incorrect length.
|
||||
"""
|
||||
logger.debug("[Orchestrator] generate() called")
|
||||
if sampling_params_list is None:
|
||||
sampling_params_list = self.default_sampling_params_list
|
||||
@@ -510,9 +579,6 @@ class AsyncOmniLLM(EngineClient):
|
||||
return None
|
||||
|
||||
async def get_input_preprocessor(self) -> InputPreprocessor:
|
||||
# for stage in self.stage_list:
|
||||
# if stage.is_comprehension:
|
||||
# return stage.input_preprocessor
|
||||
return None
|
||||
|
||||
async def get_tokenizer(self) -> AnyTokenizer:
|
||||
@@ -569,6 +635,31 @@ class AsyncOmniLLM(EngineClient):
|
||||
|
||||
|
||||
class AsyncOmniStageLLM(AsyncLLM):
|
||||
"""Async single-stage LLM engine for use within a stage worker process.
|
||||
|
||||
This class extends the base vLLM AsyncLLM class with omni-specific
|
||||
processors for handling multimodal inputs and outputs. It is used
|
||||
internally by AsyncOmniStage workers and should not be instantiated
|
||||
directly by users.
|
||||
|
||||
Args:
|
||||
engine_args: AsyncOmniEngineArgs containing engine configuration
|
||||
vllm_config: Global vLLM configuration
|
||||
executor_class: Executor implementation class, e.g. MultiprocExecutor
|
||||
log_stats: Whether to log statistics
|
||||
usage_context: Usage context of the LLM (default: ENGINE_CONTEXT)
|
||||
mm_registry: Multi-modal registry for processing multimodal inputs
|
||||
use_cached_outputs: Whether to use cached outputs
|
||||
log_requests: Whether to log requests
|
||||
start_engine_loop: Whether to start the engine loop automatically
|
||||
stat_loggers: Customized stat loggers for the engine.
|
||||
If not provided, default stat loggers will be used.
|
||||
Note: Stat logger interface may change in V1.
|
||||
client_addresses: Optional dictionary mapping client names to addresses
|
||||
client_count: Total number of clients (default: 1)
|
||||
client_index: Index of this client (default: 0)
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
engine_args: AsyncOmniEngineArgs,
|
||||
|
||||
Reference in new issue
Block a user