Skip to main content

Quantization

Enum Quantization 

Source
pub enum Quantization {
Show 63 variants Iq1S, Iq1M, UdIq1S, UdIq1M, Tq1_0, UdTq1_0, Iq2Xxs, UdIq2Xxs, Iq2Xs, Iq2S, Iq2M, UdIq2M, Q2KXl, Q2KL, Q2K, Iq3Xxs, UdIq3Xxs, Iq3Xs, Iq3S, UdIq3S, Iq3M, Q3KXl, Q3KL, Q3KM, UdQ3KM, Q3KS, UdQ3KS, Iq4Xs, UdIq4Xs, Iq4Nl, UdIq4Nl, Q4KXl, Q4KL, Q4KM, UdQ4KM, Q4KS, UdQ4KS, Q4_1, Q4_0, Mxfp4, Q4, Q5KXl, Q5KL, Q5KM, UdQ5KM, Q5KS, UdQ5KS, Q5_0, Q5_1, Q5, Q6KXl, Q6KL, Q6K, UdQ6K, Q6, Q8KXl, Q8_0, Q8, Bf16, F16, F32, Imatrix, Unknown,
}
Expand description

Represents the quantization type of a GGUF model file.

This enum provides type-safe handling of quantization types commonly used in GGUF model naming conventions.

§Unsloth Dynamic (“UD-”) quants

Unsloth publishes many repos with both a plain quant (e.g. Q6_K) and a “UD-” prefixed Unsloth Dynamic quant (e.g. UD-Q6_K) that otherwise shares the exact same bit-depth suffix. These are modeled as distinct variants (Q6K vs UdQ6K) so they are never conflated: without this distinction, a naive filename match would treat Q6_K/model.gguf and UD-Q6_K/model.gguf as the same quantization, which previously caused both to be downloaded together as if they were shards of one request. See from_filename for how the “UD-” modifier is detected.

Variants§

§

Iq1S

§

Iq1M

§

UdIq1S

Unsloth Dynamic (“UD-”) variant of Self::Iq1S.

§

UdIq1M

Unsloth Dynamic (“UD-”) variant of Self::Iq1M.

§

Tq1_0

§

UdTq1_0

Unsloth Dynamic (“UD-”) variant of Self::Tq1_0.

§

Iq2Xxs

§

UdIq2Xxs

Unsloth Dynamic (“UD-”) variant of Self::Iq2Xxs.

§

Iq2Xs

§

Iq2S

§

Iq2M

§

UdIq2M

Unsloth Dynamic (“UD-”) variant of Self::Iq2M.

§

Q2KXl

§

Q2KL

§

Q2K

§

Iq3Xxs

§

UdIq3Xxs

Unsloth Dynamic (“UD-”) variant of Self::Iq3Xxs.

§

Iq3Xs

§

Iq3S

§

UdIq3S

Unsloth Dynamic (“UD-”) variant of Self::Iq3S.

§

Iq3M

§

Q3KXl

§

Q3KL

§

Q3KM

§

UdQ3KM

Unsloth Dynamic (“UD-”) variant of Self::Q3KM.

§

Q3KS

§

UdQ3KS

Unsloth Dynamic (“UD-”) variant of Self::Q3KS.

§

Iq4Xs

§

UdIq4Xs

Unsloth Dynamic (“UD-”) variant of Self::Iq4Xs.

§

Iq4Nl

§

UdIq4Nl

Unsloth Dynamic (“UD-”) variant of Self::Iq4Nl.

§

Q4KXl

§

Q4KL

§

Q4KM

§

UdQ4KM

Unsloth Dynamic (“UD-”) variant of Self::Q4KM.

§

Q4KS

§

UdQ4KS

Unsloth Dynamic (“UD-”) variant of Self::Q4KS.

§

Q4_1

§

Q4_0

§

Mxfp4

§

Q4

§

Q5KXl

§

Q5KL

§

Q5KM

§

UdQ5KM

Unsloth Dynamic (“UD-”) variant of Self::Q5KM.

§

Q5KS

§

UdQ5KS

Unsloth Dynamic (“UD-”) variant of Self::Q5KS.

§

Q5_0

§

Q5_1

§

Q5

§

Q6KXl

§

Q6KL

§

Q6K

§

UdQ6K

Unsloth Dynamic (“UD-”) variant of Self::Q6K.

§

Q6

§

Q8KXl

§

Q8_0

§

Q8

§

Bf16

§

F16

§

F32

§

Imatrix

§

Unknown

Implementations§

Source§

impl Quantization

Source

pub const fn is_unknown(&self) -> bool

Returns true if this quantization type is unknown.

Source

pub fn from_filename(filename: &str) -> Self

Extract quantization type from a filename.

Matching is boundary-aware and allocation-free: a pattern only counts as a match when it is flanked by non-alphanumeric characters (or the start/end of the string), which avoids false positives against unrelated alphanumeric substrings in a model name. When multiple patterns match, the longest one wins, so correctness does not depend on QUANT_PATTERNS ordering.

Unsloth’s “UD-” (“Unsloth Dynamic”) naming convention is detected as an orthogonal, delimited token immediately preceding the matched base pattern (see UD_VARIANT_MAP), rather than by duplicating full pattern strings like "UD-Q6_K" — this keeps e.g. Q6_K and UD-Q6_K as distinct values even though they share the same underlying bit-depth pattern.

Source

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

Get the canonical string representation.

Source

pub fn canonical_patterns() -> impl Iterator<Item = &'static str>

Every canonical filename pattern string recognized by Self::from_filename, for callers that need to generate candidate filenames rather than match an existing one — e.g. probing a repository for known-quantization files when a richer listing API is unavailable.

Exposes only the pattern strings, not the private "UD-" variant table: candidate generation only needs the string half, and the smaller surface avoids committing to more than the current caller needs.

Trait Implementations§

Source§

impl Clone for Quantization

Source§

fn clone(&self) -> Quantization

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 Debug for Quantization

Source§

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

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

impl Default for Quantization

Source§

fn default() -> Quantization

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Quantization

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Quantization

Source§

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

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

impl FromStr for Quantization

Source§

type Err = ()

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

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

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

impl PartialEq for Quantization

Source§

fn eq(&self, other: &Quantization) -> 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 Serialize for Quantization

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Quantization

Source§

impl Eq for Quantization

Source§

impl StructuralPartialEq for Quantization

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.

§

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> Same for T

Source§

type Output = T

Should always be Self
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,