Skip to content
Closed
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
1 change: 1 addition & 0 deletions src/mcore_bridge/model/gpt_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def _apply_rotary_pos_emb_bshd(
rotary_interleaved: bool = False,
multi_latent_attention: bool = False, # not use
mscale: float = 1.0,
**kwargs,
) -> torch.Tensor:
"""Apply rotary positional embedding to input tensor T.

Expand Down
5 changes: 4 additions & 1 deletion src/mcore_bridge/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ def _apply_rotary_pos_emb_thd(
multi_latent_attention: bool = False,
mscale: float = 1.0,
cp_group: torch.distributed.ProcessGroup = None,
**kwargs,
) -> torch.Tensor:
"""A baseline implementation of applying RoPE for `thd` format.

Expand All @@ -629,7 +630,8 @@ def _apply_rotary_pos_emb_thd(
use_batched_rope = (freqs.dim() >= 1 and freqs.shape[0] == cu_seqlens_for_batched[-1]).item()
if not use_batched_rope:
logger.warning_once('Using non-batched RoPE, which may affect performance.')
kwargs = {'cp_group': cp_group} if mcore_013 else {}
if mcore_013:
kwargs['cp_group'] = cp_group
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Modifying the kwargs dictionary in-place can lead to unexpected side effects for the caller. It's safer to create a new dictionary for the call, which avoids mutating the object passed by the caller.

Suggested change
kwargs['cp_group'] = cp_group
kwargs = {**kwargs, 'cp_group': cp_group}

return _origin_apply_rotary_pos_emb_thd(
t,
cu_seqlens,
Expand All @@ -646,6 +648,7 @@ def _apply_rotary_pos_emb_thd(
rotary_interleaved=rotary_interleaved,
multi_latent_attention=multi_latent_attention,
mscale=mscale,
**kwargs,
).squeeze(1)

rope_utils._apply_rotary_pos_emb_thd = _apply_rotary_pos_emb_thd
Expand Down
2 changes: 1 addition & 1 deletion src/mcore_bridge/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Make sure to modify __release_datetime__ to release time when making official release.
__version__ = '1.0.1.dev0'
__version__ = '1.1.0.dev0'
# default release datetime for branches under active development is set
# to be a time far-far-away-into-the-future
__release_datetime__ = '2099-12-31 23:59:59'
Loading