Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable AMX to hnswlib for FP32 innerproduct. #609

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

ruclz
Copy link

@ruclz ruclz commented Jan 21, 2025

Hi~, reviewer, Intel Advanced Matrix Extensions (AMX) is a set of specialized instructions designed to accelerate matrix operations, which are fundamental in many areas of modern computing such as machine learning, scientific computing, and graphics processing. AMX leverages dedicated tile-based architecture within the CPU to perform these operations more efficiently than traditional scalar or SIMD (Single Instruction, Multiple Data) methods.

During our analysis of vector search performance in hnswlib, we identified that the SIMD-based IP distance computation was a significant bottleneck. Recognizing the potential for optimization with AMX, we implemented changes that replaced SIMD operations with AMX, achieving a 1.08x performance gain. This finding prompted us to submit this patch.

It is worth noting that AMX exclusively supports FP16, BF16, and INT8 data types. Consequently, in this patch, we perform a conversion from FP32 to BF16 prior to each computation. Furthermore, we have developed an alternative patch that eliminates the need for data type conversion by using BF16 for both storage and computation, leading to a more substantial performance improvement of 1.78x. We are prepared to submit a new pull request for this alternative approach if it is deemed appropriate.

All tests were performed on an Intel(R) Xeon(R) 6980P processor, employing 16 physical cores and 16 threads. The dataset utilized for benchmarking purposes was 1000*1024 vectors.

image

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.

1 participant