vqls

Runs the Variational Quantum Linear Solver on caller-provided power-of-two linear systems.

18|3|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/unitarylab/quantum-practices --skill vqls-unitarylab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vqls
Source: https://github.com/unitarylab/quantum-practices/tree/main/algorithms/linear-systems/vqls
Command: npx skills add https://github.com/unitarylab/quantum-practices --skill vqls-unitarylab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, scipy, unitarylab, unitarylab_algorithms, and includes scripts (resource) components.

What problem does it solve? Solving linear systems A·x = b with variational quantum circuits requires correctly wiring Pauli decomposition, ansatz construction, cost-function selection, and COBYLA optimization; this Skill documents the exact implemented behavior of the VQLS algorithm so you can explain, run, debug, or reimplement it without guessing at unsupported guarantees. ## Core Features & Use Cases - Three cost-function paths: Choose between local Hadamard-test circuits, local classical dense-matrix evaluation, or a global overlap objective when solving A·x = b. - Source-verified contract: Documents the exact run() signature, validation boundaries (square power-of-two A, normalized b), return fields, and known limitations such as NaN fidelities and non-interrupting epsilon thresholds. - Use Case: Given a 4x4 NumPy coefficient matrix and matching right-hand-side vector, run VQLSAlgorithm.run() with cost_function="local_classical" and inspect the returned Fidelity, Ax Fidelity, Cost History, and exported circuit to evaluate the variational solution against the classical reference. ## Quick Start Ask the assistant to run the VQLS algorithm on a 2x2 NumPy matrix A and vector b using the local_classical cost function and print the returned fidelity and status.

Frequently Asked Questions about vqls

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run the VQLS algorithm on my own matrix?

Call VQLSAlgorithm.run() with a NumPy array A that is square with power-of-two dimension and a vector b of matching length. Select cost_function from "local_ht", "local_classical", or "global", and optionally set n_layers, maxiter, tol, and seed.

What is the difference between VQLS local and global cost functions?

The global cost computes 1 minus the squared overlap between b and normalized A@x directly. The local paths accumulate Pauli-term expectation values either through dense matrix arithmetic (local_classical) or explicit Hadamard-test ancilla circuits (local_ht).

Does VQLS require the matrix A to be Hermitian or normalized?

No. The implementation converts A to complex dtype without normalizing it and does not validate Hermiticity, invertibility, finite values, or condition-number bounds. Only b is normalized, and its norm must be at least 1e-12.

Why does VQLS return status ok when the SciPy optimizer failed?

The returned dictionary is built with a hard-coded success argument, so status is always "ok" on normal return. SciPy's result.success only sets a separate text-output flag, so check the logged success value and Cost History instead.

Why does VQLS fail with 1x1 or non-power-of-two matrices?

The qubit count is inferred as int(log2(A.shape[0])), so non-power-of-two dimensions raise ValueError. A 1x1 matrix passes that check with zero qubits but all three cost paths fail later, so use at least a 2x2 matrix.

What are the limitations of the VQLS epsilon early stopping parameter?

Epsilon only computes a local-cost threshold gamma_stop and records an Early Stopped flag when the cost reaches it. The implemented branch contains only pass, so COBYLA is never actually interrupted and runs to maxiter or tol.