Skip to content

fix: preserve cross-platform index layouts and IVF query parameters - #827

Open
iaojnh wants to merge 14 commits into
alibaba:mainfrom
iaojnh:codex/index-platform-compatibility
Open

iaojnh wants to merge 14 commits into
alibaba:mainfrom
iaojnh:codex/index-platform-compatibility

Conversation

@iaojnh

@iaojnh iaojnh commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Indexes written with 4 KiB pages can fail to open or interpret persisted graph offsets correctly on hosts with 16 KiB pages. Cached IVF contexts can also lose query overrides when switching index instances or reopening an index.

This PR preserves the writer's logical layout independently of host mapping alignment and retains explicit IVF query overrides across context rebinding.

Changes

  • Align POSIX mappings to host page boundaries while preserving logical file offsets through mapping, flushing, unmapping and remapping.
  • Read each metadata section using its persisted length, validate metadata chains, reject unreadable or invalid chunk metadata without recreating it, and propagate write/flush failures.
  • Preserve writer alignment when reopening and growing HNSW, sparse HNSW and Vamana indexes. Keep reader-side padding out of logical chunk capacity, recover legacy sparse layouts from huge-page storage, and restore native layout settings when reusing a sparse streamer for a new index.
  • Preserve explicit scan_ratio and bruteforce_threshold overrides across partial context updates and rebinding. An omitted or zero nprobe restores scan-ratio mode; query fields that were never overridden continue to follow each index's defaults.

Validation

Cross-platform validation used native macOS ARM64 with 16 KiB pages and Linux x86_64 through Rosetta in an ARM64 Linux VM with 4 KiB pages.

  • All 38 configurations completed migration, collection-level insert/update/delete, reopen and return migration.
  • Same-platform reopen checks: 410/410 passed.
  • FP16 comparisons against destination-local indexes: 32/32 passed.
  • The portability validation recorded 428 passing macOS unit tests and 267 passing Linux unit tests, with no failures in those selected suites.
  • On the final commit, 8/8 targeted IVF tests passed on macOS ARM64, including consecutive partial updates, searcher/streamer switches, index reopen, default restoration and query-result consistency.

Regression coverage includes unaligned mapping/remapping, persisted layout recovery and growth, invalid metadata handling, sparse streamer reuse and IVF context reuse.

Known validation limits

Strict comparisons against independently rebuilt destination indexes are not fully passing:

  • Eight INT8 configurations produce different persisted quantization codes between platforms.
  • Two ANN configurations exceed the initial recall-difference threshold. Exhaustive comparisons pass, and migrated recall falls within the range observed across three destination-local builds.

These comparison failures remain recorded. Physical Linux x86_64 hardware has not been validated; the Rosetta run does not replace that coverage.

Use ASCII separators so UTF-8 continuation bytes are not classified
as whitespace differently across operating systems and locales.
Add regressions for locale changes, UTF-8 tokens, and byte offsets.

Affected legacy whitespace indexes must be rebuilt from stored text.
Restore the original AILEGO and Turbo numerical policies and their tests while retaining mmap, persisted-layout, tokenizer and IVF context fixes.

Add destination-local reference validation and document the 38-configuration migration round trip. FP16 comparisons pass; retain INT8 encoding and ANN recall differences and the physical x86 validation limitation.
Persist the ASCII whitespace tokenizer version per field and reject unversioned or unsupported indexes with rebuild instructions propagated to collection callers.

Preserve version metadata across snapshots and compaction, reject mixed versions, and refresh metadata during field rebuilds. Add regressions for legacy UTF-8 postings, read-only and writable reopen, sealed indexes, and collection-level error propagation.
Restore whitespace tokenization, FTS format checks, compaction metadata handling and related tests to the branch's main baseline.

Retain all 23 mapping, persisted-layout and IVF compatibility files unchanged. Keep local validation scripts and documents outside the branch.
@iaojnh iaojnh changed the title fix: preserve index layouts and query settings across platforms fix: preserve cross-platform index layouts and IVF query parameters Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant