NeurIPS 2026QuestionsPapersAreasAboutMarkdown

Differentiable Knapsack and Top-k Operators via Dynamic Programming

Germain Vivier-Ardisson, Michael E Sander, Axel Parmentier, Mathieu Blondel

NeurIPS page · OpenReview · alphaXiv · Open on the map

Category: Optimization & Federated Learning › Neural Combinatorial Optimization · Type: new method · Keywords: differentiable knapsack, top-k operators, dynamic programming, gradient smoothing, discrete optimization

Summary

A unified dynamic-programming smoothing framework makes knapsack and top-k operators differentiable for neural networks.

Explained to a 5-year-old

Sometimes we want to pick a few things that fit in a bag (knapsack) or choose the biggest items (top-k). Computers that learn need to know how to change themselves, but these picking rules don't give helpful hints. This paper finds a way to make those rules smooth so computers can learn from them. It uses a step-by-step plan that helps the computer figure out which items to pick. Now computers can learn to pick things better without getting stuck.

Explained to a 5-year-old, longer

Imagine you have a backpack and you want to put in only the biggest toys (top-k). Sometimes you also want to fit as many toys as possible without making the backpack too heavy (knapsack). When we try to teach a computer to do these choices, the computer needs to know how to improve. The problem is that these picking rules are like stairs - they don’t give smooth clues for the computer. This paper smooths those stairs so the computer can slide along them and learn. It creates a plan that works step by step, like a recipe for picking items. The plan works both when the computer makes a guess and when it checks its answer. It also helps the computer understand which items are most important. The authors show that a simple rule called entropy helps the computer make fair choices. They test the new method on a puzzle about filling a backpack with the best items. They also try it on a different problem where a robot decides what to sell. The result is that computers can now learn to pick items more smoothly and accurately.

For a technical reader

The paper addresses the lack of gradients in discrete selection operators such as knapsack and top-k when used inside neural networks. It casts these operators as dynamic programs and smooths their recursion to obtain differentiable approximations. Parallel algorithms are provided for both deterministic and stochastic forward passes, along with efficient vector-Jacobian products for back-propagation. Theoretical analysis identifies entropy as the unique regularizer for permutation-equivariance and characterizes sparsity-inducing regularizers. Experiments on a knapsack benchmark, a discrete VAE extension, and a constrained dynamic assortment RL problem demonstrate the framework’s effectiveness.

Problem

Integrating piecewise-constant knapsack and top-k selection operators into neural networks is difficult because they provide zero gradients almost everywhere, limiting learning. Existing approaches cannot differentiate through these discrete selections efficiently.

Method

The approach casts knapsack and top-k operators as dynamic programs and smooths their recursions to obtain differentiable relaxations. It provides parallel algorithms for deterministic and stochastic forward passes and vector-Jacobian products for back-propagation.

Contributions

It offers a unified differentiable relaxation for knapsack and top-k operators via dynamic-programming smoothing, along with parallel algorithmic implementations for forward and backward passes. It also proves theoretical properties of entropy regularization for permutation-equivariance and validates the approach on a benchmark, a discrete VAE extension, and a constrained dynamic assortment RL problem.

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction