Differentiable Knapsack and Top-k Operators via Dynamic Programming

Germain Vivier-Ardisson, Michaël E. Sander, Axel Parmentier, Mathieu Blondel
1/29/2026
cs.LG

No confident code implementation found for this paper.

Abstract

Knapsack and Top-k operators are useful for selecting discrete subsets of variables. However, their integration into neural networks is challenging as they are piecewise constant, yielding gradients that are zero almost everywhere.

Show full abstract

In this paper, we propose a unified framework casting these operators as dynamic programs, and derive differentiable relaxations by smoothing the underlying recursions. On the algorithmic side, we develop efficient parallel algorithms supporting both deterministic and stochastic forward passes, and vector-Jacobian products for the backward pass. On the theoretical side, we prove that Shannon entropy is the unique regularization choice yielding permutation-equivariant operators, and characterize regularizers inducing sparse selections. Finally, on the experimental side, we demonstrate our framework on a decision-focused learning benchmark, a constrained dynamic assortment RL problem, and an extension of discrete VAEs.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{vivierardisson2026differentiable,
  title  = {Differentiable Knapsack and Top-k Operators via Dynamic Programming},
  author = {Germain Vivier-Ardisson and Michaël E. Sander and Axel Parmentier and Mathieu Blondel},
  year   = {2026},
  eprint = {2601.21775},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2601.21775v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2601.21775.svg)](https://codeofpaper.com/paper/2601.21775)

Discussion