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
21 changes: 17 additions & 4 deletions megatron/core/transformer/moe/fused_a2a.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def set_deepep_num_sms(num_sms):
def init_hybrid_ep_buffer(
group: torch.distributed.ProcessGroup,
hidden_dim: int,
seq_len: int,
num_tokens: int,
num_local_experts: int,
num_sms_dispatch_api: int,
num_sms_combine_api: int,
Expand Down Expand Up @@ -313,7 +313,7 @@ def init_hybrid_ep_buffer(
_hybrid_ep_buffer = HybridEPBuffer(
group=group,
hidden_dim=hidden_dim,
max_num_of_tokens_per_rank=seq_len,
max_num_of_tokens_per_rank=num_tokens,
num_local_experts=num_local_experts,
use_fp8=fp8_dispatch,
num_sms_dispatch_api=num_sms_dispatch_api,
Expand Down Expand Up @@ -351,12 +351,25 @@ def forward(
Forward pass of fused dispatch of the HybridEP backend
'''
if _hybrid_ep_buffer is None:
seq_len, hidden_dim = x.shape[-2:]
num_tokens, hidden_dim = x.shape[-2:]

# --- Hardware Limit Guardrail ---
# DeepEP calculates tx_depth = 3 * num_tokens + 1.
Comment thread
janEbert marked this conversation as resolved.
# InfiniBand strictly asserts tx_depth < 65536.
tx_depth = 3 * num_tokens + 1
if tx_depth >= 65536:
raise ValueError(
f"HybridEP RDMA Queue Pair depth ({tx_depth}) exceeds the InfiniBand "
f"hardware limit of 65535. This occurs because the total tokens per rank "
f"({num_tokens}) too high. Reduce sequence length or micro-batch size, "
f"or increase Tensor Parallelism (TP) / Context Parallelism (CP) to reduce "
f"the number of tokens processed per rank."
)
fp8_dispatch = False # Currently, we do not support fp8 dispatch
init_hybrid_ep_buffer(
group,
hidden_dim,
seq_len,
num_tokens,
num_local_experts,
num_sms_dispatch_api,
num_sms_combine_api,
Expand Down
Loading