Skip to main content

SmoothQuantLinearPlan

Struct SmoothQuantLinearPlan 

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

SmoothQuant linear plan — pure Rust composition over the bespoke quantized_linear_w8a8 kernel.

When to use: SmoothQuant inference matmul. Activation has already been smoothed (divided by per-channel s[K]) and quantized per-tensor to int8; weight has already been smoothed (multiplied by s[K]) and quantized per-output-channel to int8; caller passes both, plus the static per-tensor act-scale + per-N weight-scale, to this plan.

Dtypes (trailblazer): TIn (scales/out) ∈ {f32, f64}; TWQ = S8 weight; activation is fixed at S8. f16 / bf16 / u8 weight follow once the underlying quantized_linear_w8a8 kernel grows those dtypes (same matrix as super::QuantizedLinearPlan).

Shape limits: act_q [M, K]; weight_q [N, K]; weight_scale [N]; output [M, N]. [N, K] weight layout matches y = x · W^T (PyTorch nn.Linear.weight).

Workspace: zero in Workspace. Caller supplies act_scale_scratch [M] (FP) in SmoothQuantLinearArgs for the act-scale broadcast.

Precision guarantee: deterministic, bit-stable on the same hardware (inherits from the underlying quantized_linear_w8a8 kernel — register-only int32 accumulator + serial FP scale multiply, no atomics).

Implementations§

Source§

impl<TIn: Element, TWQ: IntElement> SmoothQuantLinearPlan<TIn, TWQ>

Source

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

Pick a kernel for desc.

Source

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

Validate args at run time.

Source

pub fn workspace_size(&self) -> usize

Workspace bytes — none. The act-scale [M] broadcast buffer is caller-owned via the args bundle (act_scale_scratch), allowing reuse across launches.

Source

pub fn sku(&self) -> KernelSku

Identity of the selected kernel.

Source

pub fn precision_guarantee(&self) -> PrecisionGuarantee

Numerical guarantees.

Source

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

Launch.

Two-pass: (1) fill the [M] scratch with the descriptor’s act_scale; (2) launch the quantized_linear_w8a8 kernel directly via the FFI (skips the dynamic-range-quantize pass that super::QuantizedLinearPlan does).

Auto Trait Implementations§

§

impl<TIn, TWQ> Freeze for SmoothQuantLinearPlan<TIn, TWQ>

§

impl<TIn, TWQ> RefUnwindSafe for SmoothQuantLinearPlan<TIn, TWQ>
where TIn: RefUnwindSafe, TWQ: RefUnwindSafe,

§

impl<TIn, TWQ> Send for SmoothQuantLinearPlan<TIn, TWQ>
where TIn: Send, TWQ: Send,

§

impl<TIn, TWQ> Sync for SmoothQuantLinearPlan<TIn, TWQ>
where TIn: Sync, TWQ: Sync,

§

impl<TIn, TWQ> Unpin for SmoothQuantLinearPlan<TIn, TWQ>
where TIn: Unpin, TWQ: Unpin,

§

impl<TIn, TWQ> UnsafeUnpin for SmoothQuantLinearPlan<TIn, TWQ>

§

impl<TIn, TWQ> UnwindSafe for SmoothQuantLinearPlan<TIn, TWQ>
where TIn: UnwindSafe, TWQ: 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.