Skip to main content

Crate ruvector_temporal_tensor

Crate ruvector_temporal_tensor 

Source
Expand description

Temporal Tensor Compression with Tiered Quantization

Implements ADR-017: groupwise symmetric quantization with temporal segment reuse and access-pattern-driven tier selection (8/7/5/3 bit).

§Architecture

f32 frame → tier_policy → quantizer → bitpack → segment
segment → bitpack → quantizer → f32 output

§Compression Ratios

TierBitsRatio vs f32Use Case
Hot8~4.0xFrequently accessed tensors
Warm7~4.57xModerately accessed
Warm5~6.4xAggressively compressed warm
Cold3~10.67xRarely accessed

§Zero Dependencies

This crate has no external dependencies, making it fully WASM-compatible.

§Quick Start

use ruvector_temporal_tensor::{TemporalTensorCompressor, TierPolicy};

// Create a compressor for 128-element tensors
let mut comp = TemporalTensorCompressor::new(TierPolicy::default(), 128, 0);
comp.set_access(100, 0); // hot tensor -> 8-bit quantization

let frame = vec![1.0f32; 128];
let mut segment = Vec::new();

// Push frames; segment is populated when a boundary is crossed
comp.push_frame(&frame, 1, &mut segment);
comp.flush(&mut segment); // force-emit the current segment

// Decode the segment back to f32
let mut decoded = Vec::new();
ruvector_temporal_tensor::segment::decode(&segment, &mut decoded);
assert_eq!(decoded.len(), 128);

§Random-Access Decode

// Decode only frame 0 without decoding the entire segment
let single = ruvector_temporal_tensor::segment::decode_single_frame(&seg, 0);
assert!(single.is_some());

§Compression Ratio Inspection

let ratio = ruvector_temporal_tensor::segment::compression_ratio(&seg);
assert!(ratio > 1.0);

Re-exports§

pub use compressor::TemporalTensorCompressor;
pub use tier_policy::TierPolicy;

Modules§

agentdb
AgentDB adapter for pattern-aware tiering.
bitpack
Bitstream packer/unpacker for arbitrary bit widths (1-8).
coherence
Coherence gate: read-after-write validation for the temporal tensor store.
compressor
TemporalTensorCompressor: the main entry point.
core_trait
Abstract trait interface for tensor block storage.
delta
Delta compression, delta chains, and reconstruction policies (ADR-021).
f16
Software IEEE 754 half-precision (f16) conversion.
metrics
Witness logging and decision audit for the temporal tensor store.
quantizer
Groupwise symmetric quantization with f16 scales.
segment
Segment binary format: encode and decode.
store
Block-based storage engine for temporal tensor compression (ADR-018).
tier_policy
Tier policy for access-pattern-driven bit-width selection.
tiering
Enhanced temporal scoring with EMA + popcount + recency, hysteresis, and budgeted maintenance (ADR-020).