Skip to main content

DynQuantizedStorage

Trait DynQuantizedStorage 

Source
pub trait DynQuantizedStorage:
    Send
    + Sync
    + Debug {
Show 15 methods // Required methods fn dtype(&self) -> GgmlDType; fn block_size(&self) -> usize; fn storage_size_in_bytes(&self) -> usize; fn quantize(&mut self, src: &dyn DynBackendStorage) -> Result<(), Error>; fn quantize_imatrix( &mut self, src: &dyn DynBackendStorage, imatrix_weights: &[f32], n_per_row: usize, ) -> Result<(), Error>; fn quantize_onto( &mut self, src: &dyn DynBackendStorage, ) -> Result<(), Error>; fn quantize_imatrix_onto( &mut self, src: &dyn DynBackendStorage, imatrix_weights: &[f32], n_per_row: usize, ) -> Result<(), Error>; fn dequantize( &self, elem_count: usize, ) -> Result<Box<dyn DynBackendStorage>, Error>; fn data(&self) -> Result<Cow<'_, [u8]>, Error>; fn fwd( &self, self_shape: &Shape, input: &dyn DynBackendStorage, layout: &Layout, ) -> Result<(Box<dyn DynBackendStorage>, Shape), Error>; fn as_any(&self) -> &(dyn Any + 'static); fn device_arc_dyn(&self) -> Arc<dyn DynBackendDevice> ⓘ; // Provided methods fn dequantize_f16( &self, _elem_count: usize, ) -> Result<Box<dyn DynBackendStorage>, Error> { ... } fn device_ptr(&self) -> Result<*const u8, Error> { ... } fn indexed_moe_forward( &self, _self_shape: &Shape, _input: &dyn DynBackendStorage, _input_layout: &Layout, _ids: &dyn DynBackendStorage, _ids_layout: &Layout, ) -> Result<(Box<dyn DynBackendStorage>, Shape), Error> { ... }
}
Expand description

Object-safe per-backend quantized storage. Each backend (CPU, CUDA, Metal, …) supplies a concrete type that implements this trait; fuel-core holds them as Box<dyn DynQuantizedStorage> and dispatches without naming backends.

The _src arguments to quantize* are typed as &dyn DynBackendStorage so the implementor can downcast to its own concrete storage; the _onto variants take a HostBuffer-shaped CPU source.

Required Methods§

Source

fn dtype(&self) -> GgmlDType

Source

fn block_size(&self) -> usize

Source

fn storage_size_in_bytes(&self) -> usize

Source

fn quantize(&mut self, src: &dyn DynBackendStorage) -> Result<(), Error>

Quantize an in-device source storage onto self.

Source

fn quantize_imatrix( &mut self, src: &dyn DynBackendStorage, imatrix_weights: &[f32], n_per_row: usize, ) -> Result<(), Error>

Quantize with importance-matrix weighting.

Source

fn quantize_onto(&mut self, src: &dyn DynBackendStorage) -> Result<(), Error>

Quantize a CPU source onto self (cross-device).

Source

fn quantize_imatrix_onto( &mut self, src: &dyn DynBackendStorage, imatrix_weights: &[f32], n_per_row: usize, ) -> Result<(), Error>

Quantize with importance matrix from a CPU source.

Source

fn dequantize( &self, elem_count: usize, ) -> Result<Box<dyn DynBackendStorage>, Error>

Dequantize to backend-native f32 storage.

Source

fn data(&self) -> Result<Cow<'_, [u8]>, Error>

Raw bytes of the quantized data (host-readable copy).

Source

fn fwd( &self, self_shape: &Shape, input: &dyn DynBackendStorage, layout: &Layout, ) -> Result<(Box<dyn DynBackendStorage>, Shape), Error>

QMatMul forward against an in-device input storage. Returns a fresh device storage and its output shape. self_shape is the weight shape (the QTensor’s own shape).

Source

fn as_any(&self) -> &(dyn Any + 'static)

Identity returns the host device tag this storage is on.

Source

fn device_arc_dyn(&self) -> Arc<dyn DynBackendDevice> ⓘ

Owning device handle. Lets fuel-core recover a Device from a QTensor without keeping a parallel device field on QTensor.

Provided Methods§

Source

fn dequantize_f16( &self, _elem_count: usize, ) -> Result<Box<dyn DynBackendStorage>, Error>

Dequantize to f16 (CUDA fast path; default impl rejects).

Source

fn device_ptr(&self) -> Result<*const u8, Error>

Device pointer for callers that need raw addressing (CUDA only today).

Source

fn indexed_moe_forward( &self, _self_shape: &Shape, _input: &dyn DynBackendStorage, _input_layout: &Layout, _ids: &dyn DynBackendStorage, _ids_layout: &Layout, ) -> Result<(Box<dyn DynBackendStorage>, Shape), Error>

Indexed MoE forward (CUDA-only today; default rejects).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§