Skip to content

int8 support for cuVS cagra#4439

Closed
jinsolp wants to merge 14 commits intofacebookresearch:mainfrom
jinsolp:cuvs-cagra-int8-pub
Closed

int8 support for cuVS cagra#4439
jinsolp wants to merge 14 commits intofacebookresearch:mainfrom
jinsolp:cuvs-cagra-int8-pub

Conversation

@jinsolp
Copy link
Contributor

@jinsolp jinsolp commented Jul 17, 2025

Closes #4430 by exposing int8 for cuVS cagra.
This PR (#4411) needs to be merged before this one .

@meta-cla meta-cla bot added the CLA Signed label Jul 17, 2025
@jinsolp jinsolp changed the title [DO NOT MERGE] int8 support for cuVS cagra int8 support for cuVS cagra Jul 22, 2025
@facebook-github-bot
Copy link
Contributor

@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D78746656.

else if (auto icg = dynamic_cast<const GpuIndexCagra*>(index)) {
IndexHNSWCagra* res = new IndexHNSWCagra();
if (icg->get_numeric_type() == faiss::NumericType::Float16) {
if (icg->get_numeric_type() != faiss::NumericType::Float32) {

Choose a reason for hiding this comment

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

For my learning, what happens in the 16 and int8 case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for copyTo where we copy from GpuIndexCagra to IndexHNSWCagra.
If base_level_only=false, we end up calling hnsw_add_vertices, which only support fp32 computations on CPU, so we need it to be true.
When base_level_only=true, we can use the storage(which is IndexScalarQuantizer)'s add() instead. : )

@facebook-github-bot
Copy link
Contributor

@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D78746656.

@facebook-github-bot
Copy link
Contributor

@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D78746656.

@facebook-github-bot
Copy link
Contributor

@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D78746656.

@jinsolp
Copy link
Contributor Author

jinsolp commented Jul 24, 2025

Added logic for encode/decode for interop between cpu and gpu. Previously, it was directly copying the data bits causing issues between int8 and uint8.

For example, in the copyTo function, it was calling add_sa_codes, which copies the bits as-is.
When we call search on the copied cpu index, the scalar quantizer encodes the vectors. Thus we end up having different representation of the trained vectors copied over from the GPU, and the query vectors.

The latest commit accounts for this situation and does the encoding/decoding step as part of the copyTo and copyFrom functions.

@facebook-github-bot
Copy link
Contributor

@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D78746656.

@facebook-github-bot
Copy link
Contributor

@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D78746656.

@facebook-github-bot
Copy link
Contributor

@mnorris11 has imported this pull request. If you are a Meta employee, you can view this in D78746656.

@facebook-github-bot
Copy link
Contributor

@mnorris11 merged this pull request in b4534d8.

dian-lun-lin pushed a commit to ahuber21/faiss that referenced this pull request Jul 30, 2025
Summary:
Closes facebookresearch#4430 by exposing int8 for cuVS cagra.
This PR (facebookresearch#4411) needs to be merged before this one .

Pull Request resolved: facebookresearch#4439

Reviewed By: junjieqi

Differential Revision: D78746656

Pulled By: mnorris11

fbshipit-source-id: 79147c8196f298c443796a615fabefac34fb188d
@jinsolp jinsolp deleted the cuvs-cagra-int8-pub branch August 6, 2025 20:43
samanthawaters8882michaeldonovan added a commit to samanthawaters8882michaeldonovan/faiss that referenced this pull request Oct 12, 2025
Summary:
Closes facebookresearch/faiss#4430 by exposing int8 for cuVS cagra.
This PR (facebookresearch/faiss#4411) needs to be merged before this one .

Pull Request resolved: facebookresearch/faiss#4439

Reviewed By: junjieqi

Differential Revision: D78746656

Pulled By: mnorris11

fbshipit-source-id: 79147c8196f298c443796a615fabefac34fb188d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CAGRA to support IndexIDMap for binary and int8 types

3 participants