Repository navigation
docs(format): specify PCA model storage and index compatibility - #9968
Conversation
|
Important Format specification voteThis PR modifies the Lance format specification, so it requires 3 binding +1 votes from PMC members (excluding the proposer), at least one of them on the latest commit, and a minimum 72-hour voting period, weekends excluded, before it can merge. Vote by approving this PR (+1) or requesting changes (−1, a veto). See the voting process. Approvals carry over across pushes, so a rebase or a typo fix does not send everyone back to re-vote. Whoever approves the latest commit is vouching that nothing substantive has changed since the earlier approvals; if something has, ask for fresh votes. Status: ❌ Blocked — 0 of 3 required approvals
Updated automatically by the format-spec vote gate, which re-checks every 15 minutes — just voted? Re-check now (press Run workflow; leave the input blank to re-check every open format PR). A PMC member may apply the |
There was a problem hiding this comment.
❌ Gate recommendation: request changes.
Make this a self-contained persisted-format proposal, then land training and search implementation after the contract is agreed. The implementation from #9967 is included in this PR’s live main-based diff. Several independent gaps in the model’s persisted contract also prevent other runtimes from implementing interoperable readers and writers.
Please mark this PR with the breaking-change label.
| /// | ||
| /// Training rejects null or non-finite values. All statistics and matrix | ||
| /// decompositions use `f64`; the returned runtime model uses `f32`. | ||
| pub fn train(data: &FixedSizeListArray, params: &PcaParams) -> Result<Self> { |
There was a problem hiding this comment.
Keep the persisted-format proposal separate from the implementation. Against the live main base, this PR includes the PCA trainer, query decorator, kernels, and dependency additions from #9967. protos/AGENTS.md and docs/src/format/AGENTS.md require a persisted-format PR to contain the schema, matching specification, and only library edits needed to compile, with implementation in a follow-up. The current diff makes that format decision include several thousand lines of runtime code. Please make this main-based diff a self-contained format proposal, including the PcaModel schema, and keep training/search implementation in the follow-up.
There was a problem hiding this comment.
The trainer and query-transform code is now inherited from the merged PCA model PR #9967. The split request remains for the new build-parameter APIs, index-details serialization/validation/JSON, and compatibility-version changes: these implement behavior beyond the edits needed to compile the protobuf addition. Please move that behavior to the build/query follow-up #9970, keeping this proposal to the schema, specification, and compile-required edits.
There was a problem hiding this comment.
Fixed in ef04972: The PR now contains the persisted schema/specification and minimal library changes. PCA build-parameter and metadata behavior has been removed, and version 3 remains reserved rather than advertised as readable.
|
|
||
| An `IVF_RQ` index may store one PCA pre-transform in `VectorIndexDetails.pre_transform`. | ||
| When the field is absent, vectors are indexed in their original dimension. | ||
| When it is present, vectors are projected by the stored `PcaModel` before IVF and |
There was a problem hiding this comment.
Specify how a reader locates and applies the stored model. PcaParameters contains a fingerprint, but no matrix/mean or model pointer, and the format never identifies the file or global buffer containing PcaModel. An independent reader cannot construct the required query projection from this specification. Please define the owning file, the lance:pca schema-metadata entry and buffer numbering, protobuf/tensor encoding and dimension checks, and y = A * (x - mean) semantics, including whether rotation/whitening are baked into A and which metrics are supported. These are the reader-navigation and algorithm rules required by docs/src/format/AGENTS.md.
There was a problem hiding this comment.
Fixed in b16f416: The format now specifies the index.idx global-buffer location, lance:pca pointer and numbering, tensor validation, L2-only projection, and rotation semantics.
| // BLAKE3 fingerprint of the exact trained model applied by the index. | ||
| // This must contain exactly 32 raw bytes and is required whenever this | ||
| // message is present. | ||
| bytes model_fingerprint = 9; |
There was a problem hiding this comment.
Define the canonical input to this required fingerprint. “BLAKE3 fingerprint of the exact trained model” permits incompatible interpretations, such as hashing the protobuf payload or hashing tensor bytes. The Rust recipe hashes the domain separator lance-vector-pre-transform:pca:v1, a little-endian u32 model version, row-major matrix elements, then the mean, using little-endian f32 values with negative zero normalized to positive zero. Another writer following this schema can produce a 32-byte digest that a validating reader rejects for the same model. Please specify that recipe in the format contract and state when the manifest fingerprint must match the loaded model.
There was a problem hiding this comment.
Fixed in b16f416: The format now defines the complete BLAKE3 byte sequence, little-endian encoding, zero-sign normalization, and comparison with the manifest fingerprint on load.
There was a problem hiding this comment.
The fingerprint concern no longer applies to the simplified proposal: the manifest now contains an empty PCA marker, with no digest to canonicalize or compare. Readers obtain the projection and dimensions from the stored model. This finding remains addressed.
Persist PCA parameters in the index manifest and raise the reader version when a pre-transform is present. The IVF_RQ index version stays unchanged.
Document the index.idx model buffer and fingerprint, and persist only the PCA parameters that remain on main.
b16f416 to
e400d7d
Compare
Keep the format CI gates from failing on import order, proto comment style, and helpers the build path has not wired up yet.
The format branch's Python doctest fails on pandas 3's vec_to_table output, and the Windows test run hits the flaky HNSW memtable search that main already stabilized. Merging main brings those fixes in without changing the format contract.
Merge main and preserve its row-address specification. Reserve metadata version 4 for PCA because version 3 is already assigned to the row-address domain. Keep the final PR diff documentation-only.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
Using index metadata version 4 avoids the version 3 allocation for row addresses in merged #10299. The model storage, projection, and dimension contracts remain intact, and this PR stays documentation-only. Runtime support for version 4 remains separate build/query work.
|
skip voting as it's an experimental feature |
The row-address migration was specced at index_version 3 (#10299). Since then #10522 shipped IVF_HNSW_RQ at version 3, so the migration takes 4. PCA (#9968) had claimed 4 and described itself as retaining the domain "introduced by version 3", so it moves to 5. It is not wired into index creation, so no index records either number yet. Co-Authored-By: Claude Opus 5 <[email protected]>
PCA indices need a persisted projection so reopened queries use the same model as index construction. This specification defines how
lance:pcalocates the existingPcaModelprotobuf in anindex.idxglobal buffer, along with the projection, tensor layout, and dimensional constraints.Index metadata version 4 identifies PCA-enabled IVF_RQ indices so readers without PCA support skip them. Version 3 is already assigned to the row-address domain by #10299; PCA version 4 retains that domain, while indices without PCA keep their existing compatibility version. The model and this version contract are sufficient to identify PCA, without adding a manifest marker, training parameters, or a fingerprint.
This PR changes only the format documentation. Build and query integration, including advertising version 4 as readable, belongs in a follow-up.
Validation:
make -C docs buildpassed with placeholders for unavailable external repository docs and existing unrelated link warnings.maincontains only the PCA documentation section; Rust and protobuf files matchmainexactly.Discussion: #9122