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
92cbef59
Unverified
Commit
92cbef59
authored
Aug 08, 2025
by
Elfie Guo
Committed by
GitHub
Aug 08, 2025
Browse files
[bug fix] Ensure local token and global token buffers are pointing to different storage (#8785)
parent
b3359dc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
python/sglang/srt/layers/dp_attention.py
python/sglang/srt/layers/dp_attention.py
+8
-6
No files found.
python/sglang/srt/layers/dp_attention.py
100644 → 100755
View file @
92cbef59
...
...
@@ -264,9 +264,10 @@ def _dp_gather_via_all_reduce(
assert
global_tokens
.
is_contiguous
()
if
local_tokens
.
shape
[
0
]
>
0
and
(
is_partial
or
get_attention_tp_rank
()
==
0
):
assert
(
local_tokens
.
untyped_storage
()
is
not
global_tokens
.
untyped_storage
()
),
"aliasing between global_tokens and local_tokens not allowed"
if
local_tokens
.
untyped_storage
()
is
global_tokens
.
untyped_storage
():
# dp_gather is an in-place operation and requires input and output tensors to not be aliased.
# so we create a separate buffer if they share the same storage.
global_tokens
=
torch
.
empty_like
(
global_tokens
)
memcpy_triton
(
global_tokens
,
local_tokens
,
0
,
local_start_pos
,
local_num_tokens
,
False
...
...
@@ -347,9 +348,10 @@ def dp_scatter(
assert
local_tokens
.
is_contiguous
()
assert
global_tokens
.
is_contiguous
()
if
local_tokens
.
shape
[
0
]
>
0
:
assert
(
local_tokens
.
untyped_storage
()
is
not
global_tokens
.
untyped_storage
()
),
"aliasing between local_tokens and global_tokens not allowed"
if
local_tokens
.
untyped_storage
()
is
global_tokens
.
untyped_storage
():
# dp_scatter is an in-place operation and requires input and output tensors to not be aliased.
# so we create a separate buffer if they share the same storage.
local_tokens
=
torch
.
empty_like
(
local_tokens
)
memcpy_triton
(
local_tokens
,
global_tokens
,
0
,
local_start_pos
,
local_num_tokens
,
True
...
...
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