OpenBLAS icon indicating copy to clipboard operation
OpenBLAS copied to clipboard

BFloat16 data type naming

Open Guobing-Chen opened this issue 6 years ago • 54 comments

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.

Guobing-Chen avatar Aug 11 '20 03:08 Guobing-Chen

The drawback of having verbose names is that you are halfway through writing down the implementation by the time you have finished typing the name, so everybody will come up with their personal shortcut macros (unless forcing everyone to use an IDE with predictive texts or a full code-generating AI is the ultimate goal). Perhaps the current generation of freshmen will eventually have us all use emoji (which would at least make it easy to name functions that have side effects.) Am I reading you correctly here as stating that there will be no interim standard before adoption of that next-gen BLAS naming, turning the supposedly supreme blessing given SHGEMM into more of a "don't really care how you call it in the old idiom" ?

martin-frbg avatar Aug 17 '20 15:08 martin-frbg

If there is no preferred standard for this before BLAS G2, then end-users and BFloat16 community's existing convention can be a good way to follow, like 'b' or 'bf' or 'bf16' or 'bfloat16', etc.

How do you think, Martin?

Guobing-Chen avatar Aug 21 '20 01:08 Guobing-Chen

I think I would like to see the new function used for something other than big company politics...

martin-frbg avatar Aug 21 '20 01:08 martin-frbg

That's fair. And my purpose to raise this issue is also try to help these new BF16 related functions in OpenBLAS better utilized by community as providing a more user familiar naming.

And these daysI am preparing more BF16 functions for OpenBLAS, if the decision has made to keep the current naming, I will follow this convention for my new functions.

Guobing-Chen avatar Aug 21 '20 02:08 Guobing-Chen

Haven't seen any messages from the mountain top since the categorical "OpenBLAS cannot start inventing names" but I guess we could always create aliases if there are alternate names already in use. (Would be nice if functions differ in name only though).

Be warned that everything besides SHGEMM itself may appear as if it is already implemented, but actually leads to the corresponding single-precision real function without any attempt at argument conversion right now.

martin-frbg avatar Aug 21 '20 06:08 martin-frbg

