Differentiating through the solution of a quadratic program (QP) is a central problem in differentiable optimization. Most existing approaches differentiate through the Karush--Kuhn--Tucker (KKT) system, but their computational cost and numerical robustness can degrade at scale. To address these limitations, we propose dXPP, a penalty-based differentiation framework that decouples QP solving from differentiation. In the solving step (forward pass), dXPP is solver-agnostic and can leverage any black-box QP solver. In the differentiation step (backward pass), we map the solution to a smooth approximate penalty problem and implicitly differentiate through it, requiring only the solution of a much smaller linear system in the primal variables. This approach bypasses the difficulties inherent in explicit KKT differentiation and significantly improves computational efficiency and robustness. We evaluate dXPP on various tasks, including randomly generated QPs, large-scale sparse projection problems, and a real-world multi-period portfolio optimization task. Empirical results demonstrate that dXPP is competitive with KKT-based differentiation methods and achieves substantial speedups on large-scale problems.
翻译:对二次规划(QP)解进行微分是可微优化领域的核心问题。现有方法大多通过Karush--Kuhn--Tucker(KKT)系统进行微分,但其计算成本与数值鲁棒性会随问题规模增大而恶化。为克服这些局限,本文提出dXPP——一种基于惩罚的微分框架,将QP求解与微分过程解耦。在求解阶段(前向传播),dXPP与求解器无关,可兼容任意黑盒QP求解器。在微分阶段(反向传播),我们将原问题解映射至光滑近似惩罚问题,并通过隐式微分进行处理,仅需在原变量空间求解规模显著缩减的线性系统。该方法规避了显式KKT微分的固有困难,显著提升了计算效率与鲁棒性。我们在随机生成QP、大规模稀疏投影问题及实际多周期投资组合优化任务上评估dXPP。实验结果表明,dXPP与基于KKT的微分方法性能相当,且在大规模问题上实现了显著加速。