A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 5, 18:30 UTC
[KVConnector] Remove redundant method KVConnectorOutput::merge() (#38546)
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
Martin Hickey committed
Mar 31, 2026 at 05:11 UTC
350af48e14710627609ba94a4312a01798980315
1 file changed
+1
-53
vllm/v1/outputs.py
+1
-53
@@ -2,9 +2,8 @@
2
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
from abc import ABC, abstractmethod
5
-from collections.abc import Callable
5
from dataclasses import dataclass, field
7
-from typing import TYPE_CHECKING, NamedTuple, TypeAlias, TypeVar
6
+from typing import TYPE_CHECKING, NamedTuple, TypeAlias
7
8
import numpy as np
9
import torch
@@ -125,20 +124,6 @@ class SamplerOutput:
124
logprobs_tensors: LogprobsTensors | None
125
126
128
-T = TypeVar("T")
129
-
130
-
131
-def _combine_non_none(f: Callable[[T, T], T], items: list[T | None]) -> T | None:
132
- non_none = [item for item in items if item is not None]
133
- if len(non_none) == 0:
134
- return None
135
-
136
- combined = non_none[0]
137
- for item in non_none[1:]:
138
- combined = f(combined, item)
139
- return combined
140
-
141
-
127
@dataclass
128
class KVConnectorOutput:
129
# [req_ids]
@@ -167,43 +152,6 @@ class KVConnectorOutput:
152
and not self.kv_connector_worker_meta
153
)
154
170
- @classmethod
171
- def merge(cls, *outputs: "KVConnectorOutput"):
172
- assert len(outputs) > 0, "Cannot merge empty outputs"
173
- finished_sending = _combine_non_none(
174
- set.union, [output.finished_sending for output in outputs]
175
- )
176
- finished_recving = _combine_non_none(
177
- set.union, [output.finished_recving for output in outputs]
178
- )
179
- kv_connector_stats = _combine_non_none(
180
- lambda x, y: x.aggregate(y),
181
- [output.kv_connector_stats for output in outputs],
182
- )
183
- kv_cache_events = _combine_non_none(
184
- lambda x, y: x.merge(y),
185
- [output.kv_cache_events for output in outputs],
186
- )
187
- invalid_block_ids = _combine_non_none(
188
- set.union, [output.invalid_block_ids for output in outputs]
189
- )
190
- assert invalid_block_ids is not None
191
-
192
- assert all(
193
- output.expected_finished_count == outputs[0].expected_finished_count
194
- for output in outputs
195
- )
196
- expected_finished_count = outputs[0].expected_finished_count
197
-
198
- return cls(
199
- finished_sending=finished_sending,
200
- finished_recving=finished_recving,
201
- kv_connector_stats=kv_connector_stats,
202
- kv_cache_events=kv_cache_events,
203
- invalid_block_ids=invalid_block_ids,
204
- expected_finished_count=expected_finished_count,
205
- )
206
-
155
156
@dataclass
157
class ECConnectorOutput: