TL;DR
Neural networks that integrate optimization solvers as internal layers are vulnerable to a new class of adversarial attacks that force numerical instability, resulting in "NaN" (Not a Number) outputs and total system failure. This paper introduces a robust defense by adding a differentiable layer that uses Singular Value Decomposition (SVD) to bound the condition number of input matrices, ensuring numerical stability and often improving overall training performance.
What Problem Does This Paper Address?
There is a growing trend in AI to embed optimization solvers directly into neural network architectures (e.g., OptNet). This allows models to perform complex reasoning or planning—like solving a Sudoku puzzle or planning a vehicle's speed—within a single forward pass.
However, these solvers are sensitive to the mathematical properties of their inputs. If the neural network outputs a matrix that is "singular" (meaning it cannot be inverted) or "ill-conditioned" (numerically unstable), the solver can fail. An adversary can exploit this by crafting inputs that force the solver into these failure states. Unlike traditional adversarial attacks that aim to trick a model into misclassifying an image, these "NaN attacks" aim for a complete denial of service. In critical applications like autonomous driving, a sudden NaN output could lead to catastrophic outcomes because the system loses its ability to make a decision.
Methods
The authors tackle the problem from both offensive and defensive perspectives:
The Attacks
They propose three methods to find inputs $u$ that cause the solver's constraint matrix $A$ to become singular:
- AllZeroRowCol: Uses gradient descent to force an entire row or column of the matrix to zero.
- ZeroSingularValue: Targets the smallest singular value of the matrix to force it to zero.
- ConditionGrad: Directly maximizes the matrix's condition number (the ratio of its largest to smallest singular values) using its gradient.
The Defense
The core contribution is a novel, differentiable defense layer. Before the parameters reach the solver, this layer performs a Singular Value Decomposition (SVD) on the matrix $A$. It then "clamps" the singular values so that the condition number $\kappa_2(A)$ never exceeds a user-defined bound $B$. By ensuring the matrix is always well-conditioned, the solver is guaranteed to produce a stable, numerical result.
Datasets
The researchers evaluated their work across three distinct domains:
- Synthetic Data: An abstract assignment problem designed to test varying constraint matrix sizes.
- Jigsaw Sudoku: A complex variant of Sudoku where constraints are based on irregular geometric shapes. The model must infer these constraints directly from images of the puzzle (using MNIST digits).
- Autonomous Driving (BelgiumTS): A real-world scenario where the network plans a speed profile based on traffic sign images and the vehicle's current state (speed, distance to destination, etc.).
Key Insights and Ideas
- Simplicity Wins: Surprisingly, the simplest attack (AllZeroRowCol) was the most effective. Theoretically "principled" methods like ZeroSingularValue often failed in practice due to the very numerical precision errors they were trying to exploit.
- Defense as a Regularizer: The SVD-based defense didn't just stop attacks; it actually improved training. By bounding the condition number, it stabilized the gradients flowing back through the solver, leading to faster convergence and lower final loss.
- Silent Failures: The authors discovered that popular optimization libraries (like
qpth) often fail silently. Instead of throwing an error when faced with an infeasible problem, they might return wildly incorrect results, which is arguably more dangerous than a NaN. - Context Matters: A simple "default safe action" (like braking) isn't a universal fix for NaN outputs in driving, as the safest action depends entirely on the current context (e.g., speed of the car behind you).
Key Results
- Attack Success: In undefended models, the AllZeroRowCol attack achieved a 100% success rate in producing NaNs across almost all test cases.
- Defense Efficacy: With the SVD defense in place (using various bounds $B$), the attack success rate dropped to 0.00%.
- Performance Gains: In the autonomous driving task, the original model was highly unstable, with a massive test loss variance ($7928.76 \pm 38565$). The defended model ($B=2$) was significantly more stable and accurate, achieving a test loss of just $6.64 \pm 3.52$.
- Reliability: In the driving experiments, only 12.8% of training runs for the original model were successful (others failed due to numerical issues). The defended model succeeded in every run.
Limitations and Future Work
- Computational Overhead: While SVD is efficient, it is still more computationally expensive than standard layers. However, the authors note it is still faster than the optimization solver itself.
- Solver Auditing: The paper highlights significant bugs in standard libraries (like PyTorch's
lu_solve). A major future direction is a more thorough audit of the low-level mathematical libraries that AI researchers take for granted. - Complex Attacks: Future work could explore more sophisticated, photorealistic adversarial attacks that maintain semantic meaning while still triggering numerical failures.
Summary updated