BFloat16 data type naming
In current code base, the BFloat16 data type is named as shxxxx (e.x.: shgemm), and related build flag as BUILD_HALF. Seems we simply take BF16 as half precision of float. This is not true as to the standard definition of IEEE. Half precsion should be FP16, which is different in format and content as compared with BFloat16. As for OpenBLAS, we may both support BFloat16 and and FP16 as valuable for different domains -- BFloat16 mostly valuable for Deep Learning and Machine Learning, while FP16 more valuable for traditional scientific computation and telecom processing.
Suggest to change the naming of data type and build flag to be bxxxx (e.x.: bgemm) and BUILD_BF16. While we can leave shxxxx for the real half precision data type -- FP16, or even make it as hxxxx (e.x.: hgemm). Whatever, use shxxxx and BUILD_HALF is quite confusing to community, every other math libs like Eigen/oneDNN (previously mkldnn) use keywords like bf or bf16 or so.
I can submit PR to make this change if we are OK on this.
The first 's' is for the result (single-precision). If b is for the input (bf16), bgemm would imply that both input and output are bfloat16, which is not the case. So 'sbgemm' would explain it better.
Good point! 'sb' prefix is good to me also as specific to bfloat16.
I remember suggesting to @edelsohn that function names be coordinated with other interested parties before the code lands, but I have to admit that seeing the actual implementation might be a prerequisite. Also I have no clear idea what the appropriate panel for deciding naming and API for BLAS extensions would be these days ?
I remember suggesting to @edelsohn that function names be coordinated with other interested parties before the code lands, but I have to admit that seeing the actual implementation might be a prerequisite. Also I have no clear idea what the appropriate panel for deciding naming and API for BLAS extensions would be these days ?
Do you mean naming thing and new APIs should be discussed in a specific panel? If Yes, can I attend? Besides this naming, I also have some new APIs (extensions) to suggest to add.
TBH I haven't the froggiest idea how this is currently handled, if at all. Back in the early days of BLAS and LAPACK there must have been enough of a working group to leave meeting notes and whitepapers for posterity, but as I came into my maintainer role purely from a user background as a computational chemist I do not know if any such coordination is still taking place.
Emmm... then can we make it simple to just add a note in the release note, considering that this BF16 based shgemm is just added recently that suppose very little users will be impacted.
Also a side question may be silly one -- I don't see this shgemm API been added in cblas.h, then how a user will use it normally?
Good point - I am old enough to consider FORTRAN "normal use" though :smile:
Definitely you run so quickly to that far away LOL
Still curious - is there any coordination on BLAS/LAPACK extension APIs still happening among major interested parties @langou @cparrott73 or does everybody get to name their pet function as they like ?
I created a PR about the change of the naming based on this proposal and RajalakshmiSR's comment. We can update the PR more if we have more idea on the naming/prefix.
The naming was coordinated with and approved by Jack Dongarra, who is the leader of NETLIB. OpenBLAS cannot start inventing names.
Thx. I vaguely remembered your stated intention but not any outcome, and did not see it mentioned at netlib.I guess OpenBLAS should evolve its own documentation eventually - added the information to the "OpenBLAS extensions" page in the wiki for now.
IMO extensions should be configurable out so that people dont get into thinking they somehow are part of BLAS and build eventually broken executables.
The naming was coordinated with and approved by Jack Dongarra, who is the leader of NETLIB. OpenBLAS cannot start inventing names.
OK, but still this 'sh' prefix is quite confusing, and it is totally different with other math libs supporting BFloat16. Any channel to raise a concern to Jack? And any place we can find netlib's spec about BF16 based APIs or naming?
BLAS G2 has a proposed naming scheme. Here's the extended abstract (4 page) https://tinyurl.com/yb7m7lov and the whole proposal (48 page) http://goo.gl/D1UKnw
To summarize:
real has "r" and # bits: gemm_r16 is IEEE 16-bit gemm gemm_rb16 is bfloat 16-bit gemm gemm_r32 is 32-bit sgemm gemm_r64 is 64-bit dgemm gemm_r128 is 128-bit gemm gemm_r64x2 is double-double gemm
complex has "c" and # bits: gemm_c16 is IEEE 16-bit gemm gemm_cb16 is bfloat 16-bit gemm gemm_c32 is 32-bit cgemm gemm_c64 is 64-bit zgemm gemm_c128 is 128-bit gemm gemm_c64x2 is double-double gemm
The scheme also allows for combinations, like gemm_r16r16r32 for A, B matrices in 16-bit, C matrix in 32-bit, as for NVIDIA's Tensor cores, as well as extension to reproducible accumulators, routines with separate C_in and C_out arguments, etc.
Mark Gates Innovative Computing Laboratory, University of Tennessee, Knoxville (Jack Dongarra's group)
Great, thanks (time to fetch myself a beer I guess). That looks to be next year's can of worms though ?
The naming was coordinated with and approved by Jack Dongarra, who is the leader of NETLIB. OpenBLAS cannot start inventing names.
OK, but still this 'sh' prefix is quite confusing, and it is totally different with other math libs supporting BFloat16. Any channel to raise a concern to Jack? And any place we can find netlib's spec about BF16 based APIs or naming?
Some clarification: at the time the decision was made, the only half precision type being considered was bfloat16. That motivated choosing 'H' for the type.
I agree that, if OpenBLAS is going to support IEEE 16-bit, this can be confusing. I have no objection changing it, as long all the parties involved are in agreement.
Thanks the information of BLAS G2, @mgates3. This looks great to me as for next generation to make all the API more readable and flexible. Just to confirm that you aims to show us this next generation BLAS, but not try to explain why we choose the 'h' prefix, Right?
And also thanks for the background information and opinion, @ceseo. That is also my point. When people (users, general developers, etc.) look into or think about half precision, mostly it comes to IEEE's half precision format (because that is from IEEE... LOL) which is FP16, while BFloat16 is taken as BFLOAT16 or bfloat16 or BF16 or bf or b. This is also the practice for all other libs supporting this data type. OpenBLAS using this 'h' prefix will definitely confuse any users caring this part. That will be a loss for OpenBLAS, and sad to OpenBLAS fans like me.
Short excerpt from clang source:
bfloat is currently stored as a double internally because
Yes, that was to give an update on where the BLAS standard is going. Namely, that we're proposing to move away from single letter precisions, so likely will never standardize on h for half. Any feedback on the proposal is also welcome—you can comment in the Google doc. h has been used in some libraries for half, but differentiating IEEE half and bfloat16 half with one letter is confusing. Also, what would be used for complex-half? Single letters are just not flexible and descriptive enough.
Using sh, when the output is single (32-bit) and the input is half (16-bit), would be consistent with other routines such as scnrm2. Again, I wouldn't expect that to be standardized.