---
title: Variational Quantum Linear Solver
url: https://www.emergentmind.com/topics/variational-quantum-linear-solver-algorithm
type: topic
---

# Variational Quantum Linear Solver

The Variational Quantum Linear Solver (VQLS) is a hybrid quantum–classical algorithm developed for solving linear systems of the form $A x = b$ on noisy intermediate-scale quantum (NISQ) hardware, with demonstrated compatibility for solving PDEs and banded linear algebra problems such as those arising from finite element and finite difference discretizations. VQLS variationally prepares a quantum state $|x(\theta)\rangle$ that encodes the solution, optimizing its parameters through a quantum–classical feedback loop so that $A |x(\theta)\rangle \propto |b\rangle$ or reaches a prescribed accuracy set by a cost function. The algorithm’s technical performance, decomposition strategy, and resource scaling have been validated up to real hardware implementations for small tridiagonal systems and by extensive simulations for larger, structured sparse matrices [2412.04938].

## 1. VQLS Cost Function and Problem Mapping

The key variational principle of VQLS recasts the linear system $A x = b$ as an optimization over quantum states:
- Prepare a parameterized ansatz state $|x(\theta)\rangle = V(\theta)|0\rangle$.
- Define the normalized global cost as  
  $$C_G(\theta) = 1 - |\langle b | \Psi(\theta) \rangle |^2$$  
  where $|\Psi(\theta)\rangle = A |x(\theta)\rangle/\|A |x(\theta)\rangle\|$.
- Alternatively, use the unnormalized global cost  
  $$C'_G(\theta) = \langle x(\theta)|A^\dagger A|x(\theta)\rangle - 2\,\mathrm{Re}\langle x(\theta)|A^\dagger|b\rangle + \langle b|b\rangle$$  
  which vanishes exactly when $A |x(\theta)\rangle = |b\rangle$.
- In Hamiltonian language, define  
  $$H_G = A^\dagger(I - |b\rangle\langle b|)A$$  
  and cost is  
  $$C_G(\theta) = \langle x(\theta) | H_G | x(\theta) \rangle / \langle x(\theta) |A^\dagger A| x(\theta) \rangle$$.

This framework ensures that minimizing $C_G$ drives the output quantum state toward a normalized solution of the linear system, with mathematically rigorous error guarantees [1909.05820]. Boundaries on the tolerated solution error $\epsilon$ are set by the condition $C_G \geq \epsilon^2/\kappa^2$ where $\kappa$ is the condition number of $A$.

## 2. Ansatz Design and Circuit Architecture

For proof-of-principle runs on tridiagonal systems such as the discretized 1D Poisson equation, a minimalist hardware-efficient ansatz is employed:
- Each of $n$ qubits receives a single $R_Y(\theta_i)$ rotation:  
  $$R_Y(\theta_i) = \exp(-i\,\theta_i\,Y/2)$$  
  so the ansatz state is  
  $$|x(\theta)\rangle = \bigotimes_{i=1}^n R_Y(\theta_i)|0\rangle$$.
- No entangling gates are used, minimizing circuit depth and thus mitigating decoherence sources on NISQ devices.
- For larger or less trivial problems, additional layers or entangling gates may be needed for sufficient expressivity, though circuit depth must remain compatible with device coherence times [2412.04938].

## 3. Structured Matrix Decomposition: Pauli vs Multi-Qubit Basis

Efficient evaluation of cost functions necessitates decomposing $A$ into terms suitable for quantum implementation. Two major approaches:

### Pauli-String Decomposition
- General real symmetric tridiagonal $A$ admits an expansion  
  $$A = \sum_{i=1}^{N^2} c_i P_i$$  
  with $P_i$ Pauli strings and nonzero $c_i$ for $N$ of the $2^n\,\cdot\,2^n$ possible strings.
- Example for $N=4$ (2 qubits):  
  $$A = 2 I_1 I_0 - 1 I_1 X_0 - \frac{1}{2} X_1 X_0 - \frac{1}{2} Y_1 Y_0$$  
  Number of terms: $2^n$.

