mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-05-13 13:20:16 +08:00
Remove tuple stuff
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: weichen <calvin_zhu0210@outlook.com>
This commit is contained in:
parent
601387735c
commit
53d57d9dca
@ -2,9 +2,9 @@
|
|||||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||||
import time
|
import time
|
||||||
from functools import total_ordering
|
from functools import total_ordering
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
from vllm.v1.core.sched.policy.normalized_scorer import TimeAndLengthScorer
|
from vllm.v1.core.sched.policy.normalized_scorer import TimeAndLengthScorer
|
||||||
|
from vllm.v1.request import Request
|
||||||
|
|
||||||
TimeAndLengthScorer_Instance = None
|
TimeAndLengthScorer_Instance = None
|
||||||
|
|
||||||
@ -20,15 +20,11 @@ if TimeAndLengthScorer_Instance is None:
|
|||||||
|
|
||||||
@total_ordering
|
@total_ordering
|
||||||
class WeightedScoreSorter:
|
class WeightedScoreSorter:
|
||||||
def __init__(
|
def __init__(self, request: Request):
|
||||||
self,
|
self.request = request
|
||||||
request_length: int,
|
assert request.prompt_token_ids is not None
|
||||||
request_arrival_time: float,
|
self.request_length = len(request.prompt_token_ids)
|
||||||
request_slo_requirement: list[Any] | None = None,
|
self.request_arrival_time = request.arrival_time
|
||||||
):
|
|
||||||
self.request_length = request_length
|
|
||||||
self.request_arrival_time = request_arrival_time
|
|
||||||
self.request_slo_requirement = request_slo_requirement
|
|
||||||
self.__update_stats()
|
self.__update_stats()
|
||||||
|
|
||||||
def __lt__(self, other_request_weighted_score: "WeightedScoreSorter") -> bool:
|
def __lt__(self, other_request_weighted_score: "WeightedScoreSorter") -> bool:
|
||||||
|
|||||||
@ -228,18 +228,13 @@ class SJFRequestQueue(RequestHeap):
|
|||||||
"""A Shortest Job First (SJF) queue where requests are ordered by weighted score.
|
"""A Shortest Job First (SJF) queue where requests are ordered by weighted score.
|
||||||
Requests with higher weighted scores (shorter jobs) are processed first."""
|
Requests with higher weighted scores (shorter jobs) are processed first."""
|
||||||
|
|
||||||
def _request_to_heap(self, request: Request) -> tuple[WeightedScoreSorter, Request]:
|
def _request_to_heap(self, request: Request) -> WeightedScoreSorter:
|
||||||
"""Convert request to (weighted_score, request) tuple for heap."""
|
"""Convert request to `WeightedScoreSorter` for heap."""
|
||||||
assert request.prompt_token_ids is not None
|
return WeightedScoreSorter(request)
|
||||||
return (
|
|
||||||
WeightedScoreSorter(len(request.prompt_token_ids), request.arrival_time),
|
|
||||||
request,
|
|
||||||
)
|
|
||||||
|
|
||||||
def _heap_to_request(self, element: tuple[WeightedScoreSorter, Request]) -> Request:
|
def _heap_to_request(self, element: WeightedScoreSorter) -> Request:
|
||||||
"""Extract request from the (score, request) tuple with type checking."""
|
"""Extract request from the `WeightedScoreSorter`."""
|
||||||
_, request = element
|
return element.request
|
||||||
return request
|
|
||||||
|
|
||||||
|
|
||||||
def create_request_queue(policy: SchedulingPolicy) -> RequestQueue:
|
def create_request_queue(policy: SchedulingPolicy) -> RequestQueue:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user