Refactor OmniProcessor and update parsing logic
- Removed redundant imports of `torch` and `numpy` in `OmniProcessor` class. - Improved comments in `parse_singleton_prompt_omni` function for clarity on token handling. - Ensured `current_platform` is imported only once for better code organization.
This commit is contained in:
1 parent
3a27ff51d0
commit
4cd3b36fa0
2 files changed
+4
-7
No files matched your search
@@ -14,10 +14,11 @@ from vllm.config import VllmConfig
|
||||
from vllm.transformers_utils.tokenizer_group import TokenizerGroup
|
||||
from vllm.multimodal import MULTIMODAL_REGISTRY, MultiModalRegistry
|
||||
from vllm_omni.inputs.preprocess import OmniInputPreprocessor
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
from vllm.v1.engine.processor import Processor
|
||||
from vllm_omni.engine import PromptEmbedsPayload, AdditionalInformationPayload, AdditionalInformationEntry, OmniEngineCoreRequest
|
||||
|
||||
import torch
|
||||
|
||||
class OmniProcessor(Processor):
|
||||
def __init__(self,
|
||||
@@ -71,7 +72,6 @@ class OmniProcessor(Processor):
|
||||
lora_request=lora_request,
|
||||
return_mm_hashes=return_mm_hashes,
|
||||
)
|
||||
from vllm.platforms import current_platform
|
||||
current_platform.validate_request(
|
||||
prompt=prompt,
|
||||
params=params,
|
||||
@@ -157,8 +157,7 @@ class OmniProcessor(Processor):
|
||||
prompt_embeds_payload: Optional[PromptEmbedsPayload] = None
|
||||
additional_information_payload: Optional[AdditionalInformationPayload] = None
|
||||
if "prompt_embeds" in decoder_inputs: # type: ignore[operator]
|
||||
import numpy as np
|
||||
import torch
|
||||
|
||||
pe: torch.Tensor = decoder_inputs["prompt_embeds"] # type: ignore[index]
|
||||
if pe.ndim != 2:
|
||||
raise ValueError(
|
||||
@@ -174,8 +173,6 @@ class OmniProcessor(Processor):
|
||||
dtype=dtype_str,
|
||||
)
|
||||
if "additional_information" in decoder_inputs: # type: ignore[operator]
|
||||
import numpy as np
|
||||
import torch
|
||||
raw_info: dict[str, Any] = decoder_inputs["additional_information"] # type: ignore[index]
|
||||
entries: dict[str, AdditionalInformationEntry] = {}
|
||||
for key, value in raw_info.items():
|
||||
|
||||
@@ -8,7 +8,7 @@ def parse_singleton_prompt_omni(prompt: SingletonPrompt) -> ParsedSingletonPromp
|
||||
elif isinstance(prompt, dict):
|
||||
# Type ignores are because mypy does not correctly infer the TypedDicts
|
||||
# Pyright does succeed.
|
||||
# 优先 tokens:当 tokens 与 embeds 同在时,保留两者并走 tokens 路径
|
||||
# Priority tokens: When both tokens and embeds exist, keep both and follow the tokens path
|
||||
if "prompt_token_ids" in prompt:
|
||||
return ParsedTokensPrompt(
|
||||
type="tokens", content=prompt) # type: ignore[typeddict-item]
|
||||
|
||||
Reference in new issue
Block a user