Circuit ServiceΒΆ
The CircuitService prepares an optimal quantum circuit that implements the exponential of a logical Hamiltonian associated with an optimization problem. Such a circuit is used for example in quantum optimization algorithms such as QAOA. It takes an OperatorPolynomial of a problem (that has already been mapped to parity qubits using a ParityMapping) and a DeviceConnectivity and returns a FrozenCircuit implementing the exponential of the problem Hamiltonian.
from parityos.bits import get_q
from parityos.devices.device_connectivity import (
get_rectangular_nearest_neighbor_connectivity,
)
from parityos.operators.elementary_operator import Z
from parityos.services.authentication import InteractiveAuth
from parityos.services.client import HTTPClient
from parityos.services.service import CircuitInput, CircuitService
# The logical Hamiltonian for which to implement the exponential
hamiltonian = 3 * Z(get_q(1, 2)) * Z(get_q(2, 2)) * Z(get_q(3, 2)) + 2 * Z(get_q(1, 4)) * Z(
get_q(2, 4)
) * Z(get_q(1, 3))
# A 5 x 5 square grid qubit quantum computing device with nearest neighbor interactions
device_layout = get_rectangular_nearest_neighbor_connectivity(5, 5)
# Set up connection to ParityOS cloud service
client = HTTPClient(InteractiveAuth("my_parityos_username")) # handles authentication
service = CircuitService(client) # handles API communication with the cloud service
# Run problem (with a certain configuration or preset and a description to recognize the job by)
# and obtain result
circuit = service.run(
CircuitInput(hamiltonian, device_layout), "my_preset", "My first parityos job."
)
# the circuit implementing the operator exponential
print(circuit)