Blog
30
January
,
2022

Circuit of the month Jan 22: a hardware-efficient variational circuit

Share the article
Our library

Given a molecule, the Hamiltonian describes the interactions between all electrons and nuclei.

Calculating the energies of a molecular Hamiltonian, and especially its ground state, allows us to understand the chemical properties of a molecule. Since the molecular Hamiltonian is inherently quantum, quantum computing can be used to calculate such properties efficiently by leveraging the same quantum effects in appropriate quantum algorithms. This is done in 3 steps:

  1. Calculating the molecular Hamiltonian for the desired molecule.
  2. Generating an appropriate variational quantum circuit to calculate the Hamiltonian's ground state. Today, we will focus on this step, demonstrate how to create a variational circuit.
  3. Executing the desired quantum circuit as part of a hybrid quantum-classical algorithm.

The ground state of a Hamiltonian is found by using an appropriate variational quantum circuit (usually called an Ansatz), and then combining it with a classical optimizer to find the minimal expectation value for the Hamiltonian. In NISQ-era devices, short and hardware-fitting quantum circuits are preferred, to reduce the noise and get better results.

In the following example, we demonstrate how to generate a hardware-efficient Ansatz, i.e. an Ansatz that is generated to fit a specific hardware.

In this example we will use a 4-qubit hardware, with full connectivity.

Using Classiq's textual model, the code looks like this:


{
    "quantum_circuit_constraints": {
        "max_depth": 100,
        "max_width": 4,
        "logic_flow": [
            {
                "function": "HardwareEfficientAnsatz",
                "function_params": {
                    "num_qubits": 4,
                    "connectivity_map": [
                        [0,1],
                        [0,2],
                        [0,3],
                        [1,2],
                        [1,3],
                        [2,3]
                    ],
                    "reps": 2
                }
            }
        ]
    }
}

Alternatively, one can synthesize the same circuit using Classiq's Python SDK:


from classiq import ModelDesigner
from classiq.builtin_functions import HardwareEfficientAnsatz

NUM_QUBITS = 4
FULLY_CONNECTED_MESH = [ [0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3] ]
hwea_params = HardwareEfficientAnsatz(
    num_qubits=NUM_QUBITS,
    connectivity_map=FULLY_CONNECTED_MESH,
    reps=2
)
model_designer = ModelDesigner()
model_designer.HardwareEfficientAnsatz(params=hwea_params)
generation_result = model_designer.synthesize()

Here is the resulting output circuit:

alt text

Given a molecule, the Hamiltonian describes the interactions between all electrons and nuclei.

Calculating the energies of a molecular Hamiltonian, and especially its ground state, allows us to understand the chemical properties of a molecule. Since the molecular Hamiltonian is inherently quantum, quantum computing can be used to calculate such properties efficiently by leveraging the same quantum effects in appropriate quantum algorithms. This is done in 3 steps:

  1. Calculating the molecular Hamiltonian for the desired molecule.
  2. Generating an appropriate variational quantum circuit to calculate the Hamiltonian's ground state. Today, we will focus on this step, demonstrate how to create a variational circuit.
  3. Executing the desired quantum circuit as part of a hybrid quantum-classical algorithm.

The ground state of a Hamiltonian is found by using an appropriate variational quantum circuit (usually called an Ansatz), and then combining it with a classical optimizer to find the minimal expectation value for the Hamiltonian. In NISQ-era devices, short and hardware-fitting quantum circuits are preferred, to reduce the noise and get better results.

In the following example, we demonstrate how to generate a hardware-efficient Ansatz, i.e. an Ansatz that is generated to fit a specific hardware.

In this example we will use a 4-qubit hardware, with full connectivity.

Using Classiq's textual model, the code looks like this:


{
    "quantum_circuit_constraints": {
        "max_depth": 100,
        "max_width": 4,
        "logic_flow": [
            {
                "function": "HardwareEfficientAnsatz",
                "function_params": {
                    "num_qubits": 4,
                    "connectivity_map": [
                        [0,1],
                        [0,2],
                        [0,3],
                        [1,2],
                        [1,3],
                        [2,3]
                    ],
                    "reps": 2
                }
            }
        ]
    }
}

Alternatively, one can synthesize the same circuit using Classiq's Python SDK:


from classiq import ModelDesigner
from classiq.builtin_functions import HardwareEfficientAnsatz

NUM_QUBITS = 4
FULLY_CONNECTED_MESH = [ [0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3] ]
hwea_params = HardwareEfficientAnsatz(
    num_qubits=NUM_QUBITS,
    connectivity_map=FULLY_CONNECTED_MESH,
    reps=2
)
model_designer = ModelDesigner()
model_designer.HardwareEfficientAnsatz(params=hwea_params)
generation_result = model_designer.synthesize()

Here is the resulting output circuit:

alt text

About "The Qubit Guy's Podcast"

Hosted by The Qubit Guy (Yuval Boger, our Chief Marketing Officer), the podcast hosts thought leaders in quantum computing to discuss business and technical questions that impact the quantum computing ecosystem. Our guests provide interesting insights about quantum computer software and algorithm, quantum computer hardware, key applications for quantum computing, market studies of the quantum industry and more.

If you would like to suggest a guest for the podcast, please contact us.

See Also

No items found.

Start Creating Quantum Software Without Limits

contact us