[Paper Review] Fast Differentiable Sorting and Ranking
This paper proposes the first differentiable sorting and ranking operators with $O(n"log n)$ time complexity and $O(n)$ memory usage, achieving exact computation and differentiation by formulating sorting and ranking as projections onto the permutahedron—a convex hull of permutations—via isotonic optimization. The method enables efficient, exact backpropagation through sorting and ranking operations, outperforming prior approaches by an order of magnitude in speed and enabling novel applications in robust statistics and ranking metrics.
The sorting operation is one of the most commonly used building blocks in computer programming. In machine learning, it is often used for robust statistics. However, seen as a function, it is piecewise linear and as a result includes many kinks where it is non-differentiable. More problematic is the related ranking operator, often used for order statistics and ranking metrics. It is a piecewise constant function, meaning that its derivatives are null or undefined. While numerous works have proposed differentiable proxies to sorting and ranking, they do not achieve the $O(n \log n)$ time complexity one would expect from sorting and ranking operations. In this paper, we propose the first differentiable sorting and ranking operators with $O(n \log n)$ time and $O(n)$ space complexity. Our proposal in addition enjoys exact computation and differentiation. We achieve this feat by constructing differentiable operators as projections onto the permutahedron, the convex hull of permutations, and using a reduction to isotonic optimization. Empirically, we confirm that our approach is an order of magnitude faster than existing approaches and showcase two novel applications: differentiable Spearman's rank correlation coefficient and least trimmed squares.
Motivation & Objective
- To address the lack of efficient, differentiable sorting and ranking operators in machine learning, which are critical for robust statistics and ranking metrics.
- To overcome the non-differentiability of sorting (piecewise linear with kinks) and ranking (piecewise constant) in gradient-based optimization.
- To design a differentiable sorting and ranking operator with optimal $O(n\log n)$ time complexity and $O(n)$ space, enabling end-to-end training.
- To enable new applications such as differentiable Spearman’s rank correlation and soft least trimmed squares for robust regression.
- To provide exact computation and differentiation, avoiding iterative approximation methods like Sinkhorn or pairwise comparisons.
Proposed method
- Formulate sorting and ranking as linear programs over the permutahedron, the convex hull of all permutations of $[n]$.
- Introduce regularization to transform the linear programs into projections onto the permutahedron, enabling differentiability.
- Reduce the projection problem to isotonic optimization, which allows $O(n\log n)$ computation using efficient algorithms like the pool adjacent violators (PAV) algorithm.
- Derive differentiable sorting and ranking operators as the solution to these regularized projections, ensuring exact gradients via automatic differentiation.
- Use the soft sorting operator $s_{\varepsilon\Psi}(\bm{\theta})$ as a continuous, differentiable proxy for hard sorting, with $\varepsilon$ controlling the smoothness.
- Leverage the structure of the permutahedron and isotonic optimization to achieve exact, closed-form differentiation in $O(n)$ time.
Experimental results
Research questions
- RQ1Can we design a differentiable sorting operator with $O(n\log n)$ time complexity and exact gradients?
- RQ2Can we extend this to differentiable ranking while maintaining efficiency and exactness?
- RQ3Can we achieve exact computation and differentiation without relying on iterative approximation methods like Sinkhorn or pairwise comparisons?
- RQ4Can our operators be used to build new differentiable metrics, such as Spearman’s rank correlation, for end-to-end learning?
- RQ5Can our soft sorting operator enable adaptive robust regression, such as soft least trimmed squares, that interpolates between least squares and robust LTS?
Key findings
- The proposed differentiable sorting and ranking operators achieve $O(n\log n)$ time complexity and $O(n)$ memory usage, representing a significant improvement over prior $O(n^2)$ or $O(n^3)$ methods.
- The method enables exact computation and differentiation through projections onto the permutahedron, avoiding approximation errors from iterative algorithms.
- Empirically, the approach is an order of magnitude faster than existing differentiable sorting and ranking methods, including Sinkhorn-based and pairwise comparison approaches.
- The soft least trimmed squares objective, derived from the soft sorting operator, interpolates between least squares ($\varepsilon \to \infty$) and hard least trimmed squares ($\varepsilon \to 0$), enabling adaptive robust regression.
- In experiments on datasets with label noise, the soft least trimmed squares method outperformed ridge regression and Huber loss, particularly under high outlier rates, with adaptive selection of $\varepsilon$ via cross-validation.
- The differentiable Spearman’s rank correlation coefficient, enabled by the soft ranking operator, allows end-to-end training in label ranking tasks with gradient-based optimization.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.