Skip to content

Commit e5931af

Browse files
committed
Additional fixes after code review
Signed-off-by: Staszek Pasko <[email protected]>
1 parent 4bdd16e commit e5931af

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

vllm/v1/serial_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,22 @@ def dec_hook(self, t: type, obj: Any) -> Any:
146146
if isclass(t):
147147
if issubclass(t, np.ndarray):
148148
return self._decode_ndarray(obj)
149-
if issubclass(t, MultiModalKwargs)
149+
if issubclass(t, torch.Tensor):
150+
return torch.from_numpy(self._decode_ndarray(obj))
151+
if issubclass(t, MultiModalKwargs):
150152
if isinstance(obj, list):
151-
return MultiModalKwargs.from_items(self._decode_items(obj))
153+
return MultiModalKwargs.from_items(self._decode_mm_items(obj))
152154
return MultiModalKwargs(
153155
{k: self._decode_nested(v)
154156
for k in obj.items()})
155-
if issubclass(t, torch.Tensor):
156-
return torch.from_numpy(self._decode_ndarray(obj))
157157
return obj
158158

159159
def _decode_ndarray(self, arr: Any) -> np.ndarray:
160160
dtype, shape, data = arr
161161
buffer = self.aux_buffers[data] if isinstance(data, int) else data
162162
return np.ndarray(buffer=buffer, dtype=np.dtype(dtype), shape=shape)
163163

164-
def _decode_items(self, obj: list) -> list[MultiModalKwargsItem]:
164+
def _decode_mm_items(self, obj: list) -> list[MultiModalKwargsItem]:
165165
all = []
166166
for item in chain.from_iterable(obj):
167167
elems = []

0 commit comments

Comments
 (0)