-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
ENH: numpy bfloat16 support #19808
Comments
NEPs 41-43 are mostly implemented (there is one major step remaining, that is mostly finished though; there will be few smaller steps until we are there though, and I expect things will come up as soon as someone tries to write a more complex dtype – which bfloat16 is probably not though). However, it is not yet public API, I hope to followup with an experimental public API very soon, though. And there is a repo (which has to change a bit soon) here. I am personally not sure whether or not we should include But, opinions will probably differ, I would somewhat prefer a Or, we include it in NumPy (for ABI reasons) but make it accessible through its own import? |
This would be my preference for bfloat16 (the current issue) and complex32 (#14753). Would be very useful for GPU libraries like CuPy (and especially CuPy, which does not have its own type system and simply uses the dtypes from NumPy). |
No matter the outcome of the discussion, I think it may make sense to start with a new The reason is that I think there are a few questions that need answering, e.g. whether we even want a |
Agreed. Just to add to that, there may be issues in a Sebastian, do you have thoughts on whether having a new repo live here (under the NumPy org) would make sense? Or is there some incubator or contrib NumPy org that would make sense? How should experimental things like this develop? |
I think we can start such a thing in the NumPy |
+1 to adding this support. From the thread in this JAX bug, it seems that there are several inconsistencies in type promotion behavior for the current custom |
This is not true anymore, they can be addressed in a fully compatible way with the new (although not yet public) API. Yes, there will be road-bumps, but the point is that there is a path of starting this outside of NumPy and then considering whether that is good or whether inclusion is desired. EDIT: The API is experimentally public, see also https://github.com/seberg/unitdtype |
I wrote that bfloat16 extension (the TF/JAX one) targeting NumPy 1.16 when working on early TPUs. NumPy's type extension APIs have certainly advanced since then. So it's probably time someone had a go at adapting it to the new APIs. In passing: one other observation I will make while I am here is that at least two varieties of 8-bit floating point type are gaining popularity in the machine learning world as well (e.g., non-standard E4M3 and E5M2 types from hardware vendors), and we were looking at generalizing the extension to support those as well. |
(@jakevdp for visibility) Thanks! In that case, @hawkinsp would it be useful if I file a bug similar to google/jax#11014 , but in the tensorflow repo? |
The JAX repo bug is fine: in practice we are the ones working on this and that's the project we work in most. (Really this extension should be its own pip package, and we may do that. I note that someone did fork our code and do this already ( |
Hi @hawkinsp, I am an author of paddle_bfloat package which is an upgraded version of "original" bfloat16 package which contains some minor fixes(fixing compilator warnings, some missing functions on windows etc). If I could help you in any way, please let me know. |
Is some bfloat16 support being developped in Numpy or is it still an idea as of today? |
@BlueskyFR We will adopt this approach
so please help one of the implementations mentioned here to reach maturity. |
@mattip I don't really understand what is going on, why is it developed as external repos and not as a Numpy branch? |
NumPy is very conservative when it comes to enhancements since any new NumPy enhancement becomes part of the entire scientific python stack. There are too many unknowns with The Data API has also not adopted The approach to first have code as a stand-alone library was successfully used when revamping the |
Okay, thanks for the explanation. Still, developing a feature as a branch of the repo doesn't mean that it is released with it, it would just be a common place to develop such a feature. The problem with waiting for external libraries to do that is that community effort is extremely limited whereas the Numpy repo can bring people together. I am affraid that waiting for some external support requires a couple more years before reaching something stable, so IMO the Numpy repo has the capacity to help this effort with endangering the public stable releases. |
@BlueskyFR doing a branch in NumPy means you get slowed down by PRs to the NumPy repo. Slower review, etc. If there was a champion who is already a NumPy dev there may be a point to it, but we do not have that. We can still consider putting it into the NumPy organization, but I am not sure that it would help much. NumPy does not have resources to push this, having a feature branch that doesn't move quickly will not be helpful IMO. You can use this issue, the NumPy mailing list, and https://discuss.scientific-python.org to coordinate. I can try to keep an eye on things also to have a NumPy dev in the loop, but we are not the ones that can drive this for now. |
Okay, many thanks for the replies! |
@BlueskyFR if you start such an external implementation, please put the a link to it in a comment here (or even in the description of this issue) so that people googling for "numpy bfloat16" and end up here as I just did will find there way to your project and start consolidating efforts there. |
Hi all – we just released |
Feature
Hi,
I am working at PaddlePaddle(chinese DL framework). We and other DL frameworks would extremely benefit from integrated bfloat16 numpy datatype. I have seen that TF added its own implementation and lately a standalone pip package bfloat16 was released.
I have also seen NEP 41, 42, 43 which from what I understand will allow adding new, user-defined datatypes. Are you guys planning to integrate bfloat16 into core numpy? If you don't have the bandwidth to do that, is there anyone that can guide me how to implement that so I can make a PR? And how are these NEPs going?
The text was updated successfully, but these errors were encountered: