Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
4ed9053e
Unverified
Commit
4ed9053e
authored
Sep 03, 2025
by
timmy-feng
Committed by
GitHub
Sep 03, 2025
Browse files
Remove mrope position sync (#9460)
Co-authored-by:
Nathan Wang
<
nathan.r.wang@gmail.com
>
parent
5e19b159
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
35 deletions
+16
-35
python/sglang/srt/layers/rotary_embedding.py
python/sglang/srt/layers/rotary_embedding.py
+0
-18
python/sglang/srt/model_executor/forward_batch_info.py
python/sglang/srt/model_executor/forward_batch_info.py
+16
-17
No files found.
python/sglang/srt/layers/rotary_embedding.py
View file @
4ed9053e
...
...
@@ -1433,24 +1433,6 @@ class MRotaryEmbedding(RotaryEmbedding):
return
position_ids
,
mrope_position_deltas
@
staticmethod
def
get_next_input_positions
(
mrope_position_delta
:
int
,
context_len
:
int
,
seq_len
:
int
,
)
->
torch
.
Tensor
:
return
torch
.
tensor
(
[
list
(
range
(
context_len
+
mrope_position_delta
,
seq_len
+
mrope_position_delta
,
)
)
for
_
in
range
(
3
)
]
)
class
DualChunkRotaryEmbedding
(
CustomOp
):
"""Rotary positional embedding for Dual Chunk Attention."""
...
...
python/sglang/srt/model_executor/forward_batch_info.py
View file @
4ed9053e
...
...
@@ -516,24 +516,23 @@ class ForwardBatch:
for
batch_idx
in
range
(
batch_size
):
mm_input
=
batch
.
multimodal_inputs
[
batch_idx
]
if
self
.
forward_mode
.
is_decode
():
mrope_position_deltas
=
(
[
0
]
if
mm_input
is
None
else
flatten_nested_list
(
mm_input
.
mrope_position_delta
.
tolist
())
)
next_input_positions
=
[]
for
mrope_position_delta
in
mrope_position_deltas
:
# batched deltas needs to be processed separately
# Convert list of lists to tensor with shape [3, seq_len]
next_input_positions
+=
[
MRotaryEmbedding
.
get_next_input_positions
(
mrope_position_delta
,
int
(
self
.
seq_lens
[
batch_idx
])
-
1
,
int
(
self
.
seq_lens
[
batch_idx
]),
)
]
# 3 * N
mrope_positions_list
[
batch_idx
]
=
torch
.
cat
(
next_input_positions
,
dim
=
1
)
if
mm_input
is
None
:
mrope_positions_list
[
batch_idx
]
=
torch
.
full
(
(
3
,
1
),
self
.
seq_lens
[
batch_idx
]
-
1
,
dtype
=
torch
.
int64
,
device
=
model_runner
.
device
,
)
else
:
mrope_position_deltas
=
mm_input
.
mrope_position_delta
.
flatten
().
to
(
model_runner
.
device
,
non_blocking
=
True
)
mrope_positions_list
[
batch_idx
]
=
(
(
mrope_position_deltas
+
self
.
seq_lens
[
batch_idx
]
-
1
)
.
unsqueeze
(
0
)
.
repeat
(
3
,
1
)
)
elif
self
.
forward_mode
.
is_extend
():
extend_seq_len
,
extend_prefix_len
=
(
batch
.
extend_seq_lens
[
batch_idx
],
...
...
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