(As per suggestion from @martin-frbg, continuing a discussion started in https://github.com/xianyi/OpenBLAS/pull/2796)

If you are quoting from #2767, you will have seen how the SH.. names came to be. Please comment there if you are not satisfied with Edelsohn's dictum.

OpenBLAS can certainly push back against any "dictums", especially recently made ones that were done without properly taking into account context and existing published standards. Just because something was seemingly rubber stamped by Jack Dongarra, it doesn't automatically mean it's the best decision.

I suspect the size of the userbase for OpenBLAS is far larger than "plain" BLAS these days. Given that, OpenBLAS users and contributors can at the very least provide actionable feedback on actual real world usage and implications of any proposed changes/extensions to BLAS. There is also no need to propagate questionable changes from BLAS into OpenBLAS; this type of action can be used as an alternative feedback mechanism, if nothing gets through "normal" channels.

conradsnicta avatar Sep 07 '20 06:09 conradsnicta

I find all of the comments about "Edelsohn's dictums" offensive and unnecessary.

We, IBM, did not invent names nor force them on OpenBLAS. There was a question of how to name the new functions and we approached Jack Dongarra and the Innovative Computing Lab, who maintain NETLIB, about the recommended naming. The definition of BLAS is not a standard maintained by the ISO. The landscape of precisions has become more complicated than when ICL provided the guidance, so all of us need to adapt. Because of the rapid changes in hardware and use in ML/DL algorithms, this field is evolving rapidly.

BLAS is not just OpenBLAS: it's NETLIB, ATLAS, BLIS, IBM ESSL, Intel MKL, Eigen, and others. We, and other vendors adding low-precision features, were and are trying to ensure compatibility across the spectrum of packages.

Martin, Guobing, and Conrad are welcome to contact ICL, join the conversation and help to coordinate this space. Pointing fingers and recommending unilateral action is not productive.

edelsohn avatar Sep 07 '20 13:09 edelsohn

https://github.com/xianyi/OpenBLAS/issues/2767#issuecomment-671896840 is certainly open to (mis)interpretation. I had hoped that the naming would have been agreed on (and perhaps publicized in whatever the usual manner, if any) by "vendors" and other interested parties by the time the contribution got merged, and not have this devolve into a company grandstanding contest before the new functionality got even one user. Keeping the number of unresolved technical issues in check is hard enough as it is.

martin-frbg avatar Sep 07 '20 14:09 martin-frbg

Though I'm not entitled to give opinions on these matters, I think the importance of the names and letters choice is irrelevant here. The most important thing is should be having standardized mangled entry names. The ones who want friendly names could write generators to produce. so I believe the OpenBlas team should adopt suggested names and concentrate on performance

quickwritereader avatar Sep 08 '20 00:09 quickwritereader

We thought that the names and semantics for reduced precision that IBM contributed to OpenBLAS had the agreement of ICL. The IBM team will work with OpenBLAS to update the APIs and implementation so that they are compatible with the definitions being adopted by ICL and other packages.

edelsohn avatar Sep 08 '20 00:09 edelsohn

Just re-read all the comments, though that I am already working on new bfloat16 functions with 'sh' prefix...

One question to @edelsohn, could you show more detail on in which place/doc ICL approved to use the 'h' prefix? I have this question because @mgates3 said in comments that there is no standard and will not be standard single letter like 'h', and the trending is with more comprehensive name in BLAS G2 which is working in progress. As @mgates3 comes from ICL, you two's comments seem a bit conflict.

Guobing-Chen avatar Sep 08 '20 01:09 Guobing-Chen

@edelsohn We may need to clarify the timeline and what exactly has been proposed by who (and to who). I agree with @Guobing-Chen about the need for a specific document for the proposed naming, and how this doesn't conflict with both the comment by @mgates3: "... likely will never standardize on h for half ..." and the proposal given in http://goo.gl/D1UKnw

The landscape of precisions has become more complicated than when ICL provided the guidance (...) Because of the rapid changes in hardware and use in ML/DL algorithms, this field is evolving rapidly.

I'm not sure I agree with assertion about all of this being "complicated" and "rapid". bfloat16 has been around for a while now, and IEEE half precision floating point has been around for even longer. These are clearly two well-known, valid and separate formats to represent floating point numbers stored in 16 bit. I don't see why all of a sudden there should be a mad rush to implement a half-baked proposal (no pun intended) that confuses between the two formats.

conradsnicta avatar Sep 08 '20 02:09 conradsnicta

I suspect the impetus comes from recent implementations of bfloat16 operations in CPU rather than GPU hardware that are assumed to become a strong selling point for certain high-end processors. And I must admit that I am not even aware who still uses IEEE half precision nowadays - I remember it from GPU shaders but never saw it in any of the scientific and engineering fields I came into contact with over the years. There will probably be important ones, and in any case creating confusion among such a mixed userbase as OpenBLAS is likely to have is certainly not a good start. (Which is why I am a bit unhappy with the current situation, though we may have arrived at it through a series of honest misunderstandings. For all the merits of the next-gen naming proposal, I suspect it will be years to its wide-spread adoption while what is needed is an acceptable solution for now, for both "AI" and "IEEE" camps, in the current F77 alphabet soup style.)

martin-frbg avatar Sep 08 '20 07:09 martin-frbg

The U.S. is returning from a weekend holiday. I am asking my colleague who had the conversation with Jack to clarify the naming information.

edelsohn avatar Sep 08 '20 14:09 edelsohn

Dear Friend,

I have not been following this thread in detail, but I feel it would be appropriate for me to clarify how the name "shgemm" came to be proposed by the IBM team for this new mixed-precision routine we are discussing. I want to start by saying that I am solely responsible for choosing that name.

Future IBM processors will have support for reduced-precision 16-bit floating-point formats, including the format commonly known as bfloat16. As we prepare for those future processors, it became clear that it would be useful to have routines in BLAS (and OpenBLAS in particular) that support the format. Our first candidate routine was general matrix multiply (GEMM) that took two bfloat16 inputs A and B and produced a single-precision (IEEE binary32 format) result C. We developed and coded a reference implementation for that routine, as well as an implementation optimized for the future IBM POWER10 processor.

We had to choose a name for our new routine. I reached out to members of the Innovative Computing Laboratory at the University of Tennessee for guidance in naming mixed-precision routines. I received good guidance and reference materials. One of those materials was a pointer to the way MAGMA has named mixed-precision routines, as described in "https://icl.cs.utk.edu/projectsfiles/magma/doxygen/routines.html", with the warning that the naming approach could be improved. Inspired by the approach in MAGMA of using two-letter prefixed (first for result precision, second for input precision) I personally made the decision of calling the new routine "shgemm". That was my decision and my decision alone. After that decision, I did not reach out to anyone else, in academia or industry, to validate that name. From the discussion in this thread, I must conclude that I failed to communicate to my colleagues at IBM, who have done all the work and constantly interact with the broader community, that the decision was purely mine. My colleagues had no ill intentions when they proposed the new routine, with the name I gave it, to the OpenBLAS community. They thought that they were proposing a name with broader industry, academia and community support.

I understand that people want to revisit that name. I think it is a great idea for the community to work together and agree on a set of names for (at least) the two main half-precision formats: IEEE binary16 and the format commonly known as bfloat16. The work would have broad impact, as there are more machines coming up with hardware support for reduced-precision floating-point formats.

Sincerely,

Jose Moreira

joseemoreira avatar Sep 10 '20 00:09 joseemoreira

Thank you very much for the detailed explanation. So I guess we are the provisional brainfloaters working group now. 🙂

martin-frbg avatar Sep 10 '20 06:09 martin-frbg

So are there any objections against changing the prefix to "sb" (and the build option to something like BUILD_BFLOAT I guess) so far ? Anybody else we should invite to comment on this matter ? I am currently recovering from dental surgery (previous message was actually sent from the chair, waiting for the local anesthetic to kick in) but would like to see this resolved before the next release if possible.

martin-frbg avatar Sep 14 '20 06:09 martin-frbg

I like the "sb" prefix for "bfloat16" input and "single-precision" output. It leaves open "sh" for IEEE 16-bit input.

Martin: Hope your dental surgery recover goes well. I had one of those several years ago. Not fun :-(

joseemoreira avatar Sep 14 '20 16:09 joseemoreira

@martin-frbg, have a speedy recovery!

quickwritereader avatar Sep 14 '20 17:09 quickwritereader

I just hope nobody has discovered the current "shgemm" for their project so that we can safely repurpose the name. And thanks a lot for your kind wishes, I do find that my childhood wish to live entirely on ice cream has not aged well :-/

martin-frbg avatar Sep 14 '20 18:09 martin-frbg