pub struct CoherenceCheck {
pub max_relative_errors: [f32; 4],
}Expand description
Per-tier maximum relative error bounds for read-after-write validation.
After a put(), the block is immediately read back and the maximum
relative error (per-element |orig - decoded| / |orig|) is compared
against the bound for the block’s current tier.
Fields§
§max_relative_errors: [f32; 4]Maximum acceptable relative error for each tier, indexed by
Tier as usize: [Tier0, Tier1, Tier2, Tier3].
Tier0 (evicted) has no payload, so any read will fail before the
error comparison is reached. The bound is set to f32::MAX as a
sentinel.
Implementations§
Source§impl CoherenceCheck
impl CoherenceCheck
Sourcepub fn new(max_relative_errors: [f32; 4]) -> Self
pub fn new(max_relative_errors: [f32; 4]) -> Self
Create a CoherenceCheck with custom per-tier error bounds.
Sourcepub fn check_coherence(
&self,
store: &mut TieredStore,
key: BlockKey,
original_data: &[f32],
now: u64,
) -> Result<CoherenceResult, StoreError>
pub fn check_coherence( &self, store: &mut TieredStore, key: BlockKey, original_data: &[f32], now: u64, ) -> Result<CoherenceResult, StoreError>
Validate read-after-write coherence for a block that was just written.
Reads the block back from store, computes the maximum relative
error against original_data, and checks whether it falls within
the configured bound for the block’s tier.
§Errors
Returns StoreError::BlockNotFound if the key does not exist,
StoreError::TensorEvicted if the block is in Tier0, or any
other StoreError from the underlying read.
Sourcepub fn verify_put(
&self,
store: &mut TieredStore,
key: BlockKey,
data: &[f32],
tier: Tier,
now: u64,
) -> Result<CoherenceResult, StoreError>
pub fn verify_put( &self, store: &mut TieredStore, key: BlockKey, data: &[f32], tier: Tier, now: u64, ) -> Result<CoherenceResult, StoreError>
Convenience: put followed by check_coherence in one call.
Stores the data at the given tier, then immediately reads it back and validates the round-trip error. Returns the coherence result so the caller can decide whether to retry at a higher-fidelity tier.
§Errors
Propagates errors from both put and the subsequent get.
Trait Implementations§
Source§impl Clone for CoherenceCheck
impl Clone for CoherenceCheck
Source§fn clone(&self) -> CoherenceCheck
fn clone(&self) -> CoherenceCheck
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more