Add AVX512_BF16 fast path for BF16 inner product#1
Merged
xtangxtang merged 2 commits intomainfrom Mar 5, 2026
Merged
Conversation
Implement DCBF16IPDpbf16 distance computer that leverages AVX512_BF16 instructions (VDPBF16PS) for accelerated BF16 inner product computation. Key features: - Quantizes query to BF16 once in set_query() - Computes inner products using VDPBF16PS against BF16-coded vectors - Only enabled when __AVX512BF16__ is available (e.g., -march=sapphirerapids) - Requires d % 32 == 0 to use dpbf16 cleanly (32 bf16 elements per op) Performance optimization for ScalarQuantizer with QT_bf16 + IP on CPUs with AVX512_BF16 support (Sapphire Rapids and newer).
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
This PR adds a fast path for BF16 inner product computation using AVX512_BF16 instructions.
DCBF16IPDpbf16distance computer that leverages VDPBF16PS instructionsset_query(), then computes inner products against BF16-coded vectors__AVX512BF16__is available (e.g.,-march=sapphirerapids)d % 32 == 0(32 bf16 elements per dpbf16 operation)Key features:
QT_bf16 + IPDCTemplate<QuantizerBF16>when conditions not metTest plan