pub enum RotationState {
Angle(Tensor<3>),
Quaternion(Tensor<4>),
}Expand description
The cumulative-rotation accumulator carried between calls in a Mamba-3 cache
— the variant matching the block’s RotationKind.
Angle— abelian per-pair cumulative RoPE angle, shape[batch, nheads, num_rope_angles](today’scum_angle).Quaternion— per-block cumulative unit quaternion, shape[batch, nheads, blocks, 4], produced byquat_cumprod.
This is the cache-level counterpart of RotationKind. It is defined here
(the rotation module owns the accumulator type); substituting it for the
pathway caches’ cum_angle_bha field happens together with the forward/step
wiring that consumes it.
Variants§
Angle(Tensor<3>)
Abelian RoPE cumulative angle, shape [batch, nheads, num_rope_angles].
Quaternion(Tensor<4>)
Quaternion cumulative rotation, shape [batch, nheads, blocks, 4].
Implementations§
Source§impl RotationState
impl RotationState
Sourcepub fn zeros_angle(
batch: usize,
nheads: usize,
num_rope_angles: usize,
device: &Device,
) -> Self
pub fn zeros_angle( batch: usize, nheads: usize, num_rope_angles: usize, device: &Device, ) -> Self
Zero-initialised abelian angle accumulator [batch, nheads, num_rope_angles].
Sourcepub fn identity_quaternion(
batch: usize,
nheads: usize,
blocks: usize,
device: &Device,
) -> Self
pub fn identity_quaternion( batch: usize, nheads: usize, blocks: usize, device: &Device, ) -> Self
Identity-initialised quaternion accumulator [batch, nheads, blocks, 4]
(every block is the identity quaternion (1, 0, 0, 0)).
Sourcepub fn angle(self) -> Tensor<3>
pub fn angle(self) -> Tensor<3>
Unwrap the abelian angle accumulator; panics if this is a quaternion.
Sourcepub fn quaternion(self) -> Tensor<4>
pub fn quaternion(self) -> Tensor<4>
Unwrap the quaternion accumulator; panics if this is an angle.
Sourcepub fn sanity(&self)
pub fn sanity(&self)
Run the NaN/Inf guards on the held tensor.