Beating Floating Point at Its Own Game: Posit Arithmetic [pdf] (opens external site)
View full thread · View on Hacker News
To get push notifications on iPhone or iPad, add Hack and Chat to your Home Screen: tap Share → Add to Home Screen, then open the installed app and enable push in Settings.
View full thread · View on Hacker News
Source: (https://www.researchgate.net/publication/417276683_Hardware_...)
TLDR; The leading 0 + dynamic length and the 512-bit accumulators for quires require hardware specifics like extra register per MAC and barrel shifters which take up about 30% of the total unit area.
Probably not impossible to get around but in no way a drop-in or currently better supported by HW.
---
Also non-uniform relative error is a nightmare for any numerical formal verifier that are used by most frontier labs today to avoid numerical divergence during training.
Replies (5)
Replies (2)
You do pretty much always have to convert to an intermediate representation of "mantissa + exponent". That is how IEEE754 impls work also. It is a bit more complex than IEEE to do so, because of the variable-length field, but surprisingly not too much so (count-leading-0 plus a couple of shifts and xors do the trick!) Less than 2ns on my machine :)
Replies (1)
Replies (1)
Replies (1)
Slide-rules are handy because they convert multiplication into addition. Or technically that's what logarithms do, and slide-rules are a physical implementation of logarithms.
Recall the classic identity:
log(x * y) = log(x) + log(y)
Slide-rules have multiple rulers, and some are marked in log scale, which lets you multiply totally mechanically! By aligning the markings, you effectively add two lengths, which (when read back on the log tick marks) becomes multiplication.
If you perform the same algebra transform as above, you see that addition becomes (oddly, but more intuitive the more you think about it) the Softmax function.
https://en.wikipedia.org/wiki/Softmax_function
This is my first time seeing Posits, but (having had similar ideas loosely inspired by the Doom bit-hacks) I just assumed this was one of the main sales pitches for Posits!
https://github.com/interplanetary-robot/mullinengine/blob/ma...
and multiply:
https://github.com/interplanetary-robot/mullinengine/blob/ma...
Here is an example generated verilog files:
https://github.com/interplanetary-robot/mullinengine/blob/ma...
You may find the handcrafted "circ" files more useful.
https://github.com/interplanetary-robot/mullinengine/blob/ma...
https://github.com/interplanetary-robot/mullinengine/blob/ma...
This was the julia library I wrote to be able to output verilog from julia. In the case of the posit math, it's verified by compiling with verlator, and doing a comprehensive (256 x 256 8-bit) scan comparing the emitted C-abi .so file, the wire values from verilog.jl, soft-values from the SigmoidNumbers package, the "true" value.
https://github.com/interplanetary-robot/Verilog.jl
Replies (1)
> Also non-uniform relative error is a nightmare for any numerical formal verifier that are used by most frontier labs today to avoid numerical divergence during training.
I'm not sure what you mean by this. Yes IEEE has 40+ years of study behind it so its numerical properties are very well understood, that much is obvious. But I don't see what you are claiming exactly.
Replies (1)
The floating-point number format has not been chosen due to some historical accident, but because it is the only number format that combines fast computation with almost constant relative error over the domain of the represented numbers.
In almost all scientific/technical computing applications, constant relative error is what is desired, and it also enables a relatively simple analysis of the error propagation.
The non-constant relative error of the posits makes the analysis of the error propagation very difficult. Many applications need accurate estimations of the worst-case errors that can affect the results.
For any number representation system where the relative error is not constant, decreasing the error in some part of the domain increases the error in other parts of the domain, because the number of values is the same, being determined by the number of bits.
For some weird reason, posits want smaller errors around the origin, and this is paid by greater errors far from the origin.
Perhaps there are applications where this is useful, but in decades of experience with various applications of scientific/engineering computing I never wanted this error behavior, but I always wanted the constant relative error provided by FP numbers, even very far from the origin, with few exceptions where constant absolute error was desired, which is provided by fixed-point numbers, not by posits.
So for me, posits are a solution in search for a problem, because I do not see which professional would want such a thing. Tailors might work with feet and inches, so posits might be adequate for them, but fixed-point numbers are even better for them, being easier to use and having a lower absolute error. On the other hand, an electronics engineer works with picoseconds, femtofarads, nanoamperes, megavolts, terahertz, the elementary electric charge, Planck's constant, Boltzmann's constant, Avogadro's constant and so on, for which posits are useless.
Perhaps posits might be better than floating-point for ML/AI applications, but I say this only because I do not know which properties of the numbers really matter in that application, unlike for scientific/engineering computations, where I know with certainty that posits are not suitable, by leading to greater computational errors, while having a chance to be faster only for small number formats, not for 64-bit or bigger numbers.
Replies (2)
Evidently, Gustafson felt he had to change tack because he seems to have dropped unums after that debate and changed entirely to posits. And in the change to posits, he seems to have dropped most of the actual benefits of unums he was touting, although he hasn't quite dropped some of the cultish language he uses around the concept. The main trick of posits is to achieve greater precision for numbers around ±1 and greater exponent range, but by brushing the trade-offs used to achieve that under the rug. Except there's not really any demand for greater exponent range, so the trade-offs really overwhelm the marginal benefit of higher precision for a very specific range of numbers.
The new paper linked in the comment you replied to appears to acknowledge this, even in the AI tiny floating-point space, by basically fixing a maximum exponent range so that you have usable precision at higher exponents.
[1] I'd say IEEE floating-point, but the principles that Gustafson is attacking are found in virtually all formats pre-IEEE 754, with the exception of NaNs.
[2] The transcript is here, for the reader to decide for themselves: http://www.johngustafson.net/pdfs/DebateTranscription.pdf
Replies (1)
https://github.com/interplanetary-robot/SigmoidNumbers/blob/...
I mean this is kind of "intuitive" error behavior. At some point the bigness of something is more important than the exact number. However, for sci/eng applications where peoples lives depend on your error analysis maybe not so much. For a lot of applications you want higher resolution around 1 -- and really you should be normalizing back to 1 after operations in general. And yes, I kept pointing out that error analysis and propagation was going to be a bitch =D which is why I kept pushing away from applications where you care a LOT about errors and towards applications where you care less about errors (like ML inference)
https://github.com/interplanetary-robot/mullinengine/blob/ma...
At the time IEEE-16 vs posit-16 was not really a thing yet, so I can't say if the multiplication would be worse because the extended size of the multiplier is not as dramatic as it is with posit-32, and the special-case handling (denormals, NaNs) is expensive.