pub enum RotationSeq {
Angle {
cum_bsha: Tensor<4>,
rope_dim: usize,
rotate_pairwise: bool,
},
Quaternion {
cum_bshj4: Tensor<5>,
},
}Expand description
Per-token cumulative rotation of one forward call — the sequence-resolved
counterpart of the cache’s final RotationState, exported by
rotate_bc_forward (it is already materialised there) for the
physical-frame state moments: the per-token states must be de-rotated by
the inverse of the rotation absorbed into B/C (see
Self::derotate_states). Carries its own application metadata so a
consumer cannot re-derive a mismatched pairing layout.
Variants§
Angle
Abelian cumulative RoPE angles.
Fields
cum_bsha: Tensor<4>Cumulative angles [batch, sequence, nheads, num_rope_angles]
(un-wrapped — every consumer is 2π-periodic).
rotate_pairwise: boolInterleaved/NeoX (SISO) vs half-and-half/GPT-J (MIMO) pairing —
exactly the flag apply_rope_partial was called with.
Quaternion
Quaternion cumulative rotation [batch, sequence, nheads, blocks, 4];
rotates the first 4·blocks state-rank entries as consecutive blocks.
Fields
cum_bshj4: Tensor<5>Cumulative unit quaternions (the quat_cumprod output).
Implementations§
Source§impl RotationSeq
impl RotationSeq
Sourcepub fn pad_to(self, padded_len: usize) -> Self
pub fn pad_to(self, padded_len: usize) -> Self
Zero-pad the sequence axis to padded_len (the SSD chunk padding).
Pad values are never read un-masked: the moments mask excludes pad
positions before accumulation.
Sourcepub fn derotate_states(
&self,
states_blhpr: Tensor<5>,
start: usize,
) -> Tensor<5>
pub fn derotate_states( &self, states_blhpr: Tensor<5>, start: usize, ) -> Tensor<5>
Rotate the state_rank axis of per-token cache-frame states back to
the physical frame — the inverse of the rotation rotate_bc_forward
absorbed into B/C, so the result cₜ is what raw, un-rotated C reads
(yₜ = C̃ₜᵀh̃ₜ = Cₜᵀcₜ):
Angle: B/C were rotated by+θₜ, so the state getsR(−θₜ)(negated angles).Quaternion: B/C were left-multiplied byconj(Qₜ), so the state getsQₜun-conjugated.
start is the offset of this chunk of states within the rotation’s
sequence axis.
§Shapes
states_blhpr:[batch, len, nheads, per_head_dim, state_rank]- output: same shape.
Trait Implementations§
Source§impl Clone for RotationSeq
impl Clone for RotationSeq
Source§fn clone(&self) -> RotationSeq
fn clone(&self) -> RotationSeq
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more