### Mixed Pauli + Multi-Qubit Decomposition
- By incorporating SWAP and multi-qubit 'center-switch' CS gates, the number of terms reduces to $2^{n-1} + n$.
- For $N=4$:  
  $$A = 2 I_1 I_0 - 1 SWAP_{1,0} + 1 Z_1 Z_0 - 1 I_1 X_0$$  
- At larger $n$, this reduction becomes significant compared to the pure Pauli basis.

**Trade-offs**:  
- Pure Pauli decomposition yields more terms but very shallow circuits (depth-1 measurements).
- Mixed decomposition reduces measurement term count but increases circuit depth due to multi-controlled operations (Toffoli chains).
- On a benchmark $4\times4$ cost evaluation, mixed decomposition nearly doubled circuit depth (ratio $\sim$51:99 for Pauli vs mixed), so choice of decomposition should consider hardware coherence and gate errors [2412.04938].

## 4. Quantum-Classical Optimization and Hardware Implementation

The optimization loop consists of:
- Quantum subroutine: evaluate cost function by preparing $|x(\theta)\rangle$ and measuring expectations via Hadamard tests, with 8192 shots per expectation for robust statistics.
- Classical subroutine: utilize a gradient-free optimizer (COBYLA) to minimize cost.  
- System sizes tested: $N=2$ (1 qubit) and $N=4$ (2 qubits), both simulated (Qiskit’s qasm_simulator) and deployed on real quantum hardware (IBMQ Athens).
- Observed performance:  
  - For $N=2$, simulated cost vanishes; hardware cost biased (due to noise) but fidelity $F=|\langle x_{exact}|x_f\rangle|^2 \geq 0.99$.
  - For $N=4$, simulated cost $\sim0.05$ (ansatz depth-limited); fidelity $F \approx 0.96$; hardware fidelity $F \approx 0.94-0.97$.
- Shot noise and hardware decoherence typically bias cost estimates, but the variational loop is robust to these disturbances, yielding well-optimized parameters.

## 5. Generalization and Outlook

The decomposition strategy for $A$ is the critical bottleneck for resource scaling:
- The mixed Pauli + multi-qubit approach generalizes to other structured sparse matrices, such as those arising from the discretization of banded PDEs.
- For large $N$ (PDEs, FE matrices), balancing the number of measurement terms against the achievable circuit depths is fundamental.
- Extending VQLS decomposition beyond tridiagonal forms involves identifying permutation-like structures (SWAP/CS blocks) before resorting to large Pauli sets.

The research agenda includes:
- Applying decomposition and variational ansatz strategies to 2D and 3D Poisson equations, higher-dimensional PDE discretizations, and broader classes of sparse linear systems.
- Engineering deeper ansätze compatible with problem structure and device limitations.
- Developing adaptive ansatz growth, error mitigation, and possibly combining classical preconditioning for greater efficiency [2412.04938], [2312.15657].
- Systematic benchmarking on real hardware, especially as qubit counts and coherence times improve.

## 6. Algorithmic Summary Table

| Decomposition Type       | Term Count (n qubits)  | Circuit Depth      | Typical Use Case                 |
|-------------------------|------------------------|--------------------|----------------------------------|
| Pauli-String            | $2^n$                  | Depth-1            | Small N, high coherence, shallow |
| Pauli + Multi-Qubit     | $2^{n-1}+n$            | Increased (Toffoli)| Structured sparse, large N       |

Decomposition choice and ansatz adaptation are essential for achieving optimal efficiency, accuracy, and noise robustness in NISQ-era VQLS algorithms.


## References
- "Solving 1D Poisson problem with a Variational Quantum Linear Solver" [2412.04938]
- "Preconditioning for a Variational Quantum Linear Solver" [2312.15657]
- "Application of a variational hybrid quantum-classical algorithm to heat conduction equation" [2207.14630]
- "Variational Quantum Linear Solver" [1909.05820]

Source: https://www.emergentmind.com/topics/variational-quantum-linear-solver-algorithm