pub struct QuantizationErrorTracker {
pub history: VecDeque<QuantizationError>,
pub total_vectors: u64,
}Expand description
Tracks quantization error across a rolling window of vectors.
The tracker maintains the last HISTORY_CAPACITY (256) measurements and
exposes rolling statistics that let callers detect when quantization error
is accumulating to unacceptable levels.
Fields§
§history: VecDeque<QuantizationError>Rolling window of recent error measurements (capped at 256).
total_vectors: u64Total number of vectors recorded since creation (monotonically increasing).
Implementations§
Source§impl QuantizationErrorTracker
impl QuantizationErrorTracker
Sourcepub fn compute_error(
&self,
original: &[f32],
quantized: &[f32],
) -> Result<QuantizationError, QErrorError>
pub fn compute_error( &self, original: &[f32], quantized: &[f32], ) -> Result<QuantizationError, QErrorError>
Compute QuantizationError between an original and a quantized vector.
§Errors
QErrorError::EmptyVector– iforiginalis empty.QErrorError::LengthMismatch– if lengths differ.
Sourcepub fn record(&mut self, error: QuantizationError)
pub fn record(&mut self, error: QuantizationError)
Record a QuantizationError measurement into the rolling history.
When the history reaches 256 entries the oldest entry is evicted.
Sourcepub fn rolling_mse(&self) -> f64
pub fn rolling_mse(&self) -> f64
Average MSE over all entries in the rolling history.
Returns 0.0 when the history is empty.
Sourcepub fn rolling_mae(&self) -> f64
pub fn rolling_mae(&self) -> f64
Average MAE over all entries in the rolling history.
Returns 0.0 when the history is empty.
Sourcepub fn p99_mse(&self) -> f64
pub fn p99_mse(&self) -> f64
99th-percentile MSE across the rolling history.
Uses the nearest-rank method: the index is ceil(0.99 * n) - 1 (0-based)
on a sorted copy of the MSE values.
Returns 0.0 when the history is empty.
Sourcepub fn is_quality_acceptable(&self, max_mse: f64) -> bool
pub fn is_quality_acceptable(&self, max_mse: f64) -> bool
Returns true when the rolling MSE is within max_mse.
Sourcepub fn history_len(&self) -> usize
pub fn history_len(&self) -> usize
Returns the number of entries currently in the rolling history.
Sourcepub fn clear_history(&mut self)
pub fn clear_history(&mut self)
Clear all history entries. total_vectors is not reset.
Trait Implementations§
Source§impl Clone for QuantizationErrorTracker
impl Clone for QuantizationErrorTracker
Source§fn clone(&self) -> QuantizationErrorTracker
fn clone(&self) -> QuantizationErrorTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QuantizationErrorTracker
impl Debug for QuantizationErrorTracker
Auto Trait Implementations§
impl Freeze for QuantizationErrorTracker
impl RefUnwindSafe for QuantizationErrorTracker
impl Send for QuantizationErrorTracker
impl Sync for QuantizationErrorTracker
impl Unpin for QuantizationErrorTracker
impl UnsafeUnpin for QuantizationErrorTracker
impl UnwindSafe for QuantizationErrorTracker
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.