← Latest papers
🤖 AI

Fast LapSum: Exact Differentiable Top-k at Million Scale

The paper introduces Fast LapSum, an exact, differentiable soft top-kk primitive that preserves a precise selection mass of kk while running in linear time on GPUs, enabling efficient million-scale sparse computation for applications like adversarial example generation and differentiable image coding.

Original authors: Łukasz Struski, Joanna Wojciechowicz, Jakub Antczak, Marcin Mazur, Kamil Książek, Jacek Tabor

Published 2026-08-10
📖 4 min read☕ Coffee break read

Original authors: Łukasz Struski, Joanna Wojciechowicz, Jakub Antczak, Marcin Mazur, Kamil Książek, Jacek Tabor

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are running a massive digital library where millions of books are being scanned every second. To make sense of this flood of information, the library's AI needs to decide which few books are the most important to read right now. In the world of artificial intelligence, this is called "top-k selection": picking the best k items from a huge list. Usually, the AI does this by being a strict librarian who picks the top books and ignores the rest completely. This is great for speed, but it's terrible for learning because the AI can't figure out how to get better; it's like trying to learn to drive by only looking at the road when you're already in the right lane, with no way to adjust the steering wheel.

To fix this, scientists invented "soft" versions of this selection. Instead of a hard "yes or no," the AI gives a "maybe" score to every book, allowing it to learn from the mistakes. But here's the catch: these soft versions are often so slow and computationally heavy that they crash the system when the library gets too big. They are like trying to sort a million books by hand while the library is on fire. The big question for researchers has been: Can we have a librarian that is both gentle enough to learn (differentiable) and fast enough to handle millions of books without breaking a sweat?

This is where the new paper, "Fast LapSum," steps in. The authors, a team from Poland, have built a new tool that acts like a super-efficient, mathematically perfect librarian. They created a method called Fast LapSum that allows an AI to pick the top items from a list of millions while still being able to learn from the process. Unlike previous methods that either gave up on being perfectly accurate to gain speed, or were too slow to be useful, Fast LapSum manages to do both. It finds the exact right number of items to pick (the "budget") and calculates the perfect "maybe" scores for them in the blink of an eye.

The secret sauce is a clever trick involving a "blurred" view of the scores. Imagine the scores aren't sharp points but fuzzy clouds. The AI needs to draw a line through these clouds so that the total amount of "cloud" above the line equals exactly the number of books it's allowed to pick. Old methods tried to find this line by guessing and checking over and over, which took forever. Fast LapSum, however, uses a special mathematical formula (based on something called the Laplace distribution) that lets it calculate the line instantly after a single sort.

For really huge lists—like a million or even a hundred million scores—the authors added a second trick called "probabilistic bracketing." Instead of sorting the entire million-item list, which is like trying to organize a stadium full of people, the system takes a quick sample to guess where the line probably is. It then only sorts the small group of people standing right near that line. This keeps the process incredibly fast, taking just a few milliseconds even for massive datasets.

The paper proves this works by testing it on two very difficult tasks. First, they used it to create "adversarial examples," which are images that look normal to humans but trick AI classifiers. They managed to change an image so slightly—altering only about 0.02% of the pixels (roughly 600 pixels out of 3.3 million)—that the AI misidentified a picture of a tiger. This was done much faster and with less "damage" to the image than previous methods. Second, they built a differentiable image coder from scratch, a system that compresses images by selecting only the most important parts to keep. In both cases, Fast LapSum acted as the engine, handling millions of decisions per second without slowing down the learning process.

The authors show that this method is not just a theoretical idea but a practical tool that runs in milliseconds on standard computer chips. They compared their work to other recent attempts, like one called DFTopK, and found that while those methods are fast, they sacrifice the exactness of the selection (the total number of items picked drifts away from the target). Fast LapSum, they argue, is the first to keep the selection perfectly exact while remaining fast enough for real-world, large-scale AI systems. It turns a slow, expensive bottleneck into a smooth, fast operation, allowing AI to be both smart and efficient.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →