Quantum Gate
QAOA
The Quantum Approximate Optimization Algorithm (QAOA) is one of the most promising combinatorial optimization algorithms for gate-based quantum computers. The input problem needs to be unconstrained and binary, typically even quadratic in interactions (QUBO). Such a problem can be represented as an Ising cost Hamiltonian, which can directly be implemented on gate-based quantum hardware. Starting with an equal superpositions, the QAOA works through the alternating application of the cost Hamiltonian and the mixer operator, essentially boosting the probability of measuring the sought-after solution at the end of the algorithm.
QAOA is parametrized by β and γ angles that need to be optimized in a classical optimization loop in order achieve good sampling efficiency. The number of variational parameters is determined by the number of QAOA layers p (or reps). A higher number of layers generally leads to better optimization. However, the increased parameter count makes optimization harder as a drawback.
Compatible Backends
| Backend | Default |
|---|---|
| AWS | |
| IonQ | |
| IQM | |
| Rigetti | |
| IBMQuantum | |
| AerSimulator | |
| IBMFakeBackend | |
| CudaqCpu | |
| CudaqGpu |
Initialization
from luna_quantum.solve.parameters.algorithms.base_params.qaoa_circuit_params import LinearQAOAParams
from luna_quantum.solve.parameters.algorithms.base_params.scipy_optimizer import ScipyOptimizerParams
from luna_quantum.solve.parameters.algorithms.quantum_gate.qaoa import QAOA
algorithm = QAOA(
backend=None,
reps=1,
shots=1024,
optimizer=ScipyOptimizerParams(
method='cobyla',
tol=None,
bounds=None,
jac=None,
hess=None,
maxiter=100,
options={}
),
initial_params=LinearQAOAParams(
delta_beta=0.5,
delta_gamma=0.5
)
)
Usage
from luna_quantum.algorithms import QAOA
algorithm = QAOA()
solve_job = algorithm.run(model, name="my-solve-job")
QAOA Fire Opal
QAOA_FO is Q-CTRL's implementation of the Quantum Approximate Optimization Algorithm (QAOA) through their Fire Opal framework. It is a hybrid quantum-classical algorithm for solving combinatorial optimization problems with enhanced performance through Q-CTRL's error mitigation and control techniques.
The algorithm works by preparing a quantum state through alternating applications of problem-specific (cost) and mixing Hamiltonians, controlled by variational parameters that are optimized classically to maximize the probability of measuring the optimal solution.
QAOA_FO leverages Q-CTRL's expertise in quantum control to improve circuit fidelity and optimization performance. It is particularly suited for problems that can be encoded as quadratic unconstrained binary optimization (QUBO) or Ising models, such as MaxCut, TSP, and portfolio optimization.
Compatible Backends
| Backend | Default |
|---|---|
| Qctrl |
Initialization
from luna_quantum.solve.parameters.algorithms.quantum_gate.qaoa_fo import QAOA_FO
algorithm = QAOA_FO(
backend=None
)
Usage
from luna_quantum.algorithms import QAOA_FO
algorithm = QAOA_FO()
solve_job = algorithm.run(model, name="my-solve-job")
FlexQAOA
The FlexQAOA is a variant of QAOA developed by Aqarios, specifically focused on problems coming from the real world. The core issue with plain QAOA is that it requires a Quadratic Unconstrained Binary Optimization (QUBO) input format. However, real-world problems typically contain constraints, that can not be violated for a feasible solution. While constraints can be reformulated into penalty terms to form a QUBO. These penalty terms distort the energy spectrum of the optimization heavily, leading to impaired optimization performance. Additionally, in inequality-constrained cases, slack variables have to be introduced, effectively enlarging the search space.
To alleviate the issues arising with reformulation to QUBO, FlexQAOA integrates common constraints directly into the circuit architecture. Namely, it utilizes XY-mixers for the natural enforcement of one-hot constraints and Indicator Functions (IF) for effective penalization of inequality constraints.
Upon input of a constraint optimization problem, FlexQAOA identifies and handles the following constraint types:
- Equality Constraints: via Quadratic Penalties.
- Inequality Constraints:
- via Indicator Functions.
- via Transformation to Equality Constraints.
- One-Hot Constraints:
- via XY-Mixers.
- via Transformation to Equality Constraints.
- Setpacking Constraints:
- via Transformation to One-Hot Constraints.
- via slack-free Quadratic Penalty.
- via Transformation to Inequality Constraints.
The resolution path for each constraint is automatically determined by FlexQAOA. The user can freely configure which methods shall be applied in this automatic pipeline.
So far, FlexQAOA only supports an internal simulator for execution. This simulator, however, features advanced techniques, like cost caching, reduction of state vector size and efficient evaluation of indicator functions.
Note
FlexQAOA will be extended in the future to support more types of constraints and different hardware backends. Stay tuned for updates!
Compatible Backends
| Backend | Default |
|---|---|
| Aqarios | |
| AqariosGpu | |
| AerSimulator | |
| IBMFakeBackend | |
| IBMQuantum |
Initialization
from luna_quantum.solve.parameters.algorithms.base_params.qaoa_circuit_params import LinearQAOAParams
from luna_quantum.solve.parameters.algorithms.base_params.scipy_optimizer import ScipyOptimizerParams
from luna_quantum.solve.parameters.algorithms.quantum_gate.flexqaoa.config import CustomConfig
from luna_quantum.solve.parameters.algorithms.quantum_gate.flexqaoa.flexqaoa import FlexQAOA
from luna_quantum.solve.parameters.algorithms.quantum_gate.flexqaoa.pipeline import (
IndicatorFunctionConfig,
InequalityToEqualityConfig,
PenaltySetting,
PipelineParams,
QuadraticPenaltyConfig,
SetpackingAsOnehotConfig,
XYMixerConfig
)
algorithm = FlexQAOA(
backend=None,
shots=1024,
reps=1,
pipeline=PipelineParams(
penalty=PenaltySetting(
override=None,
scaling=2.0
),
inequality_to_equality=InequalityToEqualityConfig(
enable=True,
max_slack=10
),
setpacking_as_onehot=SetpackingAsOnehotConfig(
enable=True
),
xy_mixer=XYMixerConfig(
enable=True,
trotter=1,
method='ring'
),
indicator_function=IndicatorFunctionConfig(
enable=True,
penalty=PenaltySetting(
override=None,
scaling=1.0
),
method='const'
),
sp_quadratic_penalty=QuadraticPenaltyConfig(
enable=True,
penalty=PenaltySetting(
override=None,
scaling=2.0
)
),
quadratic_penalty=QuadraticPenaltyConfig(
enable=True,
penalty=PenaltySetting(
override=None,
scaling=2.0
)
)
),
optimizer=ScipyOptimizerParams(
method='cobyla',
tol=None,
bounds=None,
jac=None,
hess=None,
maxiter=100,
options={}
),
initial_params=LinearQAOAParams(
delta_beta=0.5,
delta_gamma=0.5
),
param_conversion='basic',
custom_config=CustomConfig(
max_qubits=None,
minimize_qubits=False,
wstate='log',
qft_synth='full'
)
)
Usage
from luna_quantum.algorithms import FlexQAOA
algorithm = FlexQAOA()
solve_job = algorithm.run(model, name="my-solve-job")
VQE
The Variational Quantum Eigensolver (VQE) is a hybrid quantum-classical algorithm designed to find the ground state energy of a Hamiltonian by variationally optimizing a parameterized quantum circuit. It's widely used in quantum chemistry to compute molecular ground state energies and electronic structure properties. Nevertheless, it can also be used to find the ground state of combinatorial optimization problems, like this implementation is intends to do.
Compatible Backends
| Backend | Default |
|---|---|
| IBMQuantum | |
| IBMFakeBackend | |
| AerSimulator |
Initialization
from luna_quantum.solve.parameters.algorithms.base_params.scipy_optimizer import ScipyOptimizerParams
from luna_quantum.solve.parameters.algorithms.quantum_gate.vqe import VQE
algorithm = VQE(
backend=None,
ansatz='efficient_su2',
ansatz_config={},
shots=1024,
optimizer=ScipyOptimizerParams(
method='cobyla',
tol=None,
bounds=None,
jac=None,
hess=None,
maxiter=100,
options={}
),
initial_params_seed=None,
initial_params_range=(0, 6.283185307179586)
)