Fast LapSum Enables Differentiable Top-k at Million Scale

{\L}ukasz Struski, Joanna Wojciechowicz, Jakub Antczak, Marcin Mazur, Kamil Ksi\k{a}\.zek, Jacek Tabor· August 10, 2026 View original

Key takeaways

  • Fast LapSum enables exact, differentiable soft top-k operations at million-scale.
  • It runs in linear time after sorting, with negligible overhead.
  • The method preserves an exact selection mass of 'k', unlike prior linear-time relaxations.
  • It is practical for sparse routing, retrieval, and large-scale optimization, offering significant speedups.

Who benefits

AI/ML DevelopmentComputer VisionNatural Language ProcessingCybersecurityData Compression

Summary

Fast LapSum is a novel, exact-budget soft top-k primitive that allows for fully differentiable top-k operations at million-scale, running in linear time after sorting. It preserves an exact selection mass of k, making it practical for sparse computation in large-scale models and achieving significant speedups in applications like adversarial example generation.

The "top-k" operation is a fundamental component in modern sparse computation, crucial for tasks such as token routing, expert activation, memory selection, and attention pruning in large-scale models. However, traditional hard top-k operations block gradient flow, while existing continuous (soft) relaxations are often too computationally expensive for practical use in large models. This creates a bottleneck for training and optimizing sparse AI architectures. Researchers have introduced Fast LapSum, a groundbreaking exact-budget soft top-k primitive designed to overcome these limitations. Fast LapSum is unique in that it preserves an exact selection mass of 'k' while remaining fully differentiable from end-to-end. Its GPU solver operates in linear time after an initial sorting step, making it highly efficient. The solver combines a linear-time threshold computation with an analytical vector-Jacobian product. For extremely large scales, it employs probabilistic bracketing to sort only the uncertain middle band of kernel-noised scores, further optimizing performance. This results in almost negligible overhead, processing millions of scores in milliseconds. Fast LapSum makes exact soft top-k practical for various demanding applications, including generating megapixel sparse adversarial examples with significant speedups and training fully differentiable sparse image coders from scratch.

Why it matters

For professionals working with large-scale AI models, Fast LapSum provides a critical tool for efficient and differentiable sparse computation, enabling faster training, more flexible model architectures, and new capabilities in areas like adversarial robustness and sparse data processing.

How to implement this in your domain

  1. 1Integrate Fast LapSum into your sparse computation pipelines to enable differentiable top-k operations at scale.
  2. 2Apply Fast LapSum for efficient token routing, expert activation, or memory selection in large language models.
  3. 3Utilize this primitive to develop more flexible and trainable sparse neural network architectures.
  4. 4Experiment with Fast LapSum in applications requiring exact soft budgets, such as generating sparse adversarial examples.
  5. 5Benchmark the performance gains of Fast LapSum against existing soft top-k relaxations in your specific use cases.

Original post by {\L}ukasz Struski, Joanna Wojciechowicz, Jakub Antczak, Marcin Mazur, Kamil Ksi\k{a}\.zek, Jacek Tabor

"arXiv:2608.06912v1 Announce Type: new Abstract: The top-$k$ operation is a fundamental building block of modern sparse computation, enabling token routing, expert activation, memory selection, and attention pruning. Yet standard hard top-$k$ blocks gradients, while existing conti…"

View on X

Originally posted by {\L}ukasz Struski, Joanna Wojciechowicz, Jakub Antczak, Marcin Mazur, Kamil Ksi\k{a}\.zek, Jacek Tabor on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses