Skip to content

feat(milvus): add native BF16 HNSW support - #883

Merged
jamesgao-jpg merged 5 commits into
zilliztech:mainfrom
abondarev84:feat/milvus-native-bf16
Oct 27, 2026
Merged

jamesgao-jpg merged 5 commits into
zilliztech:mainfrom
abondarev84:feat/milvus-native-bf16

Conversation

@abondarev84

@abondarev84 abondarev84 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

VectorDBBench creates Milvus collections with FLOAT_VECTOR fields only. The current SQType.BF16 option changes only the index. The stored field stays FP32.

This change adds --vector-data-type BFLOAT16 to milvushnsw. With this option, Milvus stores and searches the vectors as native BFLOAT16_VECTOR. The default, FLOAT32, keeps the current behavior.

Design

  • HNSWConfig.vector_data_type is FLOAT32 (default) or BFLOAT16. The index type stays HNSW.
  • The client converts the insert and query vectors to BF16 with round-to-nearest-even. NumPy does the conversion. There is no new dependency.
  • For a collection that already exists, a mismatch in vector field type or dim raises ValueError. FTS collections skip this check.

@abondarev84

Copy link
Copy Markdown
Contributor Author

/assign @XuanYang-cn

@abondarev84

Copy link
Copy Markdown
Contributor Author

@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>
@abondarev84
abondarev84 force-pushed the feat/milvus-native-bf16 branch from ea49e4e to 5b305cd Compare October 15, 2026 07:44
@abondarev84

Copy link
Copy Markdown
Contributor Author

rebased on latest master

@abondarev84

Copy link
Copy Markdown
Contributor Author

/assign @jamesgao-jpg

@jamesgao-jpg jamesgao-jpg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for two issues: keep the vector field datatype independent from the index identity, and validate that datatype when reusing an existing collection.

Comment thread vectordb_bench/backend/clients/api.py Resolved
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.
@abondarev84

abondarev84 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

I fixed both review comments in 11ff32b. I also updated the description for the new design.

Verification at 11ff32b:

  • make unittest passes. make lint reports only the ICN001 error in vespa.py. This error also occurs on main.
  • The 18 new tests pass. The full suite has the same failures as main.
  • On standalone Milvus 2.6.13, --vector-data-type BFLOAT16 created a BFLOAT16_VECTOR field. A FLOAT32 run on that collection then stopped with the mismatch error.
  • Zilliz Cloud uses the same client code for the reuse check. I did not test it on Zilliz Cloud.

@jamesgao-jpg jamesgao-jpg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@abondarev84

Copy link
Copy Markdown
Contributor Author

ICN001 lint error fixed in d91c90b. Payload estimate fixed in 6f1796e. 6447510 adds tests and takes each data type's width from VectorDataType.

Verification at 6447510: make lint, make unittest and the 24 new tests pass. On standalone Milvus 2.6.13 with --payload-profile vector (1536 dimensions, K=10), the recorded estimate was 61640 for FLOAT32 and 30920 for BFLOAT16.

@jamesgao-jpg

Copy link
Copy Markdown
Collaborator

/lgtm

@jamesgao-jpg

Copy link
Copy Markdown
Collaborator

/approve

@jamesgao-jpg

Copy link
Copy Markdown
Collaborator

/assign @XuanYang-cn

@jamesgao-jpg jamesgao-jpg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: abondarev84, jamesgao-jpg
To complete the pull request process, please assign xuanyang-cn after the PR has been reviewed.
You can assign the PR to them by writing /assign @xuanyang-cn in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jamesgao-jpg
jamesgao-jpg merged commit 6ca53fe into zilliztech:main Oct 27, 2026
4 checks passed
MithunEndee added a commit to endee-io/VectorDBBench that referenced this pull request Dec 1, 2026
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.
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.

3 participants