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
a6049be7
Unverified
Commit
a6049be7
authored
Oct 12, 2025
by
Lukas Geiger
Committed by
GitHub
Oct 13, 2025
Browse files
[Models][Qwen3VL] Speedup `fast_pos_embed_interpolate` (#26647)
Signed-off-by:
Lukas Geiger
<
lukas.geiger94@gmail.com
>
parent
18ed7746
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
18 deletions
+11
-18
vllm/model_executor/models/qwen3_vl.py
vllm/model_executor/models/qwen3_vl.py
+11
-18
No files found.
vllm/model_executor/models/qwen3_vl.py
View file @
a6049be7
...
@@ -467,8 +467,6 @@ class Qwen3_VisionTransformer(nn.Module):
...
@@ -467,8 +467,6 @@ class Qwen3_VisionTransformer(nn.Module):
dh_grid
,
dw_grid
=
torch
.
meshgrid
(
dh
,
dw
,
indexing
=
"ij"
)
dh_grid
,
dw_grid
=
torch
.
meshgrid
(
dh
,
dw
,
indexing
=
"ij"
)
h_floor_grid
,
w_floor_grid
=
torch
.
meshgrid
(
h_floor
,
w_floor
,
indexing
=
"ij"
)
h_floor_grid
,
w_floor_grid
=
torch
.
meshgrid
(
h_floor
,
w_floor
,
indexing
=
"ij"
)
h_ceil_grid
,
w_ceil_grid
=
torch
.
meshgrid
(
h_ceil
,
w_ceil
,
indexing
=
"ij"
)
h_ceil_grid
,
w_ceil_grid
=
torch
.
meshgrid
(
h_ceil
,
w_ceil
,
indexing
=
"ij"
)
h_floor_grid_idx
=
h_floor_grid
*
num_grid_per_side
h_ceil_grid_idx
=
h_ceil_grid
*
num_grid_per_side
# original computation of weights
# original computation of weights
# w00 = (1 - dh_grid) * (1 - dw_grid)
# w00 = (1 - dh_grid) * (1 - dw_grid)
...
@@ -480,30 +478,25 @@ class Qwen3_VisionTransformer(nn.Module):
...
@@ -480,30 +478,25 @@ class Qwen3_VisionTransformer(nn.Module):
w11
=
dh_grid
*
dw_grid
w11
=
dh_grid
*
dw_grid
w10
=
dh_grid
-
w11
w10
=
dh_grid
-
w11
w01
=
dw_grid
-
w11
w01
=
dw_grid
-
w11
w00
=
1
-
dh_grid
-
dw_grid
+
w1
1
w00
=
1
-
dh_grid
-
w0
1
idx00
=
h_floor_grid_idx
+
w_floor_grid
h_grid
=
torch
.
stack
([
h_floor_grid
,
h_floor_grid
,
h_ceil_grid
,
h_ceil_grid
])
idx01
=
h_floor_grid_idx
+
w_ceil_grid
w_grid
=
torch
.
stack
([
w_floor_grid
,
w_ceil_grid
,
w_floor_grid
,
w_ceil_grid
])
idx10
=
h_ceil_grid_idx
+
w_floor_grid
h_grid_idx
=
h_grid
*
num_grid_per_side
idx11
=
h_ceil_grid_idx
+
w_ceil_grid
indices
=
torch
.
stack
([
idx00
,
idx01
,
idx10
,
idx11
],
dim
=
0
).
reshape
(
4
,
-
1
)
indices
=
(
h_grid_idx
+
w_grid
).
reshape
(
4
,
-
1
)
weights
=
torch
.
stack
([
w00
,
w01
,
w10
,
w11
],
dim
=
0
).
reshape
(
4
,
-
1
,
1
)
weights
=
torch
.
stack
([
w00
,
w01
,
w10
,
w11
],
dim
=
0
).
reshape
(
4
,
-
1
,
1
)
weights
=
weights
.
to
(
weights
=
weights
.
to
(
dtype
=
self
.
dtype
)
dtype
=
self
.
dtype
,
device
=
self
.
device
,
non_blocking
=
True
)
embeds
=
self
.
pos_embed
(
indices
)
embeds
=
self
.
pos_embed
(
indices
)
weighted_embeds
=
embeds
*
weights
weighted_embeds
=
embeds
*
weights
p0
,
p1
,
p2
,
p3
=
weighted_embeds
.
unbind
(
dim
=
0
)
combined
=
weighted_embeds
.
sum
(
dim
=
0
)
combined
=
p0
+
p1
+
p2
+
p3
combined
=
combined
.
view
(
h
*
w
,
hidden_dim
)
combined
=
combined
.
reshape
(
repeated
=
combined
.
unsqueeze
(
0
).
expand
(
t
,
-
1
,
-
1
).
contiguous
()
h
//
m_size
,
m_size
,
w
//
m_size
,
m_size
,
hidden_dim
repeated
=
repeated
.
view
(
t
,
h
//
m_size
,
m_size
,
w
//
m_size
,
m_size
,
hidden_dim
)
)
repeated
=
repeated
.
permute
(
0
,
1
,
3
,
2
,
4
,
5
).
reshape
(
-
1
,
hidden_dim
)
combined
=
combined
.
permute
(
0
,
2
,
1
,
3
,
4
).
reshape
(
1
,
-
1
,
hidden_dim
)
repeated
=
combined
.
expand
(
t
,
-
1
,
-
1
).
reshape
(
-
1
,
hidden_dim
)
outputs
.
append
(
repeated
)
outputs
.
append
(
repeated
)
return
torch
.
cat
(
outputs
,
dim
=
0
)
return
torch
.
cat
(
outputs
,
dim
=
0
)
...
...
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