pub struct FrameCodec { /* private fields */ }Expand description
Cartan moving-frame KV cache codec.
Stores the anchor (K_0, V_0) plus a sequence of d×d frame transition
matrices F_t for t = 1..T. Decoding reconstructs K_t and V_t
by cumulative matrix product from the anchor.
Implementations§
Source§impl FrameCodec
impl FrameCodec
Sourcepub fn encode_step(&mut self, k: &[f32], v: &[f32])
pub fn encode_step(&mut self, k: &[f32], v: &[f32])
Encode one (k, v) pair. First call sets the anchor; subsequent calls
store the frame transition relative to the previous step.
k and v must each have length head_dim.
Sourcepub fn token_count(&self) -> usize
pub fn token_count(&self) -> usize
Number of tokens stored (including anchor).
Sourcepub fn decode_key(&self, t: usize) -> Vec<f32>
pub fn decode_key(&self, t: usize) -> Vec<f32>
Decode the key vector at position t by applying cumulative frame
transitions from the anchor.
Sourcepub fn decode_val(&self, t: usize) -> Vec<f32>
pub fn decode_val(&self, t: usize) -> Vec<f32>
Decode the value vector at position t.
Sourcepub fn attend(&self, query: &[f32]) -> Vec<f32>
pub fn attend(&self, query: &[f32]) -> Vec<f32>
Compute standard softmax attention over all stored tokens.
query has length head_dim. Returns the weighted sum of values.
Sourcepub fn bytes_used(&self) -> usize
pub fn bytes_used(&self) -> usize
Number of bytes used by the codec (f32 = 4 bytes each).
Sourcepub fn bytes_absolute(&self) -> usize
pub fn bytes_absolute(&self) -> usize
Number of bytes a naive absolute-vector store would use (f32 K+V per token).
Auto Trait Implementations§
impl Freeze for FrameCodec
impl RefUnwindSafe for FrameCodec
impl Send for FrameCodec
impl Sync for FrameCodec
impl Unpin for FrameCodec
impl UnsafeUnpin for FrameCodec
impl UnwindSafe for FrameCodec
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more