Skip to main content

DynamicRangeQuantizePlan

Struct DynamicRangeQuantizePlan 

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

dynamic_range_quantize plan.

Composes per-row max-abs reduction + scale computation + per-row quantize into a single fused kernel launch (the dynamic-range recipe IS the fused composition — running the reduce and quantize as one kernel avoids a scale-buffer round-trip).

The trailblazer kernel is symmetric per-token only. Future fanout adds asymmetric mode (requires xmin + xmax reductions) and the other three scopes (tensor / channel / group) by orchestrating existing primitives.

When to use: post-training activation quantization at inference — compute scale from runtime range and quantize in one launch. No BW (inference-only).

Dtypes (trailblazer): TIn ∈ {f32, f64}, TOut = S8. f16 / bf16 activation, u8 output, and asymmetric mode gated as Unsupported until follow-up milestones wire the xmin/xmax reductions and offset-compute kernel.

Shape limits: rank-2 [N, D]; N ≤ 65535 (block-per-row grid cap, lifts when row tiling lands); q_max > 0 (symmetric divisor); q_max ≥ q_min.

Workspace: none — single-launch fused kernel.

Precision guarantee: deterministic, bit-stable. One block per row, no atomics; block-tree reduction is associative-stable on a single GPU.

Implementations§

Source§

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

Source

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

Pick a kernel for desc.

Source

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

Validate args at run time.

Source

pub fn workspace_size(&self) -> usize

Workspace bytes — none. The kernel is single-launch.

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: DynamicRangeQuantizeArgs<'_, TIn, TOut>, ) -> Result<()>

Launch.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<TIn, TOut> UnwindSafe for DynamicRangeQuantizePlan<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.