potentialpaper

Differentiable Knapsack and Top-k Operators via Dynamic Programming

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

NeurIPS 2026

Edit this page

Or clone it with git

Run in a terminal:

Needs Git LFS. To push, use an API key from your profile as the password.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

Abstract. Knapsack and Top-kk 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. 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 separable binary regularization choice for the local DP smoothing that yields permutation-equivariant operators, and characterize regularizers inducing sparse selections. On the experimental side, we demonstrate our framework on a benchmark on learning to predict Knapsack solutions, an extension of discrete VAEs, and a constrained dynamic assortment RL problem.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

edit · history

DateVersionSubmitted toPDFEvidence
4 May 2026NeurIPS 2026submittedNeurIPS 2026Accept (poster)reviews ↓[1]PDF[1]
Missing a version?

NeurIPS 2026

Accept (poster) · 5 reviews · OpenReview

Updated 25 Nov 2026, 03:44 UTC.

Program Chairs · DecisionOpenReview ↗
Decision
Accept (poster)
Read decision
Meta-review

The paper considers the problem of integrating common operators like knapsack, top-k into the differentiable deep learning pipeline. The idea is to cast these operators as dynamic programs, and derive differentiable relaxations by smoothing the underlying recursions. Overall, the paper is well-written and has received positive reviews. Though no critical issues were raised, there are some important questions raised by the reviewers, which I am hoping will be answered by the authors appropriately.

Final justification

After the rebuttal, some concerns do remain. Overall it seems to be a weak accept. So I would not mind if the paper is rejected based on overall acceptance rate and other concerns. In case it is accept I hope the authors will address all the issues in the camera-ready version.

Area Chair h2mr · Meta-reviewOpenReview ↗
Read meta-review
Meta-review

The paper considers the problem of integrating common operators like knapsack, top-k into the differentiable deep learning pipeline. The idea is to cast these operators as dynamic programs, and derive differentiable relaxations by smoothing the underlying recursions. Overall, the paper is well-written and has received positive reviews. Though no critical issues were raised, there are some important questions raised by the reviewers, which I am hoping will be answered by the authors appropriately.

Final justification

After the rebuttal, some concerns do remain. Overall it seems to be a weak accept. So I would not mind if the paper is rejected based on overall acceptance rate and other concerns. In case it is accept I hope the authors will address all the issues in the camera-ready version.

Reviewer 4pabOpenReview ↗
Rating
4/6
Confidence
3/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper presents a unified framework that casts knapsack and opt-k operators as dynamic programs and derives differentiable relaxations of those problems by regularizing the max operators using a strictly convex relaxation. Given those differentiable relaxations, one can then use them as hidden or output layers in end-to-end differentiable pipelines, and the paper presents specific approaches to integrate the relaxed operators as deterministic hidden layers, stochastic hidden layers, or output layers. Numerical experiments show that the proposed framework achieves lower test regret against differentiable baselines on knapsack solution prediction tasks, and the proposed operators show competitive performance against baselines on discrete variational autoencoder training tasks.

Strengths and weaknesses

Strengths:

  1. The paper presents a unified framework to cast knapsack and top-k operators as dynamic programs and derive differentiable relaxations that enable one to deploy those operators in end-to-end differentiable pipelines such as predict-then-optimize tasks.

  2. The paper also derives specific mechanisms to enable use of the proposed relaxations as hidden layers or output layers in end-to-end differentiable pipelines.

  3. Experiments on multiple benchmarks show that the proposed framework achieves competitive runtime / performance trade-offs against established baselines.

Weaknesses:

  1. While the proposed Fenchel-Young losses are substantially faster than baselines for small nn, Figure 2a does show that their runtime still increases quickly as the number of items grows. A more thorough discussion on computational complexity and larger-scale experiments to clarify whether the runtime advantage is consistent across larger instances would strengthen the paper.

  2. Some figures are difficult to interpret (e.g., several curves in Figure 2b are hard to distinguish from each other, and the large range in the KL divergence curve makes it difficult to compare the different approaches).

Questions
  1. On Page 7, Section 6.1 mentions that the proposed losses are compared against six established baselines, but only four are listed.

  2. While competitive against baselines, the runtime of the Fenchel-Young losses seems to increase quickly as the size of the problem grows. What would explain that behavior? Would it be possible to run larger-scale experiments to sanity check whether the proposed losses still achieve competitive runtime against baselines for larger instances?

  3. For the DVAE experiments, can the authors provide numerical results such as the final error and KL divergence in addition to Figure 2b, especially for those methods that are currently hard to distinguish visually?

Limitations

Yes.

Formatting concerns

No formatting concerns.

3 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We sincerely thank the reviewer for their constructive feedback. We address your specific concerns below.

W1/Q2: Runtime complexity and scalability

We appreciate the opportunity to clarify the runtime behavior. The baselines exhibit a higher constant overhead, which penalizes them at smaller scales but makes their runtime appear relatively flat initially. In contrast, the FY losses have very low initial overhead, making them exceedingly fast for small values of nn. The increase observed in Figure 2a for our methods simply reflects their theoretical O(n)\mathcal{O}(n) time complexity.

To sanity-check whether our proposed losses maintain competitive runtimes at larger scales, we ran extended experiments for nn up to 2000. The average runtimes (in milliseconds) are reported below:

n=10 n=50 n=100 n=500 n=1000 n=1500 n=2000
Gini-FY 1.0 1.3 2.6 33.8 130.6 288.5 476.7
Shannon-FY 1.1 1.9 4.7 96.0 346.6 754.5 1275.9
Tsallis-FY 0.9 2.2 6.0 120.5 472.9 1044.5 1791.1
NCE 27.5 35.0 37.7 102.7 327.1 642.3 1125.1
NID 29.9 31.0 33.3 106.8 323.4 644.6 1121.6
DBB 58.3 58.3 60.2 197.2 646.9 1274.9 2231.7
PFY 1.1 3.6 9.4 257.1 3706.3 9080.0 35982.0

