Unofficial Hacker News client - receive Push Notifications on replies.

FP64 Is All You Want, INT8 Is All You Need, FP4/6/8 Is All You Have (opens external site)

245 points by peter_d_sherman 1 day ago | arxiv.org | 61 comments on HN | Vote on HN (opens Hacker News)

Comments (61)

  1. Up to 83x speed increase for fp64 matmul on b300. Great news for all the woefully underutilized Blackwell's out there!
    Replies (1)
    1. Like, it is? That's almost two orders of magnitude performance improvement on the same hardware.
      Replies (1)
      1. "same hardware" might be a misleading way to think about it. There's only a handful of fp64 units on the die, so it wouldn't be a big exaggeration to say the native performance is zero. This algorithm actually makes use of the computational power of the die. And going from near-zero to solid performance is automatically a near-infinite improvement factor.
        Replies (1)
        1. Intels latest GPU for compute targets fp64 performance.

          If they can deploy aoftware and models, these benefits go into hardware selection.

          Replies (2)
          1. The speed of this method is part of hardware selection for sure.

            But I'm saying the native performance number is too low to care about, so the 83x ratio isn't meaningful. It's an important number divided by an unimportant number. If native was a little better and the ratio was 50x, or native was even worse and the ratio was 600x, that change in ratio would basically not matter.

          2. The second generation Intel GPUs, i.e. Battlemage, have 1:8 FP64:FP32 throughput, which is a great improvement over the other consumer GPUs.

            The last consumer GPU with similar FP64 performance was AMD Radeon VII from 2019 (1:4 ratio).

            Nonetheless, Intel makes only small discrete GPUs. They have outstanding performance per dollar, but moderate absolute performance.

            I have an Intel Arc B580 in a computer with AMD Ryzen 9 9900X (i.e. 12-core Zen 5).

            In this configuration, the GPU and the CPU have a very similar FP64 throughput, which is less than that of a 16-core 9950X (but because adding the GPU doubles the throughput, the aggregate throughput is 50% over a 9950X).

            Adding the Intel GPU was worthwhile, because it doubled the throughput for a very low additional price, much less than with a second computer.

            Unlike Intel Battlemage, most other recent GPUs, except the AMD Instinct datacenter GPUs, have a 1:64 FP64:FP32 throughput ratio, which is trivially beaten by any software FP64 implementation.

  2. Yikes. Is this paper supposed to be read by humans or agents? Seems like the authors spent very little time doing any kind of readability checks. The results do look super impressive though. can anyone more in the know on why one wants fp64 matmuls in practice? Iiuc doing it at low bit and aggregating into bf16 was good enough eg when computing dot products even on pretty long vectors.
    Replies (4)
    1. Don't judge based only on LLMs. They are a special case coming from having a good amount of compression bias baked into their design. There are heaps of applications in scientific computing where you really need fp64 matmuls. The biggest issue comes with ill-conditioned matrices, where a low-precision matmul can cause catastrophic cancellation.
    2. In my corner of physics, the biggest theory breakthrough came from abandoning fp128 quad-precision and going to arbitrary precision libraries with tens to hundreds of (decimal!) digits.
      Replies (2)
      1. Sounds like something was wrong with the way the theory was realized in software.
        Replies (2)
        1. COBOL compilers rely on arbitrary precision, and GNU COBOL links in GNU MP to achieve it.

          https://archive.ph/K2TX3

          Replies (1)
          1. cobol has _fixed_ arbitrary precision, BCD encoded arbitrary fixed size numbers.

            they happened to use gnu MP, yes, but for cobol, dynamic arbitrary float precision or "never overflow" ints are not the point.

        2. Well yeah, but it sounds like what was wrong was the level of precision used. It's not always possible to work around numerical issues arising from finite precision.
      2. Say more! :-)
        Replies (1)
        1. The challenge is to calculate properties of three-body atomic or molecular systems (He, Li+, H2+,...) with extreme precision to allow comparisons with accurate measurements (we are doing such measurements). The starting point is to solve the Schrödinger equation, but in the three-body case, this is not possible analytically. This is one of the oldest problems in computational quantum mechanics, and the first numerical results were worked out already in 1928 by Hylleraas. It turns out that the approaches with the best convergence properties tend to be numerically unstable. The modern solution is to simply power through these numerical problems using arbitrary precision libraries with tons of digits.
    3. Unlike ML/AI computations, any not too simple physical model requires computations with an FP64 precision, and sometimes even higher. For input and output experimental data, FP32 is normally enough, but any arithmetic operations done with such FP32 input data would lose information unless they are done with FP64.

      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.

    4. > Is this paper supposed to be read by humans or agents?

      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.

  3. It should be possible to replace a small tree of neurons with a smaller set of functions that back propagate more efficiently and are cheaper to calculate meanwhile using less ram/cpu per computation. It's not probable that our first shoot in the dark with neurons got the optimal math structure.

    Why would multiplication and addition be the only needed math, and not xor gates.

    Ai should be used to find that set of functions.

    Replies (10)
    1. I do think it'd be interesting to have some kind of localized snapping when subsets of neurons adjacent enough to segment from the network as a whole are close enough to a known family of functions over their inputs. Some kind of optimizing compiler over approximated neural circuitry
      Replies (1)
      1. The rub is that this is only worthwhile with a computational complexity gain. Maybe fitting low order polynomials might give that gain, but more complex functions take extra cycles to compute and would struggle to compete with chains of simple, practical activation functions.
        Replies (1)
        1. Yeah, it seems like the kind of thing that's interesting but ultimately impractical from an optimization standpoint, but it could be an interesting mechanistic interpretability result
    2. Neurons can do XOR gates.

      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.

      Replies (1)
      1. They mean the inverse of that. Using XOR gates (or something similarly primitive) to implement neurons
    3. This sounds like Kolmogorov-Arnold networks.. rather than learning weights, learn a function computed by neurons
    4. Additions and multiplications give you gradients for back propagation, I’m not sure what the XOR equivalent would be.

      I believe binary networks use quantization-aware training for exactly that reason as well.

      Replies (2)
      1. On top of that, you can trivially construct an XOR gate with just 2 neurons in the hidden layer. Neural networks are already proven universal approximation schemes and they are differentiable, meaning you can train using gradient descent. These two facts are what gave rise to modern AI, not some half-motivated architecture or building block. Complexity is what you need, and gradient descent is what you use to tame it. There are probably still quite a few possible improvements to sections of the overall process, but the biggest revolution will probably come from making hardware more aligned with these ideas rather than making AI more aligned with traditional hardware.
      2. "XOR" is actually an incorrect name for addition modulo 2. For 3 or more inputs, true "XOR" and addition modulo 2 give different results ("exclusive or" means that 1 and only 1 of the operands is true, "addition modulo 2" means that an odd number of operands are true). No computer implements true "XOR", all implement addition modulo 2.

        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.

    5. Because multiplication and addition let you model continuous-ish functions cheaply.
    6. Replies (2)
      1. This is really cool!
      2. These are cool, you should submit them if no one did before.
    7. It's not our first shot in the dark, and the current configurations are pretty well principled. I would expect that other designs could work well in a task-specific sense, but only marginally, and in terms of a generic structure, there are a lot of theoretical benefits of the current design.

      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.

      Replies (1)
      1. At the micro-scale, exploration is giving diminishing returns. We're just starting to figure out how to build really powerful ensembles though. If random forests and boosted trees were prototype steam engines, transformer based DNNs are locomotives, and there's still a whole universe of applications and improvements.
    8. There is already a Boolean version of differentiation, called Boolean variation, which includes a chain rule and allows for a binary version of backpropagation and gradient descent:

      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.

    9. Replies (1)
      1. Very interesting!
    10. Softmax is like a differentiable xor

      5/5 - I am now banned and can't reply

      Replies (1)
      1. That happens when you win HN. It’s an award that means you are a huge dork.
  4. Could be a nice way to do nuclear weapons testing at home.
    Replies (2)
    1. Even with such a speedup, the performance per dollar of a Blackwell would be less than what you can achieve with desktop Zen 5 CPUs.

      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.

      Replies (1)
      1. I'm not sure if that holds for all markets. The B70 retails for about 2000 euros and has only 200 GB/s of memory bandwidth. It is the largest card in that price range by far so if you want to play with AI locally on a budget it is probably still the easiest way to get started.
        Replies (1)
        1. I meant performance per dollar for FP64 computations, which are the subject of this thread, not for graphics or ML/AI inference, for which it is possible that other GPUs are better.
    2. Not that the performance of "supercomputers" holds up very well over time.

      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.

      Replies (1)
      1. Computing is not the bottleneck for stockpile stewardship.
  5. Gotta be either 2 or infinity
  6. This paper is really hard to read but it seems like they're trying to optimize for fewest GEMMs instead of normalizing for the ones that run the fastest at the precision they need? I don't really understand why you would care about having fewer GEMMs.
  7. TL;DR: The problem is that modern AI GPUs -e.g., NVIDIA's Blackwell series - are fast at low-precision math (FP4, FP6, FP8, INT8) used for AI, but terrible at high-precision math (FP64) needed for scientific computing.

    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

    Replies (2)
    1. Wouldnt that also be interesting for training (backpropagation calculation)?
      Replies (2)
      1. Why not :)
      2. That’s the thing you don’t need FP64 for. It’s not at all clear you need 4-bit precision.
    2. To be clear, slow FP64 performance is not a feature of the Blackwell architecture in general. The B200, which is still actively manufactured and sold by NVIDIA, has full-speed FP64 throughput (I.e. half of its FP32 throughput). The B300 had its FP64 capability reduced, which is sensible as it’s a very high-memory device aimed at AI applications which don’t have FP64.
  8. On modern NVIDIA GPUs, both consumer and datacenter, any software implementation of FP64 computations will be much faster than the hardware FP64, because the hardware has 1:64 FP64:FP32 throughput.

    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.

    Replies (2)
    1. There is a good chance that for optimizations like that they rely on higher level layers of software to keep the values within bounds to avoid exceptions.
      Replies (1)
      1. I agree that this would be the only way to achieve the claimed speedup.

        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.

    2. One interesting observation I made is that your comment extrapolates to lower precision type. Fused code that computes over hi-lo vector pairs of bf16 is faster than fp32 compute. And code that computes fused op over hi-lo bfp16 pairs (on hardware which supports it) is faster than bf16.

      Edit: apparently paper is exactly about this (I started reading it after comments...)

  9. B300 has worse INT8 performance than my RTX Pro 6000. CUDA 13.4 cuBLAS already has Ozaki-II at 29.9 TFLOPS benchmark (just ran it personally). However, that is clearly not optimized. Should be able to do twice that since INT8 GEMM benchmarking shows me 59.1 TFLOPS.

    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.

    Replies (1)
    1. FYI Intel Arc GPUs, while the software story's still a little iffy, have really fast int8 for their price point. I've played with a 16GiB one for local models with MoE offload, but I've heard decent things too.

      There's some interesting Chinese accelerator chips bubbling up that are all int8 or just int8 and fp16 and nothing else.

      Replies (1)
      1. Exactly. I’ve been working with an Arc B390 provided by Intel cloud services for our inference engine, Xenolith.

        The hardware is quite capable but I think there is still a lot of room for architecture specific optimizations.

        Replies (1)
        1. Intel and whatever that Chinese company with the specialized chips is (forget the name) are the dark horses in the race.

          I have an Intel Nuc with a nice card built in and run local models with it as a home LLM server. Played with training baby ones too.

          Intel has great price performance already but still trails a bit on power and raw performance. Of course they are likely pricing aggressively.

          Also decent gaming GPUs from what I hear.

          Apple is another one, almost forgot, but more for just the good LLM on a laptop niche if you have the cash for one of their beefcake Pros.

  10. GEMM = "general matrix multiply"
  11. FP64 girl I like, INT8 her ex, FP8 her dad, FP6 her brother, FP4 her CRUSH, IQ1_S me