Convert formatting to use ruff instead of yapf + isort (#26247)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
Harry Mellor
2025-10-05 07:06:22 -07:00
committed by GitHub
parent 17edd8a807
commit d6953beb91
1508 changed files with 115205 additions and 94107 deletions
+25 -26
View File
@@ -8,12 +8,10 @@ from typing import TYPE_CHECKING, NamedTuple, Optional, Union
import torch
if TYPE_CHECKING:
from vllm.distributed.kv_transfer.kv_connector.v1.metrics import (
KVConnectorStats)
from vllm.distributed.kv_transfer.kv_connector.v1.metrics import KVConnectorStats
class LogprobsLists(NamedTuple):
# [num_reqs, max_num_logprobs + 1]
logprob_token_ids: list[list[int]]
# [num_reqs, max_num_logprobs + 1]
@@ -30,7 +28,6 @@ class LogprobsLists(NamedTuple):
class LogprobsTensors(NamedTuple):
# [num_reqs, max_num_logprobs + 1]
logprob_token_ids: torch.Tensor
# [num_reqs, max_num_logprobs + 1]
@@ -46,18 +43,18 @@ class LogprobsTensors(NamedTuple):
)
@staticmethod
def empty_cpu(num_positions: int,
num_tokens_per_position: int) -> "LogprobsTensors":
def empty_cpu(
num_positions: int, num_tokens_per_position: int
) -> "LogprobsTensors":
"""Create empty LogprobsTensors on CPU."""
logprob_token_ids = torch.empty(
(num_positions, num_tokens_per_position),
dtype=torch.int32,
device="cpu")
(num_positions, num_tokens_per_position), dtype=torch.int32, device="cpu"
)
logprobs = torch.empty_like(logprob_token_ids, dtype=torch.float32)
selected_token_ranks = torch.empty(num_positions,
dtype=torch.int32,
device="cpu")
selected_token_ranks = torch.empty(
num_positions, dtype=torch.int32, device="cpu"
)
return LogprobsTensors(
logprob_token_ids=logprob_token_ids,
logprobs=logprobs,
@@ -72,7 +69,6 @@ PoolerOutput = Union[torch.Tensor, list[torch.Tensor]]
@dataclass
class SamplerOutput:
# [num_reqs, max_num_generated_tokens]
# Different requests can have different number of generated tokens.
# All requests are padded to max_num_generated_tokens.
@@ -92,15 +88,18 @@ class KVConnectorOutput:
invalid_block_ids: set[int] = field(default_factory=set)
def is_empty(self):
return (not self.finished_sending and not self.finished_recving
and not self.kv_connector_stats and not self.invalid_block_ids)
return (
not self.finished_sending
and not self.finished_recving
and not self.kv_connector_stats
and not self.invalid_block_ids
)
# ModelRunnerOutput is serialized and sent to the scheduler process.
# This is expensive for torch.Tensor so prefer to use list instead.
@dataclass
class ModelRunnerOutput:
# [num_reqs]
req_ids: list[str]
# req_id -> index
@@ -134,11 +133,10 @@ class ModelRunnerOutput:
# ModelRunnerOutput wrapper for async scheduling.
class AsyncModelRunnerOutput(ABC):
@abstractmethod
def get_output(self) -> ModelRunnerOutput:
"""Get the ModelRunnerOutput for this async output.
This is a blocking call that waits until the results are ready, which
might involve copying device tensors to the host.
This method should only be called once per AsyncModelRunnerOutput.
@@ -148,17 +146,18 @@ class AsyncModelRunnerOutput(ABC):
@dataclass
class DraftTokenIds:
# [num_reqs]
req_ids: list[str]
# num_reqs x num_draft_tokens
draft_token_ids: list[list[int]]
EMPTY_MODEL_RUNNER_OUTPUT = ModelRunnerOutput(req_ids=[],
req_id_to_index={},
sampled_token_ids=[],
logprobs=None,
prompt_logprobs_dict={},
pooler_output=[],
num_nans_in_logits=None)
EMPTY_MODEL_RUNNER_OUTPUT = ModelRunnerOutput(
req_ids=[],
req_id_to_index={},
sampled_token_ids=[],
logprobs=None,
prompt_logprobs_dict={},
pooler_output=[],
num_nans_in_logits=None,
)