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

simsimd_avx512_i8_cos under vnni #91

Closed
my-vegetable-has-exploded opened this issue Feb 28, 2024 · 8 comments
Closed

simsimd_avx512_i8_cos under vnni #91

my-vegetable-has-exploded opened this issue Feb 28, 2024 · 8 comments
Labels

Comments

@my-vegetable-has-exploded

Thanks for your great work!

When i reading codes in simsimd_avx512_i8_cos, https://github.com/ashvardanian/SimSIMD/blob/main/include/simsimd/spatial.h#L1120
I am a little confusing about that both input a and b is signed, but _mm512_dpbusd_epi32 is product of ZeroExtend16 and SignedExtend16 , I think there maybe some problem when vector a contain negative number like -1.

I think may it need to add more codes like this.
https://github.com/my-vegetable-has-exploded/dot-bench/blob/main/src/lib.rs#L54-L57

@ashvardanian
Copy link
Owner

Great catch, thank you too, @my-vegetable-has-exploded! Would you have time to submit a patch?

@my-vegetable-has-exploded
Copy link
Author

Great catch, thank you too, @my-vegetable-has-exploded! Would you have time to submit a patch?

I may need some time to familiarize myself with the project. Maybe several days later.

@ashvardanian
Copy link
Owner

@my-vegetable-has-exploded, much appreciated! The CONTRIBUTING.md contents may help. The very first command should be enough to compile 🤗

@ashvardanian ashvardanian added the good first issue Good for newcomers label Mar 3, 2024
@my-vegetable-has-exploded
Copy link
Author

my-vegetable-has-exploded commented Mar 3, 2024

@my-vegetable-has-exploded, much appreciated! The CONTRIBUTING.md contents may help. The very first command should be enough to compile 🤗

Sorry, I meet some problems. The situation of my codes is computing dot product of int8 after quantization, I can promise that all numbers fall in [-127,127] in this situation. So it is okay to convert -x*y to x*-y and use dpbusd (product of unsigned and signed) to compute the result for me. But if without this gurantee, 0 - (-128) = 128 would overflow.

@ashvardanian
Copy link
Owner

@my-vegetable-has-exploded not sure about what you mean, but your Rust snippet looked reasonable. I think adjusting the C variant in this repo to work the same way is the way to go 🤷‍♂️

@my-vegetable-has-exploded
Copy link
Author

@my-vegetable-has-exploded not sure about what you mean, but your Rust snippet looked reasonable. I think adjusting the C variant in this repo to work the same way is the way to go 🤷‍♂️

For example, we have a=[1,-2,3,-4] and b=[11,12,13,14]. We would convert it to a'=[1,2,3,4], b'=[11,-12,13,-14]. But if b=[-128,-128,-128,-128], than b'=[128,128,128,128], 128 would overflow in 8bit presentation.

@ashvardanian
Copy link
Owner

@my-vegetable-has-exploded I think the best route is to upcast to 16-but and use dpwssd.

ashvardanian pushed a commit that referenced this issue Mar 4, 2024
# [3.9.0](v3.8.1...v3.9.0) (2024-03-04)

### Add

* Complex numbers support ([0a0665a](0a0665a))
* Hamming & Jaccard for pre-AVX512 CPUs ([4f1eba1](4f1eba1)), closes [#69](#69)
* Rust binary distances ([960af05](960af05)), closes [#84](#84)

### Fix

* `datatype` variable repeated ([8558c4a](8558c4a))
* VNNI casting on AVX-512 ([c4398d1](c4398d1)), closes [#91](#91)

### Improve

* Python type inference ([227de70](227de70))

### Make

* Bump ip from 2.0.0 to 2.0.1 (#92) ([559a16d](559a16d)), closes [#92](#92)
@ashvardanian
Copy link
Owner

🎉 This issue has been resolved in version 3.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants