-
Notifications
You must be signed in to change notification settings - Fork 87
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
Java: Fixing the broken pre-filtering for Brute Force #706
base: branch-25.04
Are you sure you want to change the base?
Conversation
relates #697 |
java/internal/src/cuvs_java.c
Outdated
int64_t prefilter_shape[1] = {(n_queries * n_rows + 31) / 32}; | ||
DLManagedTensor prefilter_tensor = prepare_tensor(prefilter_data_d, prefilter_shape, kDLUInt, 32, 1, kDLCUDA); | ||
// Parse the filters data | ||
uint32_t *prefilters = (uint32_t*) malloc(prefilter_data_length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why it is necessary to malloc and copy the pre filter data. Is it not possible to access it directly from the passed pointer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change the byte ordering to make it work. Just type casting it to uint32_t *
didn't work. I'll explore if doing some in-place transformation without allocating a new array is feasible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to write the expected byte order at the java level,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the C++ side I added last month an option to specify the byte order used at the time of the creation of the prefilter data: https://github.com/rapidsai/raft/blob/branch-25.04/cpp/include/raft/core/bitmap.hpp#L64.
I think in your case it was created with uint8_t
? So specifying original_nbits = sizeof(uint8_t)
should prevent you from that extra allocation/copy. It is not present yet in the C API though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisHegarty fixed, it was unnecessary to change the order. I was doing things wrong. Fixed now.
/ok to test |
Hi @chatman , the style checking seems to fail, may you have time to take a look? thanks! |
FYI, for larger dataset sizes, this fix is incorrect. Working on the proper fix. |
/ok to test |
1 similar comment
/ok to test |
a53dbf2
to
b6a7661
Compare
I think this is ready for merge. Please review @rhdong @ChrisHegarty @narangvivek10. |
/ok to test |
@rhdong Upon testing, I'm finding that on some systems, this is not working. On such systems, search call is returning non success return value, with invalid memory access. I copied the prefilter data into a device array and passed that array, and it works again. Wondering why it is working on one system with just the host array, but not on others. I'll continue the investigation and fix this by tomorrow (hopefully, before the freeze for the next release). FYI @cjnolet. |
Hi @chatman , the API always uses the filter memory pointer as a device accessible one, a little weird that |
Changed the signature from
long[] prefilter
toBitSet[] prefilters
.Added a very simple test.