• Tue. May 28th, 2024

Deepmind’s AlphaDev discovers sorting algorithms that can revolutionize computing foundations


Jun 7, 2023
Deepmind's AlphaDev discovers sorting algorithms that can revolutionize computing foundations


Join top executives in San Francisco on July 11-12, to hear how leaders are integrating and optimizing AI investments for success. Learn More

Google’s artificial intelligence (AI) research lab DeepMind has achieved a remarkable feat in computer science through its latest AI system, AlphaDev. This specialized version of AlphaZero has made a significant breakthrough by uncovering faster sorting and hashing algorithms, which are essential processes utilized trillions of times daily by developers worldwide for data sorting, storage and retrieval.

In a paper published today in the science journal Nature, DeepMind asserts that AlphaDev’s newly discovered algorithm achieves a 70% increase in efficiency for sorting short sequences of elements and approximately 1.7% for sequences surpassing 250,000 elements, as compared to the algorithms in the C++ library. Consequently, when a user submits a search query, AlphaDev’s algorithm facilitates faster sorting of results, leading to significant time and energy savings when employed on a large scale.

Moreover, the system has also uncovered a swifter algorithm for hashing information, resulting in a 30% enhancement in efficiency when applied to hashing functions within the 9 to 16 byte range in data centers.

Revolutionizing computer science

Deepmind believes this remarkable achievement revolutionizes computer science and promises to advance efficiency and effectiveness.


Transform 2023

Join us in San Francisco on July 11-12, where top executives will share how they have integrated and optimized AI investments for success and avoided common pitfalls.


Register Now

“AlphaDev discovered improved sorting algorithms, including novel innovations such as the AlphaDev copy and swap moves,” Google DeepMind staff research scientist Daniel Mankowitz told VentureBeat. “Similar to AlphaGo’s famous ‘move 37’ which yielded a new set of strategies to play the age-old game of Go, AlphaDev’s unique algorithmic discoveries can hopefully inspire new perspectives and strategies for optimizing fundamental computer science algorithms and making them faster.”

Mankowitz said this is a significant milestone for reinforcement learning as it provides more evidence of its capability of making new discoveries, especially in the domain of code optimization.

The company also announced its intention to make the new algorithms available through the LLVM libc++ standard sorting library, aiming to empower millions of developers and companies in diverse industries. Significantly, this update represents the first revision to this section of the sorting library in over a decade and the initial inclusion of an algorithm developed through reinforcement learning.

“We estimate that our open-sourced sorting algorithms, yielding speed improvements from 2% to ~70%, are called trillions of times every day worldwide,” said Mankowitz. “These algorithms can provide resource savings to developers and companies that call these functions in their systems and applications. We believe that these algorithms will inspire researchers and practitioners to develop new approaches that lead to more discoveries of new and improved algorithms.”

Utilizing reinforcement learning to enhance traditional algorithm development

According to DeepMind, most computational algorithms have reached a stage where human experts have been unable to optimize them further, resulting in an escalating computational bottleneck.

The company highlighted the fact that using deep reinforcement learning enhances development methods by generating precise and efficient algorithms. This is achieved by optimizing for actual measured latency at the CPU instruction level while conducting a more efficient search and considering the space of accurate and fast programs.

Sorting algorithms, at their core, facilitate the systematic arrangement of items in a specified order. These serve as the foundation of computer science education.

Similarly, hashing finds widespread application in data storage and retrieval, such as in a customer database. Hashing algorithms commonly employ a key (user name “Jane Doe”) to generate a unique hash corresponding to the desired data values for retrieval (“order number 164335-87”). Similar to a librarian utilizing a classification system to promptly locate a particular book, a hashing system enables the computer to possess prior knowledge of the desired information and its precise location.

Fine-detailed overview

Although developers primarily write code in user-friendly high-level languages such as C++, translating these languages into low-level assembly instructions is indispensable for computer understanding.