These extended results confirm that our proposed FY losses do not suffer from prohibitive blowups and remain highly competitive at larger scales. Gini-FY is particularly efficient, remaining strictly faster than all baselines up to n=2000n=2000. Shannon-FY and Tsallis-FY remain on par with the NCE and NID baselines, while bypassing the computational bottlenecks observed with PFY as nn grows. This is especially notable given that PFY is the only competing baseline in terms of test regret.

W2/Q3: Curve distinguishability and final metrics

We agree that some curves overlap in Figure 2b, as the corresponding methods achieve comparable performance. However, the visual grouping of the curves still clearly illustrates our three main conclusions (Lines 247-252):

  • In the reconstruction error plot, we conclude that the proposed approaches with sparse regularizers outperform Shannon-based ones (i.e., the framework of SIMPLE) and straight-through based estimators,
  • In the KL plot, we conclude that the proposed approaches outperform the straight-through based estimators,
  • In the sparsity plot, we conclude that the proposed estimators with Gini and Tsallis regularization correctly converge to sparse latent representations, contrary to LapSum and Shannon operators.

To complement the figure with exact numerical precision, we will add the final metric values to appendix E.2 as requested:

Deterministic Shannon Stochastic Shannon Deterministic Tsallis Stochastic Tsallis Deterministic Gini Stochastic Gini FDS LapSum Gumbel-ST Hard-ST
Rec. Error ×102\times10^2 0.268 0.385 0.232 0.232 0.232 0.232 0.232 0.231 2.104 2.124
KL Div. 149.23 155.68 155.22 155.16 155.09 155.07 155.26 155.16 1.11e13 1.86e13

Q1: Typo

Thank you for catching this typo. We have corrected line 212 to state "four" baselines instead of "six" in the revised manuscript.

Reviewer 4pab · CommentOpenReview ↗

The response addresses my previous questions and concerns.

Authors · CommentOpenReview ↗

We thank the reviewer for taking the time to read our rebuttal and for maintaining their recommendation for acceptance.

Reviewer EjwfOpenReview ↗
Rating
4/6
Confidence
3/5
Quality
2/4
Clarity
3/4
Significance
2/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper derives a differentiable knapsack and top-k operator. It is theoretically solid, deriving a differentiable relaxation with a stochastic and determinstic version. Care is taken to describe it's implementation suitable for integrating it into typical ML-Pipeline. It is empirically evaluated on a benchmark of generated knapsack problems, discrete VAE and a dynamical assortment with knapsack constriants.

Strengths and weaknesses

Strengths: Theoretically solid, well written and detailed description of the derivation of the method and its algorithmic form.

Weakness: The paper lacks an convincing motivation, which is followed by an unconvincing experimental section. In particular, the submission reads like an incremental contribution as it does not unlock functions that were previously unable to be integrated into an deep-learning framework, but the importance of the problem and the limitations of previous approaches that warrants such a deep and thorough investigation is not laid out in an convincing way. As an example, in the introduction the authors claim "Solver-agnostic, black-box approaches, such as (...), are flexible but computationally expensive, often requiring multiple solver calls.". This argument is not supported by a clear demonstration where this leads to issues, e.g. the multiple solver calls being too expensive. This criticism connects to the experimental section, where e.g. the knapsack problems do no clearly connect to use-cases that show existing approaches to not be adequate enough. The experimental section also feels unstructured and without a clear, consistent and motivated section of baselines demonstrating clear and important inadequacies of existing approaches.

Questions

Q1: In line 132 the authors write that the implementation is in Numba, which is a more esoteric choice compared to the usual framework (Pytorch, Jax, etc.). Can the authors explain what drove this choice? Could this be implemented in an efficient (but maybe not high-performant) way in the common frameworks or is there a blocker that led to the choice of Numba?

Q2: Is there an concrete use-case where the existing approaches fail and the proposed method is necessary?

Q3: There is no clear, consistent comparison to previous work in the experimental section. it appears like the baselines from 6.1 can also be applied to e.g. 6.3. What is the performance of the baselines from 6.1 on the other experiments? If they are e.g. computationally feasible, this would benefit from being shown and improve the argument of the paper.

Limitations

yes

Final justification

The main remaining weakness of the resulting paper is the weak narrative, which does not do much to motivate broader importance and impact on the general ML-community beyond the quite synthetic experiments. It is especially important for this paper, as the topic is quite niche so much more care should be taken why this work is relevant. Since the authors argued for a broader relevance during the rebuttal I am willing to increase my score, but only to borderline accept. A stronger narrative (and a clear accept) would include an experiment that demonstrates the superior performance in one of these examples, instead of the synthetic experiments like predicting knapsack solutions.

Formatting concerns

no concerns

5 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We thank the reviewer for their feedback. We address your specific concerns below.

General response to weaknesses (motivation and baselines):

Regarding the motivation for our paper, please see our detailed reply to Q2. Furthermore, regarding the computational bottleneck of multiple solver calls, we explicitly demonstrate this in Figure 2a (left) and Figure 3 (right). As detailed in our response to Reviewer 5, we have also conducted extended scaling experiments which conclusively show that PFY scales poorly compared to our DP-based FY losses.

Regarding the experimental section, we argue that our experiments are solid and appropriately validate the proposed method. The reviewer notes a lack of "consistent" baselines across tasks (also appearing in their Q3): we respectfully clarify that this variation is entirely by design. One of our framework's primary contributions is its versatility: it can function in both Knapsack and Top-k settings, as a deterministic hidden layer (Section 6.1), a stochastic hidden layer (Section 6.2), and an output layer (Section 6.3). Because prior methods are fundamentally limited in their capabilities, no single baseline can span all these scenarios. To ensure a rigorous evaluation, we deliberately matched our method against the strongest, strictly applicable state-of-the-art baselines for each specific setting.

