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
053278a5
Unverified
Commit
053278a5
authored
Aug 23, 2025
by
Benji Beck
Committed by
GitHub
Aug 24, 2025
Browse files
Migrate Pixtral inputs to TensorSchema (#23472)
Signed-off-by:
Benji Beck
<
benjibeck@meta.com
>
parent
c55c0289
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
vllm/model_executor/models/pixtral.py
vllm/model_executor/models/pixtral.py
+13
-11
No files found.
vllm/model_executor/models/pixtral.py
View file @
053278a5
...
...
@@ -5,7 +5,7 @@ import math
from
collections.abc
import
Iterable
,
Mapping
,
Sequence
from
dataclasses
import
dataclass
,
fields
from
functools
import
cached_property
from
typing
import
Literal
,
Optional
,
TypedDict
,
Union
from
typing
import
Annotated
,
Literal
,
Optional
,
Union
import
torch
import
torch.nn
as
nn
...
...
@@ -48,6 +48,7 @@ from vllm.platforms import current_platform
from
vllm.sequence
import
IntermediateTensors
from
vllm.transformers_utils.tokenizer
import
(
MistralTokenizer
,
cached_tokenizer_from_config
)
from
vllm.utils.tensor_schema
import
TensorSchema
,
TensorShape
from
.interfaces
import
MultiModalEmbeddings
,
SupportsMultiModal
,
SupportsPP
from
.utils
import
(
flatten_bn
,
init_vllm_registered_model
,
maybe_prefix
,
...
...
@@ -68,15 +69,20 @@ except ImportError:
PATCH_MERGE
=
"patch_merge"
class
PixtralImagePixelInputs
(
TypedDict
):
type
:
Literal
[
"pixel_values"
]
images
:
Union
[
torch
.
Tensor
,
list
[
torch
.
Tensor
]]
class
PixtralImagePixelInputs
(
TensorSchema
):
"""
Shape: `(batch_size * num_images, num_channels, image_width, image_height)`
Dimensions:
- bn: Batch size * number of images
- c: Number of channels (3)
- h: Height of each image
- w: Width of each image
The result of stacking `ImageEncoding.tokens` from each prompt.
"""
type
:
Literal
[
"pixel_values"
]
=
"pixel_values"
images
:
Annotated
[
Union
[
torch
.
Tensor
,
list
[
torch
.
Tensor
]],
TensorShape
(
"bn"
,
3
,
"h"
,
"w"
,
dynamic_dims
=
{
"h"
,
"w"
})]
class
PixtralProcessorAdapter
:
...
...
@@ -381,10 +387,6 @@ class PixtralForConditionalGeneration(nn.Module, SupportsMultiModal,
if
images
is
None
:
return
None
if
not
isinstance
(
images
,
(
torch
.
Tensor
,
list
)):
raise
ValueError
(
"Incorrect type of images. "
f
"Got type:
{
type
(
images
)
}
"
)
return
PixtralImagePixelInputs
(
type
=
"pixel_values"
,
images
=
flatten_bn
(
images
),
...
...
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