DeepMind’s researchers believe that many enhancements exist at the lower level, which may pose challenges to unveil in higher-level programming languages. The assembly level offers flexibility in computer storage and operations, presenting the vast potential for improvements that can substantially influence speed and energy efficiency.

To run an algorithm in C++, it is first compiled into low-level CPU instructions called assembly instructions, which manipulate data between memory and registers on the CPU.

“This provides a much more fine-detailed overview of how the algorithm operates and therefore makes it easier to find optimizations to improve the algorithm,” said Mankowitz. “By optimizing in assembly, we discovered the AlphaDev copy and swap moves. These are sequences of assembly instructions that reduce the program size by a single instruction when applied to an assembly program.”

Deepmind’s unique approach to discovering faster algorithms

DeepMind’s AlphaDev adopted an unconventional approach to uncover faster algorithms by venturing into the realm of computer assembly instructions — a domain seldom explored by humans.

To unlock new algorithms, AlphaDev drew inspiration from DeepMind’s renowned reinforcement learning model, AlphaZero, which has achieved victories against world champions in games like Go, chess and shogi (Japanese chess).

To train AlphaDev in discovering new algorithms, the research team reimagined sorting as a single-player’ assembly game’. AlphaDev utilized reinforcement learning to observe and generate algorithms while incorporating information from the CPU. 

The AI system proactively chose an instruction to incorporate into the algorithm at each step, resulting in an intricately complex and demanding process given the vast number of potential instruction combinations.

Discovering a faster, correct program

As AlphaDev constructed the algorithm incrementally, it also validated the correctness of each move by comparing the algorithm’s output with the expected results. The ultimate goal of this approach was to discover a correct and faster program, thereby achieving victory in the game.

DeepMind’s AI system unearthed novel sorting algorithms that resulted in substantial improvements within the LLVM libc++ sorting library.

The research primarily focused on enhancing sorting algorithms for shorter sequences, typically consisting of three to five elements. Since these algorithms are frequently incorporated into larger sorting functions, enhancing their efficiency can improve overall speed when sorting any number of items.

In order to improve usability, DeepMind reverse-engineered the uncovered algorithms and converted them into C++.

Surpassing the realm of sorting algorithms

The improvements are for sort3, sort4, and sort5 routines that sort numbers, specifically integers and floats, Mankowitz explained.

“Any time a developer or an application needs to sort these data types, our sorting algorithms can be called,” he said. “With speed improvements ranging from 2% to 70% depending on the number of items to be sorted, and these functions being called trillions of times every day, developers and users will be able to run their applications/use various services while consuming fewer resources.”

Furthermore, AlphaDev’s capabilities surpass the realm of sorting algorithms. DeepMind explored the system’s potential to generalize its approach and enhance other essential computer science algorithms, including hashing. Applying AlphaDev’s methodology to the hashing algorithm within the 9 to 16 bytes range yielded a 30% improvement in speed.

“As such, we optimized for hashing ‘correctness’ (minimizing collisions) and speed (latency),” Mankowitz explained.

The hashing algorithm is now available in the Abseil open-source library.

What’s next for Deepmind? 

DeepMind says AlphaDev is a significant milestone in the progression toward creating versatile AI tools capable of optimizing the entire computing ecosystem and tackling various societal challenges.

While optimizing low-level assembly instructions has proven immensely powerful, the company said it is actively exploring AlphaDev’s potential to optimize algorithms directly in high-level languages like C++, which would be even more valuable for developers.

“AlphaDev is optimizing one part of the computing stack,” said Mankowitz. “That makes the underlying algorithms that run in the stack more efficient. We are also trying to optimize other aspects of the stack.”

For example, scheduling resources more efficiently when running applications and services, optimizing Youtube’s video compression pipeline and optimizing the underlying hardware on which the systems and applications are run.

“We hope these algorithms will give researchers and practitioners a different perspective on how algorithms can be built,” said Mankowitz.

VentureBeat’s mission is to be a digital town square for technical decision-makers to gain knowledge about transformative enterprise technology and transact. Discover our Briefings.

Leave a Reply

Your email address will not be published. Required fields are marked *