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

Normalization of large vectors performed in the native side throws exception in some operational systems. #2

Open
hussamaa opened this issue Mar 13, 2020 · 0 comments
Labels
bug Something isn't working to be confirmed

Comments

@hussamaa
Copy link
Contributor

hussamaa commented Mar 13, 2020

Hi,

It seems that we have an issue happening in some operating systems when the normalization of large vectors is done in the native side. This crash happens while querying Index with COSINE space (which always requires normalization).

Here you go for an example of vector which was triggering the exception:

[0.0, 0.08822874, 0.0014423003, -0.22596607, -0.21152055, 0.24686494, 0.0028841705, 0.1313309, -0.10200707, 0.07393048, 0.00856743, 0.0789952, 0.06910411, 0.13004264, -0.09338167, -0.01671573, -0.09603984, 0.24946876, 0.23585884, 0.03627194, -0.14296752, -0.14825268, 0.10577056, -5.907989E-4, 0.1445684, 0.029691584, -0.111786544, 0.20851535, 0.06765229, 0.14762665, -0.027920531, -0.09301419, -0.059792746, -0.018521896, -0.022855915, -0.060387842, -0.14520852, 0.2680792, -0.046249762, -0.14196983, 0.24149212, 0.08173426, -0.066984974, 0.23593807, -0.12034095, 0.32620242, -0.061542645, -0.08294789, 0.18837827, 0.2085252, 0.10373863, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0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 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]

Result:

======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bfb)[0x7f40ac689bfb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76fc6)[0x7f40ac68ffc6]
/lib/x86_64-linux-gnu/libc.so.6(+0x7962f)[0x7f40ac69262f]
/lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7f40ac693f64]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_Znwm+0x18)[0x7f3f833a67a8]
/tmp/hnswlib-jna1859935598413192174/libhnswlib-jna.so(ZNSt6vectorISt4pairIfjESaIS1_EE19_M_emplace_back_auxIJfRiEEEvDpOT+0x6c)[0x7f3f836a104c]
/tmp/hnswlib-jna1859935598413192174/libhnswlib-jna.so(_ZNK7hnswlib15HierarchicalNSWIfE17searchBaseLayerSTILb0EEESt14priority_queueISt4pairIfjESt6vectorIS5_SaIS5_EENS1_14CompareByFirstEEjPKvm+0x40e)[0x7f3f836a057e]
/tmp/hnswlib-jna1859935598413192174/libhnswlib-jna.so(_ZNK7hnswlib15HierarchicalNSWIfE9searchKnnEPKvm+0x1c8)[0x7f3f8369f268]
/tmp/hnswlib-jna1859935598413192174/libhnswlib-jna.so(ZN5IndexIffE9knn_queryEPfbiPiS1+0x2ce)[0x7f3f8369e10e]
/home/user/.cache/JNA/temp/jna3224485875264561534.tmp(ffi_call_unix64+0x4c)[0x7f3f838bb644]
/home/user/.cache/JNA/temp/jna3224485875264561534.tmp(ffi_call+0x1fb)[0x7f3f838bb3ab]
/home/user/.cache/JNA/temp/jna3224485875264561534.tmp(+0xc565)[0x7f3f838b4565]
/home/user/.cache/JNA/temp/jna3224485875264561534.tmp(Java_com_sun_jna_Native_invokeInt+0x21)

In case you face this issue, one workaround is doing the normalization in Java, for instance:

float vector[];
Index.normalize(vector);
...
Index.addNormalizedItem(vector);
Index.knnNormalizedQuery(vector, k);

BR,
Hussama

@hussamaa hussamaa added bug Something isn't working to be confirmed labels Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working to be confirmed
Projects
None yet
Development

No branches or pull requests

1 participant