Files
vllm-omni/vllm_omni/core/sched/scheduler.py
T

52 lines
2.3 KiB
Python
Raw Normal View History

2025-10-22 15:05:23 +08:00
from __future__ import annotations
2025-10-24 16:49:19 +08:00
from vllm.logger import init_logger
2025-10-24 09:41:20 +08:00
from vllm.v1.core.sched.output import SchedulerOutput
2025-10-22 15:05:23 +08:00
from vllm.v1.core.sched.scheduler import Scheduler as VLLMScheduler
2025-10-24 16:49:19 +08:00
2025-10-22 15:05:23 +08:00
class OmniScheduler(VLLMScheduler):
2025-09-16 16:05:47 +08:00
"""
OmniScheduler: Scheduler for vLLM-omni multimodal processing.
2025-10-24 12:16:48 +08:00
This scheduler extends vLLM's scheduler to support multimodal and
non-autoregressive processing with additional fields and methods
specific to vLLM-omni.
2025-09-16 16:05:47 +08:00
"""
2025-10-22 15:05:23 +08:00
2025-10-24 16:49:19 +08:00
# Ensure scheduled_new_reqs carry omni-specific payloads
# (e.g., additional_information)
2025-10-22 15:05:23 +08:00
def schedule(self) -> SchedulerOutput: # type: ignore[override]
scheduler_output = super().schedule()
try:
# Late import to avoid circulars in some launch modes
from .output import OmniNewRequestData
2025-10-24 16:49:19 +08:00
# Rewrap base NewRequestData entries with OmniNewRequestData,
# enriching with request-level payloads
2025-10-22 15:05:23 +08:00
new_list = []
for nr in scheduler_output.scheduled_new_reqs:
req_id = getattr(nr, "req_id", None)
request = self.requests.get(req_id) if req_id else None
# Build omni entry preserving all base fields
omni_nr = OmniNewRequestData(
req_id=nr.req_id,
prompt_token_ids=nr.prompt_token_ids,
2025-11-04 22:06:41 +08:00
mm_features=nr.mm_features,
2025-10-22 15:05:23 +08:00
sampling_params=nr.sampling_params,
pooling_params=nr.pooling_params,
block_ids=nr.block_ids,
num_computed_tokens=nr.num_computed_tokens,
lora_request=nr.lora_request,
# Enrich with omni payloads from the live request object
2025-11-18 20:54:26 +08:00
prompt_embeds=(getattr(request, "prompt_embeds", None) if request else None),
additional_information=(getattr(request, "additional_information", None) if request else None),
2025-10-22 15:05:23 +08:00
)
new_list.append(omni_nr)
scheduler_output.scheduled_new_reqs = new_list # type: ignore[assignment]
except Exception:
# If anything goes wrong, leave the original output unchanged
2025-11-18 20:54:26 +08:00
init_logger(__name__).exception("Failed to wrap scheduled_new_reqs with OmniNewRequestData")
2025-10-22 15:05:23 +08:00
2025-10-24 16:49:19 +08:00
return scheduler_output