Q1: On the use of Numba

Numba targets both CPUs and GPUs, and is frequently used to implement neural network layers that require very loopy code (as in dynamic programming for example), while PyTorch/JAX are notoriously inefficient at compiling sequential for loops with data dependencies. As examples, we can cite for instance the official implementation of [1], and the successful implementation of soft-DTW [2] by Mehran Magoumi on GitHub (we cannot put links here as per the NeurIPS rules on author responses).

In our preliminary benchmarks, Numba performed order of magnitudes faster than a jitted JAX implementation. Alternatives to Numba include Triton or Pallas, though we haven’t explored them for this project.

Q2: Use-cases where the existing approaches fail and the proposed method is necessary

First, our framework natively unlocks capabilities that prior works fundamentally cannot handle:

  • For the Knapsack setting, to our knowledge, our paper introduces the first specialized differentiable layer. Knapsack constraints are not easy to incorporate into existing differentiable Top-k alternatives, which are based on totally different approaches from ours. It is our dynamic programming framework that makes it possible to seamlessly incorporate these non-uniform weights and capacity constraints.
  • For the Top-k setting, while many differentiable relaxations exist, our DP-based approach provides the first unified framework enabling exact sparsity (or equivariance), exact VJPs, and exact sampling.

Second, we demonstrate concrete use-cases in our experimental section where existing approaches fail or exhibit significant limitations, making our method strictly necessary:

  • Learning to Predict Knapsack Solutions (Section 6.1): When integrating Knapsack solvers into predictive pipelines, existing black-box differentiation methods (like DBB and NID) and contrastive surrogate losses (like NCE) yield significantly worse downstream predictive performance. As shown in Figure 2a, our DP-based Fenchel-Young losses are necessary to consistently achieve the lowest test relative regret while scaling much more efficiently than perturbation-based methods.
  • Top-k Discrete VAEs (Section 6.2): Existing straight-through (ST) estimators fail in this setting, leading to diverging KL regularization. Additionally, prior differentiable approaches like LapSum or SIMPLE cannot induce sparse latent representations. Our Gini and Tsallis dynamic programming operators solve this by achieving exact sparsity and superior optimization stability. These specific failures of baselines and the success of our method are explicitly demonstrated in Figure 2b.
  • Knapsack constraints in Structured RL (Section 6.3): Existing solver-agnostic methods like PFY require multiple solver calls, making them computationally expensive. We explicitly demonstrate this scaling bottleneck in Figure 2a. Furthermore, in our dynamic assortment task, standard perturbation-based approaches suffer from high gradient variance. Our framework significantly reduces this variance and lowers computation time, as shown in Figure 3.

Beyond the empirical evaluations in Section 6, capacity-constrained discrete selections are ubiquitous in modern machine learning. To give ideas on the broader impact of work on the ML community, we give examples on how our differentiable Knapsack operators could unlock end-to-end trainable modules for Mixture of Experts routing and LLM self-speculative decoding in our response to Reviewer Q252.

Q3: Application of baselines from 6.1 to 6.3

We refer the reviewer to our response to their "Weakness" paragraph about the consistency of our experimental evaluation.

The other baselines considered in Section 6.1 (namely, NID, DBB, and NCE) are not directly applicable to the structured RL framework of Section 6.3. Indeed, the latter necessitates the Knapsack operator to enable sampling item selections for the exploration phase of the SRL algorithm. While NID, DBB and NCE are strictly blackbox differentiation techniques or surrogate losses that do not provide a forward sampling mechanism, our proposed operators enable this thanks to Algo 3.


[1]: Lee, Dongha, Seonghyeon Lee, and Hwanjo Yu. "Learnable dynamic temporal pooling for time series classification." , AAAI 2021.

[2]: Cuturi, Marco, and Mathieu Blondel. "Soft-dtw: a differentiable loss function for time-series." International conference on machine learning. PMLR, 2017.

Reviewer Ejwf · CommentOpenReview ↗

I want to thank the authors with engaging with my comments, but i feel like there is a bit of an misunderstanding. For Q2, the question is meant in the larger context of machine learning. For example, DBB is a general tool that can be used in many optimization settings and I don't see "first specialized differentiable layer" inherently as an advantage over a general tool, which can be easier maintained, improved etc than a specialized solution (although I agree that it is not a strict superset, as a stochastic variant does not exist). From my perspective experiment 1, 2 and 3 are useful to demonstrate the technical advantage, but they are not established problems in the larger community. I think the technical contribution of the paper is solid, but I think the paper would benefit from an improved motivation that demonstrated the importance and need for the specialized operator to the broader ML-community. Right now, it just describes an algorithm and demonstrates it on generated problems. I think the question is similar to Q1 from reviewer Q252, where you point to works that would benefit from this operator (references [1] and [2]) but only as references. Unfortuntely, no results were given, but the authors can maybe still expand on this, because if e.g. only the deterministic setting is needed in these application the question arises whether this specialized layer leads to practical benefits over the general tools.

Authors · CommentOpenReview ↗

We thank the reviewer for the engaging discussion. Regarding the broader ML context and the necessity of our specialized layer over general tools like DBB, our paper demonstrates fundamental mathematical and empirical advantages that general deterministic solvers cannot provide.

Exact sampling for principled gradients (Appendix D.5)

Some applications require hard 0/1 selections in the forward pass. For instance, the recent approaches [1,2] we referenced in our answer to reviewer Q252 use Knapsack-based item selections for conditional computation. In this context, one must either perform a computation (1) or not (0), and a 0.4 selection weight would not make sense. However, when performing hard 0/1 selections in the forward pass, obtaining meaningful gradients is difficult. If one uses a general deterministic solver to obtain a hard forward pass and pairs it with a surrogate backward pass (a "mock gradient", as in DBB), the optimization suffers from severe bias. We explicitly analyze this in Appendix D.5 and demonstrate it in Figure 9: estimators relying on a hard deterministic forward pass fail to converge to the true parameters.

By contrast, our specialized DP framework natively defines the exact underlying distribution of the relaxed operator (Proposition 3) and provides an exact ancestral sampling mechanism (Algorithm 3). As proven in Appendix D.5, and building upon the theoretical framework of [3], this stochastic forward pass, combined with the VJP of its expectation in the backward pass, forms a principled, unbiased first-order estimator of the expected loss. Figure 9 confirms that this approach perfectly recovers the exact parameters where deterministic hard-forward baselines fail.

Fundamental need for sampling (Sections 6.2 and 6.3)

Beyond gradient estimation, sampling discrete subsets is fundamentally useful and of high interest to the broader ML community. This is clearly evidenced by the SIMPLE framework [4], which successfully proposed a similar stochastic forward and surrogate gradient approach for representation learning tasks such as Discrete VAEs, but is restricted to the Top-k and Shannon-entropy setting. Our DP framework strictly generalizes this impactful approach to support sparse regularizations (Gini, Tsallis), demonstrating its utility on Discrete VAEs in Section 6.2, and extends it to the non-uniform capacity constraints of the Knapsack problem.

Furthermore, certain algorithmic pipelines strictly require sampling rather than simply computing a deterministic argmax. For example, in our Structured RL experiment (Section 6.3), the exploration phase of the SRL algorithm strictly necessitates sampling capacity-constrained item selections. General deterministic tools (such as DBB, NID, or NCE) cannot be used in these generative or exploratory settings because they do not define an underlying probability distribution.

Conclusion

In summary, our results demonstrate that stochastic sampling serves two purposes: it enables principled gradient estimation under strict hard 0/1 forward constraints, and it is fundamentally required by generative and exploratory algorithms that must sample discrete combinations. We will make sure to clarify the importance of sampling in this broader ML context by adding a dedicated paragraph to the introduction of the paper.

We hope these clarifications address the concerns raised, and we would be grateful if the reviewer would reconsider their score in light of them. We remain available during the discussion period.


[1]: Li, Ziniu, et al. "Knapsack RL: Compute-Efficient Reinforcement Learning via Heterogeneous Rollout Allocation.”, ICML 2026.

[2]: Cha, Seong-Hwan et al. “KnapSpec: Self-Speculative Decoding via Adaptive Layer Selection as a Knapsack Problem.”, ICML 2026.

[3]: Liu, Liyuan, et al. "Bridging discrete and backpropagation: Straight-through and beyond.", NeurIPS 2023.

[4]: Ahmed, Kareem, et al. "Simple: A gradient estimator for k-subset sampling.", ICLR 2023.

Reviewer dYbrOpenReview ↗
Rating
4/6
Confidence
3/5
Quality
3/4
Clarity
4/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper presents a way to make the Knapsack problem, along with its special case top-k, differentiable by replacing the max operator with a generalized max operator with regularization. This allows the authors to define an end-to-end differentiable layer that produces the selections of the knapsack given the item values and item weights. The paper proposes a training method for this layer and shows the usefulness of the layer in different example problems. The speedup is mainly expected from the single call of the solver for gradient estimation use back-propagation, as other compared methods that rely on gradient estimation need multiple gradient calls. This produces state-of-the-art speedup and performance in the experiments presented.

Strengths and weaknesses

Strengths:

  • Despite its technical depth, the paper is easy to follow, and the flow is fairly intuitive.
  • The paper analyzes the choice of regularization and follows through with a theoretical characterization.

Weakness:

  • Higher values of the regularization constant γ\gamma introduce bias into the forward knapsack solver, which in turn affects the backward pass — but this effect is neither shown nor discussed in the paper.
  • No ablation for the regularization term in the Fenchel-Young discrete VAE. It's not clear how much this term actually matters. From what I can tell, the method still works without it in the experiments, so an ablation showing its effect would help.
  • Test regret isn't shown for larger problems. Experiment 1 shows how runtime scales with more items, but not how test regret scales. Since all experiments use a small number of items, it would be good to see if solution quality holds up as the problem size grows, not just speed.
  • While the paper presents new results on characterizing smoothed max operator for sparse and symmetric case, the core algorithmic contribution is largely an adaptation of known second-order techniques to the knapsack setting.
Questions
  • In the experiments, Shannon regularization lags behind the other types of regularization, mainly due to the sparsity property of the latter. My question is: is there any practical benefit to the permutation invariance of Shannon regularization proved in the paper?

  • Line 248 claims that the sparse Shannon variant surpasses the SIMPLE (deterministic) variant, but in Figure (b), the green dashed line (stochastic forward) shows a higher reconstruction error than the green solid line. Is this a typo, or am I misunderstanding something?

  • Curious about LapSum performing close to the DP method in reconstruction error but not reaching top-k performance metric, could this be an effect of the difference in regularization between the methods?

Limitations

Yes

Final justification

I will maintain my score. The paper does provide some interesting theoretical results and observations, but the experiments don't seem to fully justify the effectiveness of the proposed model on the task. In particular, not having grounding at all performs on par with the presented results. This makes me suspect that the model's performance on the task is not entirely backed by the theoretical analysis presented in the paper.

Formatting concerns

N/A

3 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We sincerely thank the reviewer for their constructive feedback. We address your specific concerns below.

W1: Effect of γ\gamma on the forward bias

