Covariance-Aware Transformers for Quadratic Programming and Decision Making
Kutay Tire, Yufan Zhang, Ege Onur Taga, Samet Oymak
TL;DR
The paper investigates whether transformer architectures can function as general-purpose solvers for convex quadratic programs and leverages this capability to improve decision making when second-order statistics matter. It provides explicit constructions showing that transformers, using linear attention and carefully designed tokens, can emulate gradient descent, primal-dual updates, ISTA, and proximal/projection steps for unconstrained, linearly constrained, and sparse QPs, with convergence guarantees under standard step-size conditions. Building on this theory, the authors introduce Time2Decide, a covariance-aware augmentation that feeds covariance tokens into a time-series foundation model to enable end-to-end forecasting and decision making in a single forward pass, surpassing traditional predict-then-optimize baselines in portfolio optimization under realistic constraints and noise. Empirically, Time2Decide demonstrates strong performance gains over base TSFMs and PtO in many regimes, highlighting the value of explicit second-order statistics in transformer-based decision pipelines. The work positions transformers as both algorithmic emulators for optimization and practical, end-to-end decision makers for complex, covariance-driven problems like portfolio construction.
Abstract
We explore the use of transformers for solving quadratic programs and how this capability benefits decision-making problems that involve covariance matrices. We first show that the linear attention mechanism can provably solve unconstrained QPs by tokenizing the matrix variables (e.g.~$A$ of the objective $\frac{1}{2}x^\top Ax+b^\top x$) row-by-row and emulating gradient descent iterations. Furthermore, by incorporating MLPs, a transformer block can solve (i) $\ell_1$-penalized QPs by emulating iterative soft-thresholding and (ii) $\ell_1$-constrained QPs when equipped with an additional feedback loop. Our theory motivates us to introduce Time2Decide: a generic method that enhances a time series foundation model (TSFM) by explicitly feeding the covariance matrix between the variates. We empirically find that Time2Decide uniformly outperforms the base TSFM model for the classical portfolio optimization problem that admits an $\ell_1$-constrained QP formulation. Remarkably, Time2Decide also outperforms the classical "Predict-then-Optimize (PtO)" procedure, where we first forecast the returns and then explicitly solve a constrained QP, in suitable settings. Our results demonstrate that transformers benefit from explicit use of second-order statistics, and this can enable them to effectively solve complex decision-making problems, like portfolio construction, in one forward pass.
