One-line decorator turns any combinatorial solver into a differentiable NN layer

PMinervini · x · 2026-10-13

Pasin Manurangsi (EdinburghNLP) shared a minimal Python decorator that turns any combinatorial solver — Dijkstra's shortest path, IR ranking functions — into a differentiable neural network layer in one line. It builds on the AAAI 2023 paper "Adaptive Perturbation-Based Gradient Estimation for Discrete Latent Variable Models", extending Implicit MLE (NeurIPS 2021) for backpropagating through black-box solvers. Code is open-sourced as torch-adaptive-imle (MIT); the demo shows wrapping a batched solver with @aimle(targetdistribution=...) to get a differentiable version for end-to-end training with discrete optimization.

Original post →

More from coding & agent

coding & agent channel →