KvCacheDtype

Enum KvCacheDtype 

Source
pub enum KvCacheDtype {
Show 16 variants Bf16, Fp8, Nvfp4, Turbo4, Turbo3, Turbo2, Turbo8, Turbo4KTurbo3V, Turbo4KTurbo8V, Turbo3KTurbo8V, Bf16KTurbo4V, Bf16KTurbo3V, Fp8KTurbo4V, Fp8KTurbo3V, Bf16KTurbo2V, Fp8KTurbo2V,
}
Expand description

2026-09-25: KV cache storage format. A symmetric variant uses one format for K and V; a *K*V variant names the K format, then the V format (kv_pair).

Variants§

§

Bf16

2026-09-25: BF16, 2 bytes per element.

§

Fp8

2026-09-25: FP8 E4M3, 1 byte per element, with one scale per tensor (the k_scale/v_scale arguments of reshape_and_cache_flash_fp8).

§

Nvfp4

2026-09-25: E2M1 values, two per byte, plus one FP8 E4M3 scale byte per 16-element group: 4.5 bits per element.

§

Turbo4

2026-09-25: WHT-rotated 16-level Lloyd-Max codebook (TURBO4_LUT) in the Nvfp4 byte layout.

§

Turbo3

2026-09-25: WHT-rotated 8-level Lloyd-Max codebook (TURBO3_LUT), 8 values in 3 bytes plus one FP8 scale byte per group: 3.5 bits per element, 22% smaller than Turbo4.

§

Turbo2

2026-09-25: WHT-rotated 4-level codebook, 4 values per byte plus one FP8 scale byte per group: 2.5 bits per element, 6.4x smaller than Bf16. The server’s auto_high_precision_layers gives this dtype a larger high-precision boundary than the other symmetric turbo dtypes.

§

Turbo8

2026-09-25: WHT-rotated FP8 E4M3 data plus one BF16 scale per group: 9 bits per element, 12.5% more than Fp8.

§

Turbo4KTurbo3V

2026-09-25: K Turbo4, V Turbo3: 8 bits per K+V element pair, against 9 for Turbo4.

§

Turbo4KTurbo8V

2026-09-25: K Turbo4, V Turbo8: 13.5 bits per K+V element pair, against 18 for Turbo8.

§

Turbo3KTurbo8V

2026-09-25: K Turbo3, V Turbo8.

§

Bf16KTurbo4V

2026-09-25: K Bf16, V Turbo4.

§

Bf16KTurbo3V

2026-09-25: K Bf16, V Turbo3.

§

Fp8KTurbo4V

2026-09-25: K Fp8, V Turbo4.

§

Fp8KTurbo3V

2026-09-25: K Fp8, V Turbo3.

§

Bf16KTurbo2V

2026-09-25: K Bf16, V Turbo2.

§

Fp8KTurbo2V

2026-09-25: K Fp8, V Turbo2.

Implementations§

Source§

impl KvCacheDtype

Source

pub const ALL: [KvCacheDtype; 16]

2026-09-25: Every variant, in declaration order. Nothing checks that a new variant is added here; add it together with its KvCacheDtype::name arm, which the compiler does require.

Source

pub const fn name(self) -> &'static str

2026-09-25: The canonical --kv-cache-dtype spelling. Display delegates here, so a listed value is the string FromStr accepts; the tests below check that round trip.

Source§

impl KvCacheDtype

Source

pub fn kv_pair(self) -> (KvCacheDtype, KvCacheDtype)

2026-09-25: The (K, V) formats. A symmetric variant returns (self, self).

Source

pub fn is_wht_rotated(self) -> bool

2026-09-25: True for the symmetric turbo formats, whose cache contents are in the WHT-rotated basis: write_kv_cache.rs runs wht_bf16_inplace on K and V before the turbo write. The decode attention calls it on each side of kv_pair(), applying the WHT to Q when K is rotated and the inverse WHT to the output when V is rotated. A *K*V variant itself returns false, so call it on a side.

Source

pub fn is_asymmetric(self) -> bool

2026-09-25: True if K and V use different formats.

Trait Implementations§

Source§

impl Clone for KvCacheDtype

Source§

fn clone(&self) -> KvCacheDtype

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KvCacheDtype

Source§

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

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

impl Display for KvCacheDtype

Source§

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

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

impl FromStr for KvCacheDtype

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for KvCacheDtype

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for KvCacheDtype

Source§

impl Eq for KvCacheDtype

Source§

impl StructuralPartialEq for KvCacheDtype

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. 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,

§

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