Skip to main content

RotationSeq

Enum RotationSeq 

Source
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 -periodic).

§rope_dim: usize

Number of rotated B/C entries (0 ⇒ the rotation is the identity).

§rotate_pairwise: bool

Interleaved/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

Source

pub fn detached(&self) -> Self

A value-identical copy detached from any autodiff graph.

Source

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.

Source

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 gets R(−θₜ) (negated angles).
  • Quaternion: B/C were left-multiplied by conj(Qₜ), so the state gets Qₜ 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

Source§

fn clone(&self) -> RotationSeq

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RotationSeq

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.