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.
For further information see qiskit’s VQE tutorial.
Compatible Backends¶
The VQE
algorithm supports the following backends:
By default, VQE
uses the IBM
backend.
Initialization¶
The following section outlines the default configurations of VQE
. You can also specify other compatible backends for the algorithm. When backend=None
is specified, the default backend will be initialized automatically. In this case, if the backend requires a token, it will be taken from the environment variables.
from luna_quantum.solve.parameters.algorithms import VQE
from luna_quantum.solve.parameters.algorithms.base_params import ScipyOptimizerParams
algorithm = VQE(
backend=None,
ansatz='EfficientSU2',
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)
)
Parameter Details
For a complete overview of available parameters and their usage, see the VQE API Reference.
Usage¶
from luna_quantum import LunaSolve
LunaSolve.authenticate("<YOUR_LUNA_API_KEY>")
# Define your model and algorithm
model = ...
algorithm = ...
solve_job = algorithm.run(model, name="my-solve-job")
API Reference¶
Bases: LunaAlgorithm[IBM]
Parameters for the Variational Quantum Eigensolver (VQE) algorithm.
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.
Attributes:
Name | Type | Description |
---|---|---|
ansatz |
Literal['NLocal', 'EfficientSU2', 'RealAmplitudes', 'PauliTwoDesign']
|
The variational form (parameterized circuit) to use. Default is "EfficientSU2", a hardware-efficient ansatz using SU(2) rotation gates that works well on NISQ devices due to its shallow depth and flexibility. |
ansatz_config |
dict[str, Any]
|
Configuration options for the selected ansatz, such as:
Default is an empty dictionary, using the ansatz's default settings. |
shots |
int | None
|
Number of measurement samples per circuit execution. Higher values improve accuracy by reducing statistical noise at the cost of longer runtime. Default is 1024, which balances accuracy with execution time. |
optimizer |
ScipyOptimizerParams | Dict
|
Configuration for the classical optimization routine that updates the variational parameters. Default is a ScipyOptimizer instance with default settings. See ScipyOptimizer class or https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html for details of contained parameters. |
initial_params_seed |
int | None
|
Seed for random number generator for intial params. |
initial_params_range |
tuple[float, float]
|
Range of initial parameter values. |
ansatz
class-attribute
instance-attribute
¶
ansatz_config
class-attribute
instance-attribute
¶
backend
class-attribute
instance-attribute
¶
initial_params_range
class-attribute
instance-attribute
¶
model_config
class-attribute
instance-attribute
¶
optimizer
class-attribute
instance-attribute
¶
optimizer: ScipyOptimizerParams = Field(
default_factory=lambda: ScipyOptimizerParams()
)
get_compatible_backends
classmethod
¶
get_compatible_backends() -> tuple[type[IBM]]
Check at runtime if the used backend is compatible with the solver.
Returns:
Type | Description |
---|---|
tuple[type[IBackend], ...]
|
True if the backend is compatible with the solver, False otherwise. |
get_default_backend
classmethod
¶
get_default_backend() -> IBM
Return the default backend implementation.
This property must be implemented by subclasses to provide the default backend instance to use when no specific backend is specified.
Returns:
Type | Description |
---|---|
IBackend
|
An instance of a class implementing the IBackend interface that serves as the default backend. |
run ¶
run(
model: Model | str,
name: str | None = None,
backend: BACKEND_TYPE | None = None,
client: LunaSolve | str | None = None,
*args: Any,
**kwargs: Any,
) -> SolveJob
Run the configured solver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model
|
Model or str
|
The model to be optimized or solved. It could be an Model instance or a string identifier representing the model id. |
required |
name
|
str | None
|
If provided, the name of the job. Defaults to None. |
None
|
backend
|
BACKEND_TYPE | None
|
Backend to use for the solver. If not provided, the default backend is used. |
None
|
client
|
LunaSolve or str
|
The client interface used to interact with the backend services. If not provided, a default client will be used. |
None
|
*args
|
Any
|
Additional arguments that will be passed to the solver or client. |
()
|
**kwargs
|
Any
|
Additional keyword parameters for configuration or customization. |
{}
|
Returns:
Type | Description |
---|---|
SolveJob
|
The job object containing the information about the solve process. |