Skip to content

Commit 0b1447f

Browse files
authored
[Bugfix] Ensure tensors are contiguous during serialisation (vllm-project#18860)
Signed-off-by: Lukas Geiger <lukas.geiger94@gmail.com>
1 parent 24d0ef8 commit 0b1447f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

vllm/v1/serial_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ def _encode_tensor(
158158
self, obj: torch.Tensor
159159
) -> tuple[str, tuple[int, ...], Union[int, memoryview]]:
160160
assert self.aux_buffers is not None
161-
# view the tensor as a 1D array of bytes
162-
arr = obj.flatten().view(torch.uint8).numpy()
161+
# view the tensor as a contiguous 1D array of bytes
162+
arr = obj.flatten().contiguous().view(torch.uint8).numpy()
163163
if obj.nbytes < self.size_threshold:
164164
# Smaller tensors are encoded inline, just like ndarrays.
165165
data = msgpack.Ext(CUSTOM_TYPE_RAW_VIEW, arr.data)

0 commit comments

Comments
 (0)