We thank the reviewer for giving us the opportunity to discuss this point. We completely agree: regularization biases the forward pass to enable meaningful gradients in the backward pass. As shown in Appendix D.4, the difference between the smoothed and unregularized DP values is bounded above and below, and the proposed layers strictly converge to the original, hard operators for vanishing regularization (γ→0\gamma \to 0). We can also explicitly bound the “forward bias” for γ>0\gamma>0, depending on the regularization choice:

  • Shannon: the relaxed operator is the expectation of a Gibbs distribution (see Section A.1). Let y⋆y^\star be the unique hard maximizer for θ\theta, and define the optimality gap δ=⟨θ,y⋆⟩−max⁡y≠y⋆⟨θ,y⟩>0\delta = \langle \theta, y^\star \rangle - \max_{y \neq y^\star} \langle \theta, y \rangle > 0. We can bound the ℓ1\ell_1 distance: \begin{align} y_{w,\Omega}^C(\theta) - y^\star &= \sum_{y \neq y^\star} (y - y^\star) \frac{\exp(\langle \theta, y \rangle / \gamma)}{\sum_{y'} \exp(\langle \theta, y' \rangle / \gamma)} \\\\ \Vert{} y_{w,\Omega}^C(\theta) - y^\star \Vert{}_1 &\le \sum_{y \neq y^\star} \Vert{} y - y^\star \Vert{}_1 \frac{\exp(\langle \theta, y \rangle / \gamma)}{\sum_{y'} \exp(\langle \theta, y' \rangle / \gamma)} \\\\ &\le \sum_{y \neq y^\star} \Vert{} y - y^\star \Vert{}_1 \frac{\exp(\langle \theta, y \rangle / \gamma)}{\exp(\langle \theta, y^\star \rangle / \gamma)} \le n \vert{}\mathcal{Y}_w^C\vert{} \exp\left(-\frac{\delta}{\gamma}\right) \end{align} Thus, the forward bias decays exponentially as γ\gamma decreases.
  • Sparse (Gini / Tsallis): Proposition 2 proves that the local gradient mapping has a finite saturation threshold τΩ\tau_\Omega (γ\gamma for Gini, 2γ2\gamma for Tsallis). If θ\theta is far enough from a decision boundary (such that local advantages exceed τΩ\tau_\Omega), the relaxed operator recovers the exact hard solution, meaning the forward bias is strictly zero.

We will extend Appendix A.4 with these regularization-specific remarks on the forward bias of the smoothed operators with respect to the hard ones, and reference it as well as briefly explain these conclusions in the main text after Definition 1.

W2: Ablation of the FY-DVAE regularization term

We thank the reviewer for prompting this ablation. To answer directly: empirically, on the considered task, setting βFY=0\beta_{FY} = 0 (no regularization) yields test metrics that are almost identical to our chosen hyperparameter (βFY=10−5\beta_{FY} = 10^{-5}).This is the result of a deliberate hyperparameter choice driven by the classic rate-distortion trade-off in VAEs. To ensure a fair comparison against purely deterministic, unregularized baselines like FDS and LapSum, we tuned βFY\beta_{FY} to a very small value so the model could prioritize reconstruction. The requested ablation demonstrates this dynamic:

βFY\beta_{FY} Test Rec. Loss FY Loss Avg. ∥y∥0\Vert{}y\Vert{}_0
0.0 (Ablated) 0.00231 1.31 3.0
1e-5 (Ours) 0.00232 1.31 3.0
3e-5 0.00236 1.26 3.3
5e-5 0.00260 0.81 6.3
7e-5 0.00279 0.31 8.8
1e-4 0.00284 0.09 9.6

Increasing βFY\beta_{FY} enforces the uniform prior, which opposes sparsity and degrades reconstruction. Therefore, the primary justification for the FY regularization term is theoretical completeness rather than an empirical boost on this specific benchmark. As detailed in Section 6.2 and Appendix E.2, LΩ1k(0;y1,Ωk(θ))L_{\Omega_1^k}(\mathbf{0}; y_{1,\Omega}^k(\theta)) generalizes the standard discrete KL divergence against a uniform prior used in prior work such as [1]. Without it, the model is simply an autoencoder with a discrete bottleneck; including it formally grounds the method a proper DVAE framework.

We will include this ablation and discussion in Appendix E.2.

W3: Test regret scaling

Figure 2a (right) evaluates test regret scaling up to n=100n=100. We capped this scale because full model training is significantly more computationally expensive than the single-pass speed profiling shown on the left. The relative ordering of the methods' performances remains completely consistent across these scales, which is the core takeaway of this plot.

W4: Differences with the DDP framework

As stated at lines 171-173, the special structure of our DAG, which has repeated edges and constant ones (see Appendix D.3), leads to important changes compared to the differentiable DP framework of [2], especially in the derivation of the layer’s VJP. Specifically, the reviewer may compare our derivation of Algo 4 (in Appendix B.4) to that of [2] in their appendix A.7 (we used the same color code for analogous terms in order to better allow one to do this comparison). While the difference in notations may still make this comparison quite hard to parse, the final expression of our orange term (see page 36 of the paper, between lines 1083 and 1084) does not benefit from the same simplifications, leading to more complex iterations in our final recursion. Thus, while a part of our algorithmic contribution is indeed based on known differentiable DP techniques, we argue that it is not a simple adaptation or instantiation, and the mapping from our framework to the one of [2], described in Appendix D.3, required non-trivial derivations in order to lead to a correct algorithm.

Q1: Benefits of permutation-equivariance

While we agree that sparsity plays a more important role in the presented experiments, permutation-equivariance may be a desirable property in some applications. For instance, when processing inherently orderless data (such as in graph neural networks, set processing, or mixture-of-experts routing), one could strictly require that the selection remains consistent regardless of how the input items are indexed. Furthermore, our Shannon-regularized DP operators are useful in applications needing to sample exactly from the Gibbs distribution itself (with Algo 3), to compute its expectation (Algo 2), or to compute the log-sum-exp over feasible selections (Algo 1).

