Skip to main content

QDType

Enum QDType 

Source
pub enum QDType {
Show 21 variants Q4_0, Q4_1, Q5_0, Q5_1, Q8_0, Q8_1, Q2_K, Q3_K, Q4_K, Q5_K, Q6_K, Q8_K, IQ2_XXS, IQ2_XS, IQ2_S, IQ3_XXS, IQ3_S, IQ1_S, IQ1_M, IQ4_NL, IQ4_XS,
}
Expand description

Quantized data type of a GGUF super-block.

The numeric codes match the ggml_type enum (ggml.h): the same codes Tensor::load_gguf matches on. Every variant loads as raw [num_blocks, block_bytes] DType::U8 via load_gguf and decodes to dense floats via Tensor::dequantize.

Variants§

§

Q4_0

4-bit, 32 elements in 18 bytes (block_q4_0).

§

Q4_1

4-bit, 32 elements in 20 bytes (block_q4_1).

§

Q5_0

5-bit, 32 elements in 22 bytes (block_q5_0).

§

Q5_1

5-bit, 32 elements in 24 bytes (block_q5_1).

§

Q8_0

8-bit, 32 elements in 34 bytes (block_q8_0).

§

Q8_1

8-bit, 32 elements in 36 bytes (block_q8_1).

§

Q2_K

2-bit super-block, 256 elements in 84 bytes (block_q2_K).

§

Q3_K

3-bit super-block, 256 elements in 110 bytes (block_q3_K).

§

Q4_K

4-bit super-block, 256 elements in 144 bytes (block_q4_K).

§

Q5_K

5-bit super-block, 256 elements in 176 bytes (block_q5_K).

§

Q6_K

6-bit super-block, 256 elements in 210 bytes (block_q6_K).

§

Q8_K

8-bit super-block, 256 elements in 292 bytes (block_q8_K).

§

IQ2_XXS

Improved 2-bit, 256 elements in 66 bytes (block_iq2_xxs).

§

IQ2_XS

Improved 2-bit, 256 elements in 74 bytes (block_iq2_xs).

§

IQ2_S

Improved 2-bit, 256 elements in 82 bytes (block_iq2_s).

§

IQ3_XXS

Improved 3-bit, 256 elements in 98 bytes (block_iq3_xxs).

§

IQ3_S

Improved 3-bit, 256 elements in 110 bytes (block_iq3_s).

§

IQ1_S

Improved 1-bit, 256 elements in 50 bytes (block_iq1_s).

§

IQ1_M

Improved 1-bit, 256 elements in 56 bytes (block_iq1_m).

§

IQ4_NL

Non-linear 4-bit, 32 elements in 18 bytes (block_iq4_nl).

§

IQ4_XS

Non-linear 4-bit, 256 elements in 136 bytes (block_iq4_xs).

Implementations§

Source§

impl QDType

Source

pub const fn gguf_code(self) -> u32

GGUF type code of this quant (ggml.h numbering).

Source

pub const fn elems_per_block(self) -> i64

Number of elements one super-block decodes to.

Source

pub const fn block_bytes(self) -> i64

Size in bytes of one super-block on disk.

Source

pub const fn from_code(code: u32) -> Option<Self>

Maps a GGUF type code to a QDType, or None for dense codes (F32, F16, ints) and removed/unsupported codes.

Trait Implementations§

Source§

impl Clone for QDType

Source§

fn clone(&self) -> QDType

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 QDType

Source§

impl DeBin for QDType

Source§

fn de_bin(o: &mut usize, d: &[u8]) -> Result<Self, DeBinErr>

Parse Self from the input bytes starting at index offset. Read more
Source§

fn deserialize_bin(d: &[u8]) -> Result<Self, DeBinErr>

Parse Self from the input bytes. Read more
Source§

impl Debug for QDType

Source§

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

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

impl Display for QDType

Source§

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

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

impl Eq for QDType

Source§

impl Hash for QDType

Source§

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

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 Ord for QDType

Source§

fn cmp(&self, other: &QDType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for QDType

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for QDType

Source§

fn partial_cmp(&self, other: &QDType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl SerBin for QDType

Source§

fn ser_bin(&self, s: &mut Vec<u8>)

Serialize Self to bytes. Read more
Source§

fn serialize_bin(&self) -> Vec<u8> ⓘ

Serialize Self to bytes. Read more
Source§

impl StructuralPartialEq for QDType

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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.