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
30ca18f4
Unverified
Commit
30ca18f4
authored
May 21, 2025
by
Yuan Luo
Committed by
GitHub
May 21, 2025
Browse files
Refactor group_concurrent_contiguous in NIXL (#6214)
Co-authored-by:
luoyuan.luo
<
luoyuan.luo@antgroup.com
>
parent
03886917
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
19 deletions
+9
-19
python/sglang/srt/disaggregation/nixl/conn.py
python/sglang/srt/disaggregation/nixl/conn.py
+9
-19
No files found.
python/sglang/srt/disaggregation/nixl/conn.py
View file @
30ca18f4
...
...
@@ -35,29 +35,19 @@ logger = logging.getLogger(__name__)
NixlEngineInfo
:
TypeAlias
=
Dict
[
str
,
Union
[
str
,
int
]]
# From Mooncake backend.
def
group_concurrent_contiguous
(
src_indices
:
npt
.
NDArray
[
np
.
int64
],
dst_indices
:
npt
.
NDArray
[
np
.
int64
]
)
->
Tuple
[
List
[
npt
.
NDArray
[
np
.
int64
]],
List
[
npt
.
NDArray
[
np
.
int64
]]]:
src_groups
=
[]
dst_groups
=
[]
current_src
=
[
src_indices
[
0
]]
current_dst
=
[
dst_indices
[
0
]]
for
i
in
range
(
1
,
len
(
src_indices
)):
src_contiguous
=
src_indices
[
i
]
==
src_indices
[
i
-
1
]
+
1
dst_contiguous
=
dst_indices
[
i
]
==
dst_indices
[
i
-
1
]
+
1
if
src_contiguous
and
dst_contiguous
:
current_src
.
append
(
src_indices
[
i
])
current_dst
.
append
(
dst_indices
[
i
])
else
:
src_groups
.
append
(
current_src
)
dst_groups
.
append
(
current_dst
)
current_src
=
[
src_indices
[
i
]]
current_dst
=
[
dst_indices
[
i
]]
"""Vectorised NumPy implementation."""
if
src_indices
.
size
==
0
:
return
[],
[]
brk
=
np
.
where
((
np
.
diff
(
src_indices
)
!=
1
)
|
(
np
.
diff
(
dst_indices
)
!=
1
))[
0
]
+
1
src_groups
=
np
.
split
(
src_indices
,
brk
)
dst_groups
=
np
.
split
(
dst_indices
,
brk
)
src_groups
.
append
(
current_src
)
dst_groups
.
append
(
current_dst
)
src_groups
=
[
g
.
tolist
()
for
g
in
src_groups
]
dst_groups
=
[
g
.
tolist
()
for
g
in
dst_groups
]
return
src_groups
,
dst_groups
...
...
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