Repository navigation
feat(milvus): add native BF16 HNSW support - #883
Conversation
|
/assign @XuanYang-cn |
|
@XuanYang-cn any feedback for the PR ? |
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>
ea49e4e to
5b305cd
Compare
|
rebased on latest master |
|
/assign @jamesgao-jpg |
jamesgao-jpg
left a comment
There was a problem hiding this comment.
Requesting changes for two issues: keep the vector field datatype independent from the index identity, and validate that datatype when reusing an existing collection.
Replace the HNSW_BF16 index type and the milvushnswbf16 command with a vector_data_type field on HNSWConfig. Only milvushnsw has the --vector-data-type option. Reject a reused collection if its vector field type or dimension does not match the configuration.
|
I fixed both review comments in 11ff32b. I also updated the description for the new design. Verification at 11ff32b:
|
jamesgao-jpg
left a comment
There was a problem hiding this comment.
Re-reviewed at 11ff32b. VERIFIED: both earlier findings are addressed: the index remains HNSW with a separate vector_data_type, and reused collections are checked for vector datatype/dimension mismatches. All 18 focused tests passed; result JSON round-trip, legacy FLOAT32 defaults, and separate FP32/BF16 reuse keys were also verified. One additional P2 is attached inline.
CI lint blocker (pre-existing on main): VERIFIED: the current run stops at make lint with ICN001 in vectordb_bench/backend/clients/vespa/vespa.py:1 (import datetime). That file is unchanged by this PR. Please change the import to import datetime as dt and update its references, or address it on main and bring that fix into this branch, so the required checks can reach the tests. Failure log: https://github.com/zilliztech/VectorDBBench/actions/runs/38956782418/job/117857887493 .
ruff reports ICN001 for this import, and make lint fails on main.
The vector payload estimate used 4 bytes per dimension for all runs. HNSWConfig now gives 2 bytes per dimension for BFLOAT16. The task runner passes this width to the estimate. FLOAT32 stays at 4 bytes.
Test the cold-latency estimate, the default width for other configs, the FTS case and the NaN branch of the BF16 encoder. VectorDataType now gives the width of each data type, with a shared FLOAT32 default in payload.py. The README now names --skip-drop-old --skip-load as the reuse flags.
|
Verification at 6447510: |
|
/lgtm |
|
/approve |
|
/assign @XuanYang-cn |
jamesgao-jpg
left a comment
There was a problem hiding this comment.
Reviewed the updated changes. The vector data type is separate from the index, existing collections are checked for compatible type and dimension, and BF16 payload estimates use two bytes per dimension. The focused Milvus and CLI tests passed (65 tests), and make lint passed.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: abondarev84, jamesgao-jpg 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 |
With a BFLOAT16 vector field the client passed float32 lists through and the Milvus server converted them by truncation, which cost recall (10M Cohere, ef 128: 0.757 instead of 0.934). Convert inserts and queries to BF16 bytes on the client with round-to-nearest-even, the same bit method as upstream VectorDBBench zilliztech#883. NaNs stay NaN. Other vector types are unchanged. MILVUS_BF16_SERVER_CONVERT=1 restores the old server-side conversion.
Summary
VectorDBBench creates Milvus collections with
FLOAT_VECTORfields only. The currentSQType.BF16option changes only the index. The stored field stays FP32.This change adds
--vector-data-type BFLOAT16tomilvushnsw. With this option, Milvus stores and searches the vectors as nativeBFLOAT16_VECTOR. The default,FLOAT32, keeps the current behavior.Design
HNSWConfig.vector_data_typeisFLOAT32(default) orBFLOAT16. The index type staysHNSW.dimraisesValueError. FTS collections skip this check.