Skip to main content

GgufBlockFormat

Enum GgufBlockFormat 

Source
#[non_exhaustive]
#[repr(u16)]
pub enum GgufBlockFormat { Q4_0 = 2, Q4_1 = 3, Q5_0 = 6, Q5_1 = 7, Q8_0 = 8, Q2K = 10, Q3K = 11, Q4K = 12, Q5K = 13, Q6K = 14, Q8K = 15, }
Expand description

GGUF block-format selector for QuantizeKind::GgufDequantize / QuantizeKind::GgufMmvq plans. Mirrors the discriminants used by llama.cpp / ggml so a descriptor can be round-tripped to a GGUF file header without translation.

Block sizes:

  • Type-0/1 variants (Q4_0, Q4_1, Q5_0, Q5_1, Q8_0) pack 32 quantized values per block plus a shared FP scale (+ min for the _1 variants).
  • k-quants variants (Q2_KQ8_K) pack 256 values per super-block with a multi-level scale hierarchy (quantized sub-block scales + FP super-block scale).

Discriminant values match the GGML_TYPE_* enum in upstream ggml.h, ensuring binary compatibility with GGUF file headers.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Q4_0 = 2

4-bit, 32-element block, single FP scale. block_q4_0.

§

Q4_1 = 3

4-bit, 32-element block, FP scale + FP min. block_q4_1.

§

Q5_0 = 6

5-bit, 32-element block, single FP scale. block_q5_0.

§

Q5_1 = 7

5-bit, 32-element block, FP scale + FP min. block_q5_1.

§

Q8_0 = 8

8-bit, 32-element block, single FP scale. block_q8_0.

§

Q2K = 10

2.5-bit (effective), 256-element super-block. block_q2_K.

§

Q3K = 11

3.4-bit (effective), 256-element super-block. block_q3_K.

§

Q4K = 12

4.5-bit (effective), 256-element super-block. block_q4_K.

§

Q5K = 13

5.5-bit (effective), 256-element super-block. block_q5_K.

§

Q6K = 14

6.6-bit (effective), 256-element super-block. block_q6_K.

§

Q8K = 15

8-bit, 256-element super-block (CPU-side intermediate). block_q8_K. Dequant supported; MMVQ NOT supported (matches llama.cpp — no upstream MMVQ specialization).

Implementations§

Source§

impl GgufBlockFormat

Source

pub const fn block_size(self) -> usize

Number of FP elements per packed block.

Source

pub const fn type_size(self) -> usize

Number of bytes per packed block. Matches sizeof(block_q*) from ggml.h. Used by the Rust plan layer to size the input weight buffer.

Source

pub const fn is_type_01(self) -> bool

true for the type-0/1 family (32-element blocks); false for the k-quants family (256-element super-blocks).

Source

pub const fn has_mmvq(self) -> bool

true if MMVQ (fused dequant + matvec) is supported for this block format. As of Phase 11.4, all 11 GGUF block formats ship a MMVQ kernel. Q8_K MMVQ is a bespoke baracuda addition (upstream llama.cpp / Fuel reserve Q8_K as a CPU-side intermediate and ship dequant only); we close that gap to avoid 2× memory traffic on the inference decode step.

Trait Implementations§

Source§

impl Clone for GgufBlockFormat

Source§

fn clone(&self) -> GgufBlockFormat

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 Copy for GgufBlockFormat

Source§

impl Debug for GgufBlockFormat

Source§

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

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

impl Eq for GgufBlockFormat

Source§

impl Hash for GgufBlockFormat

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for GgufBlockFormat

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for GgufBlockFormat

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