pub struct QuantizedKvLayer {
pub k: Vec<u8>,
pub v: Vec<u8>,
pub past_len: usize,
pub kv_dim: usize,
pub scheme: KvQuant,
}Expand description
One layer’s quantized K/V buffers.
Rows are appended back-to-back. past_len is the number of logical
rows currently stored; the byte buffers carry past_len × kv_dim
elements’ worth of quantized bytes.
Fields§
§k: Vec<u8>§v: Vec<u8>§past_len: usize§kv_dim: usize§scheme: KvQuantImplementations§
Source§impl QuantizedKvLayer
impl QuantizedKvLayer
pub fn new(kv_dim: usize, scheme: KvQuant) -> Result<Self>
Sourcepub fn append_rows(&mut self, k_rows: &[f32], v_rows: &[f32]) -> Result<()>
pub fn append_rows(&mut self, k_rows: &[f32], v_rows: &[f32]) -> Result<()>
Append rows worth of K and V (f32, row-major) — quantizing
each row independently. Caller passes interleaved K then V
blocks via separate slices.
Sourcepub fn read_all(&self) -> Result<(Vec<f32>, Vec<f32>)>
pub fn read_all(&self) -> Result<(Vec<f32>, Vec<f32>)>
Dequantize all stored rows back to f32 (K, V).
Sourcepub fn read_window(&self, window: usize) -> Result<(Vec<f32>, Vec<f32>)>
pub fn read_window(&self, window: usize) -> Result<(Vec<f32>, Vec<f32>)>
Dequantize the last window rows (or all rows if past_len ≤ window).
Sourcepub fn drop_front(&mut self, n_rows: usize) -> Result<()>
pub fn drop_front(&mut self, n_rows: usize) -> Result<()>
Drop the oldest n_rows from this layer (sliding window).
Trait Implementations§
Source§impl Clone for QuantizedKvLayer
impl Clone for QuantizedKvLayer
Source§fn clone(&self) -> QuantizedKvLayer
fn clone(&self) -> QuantizedKvLayer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for QuantizedKvLayer
impl RefUnwindSafe for QuantizedKvLayer
impl Send for QuantizedKvLayer
impl Sync for QuantizedKvLayer
impl Unpin for QuantizedKvLayer
impl UnsafeUnpin for QuantizedKvLayer
impl UnwindSafe for QuantizedKvLayer
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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