Skip to main content

TurboQuantProd

Struct TurboQuantProd 

Source
pub struct TurboQuantProd { /* private fields */ }
Expand description

Unbiased inner-product TurboQuant quantizer.

Implementations§

Source§

impl TurboQuantProd

Source

pub fn new( dimension: usize, bits: u8, mse_seed: u64, qjl_seed: u64, ) -> Result<Self, QuantError>

Create a new inner-product quantizer.

  • dimension: vector dimensionality
  • bits: total bit-width per coordinate (must be ≥ 2)
  • mse_seed: seed for the MSE rotation matrix
  • qjl_seed: seed for the QJL projection (must differ from mse_seed)
Source

pub fn dimension(&self) -> usize

The dimension this quantizer operates on.

Source

pub fn bits(&self) -> u8

The total bit-width per coordinate.

Source

pub fn quantize(&self, x: &[f32]) -> Result<QuantizedProdVector, QuantError>

Quantize a vector.

Source

pub fn dequantize( &self, q: &QuantizedProdVector, ) -> Result<Vec<f32>, QuantError>

Dequantize a vector.

Returns x̃ = x̃_mse + x̃_qjl where x̃_qjl = (√(π/2)/d) · γ · S^T · qjl

Source

pub fn inner_product_estimate( &self, query: &[f32], q: &QuantizedProdVector, ) -> Result<f32, QuantError>

Estimate ⟨query, quantized_x⟩ without full dequantization.

Computes: ⟨query, x̃_mse⟩ + QJL_estimate(query, qjl_bits, γ)

Auto Trait Implementations§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V