Skip to content

Commit 6641584

Browse files
committed
Fix some broken bits & reformat
Signed-off-by: Staszek Pasko <[email protected]>
1 parent e5931af commit 6641584

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

vllm/v1/serial_utils.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def enc_hook(self, obj: Any) -> Any:
7575
# ignore the main dict, it will be re-indexed.
7676
# pass a list of MultiModalKwargsItem, then see below
7777
# Any tensors *not* indexed by modality will be ignored.
78-
return mm._items_by_modality.values()
78+
return list(mm._items_by_modality.values())
7979
# just return the main dict if there are no modalities
8080
return dict(mm)
8181

@@ -150,10 +150,12 @@ def dec_hook(self, t: type, obj: Any) -> Any:
150150
return torch.from_numpy(self._decode_ndarray(obj))
151151
if issubclass(t, MultiModalKwargs):
152152
if isinstance(obj, list):
153-
return MultiModalKwargs.from_items(self._decode_mm_items(obj))
154-
return MultiModalKwargs(
155-
{k: self._decode_nested(v)
156-
for k in obj.items()})
153+
return MultiModalKwargs.from_items(
154+
self._decode_mm_items(obj))
155+
return MultiModalKwargs({
156+
k: self._decode_nested_tensors(v)
157+
for k, v in obj.items()
158+
})
157159
return obj
158160

159161
def _decode_ndarray(self, arr: Any) -> np.ndarray:
@@ -166,7 +168,7 @@ def _decode_mm_items(self, obj: list) -> list[MultiModalKwargsItem]:
166168
for item in chain.from_iterable(obj):
167169
elems = []
168170
for v in item.values():
169-
v['data'] = self._decode_nested(v['data'])
171+
v['data'] = self._decode_nested_tensors(v['data'])
170172
v['field'] = pickle.loads(v['field'])
171173
elems.append(MultiModalFieldElem(**v))
172174
all.append(MultiModalKwargsItem.from_elems(elems))

0 commit comments

Comments
 (0)