Skip to main content

QuantizePerGroupPlan

Struct QuantizePerGroupPlan 

Source
pub struct QuantizePerGroupPlan<TIn: Element, TOut: IntElement> { /* private fields */ }
Expand description

quantize_per_group forward plan.

Per-group quantization along the rightmost axis. Each contiguous group of group_size elements gets its own (scale, zp) pair.

When to use: INT4 LLM weight quantization (GPTQ / AWQ / GGML), typically group_size = 128. Pair with QuantizePerGroupBackwardPlan for STE. For per-channel quant use QuantizePerChannelPlan.

Dtypes: input FP {f32, f64, f16, bf16} × output int {s8, u8}. scale is input dtype; zero_point is i32.

Shape limits: rank-2 [outer_size, axis_size] (caller flattens higher-rank inputs); axis_size % group_size == 0; group_size > 0; scale and zero_point are [outer_size, num_groups]. Quant axis must be the rightmost axis (a permute is the caller’s responsibility otherwise). q_max ≥ q_min.

Workspace: none.

Precision guarantee: deterministic, bit-stable. Round-ties- even.

Implementations§

Source§

impl<TIn: Element, TOut: IntElement> QuantizePerGroupPlan<TIn, TOut>

Source

pub fn select( _stream: &Stream, desc: &QuantizePerGroupDescriptor, _pref: PlanPreference, ) -> Result<Self>

Pick a kernel for desc.

Source

pub fn can_implement( &self, args: &QuantizePerGroupArgs<'_, TIn, TOut>, ) -> Result<()>

Validate args.

Source

pub fn workspace_size(&self) -> usize

Workspace bytes — none.

Source

pub fn sku(&self) -> KernelSku

Identity.

Source

pub fn precision_guarantee(&self) -> PrecisionGuarantee

Numerical guarantees.

Source

pub fn run( &self, stream: &Stream, _workspace: Workspace<'_>, args: QuantizePerGroupArgs<'_, TIn, TOut>, ) -> Result<()>

Launch.

Auto Trait Implementations§

§

impl<TIn, TOut> Freeze for QuantizePerGroupPlan<TIn, TOut>

§

impl<TIn, TOut> RefUnwindSafe for QuantizePerGroupPlan<TIn, TOut>
where TIn: RefUnwindSafe, TOut: RefUnwindSafe,

§

impl<TIn, TOut> Send for QuantizePerGroupPlan<TIn, TOut>
where TIn: Send, TOut: Send,

§

impl<TIn, TOut> Sync for QuantizePerGroupPlan<TIn, TOut>
where TIn: Sync, TOut: Sync,

§

impl<TIn, TOut> Unpin for QuantizePerGroupPlan<TIn, TOut>
where TIn: Unpin, TOut: Unpin,

§

impl<TIn, TOut> UnsafeUnpin for QuantizePerGroupPlan<TIn, TOut>

§

impl<TIn, TOut> UnwindSafe for QuantizePerGroupPlan<TIn, TOut>
where TIn: UnwindSafe, TOut: UnwindSafe,

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