QISKit Algorithms and Circuits for QUantum Applications (QISKit ACQUA) is a set of algorithms and utilities for use with quantum computers to carry out research and investigate how to solve problems using near-term quantum computing power having short depth circuits. This library uses QISKit for its quantum computation.
This library has algorithms that may be used to solve problems across different application domains.
Note: This library has also some classical algorithms that may be useful in the near term while experimenting with, developing and testing quantum algorithms to compare and contrast results.
Links to Sections:
The following quantum algorithms are part of the library:
- VQE: Variational Quantum Eigensolver
- QPE: Quantum Phase Estimation
- IQPE: Iterative Quantum Phase Estimation
- Dynamics: Quantum Dynamics evolution
- Grover: Quantum Grover search
- SVM_QKernel: Quantum feature-map classifier via direct estimation of the kernel
- SVM_Variational: Variational Quantum feature-map classifier
and these are classical:
- ExactEigensolver: Classical eigenvalue solver
- CPLEX: Optimization solver for Ising modelled problems
- SVM_RBF_Kernel: RBF SVM algorithm
The Additional Configuration section has overall problem and quantum backend configuration that will be needed when running an algorithm.
VQE, the Variational Quantum Eigensolver algorithm, as its name suggests, uses a variational approach to find the minimum eigenvalue of a Hamiltonian energy problem. It is configured with a trial wavefunction, supplied by a variational form, and an optimizer. An initial state may be supplied too.
VQE supports the problems: energy
and ising
VQE can be configured with the following parameters:
-
operator_mode
=matrix | paulis | grouped_paulisMode used by the operator.py class for the computation
-
initial_point
=optional array of numbersAn optional array of numbers may be provided as the starting point for the variational form. The length of this array must match the variational form being used.
If not provided VQE will create a random starting point for the optimizer where its values are randomly chosen to lie within the bounds of the variational form. If the variational form provides None back for any or all elements of its bounds then VQE will default that aspect of the bound to the range -2pi to 2pi and the corresponding value for the point will be randomly generated in this default range.
Dynamics provides the lower-level building blocks for simulating universal quantum systems. For any given quantum system that can be decomposed into local interactions (e.g., a global hamiltonian H as the weighted sum of several pauli spin operators), the local interactions can then be used to approximate the global quantum system via, for example, Lloyd's method, or Trotter-Suzuki decomposition.
Note: this algorithm only supports the local_state_vector
simulator.
Dynamics supports the problems: dynamics
Dynamics can be configured with the following parameter settings:
-
evo_time
=number, default 1Evolution time, defaults tp 1.0
-
evo_mode
=matrix | circuitEvolution mode of computation, matrix or circuit
-
num_time_slices
=integer, default 1Number of time slices: non-negative integer
-
paulis_grouping
=default | randomWhen default paulis are grouped
-
expansion_mode
= trotter | suzukiExpansion mode: trotter (Lloyd's method) or suzuki for Trotter-Suzuki expansion
-
expansion_order
=integer, default 2Trotter-Suzuki expansion order: positive integer
QPE, the Quantum Phase Estimation algorithm (also sometimes abbreviated as PEA), takes two quantum registers, control and target, where the control consists of several qubits initially put in uniform superposition and the target a set of qubits prepared in an eigenstate (or, oftentimes, an guess of the eigenstate) of the unitary operator of a quantum system. QPE then evolves the target under the control using Dynamics of the unitary operator. The information of the corresponding eigenvalue is then kicked-back into the phases of the control register, which can then be deconvoluted by the inverse Quantum Fourier Transform, and then measured for read-out in binary decimal format.
QPE is configured with an initial state and an inverse quantum fourier transform
Note: this algorithm does not support the local_state_vector
simulator.
QPE supports the problems: energy
QPE is also configured with the following parameter settings:
-
num_time_slices
=integer, default 1Number of time slices: non-negative integer
-
paulis_grouping
=default | randomWhen default paulis are grouped
-
expansion_mode
=trotter | suzukiExpansion mode: trotter (Lloyd's method) or suzuki for Trotter-Suzuki expansion
-
expansion_order
=integer, default 2Trotter-Suzuki expansion order: positive integer
-
num_ancillae
=integer, default 1Number of ancillae bits
IQPE, the Iterative Quantum Phase Estimation algorithm, as its name suggests, iteratively computes the
phase so as to require less qubits. It takes in the same set of parameters as QPE except for the number
of ancillary qubits num_ancillae
, which is replaced by num_iterations
. Also, an inverse quantum fourier
transform isn't used for IQPE.
For more detail, please see https://arxiv.org/abs/quant-ph/0610214.
Note: this algorithm does not support the local_state_vector
simulator.
IQPE supports the problems: energy
Grover's Search is a well known quantum algorithm for searching through unstructured collection of records for particular targets with quadratic speedups. All that's needed for carrying out a search is an oracle for specifying the search criterion, which basically indicates a hit or miss for any given record. Currently the SAT (satisfiability) oracle implementation is provided, which takes as input a SAT problem in DIMACS CNF format and constructs the corresponding quantum circuit.
Note: this algorithm does not support the local_state_vector
simulator.
Grover supports the problems: search
Classification algorithms and methods for machine learning are essential for pattern recognition and data mining applications. Well known techniques, such as support vector machines or neural networks, have blossomed over the last two decades as a result of the spectacular advances in classical hardware computational capabilities and speed. This progress in computer power made it possible to apply techniques theoretically developed towards the middle of the XX century on classification problems that soon became increasingly challenging.
A key concept in classification methods is that of a kernel. Data cannot typically be separated by a hyperplane in its original space. A common technique used to find such a hyperplane consists on applying a non-linear transformation function to the data. This function is called a feature map, as it transforms the raw features, or measurable properties, of the phenomenon or subject under study. Classifying in this new feature space -- and, as a matter of fact, also in any other space, including the raw original one -- is nothing more than seeing how close data points are to each other. This is the same as computing the inner product for each pair of data in the set. In fact we do not need to compute the non-linear feature map for each datum, but only the inner product of each pair of data points in the new feature space. This collection of inner products is called the kernel and it is perfectly possible to have feature maps that are hard to compute but whose kernels are not.
The SVM_QKernel algorithm applies to classification problems that require a feature map for which computing the kernel is not efficient classically. This means that the required computational resources are expected to scale exponentially with the size of the problem. SVM_QKernel uses a Quantum processor to solve this problem by a direct estimation of the kernel in the feature space. The method used falls in the category of what is called supervised learning, consisting of a training phase (where the kernel is calculated and the support vectors obtained) and a test or classification phase (where new unlabelled data is classified according to the solution found in the training phase).
For more detail, please see https://arxiv.org/abs/1804.11326.
Note: this algorithm does not support the local_state_vector
simulator.
SVM_QKernel supports the problems: svm_classification
SVM_QKernel can be configured with the following parameters:
-
print_info
=False | TrueWhether to print additional information or not when the algorithm is running.
Just like SVM_Kernel, the SVM_Variational algorithm applies to classification problems that require a feature map for which computing the kernel is not efficient classically. SVM_Variational solves such problems in a quantum processor by variational method that optimizes a parameterized quantum circuit to provide a solution that cleanly separates the data.
For more detail, please see https://arxiv.org/abs/1804.11326.
Note: this algorithm does not support the local_state_vector
simulator.
SVM_Variational supports the problems: svm_classification
SVM_Variational can be configured with the following parameters:
-
circuit_depth
=integer 3 to n, defaults to 3Depth of variational circuit that is optimized.
-
print_info
=False | TrueWhether to print additional information or not when the algorithm is running.
While this algorithm does not use a quantum computer, and relies on a purely classical approach to find eigenvalues, it may be useful in the near term while experimenting with, developing and testing quantum algorithms.
ExactEigensolver supports the problems: 'energy
, excited_states
and ising
ExactEigensolver can be configured with the following parameter:
-
k
=integer 1 to n, default 1Returns up to k smallest eigenvalues. k defaults to 1.
While this algorithm does not use a quantum computer, and relies on a purely classical approach, it may be useful in the near term while experimenting with, developing and testing quantum algorithms. This algorithm uses the IBM ILOG CPLEX Optimization Studio which should be installed, and its Python API setup, for this algorithm to be operational. This algorithm currently supports computing the energy of an Ising model Hamiltonian.
CPLEX supports the problems: ising
CPLEX can be configured with the following parameter:
-
timelimit
=integer 1 to n, default 600Time limit, defaults to 600.
-
thread
=integer, default 1Thread, defaults to 1.
-
display
=integer, default 2Display, defaults to 2.
This is uses classical approach to solving feature map classification problem. It may be useful in the near term while experimenting with, developing and testing quantum algorithms to compare and contrast results.
SVM_RBF_Kernel supports the problems: svm_classification
SVM_RBF_Kernel can be configured with the following parameters:
-
gamma
=A number, default NoneGamma value used in the rbf kernel.
-
print_info
=False | TrueWhether to print additional information or not when the algorithm is running.
To run an algorithm a problem configuration is needed and for quantum algorithms a backend
PROBLEM is an optional section that includes the overall problem being solved and overall problem level configuration
-
name
=energy | excited_states | ising | dynamics | search | svm_classificationSpecifies the problem being solved. Ensures that algorithms that can handle this class of problem are used.
-
random_seed
=An integer, default NoneAspects of the computation may include use of random numbers. For instance VQE will often use a random initial point if the variation form does not supply any preference based on the initial state (and not overridden by a user supplied initial point). In this case each run of VQE, for an otherwise a constant problem, can result in a different result. And even if the final value might be the same the number of evaluations may differ. To enable repeatable experiments, with the exact same outcome, an integer random seed can be set so as the (pseudo-)random numbers will be generated the same each time the experiment is run.
BACKEND is an optional section that includes naming the QISKit quantum computational backend to be used for the quantum computation. This defaults to a local quantum simulator backend.
-
name
='qiskit backend name'Defaults to 'local_statevector_simulator' but any suitable quantum backend can be selected. The QConfig.py file may need to be setup for QISKit to access remote devices. See QISKit installation for information on how to configure the QConfig.py
-
shots
=integer defaults to 1024With a backend such as local_qasm_simulator, or a real device, this is number of repetitions of each circuit for sampling to be used.
-
skip_transpiler
=false | trueSkip circuit translation phase. If the algorithm uses only basis gates directly supported then no translation of the circuit into basis gates is required. Skipping the translation may improve overall performance a little especially when many circuits are used repeatedly such as is teh case with the VQE algorithm.
Note: use with caution as if the algorithm does not restrict itself to the set of basis gates supported by the backend then the circuit (algorithm) will fail to run.
-
noise_params
=dictionary of noise control key/values, optional, defaults to NoneWhen a local simulator is used an optional dictionary can be supplied to control its noise model. For more information see Noise Parameters The following is an example of such a dictionary that can be used:
"noise_params": {"U": {"p_depol": 0.001, "p_pauli": [0, 0, 0.01], "gate_time": 1, "U_error": [ [[1, 0], [0, 0]] ] } }
Algorithms and many of the utils objects have been designed to be pluggable. A new object may be developed according to the pattern that will be described and by simply adding the new code to set of existing code it will be immediately recognized and be made available for use within the framework of QISKit ACQUA.
To develop/deploy here any new algorithms the new class and module(s) should be under their own folder here in qiskit_acqua, like the existing algorithms, vqe etc., and should derive from QuantumAlgorithm class.
The utils folder here has common utility classes and other pluggable entities that may be used by the algorithms
-
Optimizers should go under utils/optimizers and derive from Optimizer class.
-
Trial wavefunction objects should go under utils/variational_forms and derive from VariationalForm class.
-
Initial state objects should go under utils/initial_states and derive from InitialState class.
-
IQFT (Inverse Quantum Fourier Transform) objects should go under utils/iqfts and derive from IQFT class.
-
Oracles, for use with algorithms like Grover, should go under utils/oracles and derive from Oracle class.
All the above classes above should have a configuration dictionary with "name", "description" and "input_schema" properties.
You can follow the implementations already in the repository here.