|
25 | 25 | //! [`turboquant_pack()`]: crate::turboquant_pack |
26 | 26 | //! [`turboquant_unpack()`]: crate::turboquant_unpack |
27 | 27 | //! |
28 | | -//! The full packed tree is: |
| 28 | +//! The packed storage is a row-aligned extension tree: |
29 | 29 | //! |
30 | 30 | //! ```text |
31 | 31 | //! Extension<TurboQuant>( |
32 | 32 | //! Struct { |
33 | | -//! norms: Primitive<element_ptype>, |
34 | | -//! codes: FixedSizeList<Primitive<u8>, padded_dim>, |
| 33 | +//! norms: Primitive<element_ptype, row_validity>, |
| 34 | +//! codes: FixedSizeList<Primitive<u8>, padded_dim, row_validity>, |
35 | 35 | //! } |
36 | 36 | //! ) |
37 | 37 | //! ``` |
38 | 38 | //! |
39 | | -//! Row validity is stored on the `StructArray`, preserving original vector nulls. The `norms` and |
40 | | -//! `codes` children are non-nullable and may contain deterministic placeholder values for null |
41 | | -//! rows. Centroids are not stored; they are deterministically derived from the padded dimension and |
42 | | -//! bit width, and cached process-locally. |
43 | | -//! |
44 | 39 | //! Stored norms are authoritative for future TurboQuant-aware scalar functions. Decoded quantized |
45 | 40 | //! directions are not guaranteed to have unit norm after scalar quantization and inverse rotation. |
46 | 41 | //! |
47 | | -//! The TurboQuant paper analyzes a full random orthogonal rotation. The current Vortex |
48 | | -//! implementation instead uses a fixed 3-round Walsh-Hadamard-based structured transform with |
49 | | -//! random sign diagonals generated by Vortex's frozen local SplitMix64 stream. This is a practical |
50 | | -//! approximation chosen for encode/decode efficiency, and should be understood as an |
51 | | -//! implementation choice rather than the exact construction used in the paper's proofs. |
52 | | -//! |
53 | | -//! The current encoding is also intentionally MSE-only. It does not yet implement the paper's QJL |
54 | | -//! residual correction for unbiased inner-product estimation, and it still uses internal |
55 | | -//! power-of-2 padding rather than the block decomposition proposed in RFC 0033. |
56 | | -//! |
57 | | -//! # Theoretical error bounds |
| 42 | +//! # Source map |
58 | 43 | //! |
59 | | -//! For unit-norm vectors quantized at `b` bits per coordinate, the paper's Theorem 1 |
60 | | -//! guarantees normalized MSE distortion: |
| 44 | +//! Implementation details are documented next to the code that owns them: |
61 | 45 | //! |
62 | | -//! > `E[||x - x_hat||² / ||x||²] <= (√3 · π / 2) / 4^b` |
| 46 | +//! - `vector/storage.rs`: physical storage shape, full-length child arrays, and field-level |
| 47 | +//! validity for null vectors. |
| 48 | +//! - `vector/normalize.rs`: TurboQuant-local normalization and how it differs from the tensor |
| 49 | +//! crate's null-row zeroing helper. |
| 50 | +//! - `vector/quantize.rs`: SORF rotation, centroid lookup, and why invalid rows are skipped rather |
| 51 | +//! than quantized. |
| 52 | +//! - `centroids.rs`: deterministic Max-Lloyd centroid computation and process-local caching. |
| 53 | +//! - `sorf/`: the Walsh-Hadamard-based structured rotation and the stable SplitMix64 sign stream. |
63 | 54 | //! |
64 | | -//! | Bits | MSE bound | Quality | |
65 | | -//! |------|------------|-------------------| |
66 | | -//! | 1 | 6.80e-01 | Poor | |
67 | | -//! | 2 | 1.70e-01 | Usable for ANN | |
68 | | -//! | 3 | 4.25e-02 | Good | |
69 | | -//! | 4 | 1.06e-02 | Very good | |
70 | | -//! | 5 | 2.66e-03 | Excellent | |
71 | | -//! | 6 | 6.64e-04 | Near-lossless | |
72 | | -//! | 7 | 1.66e-04 | Near-lossless | |
73 | | -//! | 8 | 4.15e-05 | Near-lossless | |
74 | | -//! |
75 | | -//! # Storage notes |
76 | | -//! |
77 | | -//! Each vector is logically stored as `padded_dim` u8 quantized codes plus one stored norm in the |
78 | | -//! vector's element float type. Non-power-of-2 dimensions are padded to the next power of 2 for |
79 | | -//! the structured rotation, which affects the storage size. Physical compression of those child |
80 | | -//! arrays is left to the normal Vortex compressor rather than implemented as a TurboQuant-specific |
81 | | -//! compressor scheme. |
| 55 | +//! The current encoding is intentionally MSE-only. It does not yet implement the paper's QJL |
| 56 | +//! residual correction for unbiased inner-product estimation, and it still uses internal |
| 57 | +//! power-of-2 padding rather than the block decomposition proposed in RFC 0033. |
82 | 58 |
|
83 | 59 | mod centroids; |
84 | 60 | mod config; |
|
0 commit comments