Beyond NaN: Resiliency of Optimization Layers in the Face of Infeasibility

Wai Tuck Wong, Sarah Eve Kinsey, Ramesha Karunasena, Thanh Hong Nguyen, Arunesh Sinha

Introduction

The integration of optimization solvers, such as Quadratic Program (QP) solvers, as differentiable layers within neural networks has enabled the paradigm of "decision-focused learning." This allows models to output optimal actions directly by solving constrained optimization problems based on predicted parameters. However, this architectural shift introduces a significant vulnerability: numerical instability.

The Problem: Numerical Infeasibility

Optimization layers rely on linear algebraic operations that are highly sensitive to the conditioning of input matrices. If a neural network's preceding layers produce parameters that result in a singular or near-singular matrix, the solver fails, typically outputting "NaN" (Not a Number). In safety-critical applications like autonomous driving, such a failure breaks the decision-making chain, potentially leading to catastrophic outcomes. Furthermore, NaNs introduced during training can cause the entire learning process to collapse.

Architecture of a neural network with an integrated optimization layer, highlighting the flow from input features to the final solution via a solver.

Methodology: Attacks and Defenses

The researchers investigate the robustness of these systems by developing a "numerical instability attack" and a corresponding "SVD-based defense."

Numerical Instability Attacks

The objective of the attack is to find an input $u$ that forces the solver's constraint matrix $A$ to become singular. Three gradient-based strategies were evaluated:

  1. AllZeroRowCol: Directly forcing a specific row or column toward zero.
  2. ZeroSingularValue: Targeting the closest singular matrix via Singular Value Decomposition (SVD).
  3. ConditionGrad: Maximizing the condition number of the matrix (the ratio of the largest to smallest singular values).

Empirically, the AllZeroRowCol attack proved most effective due to its simplicity in the gradient landscape, achieving a 100% success rate in producing NaNs across undefended models.

The SVD-Based Defense

To mitigate these risks, the paper proposes a differentiable layer that bounds the condition number of the matrix $A$ before it reaches the solver. This layer performs an SVD, clamps the smallest singular values to ensure they remain above a threshold relative to the largest singular value, and reconstructs the matrix. This ensures the matrix remains well-conditioned, effectively neutralizing potential Denial of Service (DoS) attacks.

Experimental Evaluation

The framework was tested across three distinct domains: synthetic assignment problems, Jigsaw Sudoku reasoning, and autonomous vehicle speed planning.

The Jigsaw Sudoku task requires the model to solve irregular Sudoku puzzles using visual inputs (MNIST digits).

Key Results

  • Defense Efficacy: The proposed SVD-based defense reduced the attack success rate to 0% across all tested scenarios.
  • Performance Improvements: Beyond security, the defense improved training stability. In the Jigsaw Sudoku task, test accuracy rose from 0.91 to 0.96.
  • Safety in Autonomous Driving: In speed planning scenarios, the defense enabled stable training and safer speed profiles in cases where undefended models frequently failed to converge (only 12.8% success rate for undefended runs).

Conclusion

This work highlights a critical vulnerability in modern decision-focused learning. By implementing differentiable SVD-based conditioning, practitioners can ensure that optimization layers remain robust against both adversarial attacks and natural numerical instability, leading to more stable and performant AI systems.

Summary updated

Abstract

Prior work has successfully incorporated optimization layers as the last layer in neural networks for various problems, thereby allowing joint learning and planning in one neural network forward pass. In this work, we identify a weakness in such a set-up where inputs to the optimization layer lead to undefined output of the neural network. Such undefined decision outputs can lead to possible catastrophic outcomes in critical real time applications. We show that an adversary can cause such failures by forcing rank deficiency on the matrix fed to the optimization layer which results in the optimization failing to produce a solution. We provide a defense for the failure cases by controlling the condition number of the input matrix. We study the problem in the settings of synthetic data, Jigsaw Sudoku, and in speed planning for autonomous driving. We show that our proposed defense effectively prevents the framework from failing with undefined output. Finally, we surface a number of edge cases which lead to serious bugs in popular optimization solvers which can be abused as well.
BibTeX
@inproceedings{wong2023beyond,
  author = {Wai Tuck Wong and Sarah Eve Kinsey and Ramesha Karunasena and Thanh Hong Nguyen and Arunesh Sinha},
  title = {{Beyond NaN: Resiliency of Optimization Layers in the Face of Infeasibility}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2023},
  doi = {10.1609/aaai.v37i12.26778},
}
Figure