nemo_automodel.components.models.ernie4_5.rope_utils
nemo_automodel.components.models.ernie4_5.rope_utils
Module Contents
Classes
Functions
API
Bases: Module
Rotary embedding module matching the Hugging Face ERNIE 4.5 implementation.
Build FP32 interleaved rotary coefficients for local positions.
Parameters:
Tensor of shape [batch, sequence, heads, head_dim] or packed [tokens, heads, head_dim]; used to select the device.
Integer tensor [batch, sequence] or packed [tokens].
BSHD or packed THD tensor layout.
Returns: torch.Tensor
FP32 cosine and sine tensors [batch, sequence, head_dim] or
Apply ERNIE 4.5 interleaved rotary embeddings to q and k.
Parameters:
Query tensor in BSHD or THD format.
Key tensor in BSHD or THD format.
Cosine tensor with shape [B, S, D] for BSHD or [T, D] for THD.
Sine tensor with shape [B, S, D] for BSHD or [T, D] for THD.
Rotate interleaved RoPE pairs: [x0, x1] -> [-x1, x0].