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
808d2e9a
Unverified
Commit
808d2e9a
authored
Aug 22, 2025
by
Woosuk Kwon
Committed by
GitHub
Aug 22, 2025
Browse files
[Misc] Move M-RoPE init logic to _init_mrope_positions (#23422)
Signed-off-by:
Woosuk Kwon
<
woosuk.kwon@berkeley.edu
>
parent
285178b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
32 deletions
+31
-32
vllm/v1/worker/gpu_model_runner.py
vllm/v1/worker/gpu_model_runner.py
+31
-32
No files found.
vllm/v1/worker/gpu_model_runner.py
View file @
808d2e9a
...
...
@@ -507,42 +507,11 @@ class GPUModelRunner(LoRAModelRunnerMixin, KVConnectorModelRunnerMixin):
output_token_ids
=
[],
lora_request
=
new_req_data
.
lora_request
,
)
self
.
requests
[
req_id
]
=
req_state
# Only relevant for models using M-RoPE (e.g, Qwen2-VL)
if
self
.
uses_mrope
:
image_grid_thw
=
[]
video_grid_thw
=
[]
second_per_grid_ts
=
[]
audio_feature_lengths
=
[]
use_audio_in_video
=
False
for
mm_item
in
req_state
.
mm_kwargs
:
mm_input
=
mm_item
.
get_data
()
if
(
t
:
=
mm_input
.
get
(
"image_grid_thw"
))
is
not
None
:
image_grid_thw
.
append
(
t
.
tolist
())
if
(
t
:
=
mm_input
.
get
(
"video_grid_thw"
))
is
not
None
:
video_grid_thw
.
append
(
t
.
tolist
())
if
(
t
:
=
mm_input
.
get
(
"second_per_grid_ts"
))
is
not
None
:
second_per_grid_ts
.
append
(
t
)
if
(
t
:
=
mm_input
.
get
(
"audio_feature_lengths"
))
is
not
None
:
audio_feature_lengths
.
append
(
t
)
if
mm_input
.
get
(
"use_audio_in_video"
)
is
True
:
use_audio_in_video
=
True
hf_config
=
self
.
model_config
.
hf_config
req_state
.
mrope_positions
,
req_state
.
mrope_position_delta
=
\
MRotaryEmbedding
.
get_input_positions_tensor
(
req_state
.
prompt_token_ids
,
hf_config
=
hf_config
,
image_grid_thw
=
image_grid_thw
,
video_grid_thw
=
video_grid_thw
,
second_per_grid_ts
=
second_per_grid_ts
,
audio_feature_lengths
=
audio_feature_lengths
,
use_audio_in_video
=
use_audio_in_video
,
)
self
.
_init_mrope_positions
(
req_state
)
reqs_to_add
.
append
(
req_state
)
...
...
@@ -639,6 +608,36 @@ class GPUModelRunner(LoRAModelRunnerMixin, KVConnectorModelRunnerMixin):
# Refresh batch metadata with any pending updates.
self
.
input_batch
.
refresh_metadata
()
def
_init_mrope_positions
(
self
,
req_state
:
CachedRequestState
):
image_grid_thw
=
[]
video_grid_thw
=
[]
second_per_grid_ts
=
[]
audio_feature_lengths
=
[]
use_audio_in_video
=
False
for
mm_item
in
req_state
.
mm_kwargs
:
mm_input
=
mm_item
.
get_data
()
if
(
t
:
=
mm_input
.
get
(
"image_grid_thw"
))
is
not
None
:
image_grid_thw
.
append
(
t
.
tolist
())
if
(
t
:
=
mm_input
.
get
(
"video_grid_thw"
))
is
not
None
:
video_grid_thw
.
append
(
t
.
tolist
())
if
(
t
:
=
mm_input
.
get
(
"second_per_grid_ts"
))
is
not
None
:
second_per_grid_ts
.
append
(
t
)
if
(
t
:
=
mm_input
.
get
(
"audio_feature_lengths"
))
is
not
None
:
audio_feature_lengths
.
append
(
t
)
if
mm_input
.
get
(
"use_audio_in_video"
)
is
True
:
use_audio_in_video
=
True
req_state
.
mrope_positions
,
req_state
.
mrope_position_delta
=
\
MRotaryEmbedding
.
get_input_positions_tensor
(
req_state
.
prompt_token_ids
,
hf_config
=
self
.
model_config
.
hf_config
,
image_grid_thw
=
image_grid_thw
,
video_grid_thw
=
video_grid_thw
,
second_per_grid_ts
=
second_per_grid_ts
,
audio_feature_lengths
=
audio_feature_lengths
,
use_audio_in_video
=
use_audio_in_video
,
)
def
_extract_mm_kwargs
(
self
,
scheduler_output
:
"SchedulerOutput"
,
...
...
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