-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
[Bugfix] fix bf16 multimodal model hash #23623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4e64ec1
8c6b773
5646453
9d39378
df66349
9471f50
8b35955
6f7c652
4583d60
34ae3c1
eb452fe
a69102c
8a8dcf7
67a0f70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -43,7 +43,19 @@ def serialize_item(cls, obj: object) -> Union[bytes, memoryview]: | |||||||||||||||
| return cls.item_to_bytes( | ||||||||||||||||
| "image", np.asarray(convert_image_mode(obj, "RGBA"))) | ||||||||||||||||
| if isinstance(obj, torch.Tensor): | ||||||||||||||||
| return cls.item_to_bytes("tensor", obj.cpu().numpy()) | ||||||||||||||||
| tensor_obj: torch.Tensor = obj.cpu() | ||||||||||||||||
| tensor_dtype = tensor_obj.dtype | ||||||||||||||||
| if tensor_dtype == torch.bfloat16: | ||||||||||||||||
| tensor_obj = tensor_obj.contiguous() | ||||||||||||||||
| tensor_obj = tensor_obj.view( | ||||||||||||||||
| (tensor_obj.numel(), )).view(torch.uint8) | ||||||||||||||||
| return cls.item_to_bytes( | ||||||||||||||||
| "tensor", { | ||||||||||||||||
| "original_dtype": str(tensor_dtype), | ||||||||||||||||
| "original_shape": tuple(tensor_obj.shape), | ||||||||||||||||
|
Comment on lines
+54
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for being late to the party. This is still the 1D shape of the uint8 tensor since Could you extend the tests to verify the bfloat16 code path as well: vllm/tests/multimodal/test_hasher.py Lines 57 to 63 in 7ea22e4
Otherwise it would cause another CVE similar to #17378
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, let me open another PR to fix
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||
| "data": tensor_obj.numpy() | ||||||||||||||||
| }) | ||||||||||||||||
| return cls.item_to_bytes("tensor", tensor_obj.numpy()) | ||||||||||||||||
| if isinstance(obj, np.ndarray): | ||||||||||||||||
| # If the array is non-contiguous, we need to copy it first | ||||||||||||||||
| arr_data = obj.data if obj.flags.c_contiguous else obj.tobytes() | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.