r/slatestarcodex • • Jun 07 '23

Faster sorting algorithms discovered using deep reinforcement learning

https://www.nature.com/articles/s41586-023-06004-9
45 Upvotes

10 comments sorted by

69

u/ChiefExecutiveOcelot How The Hell Jun 07 '23

From HN:

AlphaDev uncovered new sorting algorithms that led to improvements in the LLVM libc++ sorting library that were up to 70% faster for shorter sequences and about 1.7% faster for sequences exceeding 250,000 elements. As someone that knows a thing or two about sorting... bullshit. No new algorithms were uncovered, and the work here did not lead to the claimed improvements.

They found a sequence of assembly that saves... one MOV. That's it. And it's not even novel, it's simply an unrolled insertion sort on three elements. That their patch for libc++ is 70% faster for small inputs is only due to the library not having an efficient implementation with a branchless sorting network beforehand. Those are not novel either, they already exist, made by humans.

By open sourcing our new sorting algorithms in the main C++ library, millions of developers and companies around the world now use it on AI applications across industries from cloud computing and online shopping to supply chain management. This is the first change to this part of the sorting library in over a decade and the first time an algorithm designed through reinforcement learning has been added to this library. We see this as an important stepping stone for using AI to optimise the world’s code, one algorithm at a time.

I'm happy for the researchers that the reinforcement learning approach worked, and that it gave good code. But the paper and surrounding press release is self-aggrandizing in both its results and impact. That this is the first change to 'this part' of the sorting routine in a decade is also just completely cherry-picked. For example, I would say that my 2014 report and (ignored patch of) the fact that the libc++ sorting routine was QUADRATIC (https://bugs.llvm.org/show_bug.cgi?id=20837) finally being fixed late 2021 https://reviews.llvm.org/D113413 is quite the notable change. If anything it shows that there wasn't a particularly active development schedule on the libc++ sorting routine the past decade.

https://news.ycombinator.com/item?id=36231147

21

u/vorpal_potato Jun 07 '23 edited Jun 07 '23

Yeah, this is honestly pretty embarrassing. And it's not even an exciting MOV, but just some little register-to-register MOV that probably doesn't even get executed on most modern CPUs. And yet they're claiming significant numbers because of some easy, non-AI-related changes they happened to make to libc++ along the way?

I mean, their tricks for dealing with the computational problems of superoptimization are clever enough, but those results... are pretty heavily overblown.

6

u/WhyYouLetRomneyWin Jun 08 '23

But it was done by a machine.

Any paragraph written by chatGPT isn't very new or impressive if it were made by a human. But it's impressive because it was not made by a human.

9

u/darkapplepolisher Jun 08 '23

Agreed, but let that stand on its own merit, rather than stretching too far with "faster" and "discovered". "Independently duplicated the fastest known sorting algorithm from scratch" should stand alone.

6

u/vorpal_potato Jun 08 '23

This sort of thing has been happening for a while, broadly speaking; I probably should have linked superoptimization. The approach in this paper is interesting, but the level of concrete impact is underwhelming compared to other non-human-made feats in the same field.

(It's a great start!)

8

u/UncleWeyland Jun 07 '23

You mean someone would do that? Just publish in Nature and tell lies?

14

u/ChiefExecutiveOcelot How The Hell Jun 08 '23

They're not lies. The paper is true. It's just that the sorting innovation is not a game changer like AlphaFold was

-4

u/UncleWeyland Jun 08 '23

It was a joke.

2

u/A_Light_Spark Jun 07 '23

What a great paper. The branching solution is interesting because it confirms the principle of dynamic programming of memoization, but in this case it's not just for remembering the states but gives performance benefits as well.
The AlphaDev-S result is as expected, but AlphaDev could be deployed over many algorithms to further optimize them. The real ingenious part imk is using transformer on algorithms as sets of instructions. I kinda want to see the code implementation but that is going to be dense.