Skip to main content

CacheSignature

Struct CacheSignature 

Source
pub struct CacheSignature {
    pub format_version: u32,
    pub model: String,
    pub n_layers: usize,
    pub n_kv_heads: usize,
    pub head_dim: usize,
    pub dtype: KvDtype,
    pub tokens: usize,
    pub layout: BlockLayout,
}
Expand description

What a block’s payload is: the shape any reader must match to use it. Construct it from a payload with Self::from_payload, or as a reader’s requirement with Self::expected.

Fields§

§format_version: u32§model: String

Identifies the weights the KV state was computed under. The one field no payload can prove about itself – which is exactly why it is checked against the reader’s expectation in step 3.

§n_layers: usize§n_kv_heads: usize§head_dim: usize§dtype: KvDtype§tokens: usize

Token positions actually stored, per layer. Equal to layout.block_size() for any block this module will stamp or verify.

§layout: BlockLayout

How the sequence was cut into blocks, and the sliding window that cut had to line up with. See the module note.

Implementations§

Source§

impl CacheSignature

Source

pub fn from_payload( model: &str, layout: BlockLayout, layers: &[KvCache], ) -> Result<Self, SignatureError>

Derives a signature by measuring layers. There is deliberately no parameter to fill a gap from: every shape field except model and the sliding window comes from the tensors themselves, and even the declared layout’s block size is checked against the depth the tensors actually have.

Fails if the payload cannot describe itself coherently: no layers at all, layers that disagree with each other, a layer whose buffers do not match its own declared shape, or a token depth that is not the block size the layout claims.

Source

pub fn expected( model: &str, layout: BlockLayout, n_layers: usize, n_kv_heads: usize, head_dim: usize, tokens: usize, ) -> Self

A reader’s requirement: the shape this process would compute itself. Never stamped onto a block – only compared against one.

Trait Implementations§

Source§

impl Clone for CacheSignature

Source§

fn clone(&self) -> CacheSignature

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 CacheSignature

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for CacheSignature

Source§

impl PartialEq for CacheSignature

Source§

fn eq(&self, other: &CacheSignature) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CacheSignature

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
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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.