I learned recently that Excel rounds numbers (which it stores as IEEE 754 binary64) as though they were 80-bit extended precision, a la x87. It seems the "we don't actually need that much precision" trend has been going for a long time.
This sounds like a backwards compat solution. Microsoft probably didn't want customers freaking out that their spreadsheets show slightly different numbers on different platforms.
One of the biggest mystery for me in terms of computing is precisely the proliferation of floating point numbers. We spent almost half a year of numerical methods classes dealing with floating points numbers, at it never sit right with me, precisely because it was serious science.
The way I think computing should have evolved, given their history in scientific and military applications:
Starting with arbitrary precision formats
Noticing it's sometimes too slow
Developing IEEE-754 and surrounding set of maths as principled hacks to speed up key computations.
What reality seems to look like:
Limited precision calculations are the default.
There is a side branch of CS developing principled ways of dealing with it, and you hope hope hope at least some scientists are aware of that, instead of just using floats and thinking computers are always right.
Everyone assumes this is how things should be, and the only somewhat known exception is finance, specifically "don't use floats to add moneys".
“Several of the digital computers being planned or built in this country or in England are to contain a so-called floating decimal point.' ... There appear to be two major purposes in a 'floating' decimal point system both of which arise from the fact that the number of digits in a word is constant, fixed by design considerations for each particular machine. The first of these purposes is to retain in a sum or product as many significant digits as possible and the second of these is to free the human operator from the burden of estimating and inserting into a problem 'scale factors' multiplication constants which serve to keep numbers within the limits of the machine.
There is, of course, no denying the fact that human time is consumed in arranging for the introduction of suitable scale factors. We only argue that the time consumed is a very small percentage of the total time we will spend in preparing an interesting problem for our machine. The first advantage of the floating point is, we feel, somewhat illusory. In order to have such a floating point one must waste memory capacity which could otherwise be used for carrying more digits per word. It would therefore seem to us not at all clear whether the modest advantages of a floating binary point offset the loss of memory capacity and the increased complexity of the arithmetic and control circuits”
(Historically, the idea of fixed-point floats go back centuries, to the first mechanical calculators and the slide rule)
This was one of the few cases when von Neumann was proved to be very wrong.
He thought that the work of inserting in programs adequate scale factors in computations would not take too much of programmer's time, because he did not envision how big the problems solvable with computers will become, and also he did not envision how cheap computer memory will become, because at that time he was very much concerned that the high cost of memory was the main limiting factor for what could be done with computers.
Only a few years later it became obvious that far too much work is required to determine adequate scale factors, so this work is better left to the computer, by the use of floating-point numbers, and that the additional memory cost is cheaper than the programming work saved thus.
Limited precision calculations have become important only during the last 15 years, since NVIDIA broke their initial promises made when they first began to promote GPGPU and CUDA, when they claimed that unlike the mean CPU vendors they will provide a supercomputer for every computer user. Making a U-turn, NVIDIA removed the ability to make fast FP64 computations from their "consumer" GPUs, a policy that was also followed by AMD a few years later.
Because all cheap GPUs suck at FP64, but they have excellent throughput for lower-precision numbers, it has become important to devise algorithms for computing with hybrid precision, using as much low-precision computation as possible, in order to be able to use GPUs for accelerating the solutions.
The use of GPUs for low-precision computations can provide a great acceleration when implemented correctly, but it requires much more programming work than when you can use FP64 for everything, and it provides much more opportunities for subtle bugs.
Before GPUs, for many decades, already since the fifties, it was never worthwhile to try to implement scientific/technical computations with low-precision hardware, instead of buying or renting adequate high-precision hardware.
> given their history in scientific and military applications
Ah, but there is the answer to the mystery. This history is dominated by the successes of processing elements that have been pressed to their absolute limits continuously, from the first day till today. At no point in that history have the most ambitious new applications had the luxury of foregoing the essential performance benefits of suffering imprecision: the ambitions of new applications invariably require whatever performance can be had. This self-evidently explains why there has not been a time in which these techniques have been reconsidered: the focus is always whatever is now just plausibly possible with whatever new performance frontier we are provided, and so these techniques win yet more battles.
It is possible to find this disappointing, and perhaps even cynical: there is no force to restrain the chronic habit of compromising precision for the sake of some application, as long as it yields useful results. I can understand that, but I recommend not indulging the fantasy of some hypothetical world where this will not happen.
What I find interesting is this question: What ugly truth about the universe do we miss by failing to recognize and appreciate whatever this pattern is telling us?
With fp4 you only have 16 values, if you define it to be symmetric by sign you only have 8 absolute values.
That seems like a low enough size that you could measure the effectiveness of any set of 8 values across a wide variety of neural net tasks. I would think that it could be possible to do a search for the optimal generally useful 4-bit representation.
Would the ideal values fall on a simple function? would they seem randomly spaced?
It would probably be interesting for an architecture and a dataset but I wouldn't assume another architecture and/or another dataset would have the same optimum.
I agree that there are almost certainly various specialised optimums. But the idea for a general best would be to find what is most likely to give a good result when you don't know the architecture or task.
One of the problems with optimising implementations for the task that everyone is doing today is that it discourages people from finding new ways of looking at things if they have to take a performance hit to even consider it.
A modest proposal - dear hardware designers: your multiplier's internal datapath is already much wider than these narrow formats, and you already widen the input as you go. Instead of hardware support for specific schemes - which are already too prolific, with new ones landing faster than any plausible hardware design lead time - have your hardware take a generic description of the packing (mantissa/exponent/sign bits; biases for mantissa and exponent, which may be constant or may come from a separate data stream per group; data stream strides and group sizes) to support all current and future formats then stop worrying about it.
I do wonder if we will be getting specialized hardware support for these, aimed at running quantized models. You could fit many FP8 or FP4 units in the same die space as a single FP32 one. Even more if you remove capabilities other than strictly needed (mainly addition and multiplication).
For cpu and mobile, I’ve been using int8 a lot because it has broad instruction support and is much faster to inference than fp32.
I think fp8 instructions are becoming more prevalent on arm and x86 as well. The main issue is just that if you export a model for fp8, then it would not be supported on a large number of platforms yet and would fall back to fp32 and be slower than int8.
Zen 6 has already been launched (for servers), so it still supports only BF16, FP16 and INT8, but Zen 7 and the future Intel CPUs will support FP8 and a few other ML/AI small number formats (according to the ACE specification; ACE = AI Compute Extensions).
I'm surprised this doesn't mention posits. I had the pleasure of attending Gustafson's CoNGA-Q@SC26 talk the week before last. Here's a summary of how they work in case you're curious.
Their ability to extend the exponent range toward infinity at lowered accuracy sounds useful, but the ability to extend the exponent range toward 0 at lowered accuracy sounds less useful to me.
Though even if it can save a bit or two it's a lot of decoding work if you want to use normal hardware, so I'm not surprised to see limited attention. And in realistic circumstances I don't think it's saving more than a bit or two.
>lot of decoding work if you want to use normal hardware
Like any logarithmic number system, you can use the shortcut where multiplication becomes addition, division becomes subtraction, and addition becomes softmax (which can be implemented with simple bit arithmetic hardware similar to MSb).
That transformation sounds slower than doing the handful of bit shifts.
The problem is that a handful of bit shifts on top of 12 bit multiply or similar ends up being a huge overhead percentage-wise.
Also you can do the same transformation with normal floats, so I'm not sure why you're bringing it up here.
Edit: Reading the thread over there I think you misunderstood posits. They're an alternative way to encode the exponent of floating point numbers that's variable-length. This has benefits and costs but posits don't really change how you do the math at all. There's a reason the implementer of that library said [[You do pretty much always have to convert to an intermediate representation of "mantissa + exponent".]]. And posits come with the suggestion of a giant accumulator but that's a separate feature from the number format and could be attached to a normal FPU.
>That transformation sounds slower than doing the handful of bit shifts.
It certainly would be, except you don't actually perform the log or exp transform in/out of every operation. The representation stays logarithmic the whole time.
Indeed I see little value in variable length exponents. It was a convenient jumping off point, don't think too much of it. ;)
This simplifications works in any log-distributed number representation (ie not FP). Naturally, you can also fake it in FP by just re-labeling all your numbers, or do it approximately like Carmack's fast InvSqrt.
I learned recently that Excel rounds numbers (which it stores as IEEE 754 binary64) as though they were 80-bit extended precision, a la x87. It seems the "we don't actually need that much precision" trend has been going for a long time.
This sounds like a backwards compat solution. Microsoft probably didn't want customers freaking out that their spreadsheets show slightly different numbers on different platforms.
Definitely has been.
One of the biggest mystery for me in terms of computing is precisely the proliferation of floating point numbers. We spent almost half a year of numerical methods classes dealing with floating points numbers, at it never sit right with me, precisely because it was serious science.
The way I think computing should have evolved, given their history in scientific and military applications:
What reality seems to look like:
WTF.
> The way I think computing should have evolved, given their history in scientific and military applications:
> 1. Starting with arbitrary precision formats
> 2. Noticing it's sometimes too slow
And always too costly. Both were so bloody obvious that they didn’t consider 1 at all.
> What reality seems to look like:
> 1. Limited precision calculations are the default
Historically, fixed precision integer calculations with implied decimal points were the default.
Von Neumann, in 1946 (https://www.arithmazium.org/library/lib/wk_floating_point_hi...):
“Several of the digital computers being planned or built in this country or in England are to contain a so-called floating decimal point.' ...
There appear to be two major purposes in a 'floating' decimal point system both of which arise from the fact that the number of digits in a word is constant, fixed by design considerations for each particular machine. The first of these purposes is to retain in a sum or product as many significant digits as possible and the second of these is to free the human operator from the burden of estimating and inserting into a problem 'scale factors' multiplication
constants which serve to keep numbers within the limits of the machine.
There is, of course, no denying the fact that human time is consumed in arranging for the introduction of suitable scale factors. We only argue that the time consumed is a very small percentage of the total time we will spend in preparing an interesting problem for our machine. The first advantage of the floating point is, we feel, somewhat illusory. In order to have such a floating point one must waste memory capacity which could otherwise be used for carrying more digits per word. It would therefore seem to us not at all clear whether the modest advantages of a floating binary point offset the loss of memory capacity and the increased complexity of the arithmetic and control circuits”
(Historically, the idea of fixed-point floats go back centuries, to the first mechanical calculators and the slide rule)
Thank you! This is exactly the back-story I missed in my CS education.
This was one of the few cases when von Neumann was proved to be very wrong.
He thought that the work of inserting in programs adequate scale factors in computations would not take too much of programmer's time, because he did not envision how big the problems solvable with computers will become, and also he did not envision how cheap computer memory will become, because at that time he was very much concerned that the high cost of memory was the main limiting factor for what could be done with computers.
Only a few years later it became obvious that far too much work is required to determine adequate scale factors, so this work is better left to the computer, by the use of floating-point numbers, and that the additional memory cost is cheaper than the programming work saved thus.
> and the only somewhat known exception is finance, specifically "don't use floats to add moneys".
Even that one is mostly a myth. A whole heap of investment-oriented things just round to the nearest cent and use floats anyway.
[deleted]
Arbitrary precision was not a thing before computers. Why would the first computers default to that given how expensive memory was?
> Limited precision calculations are the default
Limited precision calculations have become important only during the last 15 years, since NVIDIA broke their initial promises made when they first began to promote GPGPU and CUDA, when they claimed that unlike the mean CPU vendors they will provide a supercomputer for every computer user. Making a U-turn, NVIDIA removed the ability to make fast FP64 computations from their "consumer" GPUs, a policy that was also followed by AMD a few years later.
Because all cheap GPUs suck at FP64, but they have excellent throughput for lower-precision numbers, it has become important to devise algorithms for computing with hybrid precision, using as much low-precision computation as possible, in order to be able to use GPUs for accelerating the solutions.
The use of GPUs for low-precision computations can provide a great acceleration when implemented correctly, but it requires much more programming work than when you can use FP64 for everything, and it provides much more opportunities for subtle bugs.
Before GPUs, for many decades, already since the fifties, it was never worthwhile to try to implement scientific/technical computations with low-precision hardware, instead of buying or renting adequate high-precision hardware.
> given their history in scientific and military applications
Ah, but there is the answer to the mystery. This history is dominated by the successes of processing elements that have been pressed to their absolute limits continuously, from the first day till today. At no point in that history have the most ambitious new applications had the luxury of foregoing the essential performance benefits of suffering imprecision: the ambitions of new applications invariably require whatever performance can be had. This self-evidently explains why there has not been a time in which these techniques have been reconsidered: the focus is always whatever is now just plausibly possible with whatever new performance frontier we are provided, and so these techniques win yet more battles.
It is possible to find this disappointing, and perhaps even cynical: there is no force to restrain the chronic habit of compromising precision for the sake of some application, as long as it yields useful results. I can understand that, but I recommend not indulging the fantasy of some hypothetical world where this will not happen.
What I find interesting is this question: What ugly truth about the universe do we miss by failing to recognize and appreciate whatever this pattern is telling us?
With fp4 you only have 16 values, if you define it to be symmetric by sign you only have 8 absolute values.
That seems like a low enough size that you could measure the effectiveness of any set of 8 values across a wide variety of neural net tasks. I would think that it could be possible to do a search for the optimal generally useful 4-bit representation.
Would the ideal values fall on a simple function? would they seem randomly spaced?
NVFP4 and MXFP4 actually have block scaling to adapt to a wide range of values. NVFP4 has an additional tensor scale.
GP meant the distribution of values, after normalisation
It would probably be interesting for an architecture and a dataset but I wouldn't assume another architecture and/or another dataset would have the same optimum.
I agree that there are almost certainly various specialised optimums. But the idea for a general best would be to find what is most likely to give a good result when you don't know the architecture or task.
One of the problems with optimising implementations for the task that everyone is doing today is that it discourages people from finding new ways of looking at things if they have to take a performance hit to even consider it.
A modest proposal - dear hardware designers: your multiplier's internal datapath is already much wider than these narrow formats, and you already widen the input as you go. Instead of hardware support for specific schemes - which are already too prolific, with new ones landing faster than any plausible hardware design lead time - have your hardware take a generic description of the packing (mantissa/exponent/sign bits; biases for mantissa and exponent, which may be constant or may come from a separate data stream per group; data stream strides and group sizes) to support all current and future formats then stop worrying about it.
I do wonder if we will be getting specialized hardware support for these, aimed at running quantized models. You could fit many FP8 or FP4 units in the same die space as a single FP32 one. Even more if you remove capabilities other than strictly needed (mainly addition and multiplication).
NVFP4 seems like what you're after. It's a hardware supported datatype purpose-built for running quantized models. Inkling 2 mini uses it.
And MXFP4 for non-CUDA devices like ROCm.
Is that the new one in Blackwell and above ?
For cpu and mobile, I’ve been using int8 a lot because it has broad instruction support and is much faster to inference than fp32.
I think fp8 instructions are becoming more prevalent on arm and x86 as well. The main issue is just that if you export a model for fp8, then it would not be supported on a large number of platforms yet and would fall back to fp32 and be slower than int8.
Zen 6 has already been launched (for servers), so it still supports only BF16, FP16 and INT8, but Zen 7 and the future Intel CPUs will support FP8 and a few other ML/AI small number formats (according to the ACE specification; ACE = AI Compute Extensions).
Plenty of hardware now supports the microscaled FP4 and FP8 types - for example Blackwell GPUs.
Didn't the old ass Titan Black specifically have hardware for something like this that made it desire able for early ML work ?
Microscaled types? It was released in 2014 - far before the OCP types. It has INT8 vector according to techpowerup.
There was FP8 block scaled MSFP on Brainwave FPGAs in 2020 - https://www.microsoft.com/en-us/research/blog/a-microsoft-cu...
Since FP precisions and bits is getting some attention today, I just whipped up a floating point bit explorer tool: https://www.linearalgebraforprogrammers.com/tools/floating_p...
This is a fun coincidence to see here.
I was hoping this would talk more about the intuition behind the creation of the actual formats… And a bit more of the history.
I'm surprised this doesn't mention posits. I had the pleasure of attending Gustafson's CoNGA-Q@SC26 talk the week before last. Here's a summary of how they work in case you're curious.
http://www.johngustafson.net/pdfs/BeatingFloatingPoint.pdf
Their ability to extend the exponent range toward infinity at lowered accuracy sounds useful, but the ability to extend the exponent range toward 0 at lowered accuracy sounds less useful to me.
Though even if it can save a bit or two it's a lot of decoding work if you want to use normal hardware, so I'm not surprised to see limited attention. And in realistic circumstances I don't think it's saving more than a bit or two.
https://news.ycombinator.com/item?id=50686475
That transformation sounds slower than doing the handful of bit shifts.
The problem is that a handful of bit shifts on top of 12 bit multiply or similar ends up being a huge overhead percentage-wise.
Also you can do the same transformation with normal floats, so I'm not sure why you're bringing it up here.
Edit: Reading the thread over there I think you misunderstood posits. They're an alternative way to encode the exponent of floating point numbers that's variable-length. This has benefits and costs but posits don't really change how you do the math at all. There's a reason the implementer of that library said [[You do pretty much always have to convert to an intermediate representation of "mantissa + exponent".]]. And posits come with the suggestion of a giant accumulator but that's a separate feature from the number format and could be attached to a normal FPU.
Indeed I see little value in variable length exponents. It was a convenient jumping off point, don't think too much of it. ;)
This simplifications works in any log-distributed number representation (ie not FP). Naturally, you can also fake it in FP by just re-labeling all your numbers, or do it approximately like Carmack's fast InvSqrt.
Just another trick in the toolbelt.
[dead]