Skip to main content

UnifiedQuantizedVector

Struct UnifiedQuantizedVector 

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

Owned, 128-byte-aligned unified quantized vector buffer.

Layout (contiguous bytes):

[ QuantHeader (32 B) | packed_bits (variable) | outlier_payload (8 B × n) | tail_pad ]

The total allocation is always a multiple of 128 bytes (one AVX-512 cache-line pair).

Implementations§

Source§

impl UnifiedQuantizedVector

Source

pub fn new( header: QuantHeader, packed_bits: &[u8], outliers: &[(u32, f32)], ) -> Result<Self, CodecError>

Construct from an explicit header, packed-bit slice, and sparse outlier list.

outliers is a slice of (dim_index, value) pairs. The outlier_bitmask in header must have exactly one bit set for each entry in outliers, and bits must correspond to entries in ascending dim_index order (i.e. popcnt-dense order).

§Errors

Returns CodecError::LayoutError if:

  • outliers.len() does not match popcnt(header.outlier_bitmask).
  • Any dim_index in outliers is ≥ 64 (bitmask only covers 64 dims).
Source

pub fn header(&self) -> &QuantHeader

Zero-copy reference to the header (first 32 bytes).

Source

pub fn packed_bits(&self) -> &[u8]

Slice of the packed-bit region.

Source

pub fn outlier_count(&self) -> u32

Number of outlier entries, computed via popcnt of outlier_bitmask.

Source

pub fn outlier_at(&self, slot: u32) -> Option<(u32, f32)>

Return the outlier (dim_index, value) for the dimension at position slot in the bitmask.

slot is the dimension index (0–63). Returns None if the bit for slot is not set in outlier_bitmask, or if slot ≥ 64.

Uses a branchless popcnt to find the dense offset into the outlier payload.

Source

pub fn as_bytes(&self) -> &[u8]

Full backing buffer suitable for direct I/O.

Trait Implementations§

Source§

impl AsRef<UnifiedQuantizedVector> for BbqQuantized

Source§

fn as_ref(&self) -> &UnifiedQuantizedVector

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<UnifiedQuantizedVector> for OpqQuantized

Source§

fn as_ref(&self) -> &UnifiedQuantizedVector

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<UnifiedQuantizedVector> for RaBitQQuantized

Source§

fn as_ref(&self) -> &UnifiedQuantizedVector

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<UnifiedQuantizedVector> for TernaryQuantized

Source§

fn as_ref(&self) -> &UnifiedQuantizedVector

Converts this type into a shared reference of the (usually inferred) input type.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.