Skip to content
Merged
Show file tree
Hide file tree
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: 2 additions & 0 deletions megatron/core/extensions/transformer_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,7 @@ def fused_apply_rotary_pos_emb_thd(
freqs: torch.Tensor,
cp_size: int = 1,
cp_rank: int = 0,
interleaved: bool = False,
) -> torch.Tensor:
"""
Apply rotary positional embedding to input tensor T in `thd` format with CP support.
Expand All @@ -2398,6 +2399,7 @@ def fused_apply_rotary_pos_emb_thd(
cu_seqlens=cu_seqlens,
cp_size=cp_size,
cp_rank=cp_rank,
interleaved=interleaved,
)
else:
assert cp_size == 1, "Only TE >= 1.12 supports RoPE fusion for THD format with CP."
Expand Down
7 changes: 6 additions & 1 deletion megatron/core/models/common/embeddings/rope_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ def apply_rotary_pos_emb(
else:
assert fused_apply_rotary_pos_emb_thd is not None, "apply_rope_fusion is not available."
return fused_apply_rotary_pos_emb_thd(
t, cu_seqlens, freqs, cp_size=cp_group.size(), cp_rank=cp_group.rank()
t,
cu_seqlens,
freqs,
cp_size=cp_group.size(),
cp_rank=cp_group.rank(),
interleaved=config.rotary_interleaved,
)
# use unfused implementation
if cu_seqlens is None:
Expand Down
Loading