feat(milvus): add native BF16 HNSW support - #883
Open
abondarev84 wants to merge 1 commit into
Open
abondarev84 wants to merge 1 commit into
abondarev84 wants to merge 1 commit into
Conversation
Add IndexType.HNSW_BF16, HNSWBF16Config, and a MilvusHNSWBF16 CLI command. The client creates BFLOAT16_VECTOR fields and converts float32 insert batches and query vectors to round-to-nearest-even BF16 byte payloads accepted by pymilvus. The conversion uses NumPy bit operations, avoiding an additional ml_dtypes runtime dependency. Milvus still receives index_type "HNSW"; BF16 is selected by the collection field's data type, so FP32, FTS, and GPU configurations keep their existing behavior. Tests cover the rounding and special-value encoding, BFLOAT16_VECTOR schema selection against the FP32 default, insert and batch-search conversion, the CLI command wiring, and HNSW_BF16 case-config registration. Co-authored-by: RJ Silk <robesilk@amazon.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: abondarev84 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Author
|
/assign @XuanYang-cn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VectorDBBench creates Milvus dense-vector collections with
FLOAT_VECTORfields, so the benchmark cannot exercise Milvus's nativeBFLOAT16_VECTORstorage and search path. BF16 is currently reachable only as a scalar-quantizer or refine option (SQType.BF16) over FP32 storage, where the stored field is still 4 bytes per dimension.This adds an opt-in
milvushnswbf16command that creates aBFLOAT16_VECTORfield and encodes insert and query vectors as BF16 before they reachpymilvus.milvushnswand all other commands are unchanged.Design
IndexType.HNSW_BF16andHNSWBF16Configinherit the existing HNSW options (M,efConstruction,ef, metric handling). The config sendsindex_type: "HNSW". BF16 is not a separate index algorithm — Milvus selects the BF16 implementation from the field's data type._float32_to_bf16_bytes()applies round-to-nearest-even to the IEEE-754 bit patterns and returns one little-endian byte string per vector. NaN inputs remain NaN. It uses NumPy bit operations, so no new runtime dependency is added.Insert conversion runs once per runner batch. Query conversion runs immediately before the search request, across the whole query batch.
pymilvusaccepts raw two-byte BF16 payloads for both insert rows and search placeholders. Verified against 2.6.15, the existing minimum inpyproject.toml. Thepymilvus>=2.6.15,<3.0.0constraint is unchanged.Request path:
Usage
Results
Cohere 1M x 768 (
Performance768D1M),M=16 efConstruction=100 ef=64 k=10, COSINE, 1,000,000 vectors per run, 3 runs per configuration. Both hosts: 8 vCPU / 16 GB, Milvus 3.0.0. One instance per architecture for all runs. Unpatchedmainand this branch, from separate checkouts.recall@10: fraction of the dataset's 10 true nearest neighbors present in the 10 returned results, averaged over 1,000 queries. Range 0 to 1. Higher is better.
milvushnsw(unpatchedmain)FLOAT_VECTORmilvushnswbf16(this branch)BFLOAT16_VECTORmilvushnsw(unpatchedmain)FLOAT_VECTORmilvushnswbf16(this branch)BFLOAT16_VECTOR