Prof-K: Probabilistic One-Pass Filtering for Efficient Top- Selection
Abstract
Top- selection is a fundamental computational primitive with applications spanning databases, information retrieval, signal processing, and modern machine learning workloads, including sparse activations and attention pruning. As data sizes grow, existing approaches become inefficient: exact methods incur high memory and compute overhead, while approximate methods often rely on brittle heuristics that degrade under adversarial or heavy-tailed inputs. In this paper, we introduce Prof-K, a fast, scalable, and distribution-agnostic top- algorithm with probabilistic correctness guarantees. Prof-K performs a single-pass filtering procedure: a small random sample estimates an adaptive threshold, the input elements are streamed once into a compact buffer, and an exact top- routine on this buffer recovers the true top- elements with probability at least , where is user specified. We derive high-probability guarantees for correctness and buffer size, together with an approximately optimal sample size that minimizes overhead as a function of and . Empirically, Prof-K achieves - speedups over the highly optimized PyTorch top- and recent RadiK implementations, with the largest gains in the large-scale, small-to-moderate- regime where prior methods struggle most. Unlike previous approaches, these guarantees hold independently of the input distribution, ensuring robustness to adversarial settings. A run-time check detects the rare failures, so the returned set can always be exact and bounds only the frequency of a second pass. We further demonstrate its impact on training BatchTopK Sparse Autoencoders (SAEs), where top- selection constitutes a significant portion of the training cost. The source code is provided in the supplementary materials and will be made publicly available.
est. 32% chance this paper gets accepted at ICLR 2027.
What do you think this paper will get?
All positions stay anonymous.