nemo_automodel.components.models.step5.rope
nemo_automodel.components.models.step5.rope
Half-split RoPE with the checkpoint’s explicit BF16 table boundary.
Module Contents
Classes
Functions
API
Bases: Module
Recompute FP32 frequencies from config; never cast a frequency buffer.
Build tables once per call; preserve eager frequency/trig rounding.
Rotate the leading half-split subspace.
Parameters:
Tensor of shape [batch, sequence, heads, head_dim].
Tensor of shape [batch, sequence] with document-local positions.
Returns: torch.Tensor
Tensor of shape [batch, sequence, heads, head_dim] in the input dtype.
Rotate local Q/K with one shared, identically rounded table pair.
Parameters:
Query tensor [batch, sequence, query_heads, head_dim].
Key tensor [batch, sequence, key_heads, head_dim], sharing query’s dtype and device. Noncontiguous key views are supported.
Document-local positions [batch, sequence].
Returns: tuple[torch.Tensor, torch.Tensor]
Rotated query and key tensors, preserving their respective shapes.
Raises:
ValueError: Q/K have different batch/sequence extents, dtype or device.
Apply already-rounded tables using FP32 half-split arithmetic.