OpenQAOA Azure API Reference

Microsoft Azure Cloud Devices

class openqaoa_azure.backends.devices.DeviceAzure(device_name, resource_id, az_location)[source]

Contains the required information and methods needed to access remote Azure QPUs and Simulators.

Parameters:

available_qpus (list) – When connection to a provider is established, this attribute contains a list of backend names which can be used to access the selected backend by reinitialising the Access Object with the name of the available backend as input to the device_name parameter.

check_connection()[source]
connectivity()[source]

obtain the device connectivity as a list of qubit pairs

Return type:

List[List[int]]

Returns:

List[List[int]]

Microsoft Azure Backends

Azure supports quantum programs defined in qiskit

class openqaoa_qiskit.backends.qaoa_qiskit_qpu.QAOAQiskitQPUBackend(qaoa_descriptor, device, n_shots, prepend_state, append_state, init_hadamard, initial_qubit_mapping=None, qiskit_optimization_level=1, cvar_alpha=1)[source]

A QAOA simulator as well as for real QPU using qiskit as the backend

Parameters:
  • device (DeviceQiskit) – An object of the class DeviceQiskit which contains the credentials for accessing the QPU via cloud and the name of the device.

  • qaoa_descriptor (QAOADescriptor) – An object of the class QAOADescriptor which contains information on circuit construction and depth of the circuit.

  • n_shots (int) – The number of shots to be taken for each circuit.

  • prepend_state (QuantumCircuit) – The state prepended to the circuit.

  • append_state (QuantumCircuit) – The state appended to the circuit.

  • init_hadamard (bool) – Whether to apply a Hadamard gate to the beginning of the QAOA part of the circuit.

  • cvar_alpha (float) – The value of alpha for the CVaR method.

assign_angles(params)

Assigns the angle values of the variational parameters to the circuit gates specified as a list of gates in the abstract_circuit.

Parameters:

params (QAOAVariationalBaseParams) – The variational parameters(angles) to be assigned to the circuit gates

Return type:

None

bitstring_energy(bitstring)

Computes the energy of a given bitstring with respect to the cost Hamiltonian.

Parameters:

bitstring (Union[List[int],str]) – A list of integers 0 and 1 of length n_qubits representing a configuration.

Returns:

The energy of a given bitstring with respect to the cost Hamiltonian.

Return type:

float

circuit_to_qasm(params)[source]

A method to convert the entire QAOA QuantumCircuit object into a OpenQASM string

Return type:

str

property exact_solution

Computes exactly the minimum energy of the cost function and its corresponding configuration of variables using standard numpy module.

Returns:

(energy, config)

  • The minimum eigenvalue of the cost Hamiltonian,

  • The minimum energy eigenvector as a binary array configuration: qubit-0 as the first element in the sequence

Return type:

Tuple[float, list]

expectation(**kwargs)

Call the execute function on the circuit to compute the expectation value of the Quantum Circuit w.r.t cost operator

expectation_w_uncertainty(**kwargs)

Call the execute function on the circuit to compute the expectation value of the Quantum Circuit w.r.t cost operator along with its uncertainty

get_counts(params, n_shots=None)[source]

Execute the circuit and obtain the counts

Parameters:
  • params (QAOAVariationalBaseParams) – The QAOA parameters - an object of one of the parameter classes, containing variable parameters.

  • n_shots (int) – The number of times to run the circuit. If None, n_shots is set to the default: self.n_shots

Return type:

dict

Returns:

A dictionary with the bitstring as the key and the number of counts as its value.

obtain_angles_for_pauli_list(input_gate_list, params)

This method uses the pauli gate list information to obtain the pauli angles from the VariationalBaseParams object. The floats in the list are in the order of the input GateMaps list.

Parameters:
  • input_gate_list (List[GateMap]) – The GateMap list including rotation gates

  • params (QAOAVariationalBaseParams) – The variational parameters(angles) to be assigned to the circuit gates

Returns:

angles_list – The list of angles in the order of gates in the GateMap list

Return type:

List[float]

property parametric_qaoa_circuit: qiskit.QuantumCircuit

Creates a parametric QAOA circuit, given the qubit pairs, single qubits with biases, and a set of circuit angles. Note that this function does not actually run the circuit. To do this, you will need to subsequently execute the command self.eng.flush().

Parameters:

params – Object of type QAOAVariationalBaseParams

qaoa_circuit(params)[source]

The final QAOA circuit to be executed on the QPU.

Parameters:

params (QAOAVariationalBaseParams) –

Returns:

qaoa_circuit – The final QAOA circuit after binding angles from variational parameters.

Return type:

QuantumCircuit

reset_circuit()[source]

Reset self.circuit after performing a computation