Q2: Small clarification at Line 248

We thank you for noticing that this sentence was not clear enough. In the specific top-k setting with Shannon regularization, both our deterministic and stochastic operators fall into the framework of [1] (which also proposes both deterministic and stochastic forward passes). The “sparse variants” we are referring to are the Tsallis and Gini-based operators, which do outperform the Shannon-based ones (=SIMPLE in this setting). We will update line 248 to:

“First, our DP-based operators match or outperform baselines in reconstruction quality; in particular, our variants equipped with sparse regularizers (Gini and Tsallis) surpass the Shannon-based SIMPLE framework across both deterministic and stochastic forward passes”.

Q3: Regularization difference with LapSum

Indeed, this discrepancy is a direct effect of the regularization. LapSum relies on a dense relaxation which forces the latent representations to remain strictly in the interior of the polytope (i.e., to produce outputs that are necessarily convex combinations of k-hot vectors). It minimizes reconstruction error by softly blending all digit classes but fails to make discrete selections. In contrast, as shown in our Proposition 2, our Gini and Tsallis variants allow hard item selections, enabling sparse latent representations.


[1]: Ahmed, Kareem, et al. "SIMPLE: A gradient estimator for k-subset sampling.", ICLR 2023.

[2]: Mensch, Arthur, and Mathieu Blondel. "Differentiable dynamic programming for structured prediction and attention.", ICML 2018.

Reviewer dYbr · CommentOpenReview ↗

I thank the authors for their clarifications, which address the points I raised. I will retain my original score.

Authors · CommentOpenReview ↗

We thank the reviewer for taking the time to read our rebuttal and for maintaining their recommendation for acceptance.

Reviewer whc1OpenReview ↗
Rating
5/6
Confidence
2/5
Quality
4/4
Clarity
3/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper proposes a novel formulation for converting Top-kk and Knapsack operators into differentiable operators using dynamic programming. First, the authors demonstrate the Top-kk problem as a special case of the Knapsack Bellman DP Recursion by setting item weights, i.e. w=1w = 1, and achieving the equality condition through proper initialization of the DP Matrix by setting V1[0,1:]V^1[0,1: ] with −∞-\infty. Having bonded both the problems into a unified framework, they then present differentiable versions of the operator.

They achieve this by using smoothed max operators, detailed in [1], [3]. The smoothed max operator, regularizes the output function, with a convex regularizer to help with differentiability. Relaxing the Bellman DP recursion for the Knapsack problem accordingly, turns the recursion into a differentiable operation solvable with time complexity O(nC)O(nC). To reduce the complexity, the authors use wavefront parallelization to bring down the time from O(nC)O(nC) to O(n)O(n).

Furthermore, the authors also provide detailed analysis on three commonly used regularization functions: Shannon entropy, Gini Entropy and 1.5 Tsallis entropies. They derive a closed form solution for the Shannon entropy regularizer, and use this to also prove permutation invariance in this case.

They also showcase the equivalence of their method to [1], which is a general framework developed for making DP-based algorithms differentiable and learnable. They showcase the equivalent required DAG construction, although with some significant changes for this special case.

To demonstrate the integration of the operator in neural networks, they describe three scenarios: as a deterministic hidden layer, as a stochastic hidden layer, and using it as an output layer. Since the operator is regularized with a convex regularizer, and it fits the scenario described in [2], the authors use this to readily derive a Fenchel Young Loss for it.

To showcase their method, the authors showcase evaluations through three experiments, which including predicting Knapsack solutions, training discrete VAEs and a RL Setting, and compare with respective baselines.

[1]: Differentiable Dynamic Programming for Structured Prediction and Attention:https://proceedings.mlr.press/v80/mensch18a/mensch18a.pdf
[2]: Learning with Fenchel-Young Losses, https://jmlr.csail.mit.edu/papers/volume21/19-021/19-021.pdf
[3]: Niculae, Vlad and Blondel, Mathieu. A Regularized Framework for Sparse and Structured Neural Attention.

Strengths and weaknesses

Strengths:

  • The application of DP and smoothed max operator to this case, although novel to this setting, is also fairly simple and easy to follow through. Using the smoothed max operator falls nicely into the Fenchel Young Loss setting, which provides a neat and convenient expression for the loss function and gradients, if the operator were used as an output layer. The authors also prove equivalence of their method to an earlier general framework for making DP-based problems differentiable. [1]
  • The mathematical treatment in the paper is rigorous, and the authors also provide a closed form solution for the Shannon entropy case, and also prove that it is the only regularizer that provides permutation invariance to the operator, which is a strongly desirable property for Knapsack/ Top-kk.
  • They also derive vector Jacobian products and demonstrate the integrations of the operator in a neural network, as a hidden layer (deterministic and stochastic), and as an output layer. They also provide sampling algorithms to convert soft targets output by the operator, to hard targets that may be necessary for inference. Furthermore, for each of the regularizers that have been analyzed, the authors derive the required initializations for both knapsack and top k, further enhancing completeness.
  • The experiments showcase the value of the improvements very clearly. In the RL Setting, there are significant speed improvements, in comparison to perturbation-based methods and PPO. Similarly, we see that using different regularizers such as Gini entropy, that can lead to sparse outputs, and explainable data, while having superior optimization quality and performance in the VAE setting.

Weaknesses:

  • As already mentioned by the authors, the standard time complexity is O(nC)O(nC). The authors implement wavefront parallelization to bring the time complexity down to O(n)O(n), however, this increases the space complexity to O(nC)O(nC), which might become a problem as CC increases.

