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
8b84e69f
Unverified
Commit
8b84e69f
authored
Jan 22, 2025
by
Lianmin Zheng
Committed by
GitHub
Jan 22, 2025
Browse files
Fix tp token sync for dp attention (#3062)
parent
5de50653
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
python/sglang/srt/layers/sampler.py
python/sglang/srt/layers/sampler.py
+6
-1
No files found.
python/sglang/srt/layers/sampler.py
View file @
8b84e69f
...
@@ -6,6 +6,7 @@ import torch.distributed as dist
...
@@ -6,6 +6,7 @@ import torch.distributed as dist
from
torch
import
nn
from
torch
import
nn
from
sglang.srt.distributed
import
get_tensor_model_parallel_group
from
sglang.srt.distributed
import
get_tensor_model_parallel_group
from
sglang.srt.layers.dp_attention
import
get_attention_tp_group
from
sglang.srt.layers.logits_processor
import
LogitsProcessorOutput
from
sglang.srt.layers.logits_processor
import
LogitsProcessorOutput
from
sglang.srt.managers.schedule_batch
import
global_server_args_dict
from
sglang.srt.managers.schedule_batch
import
global_server_args_dict
from
sglang.srt.sampling.sampling_batch_info
import
SamplingBatchInfo
from
sglang.srt.sampling.sampling_batch_info
import
SamplingBatchInfo
...
@@ -33,6 +34,10 @@ class Sampler(nn.Module):
...
@@ -33,6 +34,10 @@ class Sampler(nn.Module):
def
__init__
(
self
):
def
__init__
(
self
):
super
().
__init__
()
super
().
__init__
()
self
.
use_nan_detectioin
=
global_server_args_dict
[
"enable_nan_detection"
]
self
.
use_nan_detectioin
=
global_server_args_dict
[
"enable_nan_detection"
]
self
.
tp_sync_group
=
get_tensor_model_parallel_group
().
device_group
if
global_server_args_dict
[
"enable_dp_attention"
]:
self
.
tp_sync_group
=
get_attention_tp_group
().
device_group
def
forward
(
def
forward
(
self
,
self
,
...
@@ -140,7 +145,7 @@ class Sampler(nn.Module):
...
@@ -140,7 +145,7 @@ class Sampler(nn.Module):
torch
.
distributed
.
all_reduce
(
torch
.
distributed
.
all_reduce
(
batch_next_token_ids
,
batch_next_token_ids
,
op
=
dist
.
ReduceOp
.
MIN
,
op
=
dist
.
ReduceOp
.
MIN
,
group
=
get_tensor_model_parallel_group
().
device
_group
,
group
=
self
.
tp_sync
_group
,
)
)
return
batch_next_token_ids
.
to
(
torch
.
int32
)
return
batch_next_token_ids
.
to
(
torch
.
int32
)
...
...
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