Variational quantum machine learning algorithms are a hybrid approach in which a parameterized quantum circuit is tuned by a classical optimizer to approximate solutions to complex problems.
by Frank ZickertSeptember 15, 2025
Variational Quantum Machine Learning algorithms are the defining approach of the era of Noisy Intermediate-Scale Quantum refers to the current generation of quantum devices that have enough qubits to run non-trivial algorithms but are still small and error-prone, limiting their reliability and scalability. Learn more about Noisy Intermediate-Scale Quantum medium-sized quantum computers.
At the highest level, a variational quantum algorithm contains a simple feedback loop:
Prepare a A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin. Learn more about Quantum State using a A **Parameterized Quantum Circuit (PQC)** is a quantum circuit where certain gate operations depend on adjustable parameters—typically real numbers representing rotation angles. These parameters are tuned (often by classical optimization) to perform a specific task, such as minimizing a cost function. PQCs are central to **variational quantum algorithms**, where quantum computation provides state preparation and measurement, and a classical computer optimizes the parameters. Learn more about Parameterized Quantum Circuit (An Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz).
In quantum computing, measurement is the process of extracting classical information from a quantum state. It collapses a qubit’s superposition into one of its basis states (usually or ), with probabilities determined by the amplitudes of those states. After measurement, the qubit’s state becomes definite, destroying the original superposition. Learn more about Measurement an In quantum computing, an **observable** is a physical quantity (like energy, spin, or position) that can be **measured** from a quantum state. Mathematically, it’s represented by a **Hermitian operator**, whose eigenvalues correspond to the possible measurement outcomes. When you measure an observable, the quantum state **collapses** into one of its eigenstates, yielding one of those eigenvalues as the result. Learn more about Observable to obtain the The expectation value is the average result you'd get if you repeated a measurement of a quantity many times under identical conditions. Mathematically, it’s the weighted average of all possible outcomes, where each outcome is weighted by its probability. In quantum mechanics, it represents the average value of an observable calculated from the wavefunction. Learn more about Expectation Value.
Update the parameters with a classical Optimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization to minimize the A **cost function** measures how far a model’s predictions are from the actual outcomes by assigning a numerical “error” value. The goal of training is to **minimize this cost**, meaning the model’s predictions get closer to reality. Different cost functions (e.g., mean squared error, cross-entropy) are used depending on the type of prediction problem. Learn more about Cost Function.
This process repeats until the A **cost function** measures how far a model’s predictions are from the actual outcomes by assigning a numerical “error” value. The goal of training is to **minimize this cost**, meaning the model’s predictions get closer to reality. Different cost functions (e.g., mean squared error, cross-entropy) are used depending on the type of prediction problem. Learn more about Cost Function no longer improves.
It looks almost exactly like training a Machine Learning is an approach on solving problems by deriving the rules from data instead of explicitly programming. Learn more about Machine LearningA **model** in machine learning is a mathematical representation of patterns learned from data. It takes **inputs** (features) and produces **outputs** (predictions or classifications) based on relationships it has identified during training. Essentially, it’s a function that generalizes from examples to make decisions or predictions on new data. Learn more about Model. The An Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz is the A **model** in machine learning is a mathematical representation of patterns learned from data. It takes **inputs** (features) and produces **outputs** (predictions or classifications) based on relationships it has identified during training. Essentially, it’s a function that generalizes from examples to make decisions or predictions on new data. Learn more about Model, the In quantum computing, measurement is the process of extracting classical information from a quantum state. It collapses a qubit’s superposition into one of its basis states (usually or ), with probabilities determined by the amplitudes of those states. After measurement, the qubit’s state becomes definite, destroying the original superposition. Learn more about Measurement is its prediction, the A **cost function** measures how far a model’s predictions are from the actual outcomes by assigning a numerical “error” value. The goal of training is to **minimize this cost**, meaning the model’s predictions get closer to reality. Different cost functions (e.g., mean squared error, cross-entropy) are used depending on the type of prediction problem. Learn more about Cost Function measures the error, and the Optimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization updates the parameters. Conceptually, this results in a simple recipe: alternate between running the A **Parameterized Quantum Circuit (PQC)** is a quantum circuit where certain gate operations depend on adjustable parameters—typically real numbers representing rotation angles. These parameters are tuned (often by classical optimization) to perform a specific task, such as minimizing a cost function. PQCs are central to **variational quantum algorithms**, where quantum computation provides state preparation and measurement, and a classical computer optimizes the parameters. Learn more about Parameterized Quantum Circuit and adjusting the parameters until the A **cost function** measures how far a model’s predictions are from the actual outcomes by assigning a numerical “error” value. The goal of training is to **minimize this cost**, meaning the model’s predictions get closer to reality. Different cost functions (e.g., mean squared error, cross-entropy) are used depending on the type of prediction problem. Learn more about Cost Function converges.
This high-level recipe is neat, but incomplete. It obscures the fact that not all An Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz, In quantum computing, an **observable** is a physical quantity (like energy, spin, or position) that can be **measured** from a quantum state. Mathematically, it’s represented by a **Hermitian operator**, whose eigenvalues correspond to the possible measurement outcomes. When you measure an observable, the quantum state **collapses** into one of its eigenstates, yielding one of those eigenvalues as the result. Learn more about Observable, or Optimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization behave the same way.
Since Variational Quantum Machine Learning algorithms look pretty much like classic Machine Learning is an approach on solving problems by deriving the rules from data instead of explicitly programming. Learn more about Machine Learning algorithms, it stands to reason that greater depth also means higher quality. In Deep learning is a branch of machine learning that uses multi-layered neural networks to automatically learn complex patterns from data. Each layer transforms raw input into increasingly abstract representations, allowing the system to perform tasks like image recognition or language understanding without explicit feature engineering. It relies heavily on large datasets and high computational power for training. Learn more about Deep Learning, for example, adding layers generally increases Expressiveness in quantum computing refers to how effectively a quantum model (like a variational circuit) can represent complex functions or quantum states. A more expressive model can capture richer correlations and solve more complex problems, but may also be harder to train. It’s roughly analogous to the “capacity” or “model complexity” in classical machine learning. Learn more about Expressiveness and improves Accuracy is the proportion of correctly predicted examples (both true positives and true negatives) out of all examples. It’s calculated as correct predictions divided by total predictions. It works well when classes are balanced, but can be misleading if one class dominates. Learn more about Accuracy when sufficient data is available. With Variational Quantum Machine Learning algorithms, however, Circuit depth in quantum computing is the number of layers of quantum gates that must be applied sequentially, where gates acting on different qubits in parallel count as one layer. It measures how long a quantum computation takes, assuming gates in the same layer happen simultaneously. Lower depth is crucial because qubits lose coherence over time, so deep circuits are more error-prone. Learn more about Circuit Depth quickly becomes a disadvantage.
Figure 2 Optimization does not work on a flat cost landscape
Deeper An Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz cover a larger number of A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin. Learn more about Quantum State, but this Expressiveness in quantum computing refers to how effectively a quantum model (like a variational circuit) can represent complex functions or quantum states. A more expressive model can capture richer correlations and solve more complex problems, but may also be harder to train. It’s roughly analogous to the “capacity” or “model complexity” in classical machine learning. Learn more about Expressiveness comes at the expense of In quantum computing, *trainability* refers to how effectively a quantum machine learning model (like a variational quantum circuit) can be optimized to minimize its loss function. It depends on whether small parameter changes produce meaningful gradients rather than vanishing ones. Poor trainability—often caused by issues like barren plateaus—means the model can’t learn efficiently because gradients become too small to guide improvement. Learn more about TrainabilityMcClean, J.R., 2018, Nature Communications, Vol. 9, pp. 4812. The optimizerOptimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization then sees a flat landscape and is unable to distinguish good updates from bad ones. In practice, this means that doubling the Circuit DepthCircuit depth in quantum computing is the number of layers of quantum gates that must be applied sequentially, where gates acting on different qubits in parallel count as one layer. It measures how long a quantum computation takes, assuming gates in the same layer happen simultaneously. Lower depth is crucial because qubits lose coherence over time, so deep circuits are more error-prone. Learn more about Circuit Depth rarely leads to a doubling of performance. Instead, it often completely suppresses the learning signal.
The tension is structural: shallow circuits are trainableIn quantum computing, *trainability* refers to how effectively a quantum machine learning model (like a variational quantum circuit) can be optimized to minimize its loss function. It depends on whether small parameter changes produce meaningful gradients rather than vanishing ones. Poor trainability—often caused by issues like barren plateaus—means the model can’t learn efficiently because gradients become too small to guide improvement. Learn more about Trainability but limited, deep circuits are expressiveExpressiveness in quantum computing refers to how effectively a quantum model (like a variational circuit) can represent complex functions or quantum states. A more expressive model can capture richer correlations and solve more complex problems, but may also be harder to train. It’s roughly analogous to the “capacity” or “model complexity” in classical machine learning. Learn more about Expressiveness but untrainable. When designing ansätzeAn Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz, the focus is therefore not on more layers but on a balance between ExpressivenessExpressiveness in quantum computing refers to how effectively a quantum model (like a variational circuit) can represent complex functions or quantum states. A more expressive model can capture richer correlations and solve more complex problems, but may also be harder to train. It’s roughly analogous to the “capacity” or “model complexity” in classical machine learning. Learn more about Expressiveness and optimization stability (TrainabilityIn quantum computing, *trainability* refers to how effectively a quantum machine learning model (like a variational quantum circuit) can be optimized to minimize its loss function. It depends on whether small parameter changes produce meaningful gradients rather than vanishing ones. Poor trainability—often caused by issues like barren plateaus—means the model can’t learn efficiently because gradients become too small to guide improvement. Learn more about Trainability).
Looking at the top level, three components define how a Variational Quantum Machine Learning algorithm really works. Together, EncodingEncoding is the process of converting information from one form into another, usually so it can be stored, transmitted, or processed more efficiently. For example, text can be encoded into binary for computers to handle, or sounds into digital signals for transmission. The key idea is that encoding changes the representation, not the meaning, of the data. Learn more about Encoding, AnsatzAn Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz, and MeasurementIn quantum computing, measurement is the process of extracting classical information from a quantum state. It collapses a qubit’s superposition into one of its basis states (usually or ), with probabilities determined by the amplitudes of those states. After measurement, the qubit’s state becomes definite, destroying the original superposition. Learn more about Measurement define the hypothesis class, the optimization landscape, and the signal available for learning. In practice, it is the savvy selection of these components that makes the difference between a functioning algorithm and one that stalls.
Encoding of is a Unitary OperatorA **unitary operator** is a linear operator ( U ) on a complex vector space that satisfies ( U^\dagger U = UU^\dagger = I ), meaning it preserves inner products. In simpler terms, it preserves the **length** and **angle** between vectors—so it represents a **reversible, norm-preserving transformation**. In quantum mechanics, unitary operators describe the evolution of isolated systems because they conserve probability. Learn more about Unitary Operator (therefore ) that encodesEncoding is the process of converting information from one form into another, usually so it can be stored, transmitted, or processed more efficiently. For example, text can be encoded into binary for computers to handle, or sounds into digital signals for transmission. The key idea is that encoding changes the representation, not the meaning, of the data. Learn more about Encoding the data value according to a encoding scheme or feature mapA **Quantum Feature Map** is a process that converts classical input data into a **quantum state** using a parameterized quantum circuit. This transformation encodes data into the **high-dimensional Hilbert space** of a quantum system, allowing quantum algorithms to exploit complex correlations not easily captured classically. Essentially, it’s the quantum analogue of feature mapping in machine learning, used to make data more separable for classification or regression tasks. Learn more about Quantum Feature Map ("phi"). Different choices of correspond to different ways of embedding data into a Quantum StateA quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin. Learn more about Quantum State, such as Angle EncodingAngle encoding is a method of loading classical data into a quantum state by mapping data values to rotation angles of qubits (e.g., using quantum gates like Rx Gate, Ry Gate, or Rz Gate) Each feature of the data is represented as the angle of the quantum state vector’s rotation, which changes its probability amplitudes. This allows continuous classical values to be embedded in qQuantum states for use in quantum algorithms or quantum circuits. Learn more about Angle Encoding, Amplitude EncodingAmplitude encoding represents classical data as the amplitudes of a quantum state's basis vectors. If you have a normalized data vector , it’s encoded into an -qubit state . This allows data values to be stored in only qubits, but preparing the quantum state can be computationally expensive. Learn more about Amplitude Encoding, or more elaborate Quantum Feature MapsA **Quantum Feature Map** is a process that converts classical input data into a **quantum state** using a parameterized quantum circuit. This transformation encodes data into the **high-dimensional Hilbert space** of a quantum system, allowing quantum algorithms to exploit complex correlations not easily captured classically. Essentially, it’s the quantum analogue of feature mapping in machine learning, used to make data more separable for classification or regression tasks. Learn more about Quantum Feature Map). So means apply the unitary defined by encoding rule to input . The is not a variable like , but a tag to remind you how the data is being encoded. Learn more about : injects classical data or problem structures into a Quantum State.A quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin. Learn more about Quantum State For example, in Quantum Machine LearningQuantum Machine Learning is the field of research that combines principles from quantum computing with traditional machine learning to solve complex problems more efficiently than classical approaches. Learn more about Quantum Machine Learning, a Quantum Feature MapA **Quantum Feature Map** is a process that converts classical input data into a **quantum state** using a parameterized quantum circuit. This transformation encodes data into the **high-dimensional Hilbert space** of a quantum system, allowing quantum algorithms to exploit complex correlations not easily captured classically. Essentially, it’s the quantum analogue of feature mapping in machine learning, used to make data more separable for classification or regression tasks. Learn more about Quantum Feature Map encodes inputs into amplitudesAmplitude encoding represents classical data as the amplitudes of a quantum state's basis vectors. If you have a normalized data vector , it’s encoded into an -qubit state . This allows data values to be stored in only qubits, but preparing the quantum state can be computationally expensive. Learn more about Amplitude Encoding or phasePhase encoding in quantum computing stores information in the *phase* of a qubit’s quantum state rather than its amplitude. The qubit’s phase determines how it interferes with other states during computation, enabling quantum algorithms to exploit interference for speedups. This is used in algorithms like Quantum Fourier Transform, where phase differences represent encoded data or computational results. Learn more about Phase Encoding; in chemistry, a HamiltonianThe Hamiltonian operator () in quantum mechanics represents the total energy of a system — both kinetic and potential. It acts on a wavefunction to determine how the system evolves over time, according to the Schrödinger equation. Mathematically, , where is the kinetic energy operator and is the potential energy operator. Learn more about Hamiltonian Operator is encoded into the Quantum Circuit.A quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically. Learn more about Quantum Circuit However, the concept is the same. This part encodes the problem we want to solve.
Ansatz : The trainable part of the Quantum CircuitA quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically. Learn more about Quantum Circuit, constructed from parameterized rotationsIn quantum computing, a rotation operator is a unitary matrix that rotates a qubit’s state vector on the Bloch sphere by a specific angle around a chosen axis (X, Y, or Z). These are denoted ( R_x(\theta) ), ( R_y(\theta) ), and ( R_z(\theta) ), where ( \theta ) is the rotation angle. They generalize Pauli gates and are fundamental for creating arbitrary single-qubit operations. Learn more about Rotation Operator and entanglementsAn **entanglement operator** is a quantum operation (a unitary or measurement-based transformation) that creates or modifies **quantum entanglement** between particles or subsystems. It acts on multiple qubits so their states become correlated in a way that can’t be described independently. Common examples include two-qubit gates like the **CNOT** or **CZ** gates, which generate entangled Bell states from separable inputs. Learn more about Entanglement Operator. This is the space in which OptimizationOptimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization takes place, analogous to the architecture of a Neural NetworkAn artificial neural network is a computational model of interconnected nodes inspired by biological neurons, used to approximate functions and recognize patterns. Learn more about Neural Network whose weights describes the solution.
Measurement : The ObservableIn quantum computing, an **observable** is a physical quantity (like energy, spin, or position) that can be **measured** from a quantum state. Mathematically, it’s represented by a **Hermitian operator**, whose eigenvalues correspond to the possible measurement outcomes. When you measure an observable, the quantum state **collapses** into one of its eigenstates, yielding one of those eigenvalues as the result. Learn more about Observable that defines the learning signal. In classification, it could be a Pauli OperatorA Pauli operator is one of three 2×2 complex matrices — **σₓ, σᵧ, σ_z** — that represent the basic quantum spin operations on a single qubit. They correspond to rotations or measurements along the x, y, and z axes of the Bloch sphere. Together with the identity matrix, they form a basis for all single-qubit operations in quantum mechanics. Learn more about Pauli Operator mapped to labels.
The complete prediction takes the form of an Expectation Value,The expectation value is the average result you'd get if you repeated a measurement of a quantity many times under identical conditions. Mathematically, it’s the weighted average of all possible outcomes, where each outcome is weighted by its probability. In quantum mechanics, it represents the average value of an observable calculated from the wavefunction. Learn more about Expectation Value as shown in the ?.
Here, is a basis state. Learn more about is the reference state, which consists exclusively of zeros. is a Unitary OperatorA **unitary operator** is a linear operator ( U ) on a complex vector space that satisfies ( U^\dagger U = UU^\dagger = I ), meaning it preserves inner products. In simpler terms, it preserves the **length** and **angle** between vectors—so it represents a **reversible, norm-preserving transformation**. In quantum mechanics, unitary operators describe the evolution of isolated systems because they conserve probability. Learn more about Unitary Operator (therefore ) that encodesEncoding is the process of converting information from one form into another, usually so it can be stored, transmitted, or processed more efficiently. For example, text can be encoded into binary for computers to handle, or sounds into digital signals for transmission. The key idea is that encoding changes the representation, not the meaning, of the data. Learn more about Encoding the data value according to a encoding scheme or feature mapA **Quantum Feature Map** is a process that converts classical input data into a **quantum state** using a parameterized quantum circuit. This transformation encodes data into the **high-dimensional Hilbert space** of a quantum system, allowing quantum algorithms to exploit complex correlations not easily captured classically. Essentially, it’s the quantum analogue of feature mapping in machine learning, used to make data more separable for classification or regression tasks. Learn more about Quantum Feature Map ("phi"). Different choices of correspond to different ways of embedding data into a Quantum StateA quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin. Learn more about Quantum State, such as Angle EncodingAngle encoding is a method of loading classical data into a quantum state by mapping data values to rotation angles of qubits (e.g., using quantum gates like Rx Gate, Ry Gate, or Rz Gate) Each feature of the data is represented as the angle of the quantum state vector’s rotation, which changes its probability amplitudes. This allows continuous classical values to be embedded in qQuantum states for use in quantum algorithms or quantum circuits. Learn more about Angle Encoding, Amplitude EncodingAmplitude encoding represents classical data as the amplitudes of a quantum state's basis vectors. If you have a normalized data vector , it’s encoded into an -qubit state . This allows data values to be stored in only qubits, but preparing the quantum state can be computationally expensive. Learn more about Amplitude Encoding, or more elaborate Quantum Feature MapsA **Quantum Feature Map** is a process that converts classical input data into a **quantum state** using a parameterized quantum circuit. This transformation encodes data into the **high-dimensional Hilbert space** of a quantum system, allowing quantum algorithms to exploit complex correlations not easily captured classically. Essentially, it’s the quantum analogue of feature mapping in machine learning, used to make data more separable for classification or regression tasks. Learn more about Quantum Feature Map). So means apply the unitary defined by encoding rule to input . The is not a variable like , but a tag to remind you how the data is being encoded. Learn more about is the encoding that prepares a data-dependent state. is the trainable Parameterized Quantum CircuitA **Parameterized Quantum Circuit (PQC)** is a quantum circuit where certain gate operations depend on adjustable parameters—typically real numbers representing rotation angles. These parameters are tuned (often by classical optimization) to perform a specific task, such as minimizing a cost function. PQCs are central to **variational quantum algorithms**, where quantum computation provides state preparation and measurement, and a classical computer optimizes the parameters. Learn more about Parameterized Quantum Circuit. And is the selected ObservableIn quantum computing, an **observable** is a physical quantity (like energy, spin, or position) that can be **measured** from a quantum state. Mathematically, it’s represented by a **Hermitian operator**, whose eigenvalues correspond to the possible measurement outcomes. When you measure an observable, the quantum state **collapses** into one of its eigenstates, yielding one of those eigenvalues as the result. Learn more about Observable. The full bra-ket notationBra–ket notation is a compact way to describe quantum states and their inner products. A **ket** (|ψ⟩) represents a column vector describing a quantum state, while a **bra** (⟨φ|) represents its conjugate transpose (a row vector). The inner product ⟨φ|ψ⟩ gives a complex number (like an overlap or probability amplitude), and the outer product |ψ⟩⟨φ| gives an operator. Learn more about Bra Ket means that we average the measurement result over many runs. The adjunctionsIn mathematics, the adjoint of a matrix (or operator) is its conjugate transpose: take the transpose and then replace each entry with its conjugate. For a matrix , the adjoint is written ). It generalizes the transpose to complex spaces and is central in defining Hermitian and unitary operators. Learn more about Adjoint occur because an Expectation ValueThe expectation value is the average result you'd get if you repeated a measurement of a quantity many times under identical conditions. Mathematically, it’s the weighted average of all possible outcomes, where each outcome is weighted by its probability. In quantum mechanics, it represents the average value of an observable calculated from the wavefunction. Learn more about Expectation Value in Linear AlgebraLinear algebra is the branch of mathematics that studies vectors, vector spaces, and linear transformations between them. It provides tools for solving systems of linear equations and understanding geometric operations like rotations, projections, and scaling. Its core objects—matrices and vectors—form the basis for much of modern computation, physics, and machine learning. Learn more about Linear Algebra is an Inner Product.An inner product is a mathematical operation that takes two vectors and returns a single number measuring how similar or aligned they are. In Euclidean space, it’s the sum of the products of corresponding components (e.g., (a \cdot b = a_1b_1 + a_2b_2 + \dots + a_nb_n)). It generalizes the dot product and defines geometric concepts like **length** and **angle** in vector spaces. Learn more about Inner Product
Let's make this more practical and implement a variational Quantum Machine Learning algorithm with QiskitQiskit is an open-source Python framework for programming and simulating quantum computers. It lets users create quantum circuits, run them on real quantum hardware or simulators, and analyze the results. Essentially, it bridges high-level quantum algorithms with low-level hardware execution. Learn more about Qiskit.
We begin with some preparations as depicted in ?. To do this, we all the functions that we will use from other modules.
simple-vqa.py
1
2
3
4
5
6
7
8
import numpy as np
from qiskit import QuantumCircuit
from qiskit.quantum_info import SparsePauliOp
from qiskit_aer.primitives import EstimatorV2 as Estimator
Listing 1 Preparation for a simple variational quantum machine learning algorithmWe also initialize instances of classes that we will use in our example.
We . This creates the EstimatorV2 primitive from Qiskit AerQiskit Aer is a high-performance simulator framework for quantum circuits within Qiskit. It lets users run and test quantum algorithms on classical hardware by accurately emulating noise, decoherence, and other quantum effects. This allows developers to validate and optimize quantum programs before executing them on real quantum computers. Learn more about Qiskit Aer. You use it to calculate Expectation ValuesThe expectation value is the average result you'd get if you repeated a measurement of a quantity many times under identical conditions. Mathematically, it’s the weighted average of all possible outcomes, where each outcome is weighted by its probability. In quantum mechanics, it represents the average value of an observable calculated from the wavefunction. Learn more about Expectation Value for (Quantum CircuitA quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically. Learn more about Quantum Circuit, ObservableIn quantum computing, an **observable** is a physical quantity (like energy, spin, or position) that can be **measured** from a quantum state. Mathematically, it’s represented by a **Hermitian operator**, whose eigenvalues correspond to the possible measurement outcomes. When you measure an observable, the quantum state **collapses** into one of its eigenstates, yielding one of those eigenvalues as the result. Learn more about Observable) pairs.
We . This creates the Hermitian operatorA Hermitian matrix (or operator) is one that equals its own conjugate transpose — mathematically, . This means each element satisfies . Hermitian matrices always have real eigenvalues and orthogonal eigenvectors, which makes them central in quantum mechanics and linear algebra. Learn more about Hermitian Matrix. In practice, this example means: Measure the one QubitA qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states. Learn more about Quantum Bit we have in the basis and assign the EigenvaluesAn eigenvalue is a number that indicates how much a linear transformation stretches or compresses a vector that doesn’t change direction under that transformation (called an eigenvector). Mathematically, it satisfies ( A v = \lambda v ), where ( A ) is a square matrix, ( v ) is the eigenvector, and ( \lambda ) is the eigenvalue. In essence, it measures the scaling factor applied to certain special directions of a transformation. Learn more about Eigenvalue that correspond to Basis StatesA **basis state** in quantum computing is one of the fundamental states that form the building blocks of a quantum system’s state space. For a single qubit, the basis states are (|0⟩) and (|1⟩); any other qubit state is a superposition of these. In systems with multiple qubits, basis states are all possible combinations of 0s and 1s (e.g., (|00⟩, |01⟩, |10⟩, |11⟩)), forming an orthonormal basis for the system’s Hilbert space. Learn more about Basis State. So, we assign to is a basis state. Learn more about and to is a basis state. Learn more about .
We target = 0.0. Accordingly, the optimizerOptimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization attempts to bring to . That means, it moves the Quantum State VectorA quantum state vector is a mathematical object (usually denoted |ψ⟩) that fully describes the state of a quantum system. Its components give the probability amplitudes for finding the system in each possible basis state. The squared magnitude of each component gives the probability of measuring that corresponding outcome. Learn more about Quantum State Vector to the equator of the Bloch SphereThe Bloch sphere is a geometric representation of a single qubit’s quantum state as a point on or inside a unit sphere. The north and south poles represent the classical states |0⟩ and |1⟩, while any other point corresponds to a superposition of them. Its position encodes the qubit’s relative phase and probability amplitudes, making it a visual tool for understanding quantum state evolution. Learn more about Bloch Sphere (relative to the -axis. When you change the target value, the optimizerOptimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization will pursue this new target value. For instance, target=1 pushes toward is a basis state. Learn more about and target=-1 pushes toward is a basis state. Learn more about .
Qiskit Primitives
The next ? depicts the main Machine LearningMachine Learning is an approach on solving problems by deriving the rules from data instead of explicitly programming. Learn more about Machine Learning . But before we start this loop, we initialize the OptimizationOptimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization with a (guessed) starting parameter , the , a within which we accept results as good enough, and the from evaluating the cost function at the starting parameter value.
simple-vqa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
theta = 0.3
max_iters = 100
tol = 1e-4
prev_loss = cost(theta)
for k inrange(max_iters):
theta = spsa_update(theta, k)
curr_loss = cost(theta)
ifabs(prev_loss - curr_loss) < tol:
break
prev_loss = curr_loss
print(f"Final theta: {theta:.4f}, final cost: {curr_loss:.6f}")
Listing 2 The main machine learning loop
Each iteration starts by with the result we obtain from calling the function spsa_update(theta, k), which applies a stochastic approximation step potentially using gradient estimates affected by the .
Then, we using the cost function at the new theta.
The algorithm then , measured as the absolute difference between the previous loss and current loss, is below the tolerance threshold tol. If so, it breaks the loop early, indicating convergence.
If not converged, the to be used in the next iteration's comparison.
In this main feedback loop, we use two functions we have not yet defined: and
? shows the implementation of the spsa_update function that performs the classical Simultaneous Perturbation Stochastic ApproximationSimultaneous Perturbation Stochastic Approximation (SPSA) is an optimization method that estimates the gradient of an objective function using only two function evaluations per iteration, regardless of the problem’s dimension. It does this by randomly perturbing all parameters simultaneously and using the difference in the resulting function values to approximate the gradient. SPSA is efficient for noisy or high-dimensional problems where computing exact or finite-difference gradients is costly. Learn more about Simultaneous Perturbation Stochastic ApproximationoptimizerOptimization is the process of finding the best possible solution to a problem within given constraints. It involves adjusting variables to minimize or maximize an objective function, such as cost, time, or efficiency. In simple terms, it’s about achieving the most effective outcome with the least waste or effort. Learn more about Optimization.
Listing 3 Classical SPSA-like parameter update with stochastic gradient approximation
This optimizer the result of the cost function at slightly around theta. Here, the decays with the iteration count kto refine the approximation over time.
The difference quotient estimates the , which is used to update theta by stepping opposite to the gradient scaled by the that also decays slightly with k. Finally, we the updated theta parameter .
Let's now look at the code of the cost function in ?.
Listing 4 Cost function computing squared error from measure_expectation and target
This function evaluates the quality of the by measuring the expectation value via and comparing it to the predefined target.
The cost is computed as the squared error between the measured value and target, forming a simple loss landscape guiding the optimizer toward minimizing this difference.
So far, all the code we have seen works in a purely classical way. This now changes with the calculation of the Expectation ValueThe expectation value is the average result you'd get if you repeated a measurement of a quantity many times under identical conditions. Mathematically, it’s the weighted average of all possible outcomes, where each outcome is weighted by its probability. In quantum mechanics, it represents the average value of an observable calculated from the wavefunction. Learn more about Expectation Value depicted in ?.
simple-vqa.py
1
2
3
4
5
6
7
defmeasure_expectation(theta: float) -> float:
"""Measure the observable to get an expectation value."""
qc = build_ansatz(theta)
# V2 API: (circuit, observable, parameter_values), no free Parameters, so [] is fine
result = estimator.run([(qc, observable, [])]).result()
evs = np.asarray(result[0].data.evs)
returnfloat(np.atleast_1d(evs).ravel()[0])
Listing 5 Quantum circuit execution and measurement using the Estimator API to obtain expectation value
The function takes a single parameter theta and passes it to a we create in the .
We use the Estimator instance with a tuple containing the circuit, the observable, and an empty parameter list corresponding to no free parameters, as highlighted in to .
We extract the and coerce the batch of expectation values that we return.
? depicts the final missing piece of our variational quantum machine learning algorithm: the AnsatzAn Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz.
simple-vqa.py
1
2
3
4
5
defbuild_ansatz(theta: float) -> QuantumCircuit:
"""Prepare a parameterized state |ψ(θ)⟩."""
qc = QuantumCircuit(1)
qc.ry(theta, 0)
return qc
Listing 6 Function to create the ansatz
The build_ansatz function the simplest imaginable AnsatzAn Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz: a Quantum CircuitA quantum circuit is a sequence of quantum gates applied to qubits, representing the operations in a quantum computation. Each gate changes the qubits’ state using quantum mechanics principles like superposition and entanglement. The final qubit states, when measured, yield the circuit’s computational result probabilistically. Learn more about Quantum Circuit with a single Qubit.A qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states. Learn more about Quantum Bit. It applies the rotationIn quantum computing, a rotation operator is a unitary matrix that rotates a qubit’s state vector on the Bloch sphere by a specific angle around a chosen axis (X, Y, or Z). These are denoted ( R_x(\theta) ), ( R_y(\theta) ), and ( R_z(\theta) ), where ( \theta ) is the rotation angle. They generalize Pauli gates and are fundamental for creating arbitrary single-qubit operations. Learn more about Rotation Operator and therefore turns the Quantum State VectorA quantum state vector is a mathematical object (usually denoted |ψ⟩) that fully describes the state of a quantum system. Its components give the probability amplitudes for finding the system in each possible basis state. The squared magnitude of each component gives the probability of measuring that corresponding outcome. Learn more about Quantum State Vector around the -axis by the angle (theta) that the function takes as a .
This simple AnsatzAn Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz only explores Quantum StatesA quantum state is the complete mathematical description of a quantum system, containing all the information needed to predict measurement outcomes. It’s usually represented by a wavefunction or a state vector in a Hilbert space. The state defines probabilities, not certainties, for observable quantities like position, momentum, or spin. Learn more about Quantum State around the -axis of the Bloch SphereThe Bloch sphere is a geometric representation of a single qubit’s quantum state as a point on or inside a unit sphere. The north and south poles represent the classical states |0⟩ and |1⟩, while any other point corresponds to a superposition of them. Its position encodes the qubit’s relative phase and probability amplitudes, making it a visual tool for understanding quantum state evolution. Learn more about Bloch Sphere. This is the vertical circle in the -plane as shown in ?.
zxy|ψRy(θ)θFigure 4 States reachable by the RY-operator
After the minimal code demo with a single QubitA qubit is the basic unit of quantum information, representing a superposition of 0 and 1 states. Learn more about Quantum Bit, a single , and a -measurement, we've seen the mechanics but also the limitation: a very simple AnsatzAn Ansatz is a chosen form or structure of a quantum state (often parameterized) used as a starting point for algorithms like the Variational Quantum Eigensolver. It defines how qubits are entangled and rotated, and its parameters are optimized to approximate the solution to a problem. The quality of the Ansatz directly affects the accuracy and efficiency of the computation. Learn more about Ansatz is easy to train yet too weak for most problems. The next step is to scale carefully because the pitfalls are waiting for us. Nevertheless, Barren Plateaus,The barren plateau problem in quantum computing refers to regions in a quantum circuit’s parameter space where the **gradient of the cost function becomes exponentially small** as the number of qubits increases. This makes training variational quantum algorithms (like VQEs or QNNs) extremely difficult because optimization algorithms receive almost no useful signal to guide updates. It’s primarily caused by random circuit initialization and high circuit depth, leading to near-random output states. Learn more about Barren PlateauNoise,Noise Learn more about Noise and over-parameterization are manageable with disciplined design:
Problem-inspired ansätze: mirror the structure of the objective (chemistry Hamiltonians, graph constraints). This preserves gradient signal and reduces wasted parameters.
Shallow designs: keep depth minimal to limit noise accumulation and avoid flat landscapes while still capturing key correlations.
Initialization near identity: start close to the reference circuit so gradients don't vanish at step zero.
Geometry-aware optimization: use natural-gradient or related methods that respect the circuit’s information geometry for more stable progressStokes, J., 2020, Quantum, Vol. 4, pp. 269.
Error mitigation: apply lightweight post-processing (e.g. Zero Noise ExtrapolationZero Noise Extrapolation (ZNE) is an error mitigation technique where a quantum circuit is run multiple times at different, artificially increased noise levels. The results are then extrapolated back to the “zero-noise” limit using a mathematical fit (often linear or polynomial). This provides an estimate of what the circuit’s outcome would be if there were no hardware noise, without requiring full quantum error correction. Learn more about Zero Noise Extrapolation) to curb bias without full fault tolerance.
These are the exact fronts where Quantum Machine LearningQuantum Machine Learning is the field of research that combines principles from quantum computing with traditional machine learning to solve complex problems more efficiently than classical approaches. Learn more about Quantum Machine Learning research is concentrated today.