Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
vllm_cscc
Commits
0a298ea4
Unverified
Commit
0a298ea4
authored
Apr 01, 2025
by
Isotr0py
Committed by
GitHub
Apr 01, 2025
Browse files
[Bugfix] Fix no video/image profiling edge case for `MultiModalDataParser` (#15828)
Signed-off-by:
Isotr0py
<
2037008807@qq.com
>
parent
d330558b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
vllm/multimodal/parse.py
vllm/multimodal/parse.py
+27
-6
No files found.
vllm/multimodal/parse.py
View file @
0a298ea4
...
@@ -295,7 +295,7 @@ class MultiModalDataItems(UserDict[str, ModalityDataItems[Any, Any]]):
...
@@ -295,7 +295,7 @@ class MultiModalDataItems(UserDict[str, ModalityDataItems[Any, Any]]):
ModalityDataParser
:
TypeAlias
=
Callable
[[
ModalityData
[
Any
]],
ModalityDataParser
:
TypeAlias
=
Callable
[[
ModalityData
[
Any
]],
ModalityDataItems
[
Any
,
Any
]]
Optional
[
ModalityDataItems
[
Any
,
Any
]]
]
class
MultiModalDataParser
:
class
MultiModalDataParser
:
...
@@ -319,7 +319,15 @@ class MultiModalDataParser:
...
@@ -319,7 +319,15 @@ class MultiModalDataParser:
if
isinstance
(
data
,
torch
.
Tensor
):
if
isinstance
(
data
,
torch
.
Tensor
):
return
data
.
ndim
==
3
return
data
.
ndim
==
3
if
is_list_of
(
data
,
torch
.
Tensor
):
if
is_list_of
(
data
,
torch
.
Tensor
):
return
len
(
data
)
==
0
or
data
[
0
].
ndim
==
2
return
data
[
0
].
ndim
==
2
return
False
def
_is_empty
(
self
,
data
:
object
)
->
TypeGuard
[
None
]:
if
isinstance
(
data
,
list
):
return
len
(
data
)
==
0
if
isinstance
(
data
,
(
np
.
ndarray
,
torch
.
Tensor
)):
return
data
.
size
==
0
return
False
return
False
...
@@ -341,7 +349,12 @@ class MultiModalDataParser:
...
@@ -341,7 +349,12 @@ class MultiModalDataParser:
def
_parse_audio_data
(
def
_parse_audio_data
(
self
,
self
,
data
:
ModalityData
[
AudioItem
],
data
:
ModalityData
[
AudioItem
],
)
->
ModalityDataItems
[
Any
,
Any
]:
)
->
Optional
[
ModalityDataItems
[
Any
,
Any
]]:
# also check single audio item with sampling rate
if
self
.
_is_empty
(
data
)
or
(
isinstance
(
data
,
tuple
)
and
self
.
_is_empty
(
data
[
0
])):
return
None
if
self
.
_is_embeddings
(
data
):
if
self
.
_is_embeddings
(
data
):
return
AudioEmbeddingItems
(
data
)
return
AudioEmbeddingItems
(
data
)
...
@@ -378,7 +391,10 @@ class MultiModalDataParser:
...
@@ -378,7 +391,10 @@ class MultiModalDataParser:
def
_parse_image_data
(
def
_parse_image_data
(
self
,
self
,
data
:
ModalityData
[
ImageItem
],
data
:
ModalityData
[
ImageItem
],
)
->
ModalityDataItems
[
Any
,
Any
]:
)
->
Optional
[
ModalityDataItems
[
Any
,
Any
]]:
if
self
.
_is_empty
(
data
):
return
None
if
self
.
_is_embeddings
(
data
):
if
self
.
_is_embeddings
(
data
):
return
ImageEmbeddingItems
(
data
)
return
ImageEmbeddingItems
(
data
)
...
@@ -396,7 +412,10 @@ class MultiModalDataParser:
...
@@ -396,7 +412,10 @@ class MultiModalDataParser:
def
_parse_video_data
(
def
_parse_video_data
(
self
,
self
,
data
:
ModalityData
[
VideoItem
],
data
:
ModalityData
[
VideoItem
],
)
->
ModalityDataItems
[
Any
,
Any
]:
)
->
Optional
[
ModalityDataItems
[
Any
,
Any
]]:
if
self
.
_is_empty
(
data
):
return
None
if
self
.
_is_embeddings
(
data
):
if
self
.
_is_embeddings
(
data
):
return
VideoEmbeddingItems
(
data
)
return
VideoEmbeddingItems
(
data
)
...
@@ -427,6 +446,8 @@ class MultiModalDataParser:
...
@@ -427,6 +446,8 @@ class MultiModalDataParser:
if
k
not
in
subparsers
:
if
k
not
in
subparsers
:
raise
ValueError
(
f
"Unsupported modality:
{
k
}
"
)
raise
ValueError
(
f
"Unsupported modality:
{
k
}
"
)
mm_items
[
k
]
=
subparsers
[
k
](
v
)
# ignore empty embedding data
if
(
parsed_data
:
=
subparsers
[
k
](
v
))
is
not
None
:
mm_items
[
k
]
=
parsed_data
return
mm_items
return
mm_items
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment