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. Our implementation is open source and available at https://github.com/mmmmmmlinghu/dXPP.
翻译:在可微优化中,通过二次规划(QP)解进行微分是一个核心问题。现有方法大多通过Karush--Kuhn--Tucker(KKT)系统进行微分,但其计算成本和数值鲁棒性在大规模问题中会显著下降。为解决这些限制,我们提出dXPP,一种基于惩罚的微分框架,将QP求解与微分解耦。在求解步骤(前向传播)中,dXPP与求解器无关,可利用任意黑盒QP求解器。在微分步骤(反向传播)中,我们将映射到一个平滑的近似惩罚问题,并对其隐式微分,仅需求解一个规模小得多的原始变量线性系统。该方法规避了显式KKT微分固有的困难,显著提升了计算效率和鲁棒性。我们在多种任务上评估了dXPP,包括随机生成的QP、大规模稀疏投影问题,以及一个真实的多时期投资组合优化任务。实验结果表明,dXPP与基于KKT的微分方法具有竞争力,并在大规模问题上实现了显著加速。我们的实现已开源,可在https://github.com/mmmmmmlinghu/dXPP获取。