[1]: Differentiable Dynamic Programming for Structured Prediction and Attention:https://proceedings.mlr.press/v80/mensch18a/mensch18a.pdf

Questions
  1. In Experiment 6.1, the authors mention that there are six baselines that they compare against, however the following text, and the appendix only provide details of four baselines.
  2. Although the authors do compare with some top-k specific approaches, especially in the VAE Setting, I think the paper would also benefit by a comparison with other top-k specific methods such as [1] / [2] in the deterministic layer case. This would shed light on the computational differences and benefits in comparison to transport based regularization methods, and also showcase the performance differences.

[1]: Differentiable Top-k Operator with Optimal Transport: https://proceedings.neurips.cc/paper_files/paper/2020/file/ec24a54d62ce57ba93a531b460fa8d18-Paper.pdf
[2]: Differentiable Sorting Networks for Scalable Sorting and Ranking Supervision : https://proceedings.mlr.press/v139/petersen21a/petersen21a.pdf

Limitations

yes

Final justification

I shall keep my score as is. The paper is theoretically solid and rigorous, and is interesting to read. The proposed knapsack operator is novel and has nice properties (exact sampling and sparsity for top-k), although somewhat incremental. The showcased synthetic experiments also achieve a good speedup over regular baselines, while achieving SoTA performance. The discussion phase also clarified broader motivations, and additional experiments, which I believe help showcase the significance of the promised method if integrated. I shall also keep my confidence rating, as I'm unfamiliar with previous related work, and I had limited time to review as an emergency reviewer.

Formatting concerns

N/A

3 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We sincerely thank the reviewer for the positive assessment of our paper. We address your specific concerns below.

W1: Space complexity

While this memory footprint poses no issues for our targeted applications, exceptionally large capacities CC could indeed create memory bottlenecks. As discussed in our Limitations section (Lines 280-286), to mitigate this in extremely large state spaces, practitioners can:

  • Trade compute for memory, and store only a fraction of the DP table during the forward pass and recompute the rest during the backward pass (a form of gradient checkpointing).
  • Reduce the state space, by dividing the item weights and total capacity by a common factor, which shrinks CC directly. This is exact if using the greatest common divisor, or trades slight precision for memory if rounding.

Again, this limitation would only arise for exceptionally large capacities CC. For the applications we considered, our proposed operators are extremely fast and memory-efficient. We will add a forward-reference to this discussion directly in Section 4.1 at Line 133 so that readers are immediately aware of these considerations.

Q1: Typo

Thank you for catching this typo. We have corrected line 212 to state "four" baselines instead of "six" in the revised manuscript.

Q2: Optimal transport baseline

We completely agree that adding a transport-based specialized Top-k baseline to our experimental section would benefit the paper.

We added the soft Top-k operator from [1] to our DVAE experiment. After a search over different values of ϵ\epsilon, its best final test reconstruction error lies between the stochastic and the deterministic variants of our Shannon-based operator, with a value of 0.00280 (obtained with ϵ=0.005\epsilon=0.005), i.e., it is outperformed by the rest of our proposed operators (using Gini and Tsallis regularizations).


[1]: Xie, Yujia, et al. "Differentiable top-k with optimal transport.", NeurIPS 2020.

Reviewer whc1 · CommentOpenReview ↗

I thank the authors for addressing the questions. I shall maintain my score.

Authors · CommentOpenReview ↗

We thank the reviewer for taking the time to read our rebuttal and for maintaining their recommendation for acceptance.

Reviewer Q252OpenReview ↗
Rating
4/6
Confidence
2/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

This paper studies the Knapsack and Top-k operators and makes them differentiable via dynamic programming. The DP recursions are smoothed by replacing the hard max at each step with a smoothed maximum operator regularized by a convex function \Omega, escaping the original zero-gradient problem. They study three choices of \Omega: Shannon, Gini, and 1.5-Tsallis entropy.

Their main theoretical contribution proves a trade-off: Shannon regularization is the unique choice that makes the operator permutation-equivariant (order-independent), while Gini/Tsallis regularization instead produce sparse outputs (exact 0/1 selections) — no single regularizer gives both.

They propose three ways to use the operator as a layer: as a deterministic hidden layer (via VJPs), a stochastic hidden layer (sampling forward, surrogate gradient backward), and an output layer (via a Fenchel-Young loss). They test these across three experiments: predicting Knapsack solutions (PyEPO benchmark), a discrete VAE on stacked MNIST, and a constrained dynamic assortment RL problem.

Strengths and weaknesses

Strengths

  • I enjoyed reading the theoretical results — the idea is interesting, and the way they relax the problem, construct regularized convex functions, and characterize their properties all makes sense.
  • They validate the approach experimentally and show that the algorithm works in practice.
  • The figures and algorithms are helpful for understanding the paper.
  • They propose a more general framework for differentiable Knapsack/Top-k operators, and their parallel implementation reduces the DP's time complexity from O(nC) to O(n) parallel steps.

Weaknesses

  • It took some time to piece together the overall narrative of the paper. Each section makes sense on its own, but it isn't immediately clear what the overarching point is or why it matters. Making these operators differentiable is interesting, but I'm not sure what the concrete benefit is. The experiments look promising, but they're fairly simple settings, and it's unclear whether this would have a meaningful impact on ML more broadly. This contributes to the sense that the paper's narrative is weak.
  • While they clearly tried to simplify the notation, there are still many superscripts and subscripts that make it excessively hard to follow.
  • Most experiments combine multiple integration modes at once (e.g., 6.3 mixes stochastic sampling with Fenchel-Young gradients), so it's hard to attribute performance gains to any single mechanism in isolation. It's not clear these are the best-controlled settings for isolating the contributions of the differentiable framework.

