Fast LapSum: Exact Differentiable Top- k at Million Scale
cs.AI
Submitted: 2026-08-07
Updated: 2026-10-08
License: http://creativecommons.org/licenses/by/4.0/
The gist: The top- k operation is a fundamental building block of modern sparse computation, enabling token routing, expert activation, memory selection, and attention pruning.
Terminology
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 continuous (soft) relaxations remain too costly for large-scale models. We introduce Fast LapSum, an exact-budget soft top- k primitive whose GPU solver runs in linear time after sorting. Unlike prior linear-time methods such as DFTopK, which relax the normalization constraint, Fast LapSum is, to our knowledge, the first method to preserve an exact selection mass of k while remaining fully differentiable end-to-end. Our solver combines a linear-time threshold computation with an analytical vector--Jacobian product, and for extreme scales employs probabilistic bracketing to sort only the uncertain middle band of kernel-noised scores. The resulting overhead is almost negligible: the solver processes 10 6, 10 7, and 10 8 scores in 0.41, 1.15, and 5.23,ms, respectively. This makes exact soft top- k practical for sparse routing, retrieval, and large-scale optimization. We demonstrate Fast LapSum on two demanding applications operating over millions of coordinates inside the training loop: generating megapixel sparse adversarial examples with an exact soft budget of about 0.02% of an image's pixels, achieving an order-of-magnitude speedup over state-of-the-art methods, and training a fully differentiable sparse image coder from scratch.
Sources
- Learning with Differentiable Perturbed Optimizers
- Fast Differentiable Sorting and Ranking
- Prof-K: Probabilistic One-Pass Filtering for Efficient Top-k Selection
- Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsity
- The Lottery Ticket Hypothesis: Finding Sparse, Trainable Neural Networks
- Stochastic Optimization of Sorting Networks via Continuous Relaxations
- Learning both Weights and Connections for Efficient Neural Networks
- k-Sparse Autoencoders
- Differentiable Sorting Networks for Scalable Sorting and Ranking Supervision
- SoftSort: A Continuous Relaxation for the argsort Operator
- DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification
- Fast, Differentiable and Sparse Top-k: a Convex Analysis Perspective
- Movement Pruning: Adaptive Sparsity by Fine-Tuning
- ConvNeXt V2: Co-designing and Scaling ConvNets with Masked Autoencoders
- Differentiable Top-k Operator with Optimal Transport
- Differentiable Fast Top-K Selection for Large-Scale Recommendation
Related papers
- MAVEN-T: Reinforced Heterogeneous Distillation for Real-Time Multi-Agent Trajectory Prediction
- Model Discovery Agent: LLM-assisted Bayesian experiment design for data-efficient discovery of mechanistic world models
- Agents' Last Exam
- The Clinician's Veto: Navigating Trust, Liability, and Uncertainty in Autonomous AI Prescribing
- MindHelper: Closed-Loop Embodied Mental-State Reasoning for Precision Intervention
- Incumbent Advantage: Brand Bias and Cognitive Manipulation Dynamics in LLM Recommendation Systems