pub struct Fp8KvCache {
pub layers: Vec<Fp8KvLayer>,
}Expand description
Full multi-layer FP8-quantized KV cache for autoregressive decoding.
Wraps one Fp8KvLayer per transformer layer and exposes per-layer
mutable and immutable accessors. All layers share the same format,
num_kv_heads, head_dim, and capacity.
Fields§
§layers: Vec<Fp8KvLayer>Per-transformer-layer FP8 KV stores.
Implementations§
Source§impl Fp8KvCache
impl Fp8KvCache
Sourcepub fn new(
num_layers: usize,
num_kv_heads: usize,
head_dim: usize,
capacity: usize,
format: Fp8KvFormat,
) -> Self
pub fn new( num_layers: usize, num_kv_heads: usize, head_dim: usize, capacity: usize, format: Fp8KvFormat, ) -> Self
Allocate a new FP8 KV cache for num_layers transformer layers.
Each layer is pre-allocated for capacity token positions.
Sourcepub fn layer(&self, layer_idx: usize) -> &Fp8KvLayer
pub fn layer(&self, layer_idx: usize) -> &Fp8KvLayer
Sourcepub fn layer_mut(&mut self, layer_idx: usize) -> &mut Fp8KvLayer
pub fn layer_mut(&mut self, layer_idx: usize) -> &mut Fp8KvLayer
Sourcepub fn num_layers(&self) -> usize
pub fn num_layers(&self) -> usize
Number of transformer layers in this cache.
Sourcepub fn total_memory_bytes(&self) -> usize
pub fn total_memory_bytes(&self) -> usize
Total memory used across all layers in bytes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Fp8KvCache
impl RefUnwindSafe for Fp8KvCache
impl Send for Fp8KvCache
impl Sync for Fp8KvCache
impl Unpin for Fp8KvCache
impl UnsafeUnpin for Fp8KvCache
impl UnwindSafe for Fp8KvCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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