- Finance
Barclays: QAOA for Credit Portfolio Risk and Contract Netting
Barclays
Barclays partnered with IBM through the IBM Q Network to test QAOA for combinatorial contract netting optimization in credit portfolios, and explored quantum SVM for binary credit scoring on historical loan data.
- Key Outcome
- QAOA at p=1 reached solutions within 15-20% of optimal on 12-16 variable instances. Classical simulated annealing outperformed QAOA on all tested instances. Quantum SVM matched classical SVM accuracy on credit scoring. Identified fault-tolerant hardware as the prerequisite for practical advantage.
The Problem
Banks hold complex webs of derivative contracts with many counterparties. When two banks have offsetting positions with each other, bilateral netting allows them to cancel those positions, reducing the capital each must hold against counterparty default risk.
Finding the optimal set of contracts to net across a large portfolio is a combinatorial optimization problem. For N candidate contracts, there are 2^N possible netting sets. With N=50 or more, classical exact solvers are intractable and heuristics are used in practice.
Barclays researchers formulated this as a QUBO (Quadratic Unconstrained Binary Optimization) and tested QAOA as a potential solver. The underlying question: can QAOA find better netting sets than classical heuristics, and if so, at what circuit depth?
QAOA for Contract Netting
In the QUBO formulation, each binary variable x_i = 1 means contract i is included in the netting set. The objective captures:
- Reward: reduction in regulatory capital from netting
- Penalty: legal eligibility constraints (not all contract pairs can be netted under master agreements)
- Constraint: netting sets must be bilateral between specific counterparty pairs
from qiskit import QuantumCircuit
from qiskit.circuit import Parameter, ParameterVector
from qiskit_aer import AerSimulator
from scipy.optimize import minimize
import numpy as np
# Small contract netting instance: 12 contracts
n_contracts = 12
np.random.seed(42)
# Simulate a QUBO matrix Q where Q[i,j] represents interaction between contracts i,j
# Negative diagonal = reward for including contract i in netting set
# Positive off-diagonal = penalty for ineligible contract pairs
capital_reduction = np.random.uniform(0.5, 2.0, n_contracts)
Q = np.diag(-capital_reduction)
# Add random eligibility penalties for 20% of contract pairs
for i in range(n_contracts):
for j in range(i + 1, n_contracts):
if np.random.rand() < 0.2:
penalty = np.random.uniform(1.0, 3.0)
Q[i, j] = penalty
Q[j, i] = penalty
def build_qaoa_circuit(gamma, beta, p_layers=1):
qc = QuantumCircuit(n_contracts, n_contracts)
# Equal superposition initial state
qc.h(range(n_contracts))
for layer in range(p_layers):
g = gamma[layer]
b = beta[layer]
# Cost unitary from QUBO terms
for i in range(n_contracts):
if Q[i, i] != 0:
qc.rz(2 * g * Q[i, i], i)
for i in range(n_contracts):
for j in range(i + 1, n_contracts):
if Q[i, j] != 0:
qc.rzz(2 * g * Q[i, j], i, j)
# Mixer unitary
for i in range(n_contracts):
qc.rx(2 * b, i)
qc.measure(range(n_contracts), range(n_contracts))
return qc
def qubo_cost(bitstring, Q):
x = np.array([int(b) for b in bitstring])
return float(x @ Q @ x)
def run_qaoa(params, p_layers=1, shots=2000):
gamma = params[:p_layers]
beta = params[p_layers:]
qc = build_qaoa_circuit(gamma, beta, p_layers)
sim = AerSimulator()
counts = sim.run(qc, shots=shots).result().get_counts()
# Expected QUBO cost over measurement outcomes
total_cost = sum(
count * qubo_cost(bits, Q)
for bits, count in counts.items()
)
return total_cost / shots
# Optimize QAOA at p=1
p = 1
x0 = np.random.uniform(0, np.pi, 2 * p)
result = minimize(run_qaoa, x0, args=(p,), method='COBYLA',
options={'maxiter': 200, 'rhobeg': 0.5})
print(f"QAOA optimal params: {result.x}")
print(f"QAOA expected cost: {result.fun:.4f}")
# Extract best bitstring from final optimized circuit
gamma_opt = result.x[:p]
beta_opt = result.x[p:]
qc_final = build_qaoa_circuit(gamma_opt, beta_opt, p)
sim = AerSimulator()
counts = sim.run(qc_final, shots=4000).result().get_counts()
best_bits = min(counts, key=lambda b: qubo_cost(b, Q))
print(f"Best netting set: {best_bits}")
print(f"Best QUBO cost: {qubo_cost(best_bits, Q):.4f}")
Benchmarking Against Classical Methods
Barclays compared QAOA to two classical approaches on the same QUBO instances:
Branch-and-bound (exact solver): finds the true optimum but takes exponential time in the worst case. Used as the ground-truth reference on instances up to 16 variables.
Simulated annealing: a probabilistic heuristic that explores the solution space by accepting worse solutions with decreasing probability. Scales well and finds near-optimal solutions quickly.
Results on 12-16 variable instances:
| Method | Solution quality vs. optimal | Runtime |
|---|---|---|
| Branch-and-bound | 100% (exact) | seconds |
| Simulated annealing | 98-99% | milliseconds |
| QAOA p=1 | 80-85% | seconds (sim) |
| QAOA p=2 | 85-90% | seconds (sim) |
QAOA at p=1 and p=2 did not outperform simulated annealing on any tested instance. The gap was consistent: QAOA required deeper circuits (p=5 or more) to approach simulated annealing quality, but circuit depth is severely limited by hardware noise.
Quantum SVM for Credit Scoring
In parallel with the combinatorial optimization work, Barclays tested a quantum kernel SVM for binary credit classification (predict loan default vs. no default).
The quantum kernel computes inner products between data points by preparing quantum feature maps and measuring overlap. On a dataset of historical loan features (income, debt-to-income ratio, credit history), the quantum SVM was trained and compared to a classical RBF-kernel SVM.
Accuracy results on held-out test data:
- Classical SVM (RBF kernel): 84.2% accuracy
- Quantum SVM (ZZ feature map, 8 qubits): 83.7% accuracy
The quantum SVM matched classical accuracy on this dataset, offering no advantage but also no disadvantage. The feature map expressibility on NISQ hardware may limit the quantum kernel’s ability to capture the relevant data geometry at larger feature dimensions.
Results
Published findings from the Barclays-IBM collaboration:
- QAOA at p=1 produced solutions within 15-20% of optimal on small contract netting instances
- Classical simulated annealing outperformed QAOA at all tested circuit depths on real and simulated hardware
- Quantum SVM matched (but did not exceed) classical SVM accuracy on credit scoring
- Fault-tolerant hardware with deeper circuit support is the prerequisite for practical QAOA advantage
- Near-term quantum value is more likely in simulation (quantum chemistry for risk factor modeling) than in combinatorial optimization
What Practical Quantum Advantage Requires
Barclays’ analysis echoed findings from other financial institutions:
- Circuit depth: QAOA needs p=10-20 layers to meaningfully outperform classical heuristics on relevant problem sizes. Current NISQ hardware supports roughly p=3-5 before noise dominates.
- Qubit count: Contract portfolios at realistic scale involve hundreds of variables. Current hardware tops out at tens of usable qubits for variational algorithms.
- Error correction: Logical qubits eliminate the noise floor that limits QAOA depth, but require 100-1000x physical qubit overhead per logical qubit.
Barclays continues quantum research as a tracking and positioning activity, maintaining capability and publishing results while the hardware matures.
IBM Q Network Partnership
Barclays accessed premium IBM Quantum systems through the IBM Q Network, enabling access to newer hardware generations and collaborative methodology development. Joint publications document the full workflow from QUBO formulation through circuit construction and classical benchmarking.
Learn more: Qiskit Reference | QAOA Algorithm Guide