As an emergency reviewer, I did not have time to verify every single equation in the appendix (especially given the length of the appendix), so my assessment of the full technical soundness is limited. I would value hearing other reviewers’ views on the correctness of the detailed proofs.

Questions
  1. How do the authors see the broader impact of this work on the ML community? I understand the core idea, but I'm still unsure how it would be used in more general settings.
  2. The paper motivates the three regularizers via the equivariance/sparsity trade-off, but I'd like more intuition on the choices within the sparse family — why 1.5-Tsallis specifically?
  3. The related work positions this as generalizing prior differentiable Top-k methods, with handling non-uniform Knapsack weights as a key distinction. Beyond that, what's the main advantage of the DP-based approach over the closest prior methods (e.g., SIMPLE, LapSum) in the Top-k settings where those are also applicable?
Limitations

yes

Final justification

I maintain my positive rating but won't increase my confidence, given the limited time I had to review this paper as an emergency reviewer. The authors answered most of my questions very well, and I still find the paper interesting.

Formatting concerns

Minor note: Figure 2 appears to be missing its "Figure 2" caption label (the sub-captions (a) and (b) are present, but I couldn't find the top-level figure number/caption). The authors may want to double-check this.

3 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We sincerely thank the reviewer for their constructive feedback. We address your specific concerns below.

W1: Strengthening the narrative

Thank you for the constructive feedback. The core motivation is that while these discrete operators are ubiquitous, previous differentiable relaxations have been fragmented. Our concrete contributions address this directly across two fronts:

  • In the Knapsack setting: we introduce the first specialized differentiable layer for this problem. This unlocks the end-to-end training of models that require weighted, capacity-constrained discrete selections, while allowing them to benefit from the full diversity of our framework (supporting both stochastic and deterministic passes, as well as sparse and equivariant modes).

  • In the Top-k setting: we provide the first unified framework for differentiable operators that natively jointly combines exact sparsity (or permutation equivariance), exact VJPs, and exact sampling.

We will make sure to clarify these concrete benefits of our approach in the introduction of the paper.

W2: Notation (subscripts and superscripts)

We agree the sub/superscripts increase cognitive load, and we actively debated this during the writing process. Ultimately, we concluded this specific notation was the best way to introduce our unified framework.

W3: Experiments combining integration modes

We believe our experiments allow us to isolate the contribution of each component.

  • Section 6.1 strictly isolates the integration as an output layer with Fenchel-Young (FY) losses in the Knapsack setting.
  • Section 6.2 strictly isolates the integration as a hidden layer (either stochastic or deterministic) in the Top-k setting.
  • Section 6.3 is indeed the only experiment that blends two modes (stochastic forwards and FY gradients). We argue that their respective impacts remain clear and intuitively understandable when compared to the standard perturbation-based SRL pipeline. First, our sparse regularizers uniquely induce a sparse distribution support for the sampling phase. Second, our exact and deterministic computation of the FY gradient negates the need for Monte-Carlo sampling, further reducing variance. Third, our regularized DP has the same complexity as a single unregularized call needed by Monte-Carlo sampling for perturbation-based SRL, which in turn reduces the required computational time.

We will make sure to clarify this in Section 6.3.

Q1: Broader impact in the ML community

Beyond the specific applications in our experiments, capacity-constrained discrete selections are ubiquitous in modern ML.

For example, our Knapsack operator could unlock end-to-end differentiable budget-based expert routing in Mixture of Experts architectures, where each expert has a distinct computational load-based weight and the network is constrained by a strict total computation budget per forward pass.

Similar ideas appear in recent work such as in [1], where LLM exploration budgets for GRPO rollouts are allocated via knapsack optimization. While their approach currently relies on delayed historical heuristics to estimate a task's learning value, integrating our differentiable operators could transform this into an end-to-end trainable module that directly learns to predict optimal allocations.

Similarly, in self-speculative decoding frameworks like [2], draft-model layer selection is formulated as a knapsack problem using cosine similarity heuristics. By replacing these heuristic item values with learned parameters passed through our differentiable knapsack layer, this pipeline could be transformed into an end-to-end trainable module that directly maximizes downstream token acceptance under strict latency budgets.

Q2: Intuition for the 1.5-Tsallis choice

The Tsallis entropy with α=1.5\alpha=1.5 can be seen as a trade-off between the Shannon entropy (recovered by the Tsallis entropy with α=1\alpha=1) and the Gini entropy (recovered with α=2\alpha=2). It allows us to combine both smoothness and exact sparsity, as visually depicted in Figure 1. Furthermore, as detailed in Table 1 (last page of the appendix), this choice also yields highly efficient, closed-form expressions for both the smoothed maximum operator and its derivatives, as for Shannon and Gini variants.

Q3: Main advantages over specialized Top-k operators

Beyond natively supporting Knapsack constraints, our dynamic programming approach offers a combination of features that specialized Top-k baselines lack:

  • SIMPLE: enables exact sampling and probability computation, but lacks exact sparsity.
  • FDS: enables exact sparsity, but lacks exact sampling.
  • LapSum: lacks both exact sampling and exact sparsity.
  • Ours: jointly enables exact sampling, probability computation, and exact sparsity.

[1]: Li, Ziniu, et al. "Knapsack RL: Compute-Efficient Reinforcement Learning via Heterogeneous Rollout Allocation.”, ICML 2026.

[2]: Cha, Seong-Hwan et al. “KnapSpec: Self-Speculative Decoding via Adaptive Layer Selection as a Knapsack Problem.”, ICML 2026.

Reviewer Q252 · CommentOpenReview ↗

My questions and concerns have been well addressed. However, I don't see changes substantial enough to increase my score, so I'll keep it as it is.

Authors · CommentOpenReview ↗

We thank the reviewer for taking the time to read our rebuttal and for maintaining their recommendation for acceptance.

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Missing a submission?

Loading the discussion…