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

Deprecate creation of dtypes via np.dtype('typename') #93

Open
jakevdp opened this issue Sep 13, 2023 · 4 comments
Open

Deprecate creation of dtypes via np.dtype('typename') #93

jakevdp opened this issue Sep 13, 2023 · 4 comments

Comments

@jakevdp
Copy link
Collaborator

jakevdp commented Sep 13, 2023

See numpy/numpy#24699

I suspect this is also going to break a lot of JAX code as well...

@ngoldbaum
Copy link

For what it's worth, if the deprecation I proposed does go through, the string type names will still work for builtin numpy dtypes, just not ones added via the sctypeDict.

@jakevdp
Copy link
Collaborator Author

jakevdp commented Sep 13, 2023

Thanks for the clarification – understood. But in tensorflow and jax, we have 4+ years of legacy code written in a context where np.dtype('bfloat16') does not error, so I suspect this deprecation will bring some amount of pain downstream.

@ngoldbaum
Copy link

As @hawkinsp pointed out in the NumPy repo, adding these dtypes to NumPy itself would also fix the problem, since hopefully jax users don't care if the dtype is defined inside NumPy or in an extension. It would probably need a NEP and a reference implementation but I think the existing downstream usage by jax proves out a real need and if we can inherit names that are already used by jax that also avoids some bikeshedding.

I would hope it should be relatively straightforward to write these dtypes using the new dtype API since they are non-parametric and have a straightforward binary layout and cast definitions. The devil is in the details, of course...

I proposed adding a new dtype to NumPy written using the experimental dtype API in NEP 55. If that NEP is accepted and the code is upstreamed it should be much clearer how to integrate dtypes written outside of NumPy into NumPy itself.

Of course all of this is just my opinion so far, I'll wait to weigh in more until others from NumPy have weighed in about the sctypesDict deprecation.

@jakevdp
Copy link
Collaborator Author

jakevdp commented Sep 13, 2023

For what it's worth, we created ml_dtypes on the recommendation of Numpy maintainers in this thread, with the hope that the bfloat16 implementation might someday be upstreamed into NumPy if the community supported it.

The float8 and int4/uint4 types are a bit more experimental, and probably not suitable for inclusion in NumPy until they gain more traction.

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

No branches or pull requests

2 participants