249 points · by peter_d_sherman · 4d ago · 62 comments
Simple implementations of the FP64 operations with FP32 will result in a speed of up to 4 times greater than that of the hardware, for correct implementations that also implement the FP64 exponent range and the behaviors for special FP values.
By using the GPU "tensor" units, higher speedups should be achievable, like claimed in this paper.
Nonetheless, the 83x speedup from the paper is most likely bogus and not reachable in most applications. The real speedup might be 2 or 3 times less than that.
After a quick skimming through the paper, I could not find any mention about how they handle exponents and floating-point exceptions.
If they do not implement the standard FP64 exponent range, underflows and overflows would be extremely frequent. Depending on how they handle exceptions, this would either produce incorrect results or slow down the computation dramatically.
Edit: apparently paper is exactly about this (I started reading it after comments...)
This would achieve maximum computational efficiency, but the higher level layers of the software would have to be modified from problem to problem.
Nonetheless, it might be possible for such a rewriting of the higher level layers to become simpler than in the past, when using an LLM assistant.
Why would multiplication and addition be the only needed math, and not xor gates.
Ai should be used to find that set of functions.
https://dnhkng.github.io/posts/m4-tinystories/
https://dnhkng.github.io/posts/isa-net-compression/
I think they may have popped up on HN already.
I can write to Dan the moderator to get it through, but it's easier for someone else to post it.
https://proceedings.neurips.cc/paper_files/paper/2024/hash/7...
It uses XNOR (IFF, the opposite of XOR) as the activation function. This allows for a binary neural network that is trained directly in binary, not quantized later.
There is also a bunch of other papers that forego neural networks altogether and instead use something called "logic gate networks". Instead of neurons, they use logic gates. They don't have weights and use random connections instead. The learning consists in deciding which logic gate to use at each node ("neuron") in the network. They use conventional differentiation though, by "relaxing" the binary Boolean functions into continuous functions between 0 and 1, and then converting them to binary after training. I wonder whether the binary training approach from the paper above could be used for much faster training of these "logic gate networks". Currently they have extremely fast inference but slow training.
I believe binary networks use quantization-aware training for exactly that reason as well.
Addition modulo 2 is special, because it is identical with subtraction modulo 2. This means that computer "XOR" has 2 possible interpretations, as addition modulo 2 and as subtraction modulo 2.
Because addition modulo 2 is special, some of the algorithms that work with additions in bigger fields also work modulo 2, but other algorithms are no longer applicable.
The entire ML literature for the last 30 years has been playing genetic optimisation on model designs and architectures. We are reaching the exploitation phase because it is becoming clear that exploration is giving diminishing returns.
It's hard to determine upfront which combination of hardware and software (i.e. which primitive type to use) is going to be optimal.
My first home assignment after being introduced to NN was to draw an XOR gate on paper using neurons.
How to do it, is left as an exercise to the reader.
So, they formulated a combinatorial optimization method to unify tricks that break down a single, high-precision FP64 matrix multiplication into many small, low-precision ones using modular arithmetic (the Chinese Remainder Theorem) and then reassemble the exact result.
Conclusion: 83× speedup over native FP64 on an NVIDIA B300 GPU
So would it make more sense for me to target the paper's FP4/FP6/FP8 (maybe even the NVIDIA specific implementations) or would it make more sense for me to optimize the INT8 performance? I'm not sure the extra memory traffic wouldnt just offset non-INT8.
There's some interesting Chinese accelerator chips bubbling up that are all int8 or just int8 and fp16 and nothing else.
The hardware is quite capable but I think there is still a lot of room for architecture specific optimizations.
Not only the precision must be around that of FP64, but also the exponent range must be wide enough to make unlikely overflows and underflows, which is a condition not satisfied by FP32.
Sometimes it is possible to use mixed precision, i.e. to do some computations with FP64 and others with FP32, but the right combination varies from a problem to another and a lot of work is necessary to determine an optimum distribution of the computations over the different precisions. It is much easier to use FP64 everywhere.
In electronics, where one frequently has to solve systems of the so-called "stiff" ordinary differential equations (e.g. in SPICE analyses), using numbers with insufficient precision frequently either prevents convergence or leads to "hallucinated" incorrect solutions.
The idea frequently pushed by those who try to support NVIDIA and its followers, that one should find an approximate solution in FP32, which should do most of the work, and then the accuracy of that solution should be improved with FP64 with a little additional work, frequently fails for electronics problems and other stiff problems, because the low-precision computations may converge to a different solution, whose improvement does not lead to the correct solution obtained with high-precision computations.
That question is going to be increasingly relevant. And some will be intentionally written not for humans.
I often just pass the paper to agent and ask it to make me what the paper describes.
If they can deploy aoftware and models, these benefits go into hardware selection.
Within a given budget and if you are not a big company that can buy server CPUs and datacenter GPUs at prices much lower than their list prices, the most financially-efficient way to simulate nuclear weapons or any other complex system would be to buy a set of desktops with AMD 9950X and also dual-port 25 Gb/s Ethernet NICs for interconnecting them into a ring (1 NIC per PC) or into a mesh (2 NICs per PC).
Those computers could be augmented with Intel Battlemage GPUs, which have the maximum performance per dollar of anything existing on the market.
Like, one RTX 4090 outperforms the ASCI Red from 1997 ("First to TFLOPS").
And weapon design itself peaked decades beforehand (some time in the 60s/70s, using a trillionth? of modern compute).
Whatever the computing part of nuclear stewardship looked like at the end of the cold war, you can easily replicate that at home already.