pub struct Quant {
pub mode: QuantMode,
pub group_size: i32,
pub bits: i32,
}Expand description
How weights are quantized: a mode, a group size and a bit width. Quant::new gives
MLX’s defaults for a mode; an unsupported combination fails in the operation that uses it
(a failed array, as every operation’s errors).
use nuvec_core::{Quant, QuantMode};
assert_eq!(Quant::new(QuantMode::Mxfp4), Quant { mode: QuantMode::Mxfp4, group_size: 32, bits: 4 });
assert_eq!(Quant::affine(32, 8).bits, 8);
assert_eq!(Quant::default(), Quant::affine(64, 4));Fields§
§mode: QuantModeThe mode.
group_size: i32Values per scale (affine: 32, 64 or 128; mxfp4 and mxfp8: 32; nvfp4: 16).
bits: i32Bits per value (affine: 1–6 or 8; mxfp4 and nvfp4: 4; mxfp8: 8).
Implementations§
Source§impl Quant
impl Quant
Sourcepub const fn new(mode: QuantMode) -> Self
pub const fn new(mode: QuantMode) -> Self
mode with MLX’s default group size and bits: affine 64/4, mxfp4 32/4, mxfp8 32/8,
nvfp4 16/4.
Sourcepub const fn affine(group_size: i32, bits: i32) -> Self
pub const fn affine(group_size: i32, bits: i32) -> Self
Affine quantization with group_size values per scale and bias and bits per value.
Sourcepub const fn group_size(self, group_size: i32) -> Self
pub const fn group_size(self, group_size: i32) -> Self
This quantization with group_size values per scale.
Trait Implementations§
impl Copy for Quant
impl Eq for Quant
impl StructuralPartialEq for Quant
Auto Trait Implementations§
impl Freeze for Quant
impl RefUnwindSafe for Quant
impl Send for Quant
impl Sync for Quant
impl Unpin for Quant
impl UnsafeUnpin for Quant
impl UnwindSafe for Quant
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> Boilerplate for T
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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