[python] Stream training samples into native vector index trainers - #9758
[python] Stream training samples into native vector index trainers#9758TheR1sing3un wants to merge 1 commit into
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
Reviewed 50d1ec2. Requirement fit: supported; no actionable implementation finding.
This removes the full-shard read and full Python sample matrix from index training while preserving the evenly spaced non-null sample and production row IDs. The corpus size still reaches automatic IVF sizing, and training/add/write failures retain cleanup of the native trainer, result and temporary files.
The focused training/build suites passed locally with paimon-vindex 0.4.0: 29 tests, including byte-for-byte comparisons for IVF-FLAT/PQ/SQ/RQ and DiskANN. I also ran the three-mode complete-writer smoke benchmark at 10,000 × 32, sample ratios 1.0 and 0.1; index digests matched in every mode. Native training/build memory remains outside the Python-buffer bound, as documented.
Purpose
Vector index construction currently materializes the complete shard and training sample before calling the native trainer. Submit the same evenly spaced sample in bounded batches through
VectorIndexTrainer.create,add_training_vectors, andfinish_training. This removes the complete Python training matrix while preserving sample count/order, null-row handling, relative row IDs and automatic IVF corpus sizing.Tests
python -m pytest pypaimon/tests/vindex_training_test.py pypaimon/tests/global_index_build_test.py -q: 29 passed.git diff --checkpassed.Benchmark
Complete writer builds, including bounded source ingestion, training, adding all production vectors and writing the index. Each run uses a fresh process. macOS arm64, Python 3.9, paimon-vindex 0.4.0; 200,000 vectors x 128 dimensions, IVF-FLAT nlist=64, seed 42. Values are medians of three runs.
The sample-matrix ablation uses bounded reads but still allocates the complete training sample, separating the benefit of bounded input reads from native streaming.
All 18 runs produced identical index bytes within each sampling ratio. At ratio 1.0 the complete-build peak falls about 25%; at ratio 0.1 most of the memory reduction comes from bounding the initial read, with a smaller additional benefit from streaming. Build time is approximately unchanged. This bounds Python training buffers, not all native index-construction memory.
Reproduce with pypaimon[vindex] installed: