Skip to content

Commit 2220f77

Browse files
authored
fix apply_rotary_pos_emb_thd missing cp_group (#146)
1 parent a346c19 commit 2220f77

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/mcore_bridge/patcher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,14 @@ def _apply_rotary_pos_emb_thd(t: torch.Tensor, cu_seqlens: torch.Tensor, freqs:
201201
cp_size = cp_group.size()
202202
else:
203203
cp_size = mpu.get_context_parallel_world_size()
204+
cp_group = mpu.get_context_parallel_group()
204205
cu_seqlens_for_batched = cu_seqlens // cp_size
205206
use_batched_rope = (freqs.dim() >= 1 and freqs.shape[0] == cu_seqlens_for_batched[-1]).item()
206207
# The determination of mla_output_remove_interleaving: a quick solution for identifying deepseek_v4
207208
# (TODO: refactor)
208209
if not use_batched_rope and not kwargs.get('mla_output_remove_interleaving', False):
209210
logger.warning_once('Using non-batched RoPE, which may affect performance.')
210-
return _origin_apply_rotary_pos_emb_thd(t, cu_seqlens, freqs, *args, **kwargs)
211+
return _origin_apply_rotary_pos_emb_thd(t, cu_seqlens, freqs, *args, cp_group=cp_group, **kwargs)
211212

212213
kwargs.pop('max_seqlen', None) # compat megatron-lm dev branch
213214
return rope_utils._apply_rotary_pos_emb_bshd(t.unsqueeze(1), freqs, *args, **kwargs).squeeze(1)

0 commit comments

Comments
 (0)