Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/sglang/srt/models/deepseek_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ def __init__(
self.embed_tokens = VocabParallelEmbedding(
config.vocab_size,
config.hidden_size,
use_attn_tp_group=True,
enable_tp=not global_server_args_dict["enable_dp_attention"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability, consider adding a comment explaining why tensor parallelism for embeddings is disabled when data-parallel attention is enabled. This clarifies the rationale behind the logic.

# When data-parallel attention is enabled, the input batch is split across DP ranks.
# To avoid complex communication for the embedding lookup, we replicate the embedding layer by disabling its tensor parallelism.
self.embed_tokens = VocabParallelEmbedding(
    config.vocab_size,
    config.hidden_size,
    enable_tp=not global_server_args_dict["enable_dp_attention"],
)

)
self.alt_stream = torch.cuda.Stream() if _is_cuda else None
self.layers = nn.ModuleList(
Expand Down
Loading