Refactor OmniLLM and MultimodalOutputProcessor initialization

- Removed AsyncOmniLLM from the main entry points as it is not supported yet.
- Updated the constructor of MultimodalOutputProcessor to set a default value for engine_core_output_type.
- Adjusted output type handling in various methods to utilize the new default engine_core_output_type for consistency.
This commit is contained in:
tzhouam committed 2025-10-24 17:15:34 +08:00
1 parent 1bf3424e96
commit 3265e857eb
3 files changed
+8 -7

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ __author__ = "vLLM-omni Team"
__email__ = "hsliuustc@gmail.com" __email__ = "hsliuustc@gmail.com"
# Main entry points # Main entry points
from .entrypoints.omni_llm import OmniLLM, AsyncOmniLLM from .entrypoints.omni_llm import OmniLLM
from .config import ( from .config import (
OmniStageConfig, OmniStageConfig,
DiTConfig, DiTConfig,
@@ -31,7 +31,7 @@ __all__ = [
# Main components # Main components
"OmniLLM", "OmniLLM",
"AsyncOmniLLM", #AsyncOmniLLM is not supported yet
# Configuration # Configuration
"OmniStageConfig", "OmniStageConfig",
+4 -4
View File
@@ -177,7 +177,7 @@ class MultimodalOutputProcessor(VLLMOutputProcessor):
produce the correct RequestOutput/PoolingRequestOutput. produce the correct RequestOutput/PoolingRequestOutput.
- Allow custom per-modality handlers via register_handler(). - Allow custom per-modality handlers via register_handler().
""" """
def __init__(self, tokenizer: TokenizerGroup, log_stats: bool, engine_core_output_type: Optional[str] = None): def __init__(self, tokenizer: TokenizerGroup, log_stats: bool, engine_core_output_type: Optional[str] = "text"):
super().__init__(tokenizer=tokenizer, log_stats=log_stats) super().__init__(tokenizer=tokenizer, log_stats=log_stats)
self.output_handlers: Dict[str, Callable[[EngineCoreOutput], None]] = {} self.output_handlers: Dict[str, Callable[[EngineCoreOutput], None]] = {}
self._reqid_to_mm_type: Dict[str, str] = {} self._reqid_to_mm_type: Dict[str, str] = {}
@@ -223,7 +223,7 @@ class MultimodalOutputProcessor(VLLMOutputProcessor):
) -> OutputProcessorOutput: ) -> OutputProcessorOutput:
self._reqid_to_mm_type.clear() self._reqid_to_mm_type.clear()
for eco in engine_core_outputs: for eco in engine_core_outputs:
mm_type = (getattr(eco, "output_type", None) or "").lower() mm_type = (self.engine_core_output_type or "").lower()
if mm_type: if mm_type:
self._reqid_to_mm_type[eco.request_id] = mm_type self._reqid_to_mm_type[eco.request_id] = mm_type
self._route_and_normalize(eco) self._route_and_normalize(eco)
@@ -262,7 +262,7 @@ class MultimodalOutputProcessor(VLLMOutputProcessor):
# 2.5) Accumulate multimodal tensors in RequestState # 2.5) Accumulate multimodal tensors in RequestState
try: try:
mm_type = (getattr(eco, "output_type", self.engine_core_output_type) or "").lower() mm_type = (self.engine_core_output_type or "").lower()
if pooling_output is not None and isinstance(req_state, OmniRequestState): if pooling_output is not None and isinstance(req_state, OmniRequestState):
req_state.add_multimodal_tensor(pooling_output, mm_type) req_state.add_multimodal_tensor(pooling_output, mm_type)
except Exception: except Exception:
@@ -315,7 +315,7 @@ class MultimodalOutputProcessor(VLLMOutputProcessor):
# ---- routing helpers ---- # ---- routing helpers ----
def _route_and_normalize(self, eco: EngineCoreOutput) -> None: def _route_and_normalize(self, eco: EngineCoreOutput) -> None:
output_type = (getattr(eco, "output_type", self.engine_core_output_type) or "").lower() output_type = (self.engine_core_output_type or "").lower()
# Custom handler first (if registered) # Custom handler first (if registered)
if output_type in self.output_handlers: if output_type in self.output_handlers:
+2 -1
View File
@@ -138,7 +138,8 @@ class OmniStageLLM(LLM):
self.llm_engine = LLMEngine.from_engine_args( self.llm_engine = LLMEngine.from_engine_args(
engine_args=engine_args, usage_context=UsageContext.LLM_CLASS) engine_args=engine_args, usage_context=UsageContext.LLM_CLASS)
self.llm_engine.output_processor = MultimodalOutputProcessor(tokenizer=self.llm_engine.tokenizer, self.llm_engine.output_processor = MultimodalOutputProcessor(tokenizer=self.llm_engine.tokenizer,
log_stats=self.llm_engine.log_stats) log_stats=self.llm_engine.log_stats,
engine_core_output_type=engine_args.engine_output_type)
self.llm_engine.processor = OmniProcessor(vllm_config=self.llm_engine.vllm_config, self.llm_engine.processor = OmniProcessor(vllm_config=self.llm_engine.vllm_config,
tokenizer=self.llm_engine.tokenizer) tokenizer=self.llm_engine.tokenizer)
self.engine_class = type(self.llm_engine) self.engine_class = type(self.llm_engine)