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

Rust has an f16 and bf16 type #124

Closed
MarkReedZ opened this issue May 30, 2024 · 14 comments
Closed

Rust has an f16 and bf16 type #124

MarkReedZ opened this issue May 30, 2024 · 14 comments
Labels
wontfix This will not be worked on

Comments

@MarkReedZ
Copy link
Contributor

MarkReedZ commented May 30, 2024

Rust has a crate half that has an f16 and bf16 we could be using. Users would probably be using this?

Rust will be adding f16 into the core language.

The addition of bf16 into the core is tracked here

@ashvardanian
Copy link
Owner

Once they add, we can integrate the native type. Until then, I'd avoid dependencies.

@MarkReedZ
Copy link
Contributor Author

Great. I added a link for bf16 above and will add these when available.

@Wyctus
Copy link
Contributor

Wyctus commented Jun 14, 2024

But f16 is already supported, there is even an example!

And this implementation also does not rely on the half crate. Doesn't this mean that it is also possible to introduce bf16 without a new dependency?

Or is this also blocked by the C implementation of bf16 not being ready yet?

@ashvardanian
Copy link
Owner

We don't need a C-level or Rust-level support for f16 and bf16 to implement those. Just cast an arbitrary 16-bit scalar to a similarly named type defined in SimSIMD and you ready to go 🤗

@Wyctus
Copy link
Contributor

Wyctus commented Jun 15, 2024

Thank you for the quick answer, but I'm a little bit lost. 🙃

So I looked into the Rust code and for example in the case of cos and f16, the simsimd_cos_f16 C function is called. But this function based on the platform uses f16 specific intrinsics (e.g. svmla_f16_x).

So I would expect that the bf16-based metrics also have some corresponding C-functions (e.g. simsimd_cos_bf16), which would rely on bf16 specific intrinsics. But I haven't found anything specific.

Do such bf16 intrinsics actually exist? I saw some bf16 related stuff for ARM NEON, and some for AVX512 but, I'm not sure what to do.

@ashvardanian
Copy link
Owner

bf16 isn't implemented yet, you can track the progress here: #80

@ashvardanian
Copy link
Owner

Hey @Wyctus! As you may have seen, the bf16 is now implemented. Have you tried using it? Do you still have any questions?

@ashvardanian ashvardanian added the wontfix This will not be worked on label Aug 29, 2024
@Wyctus
Copy link
Contributor

Wyctus commented Aug 29, 2024

Hey @Wyctus! As you may have seen, the bf16 is now implemented. Have you tried using it? Do you still have any questions?

Awesome! I haven't seen it yet, but I'm gonna try it tomorrow! 🚀 Thanks!

@Wyctus
Copy link
Contributor

Wyctus commented Aug 30, 2024

I tried to test bf16 in Rust, but I couldn't find a struct bf16(u16) new type and the traits SpatialSimilarity, ProbabilitySimilarity and ComplexProducts implemented for it.

Am I missing something?

@ashvardanian
Copy link
Owner

Oh, wow, we forgot to expose it to Rust 🙈 Any chance you could contribute, @Wyctus? Should be identical to f16.

@Wyctus
Copy link
Contributor

Wyctus commented Aug 30, 2024

Sure, I'll send a PR, hopefully I'll have time today!

@ashvardanian
Copy link
Owner

Hey, @Wyctus! How is it going? Would be great to merge those extensions into #154 - gonna be an epic release, and even better with your contributions 🤗

@Wyctus
Copy link
Contributor

Wyctus commented Sep 1, 2024

Hey, I'm going to send the PR later today! 🙂

@ashvardanian
Copy link
Owner

Epic! The next release is going to be the coolest in the history of this library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants