qoqo_mock

Mock interface and backend for qoqo.

Translates qoqo operations and circuits to mocked operations via interface Mocks quantum computing simulation for performance tests.

mocked_call_operation(operation, ...[, ...])

Execute mocked qoqo operation.

mocked_call_circuit(circuit, ...[, ...])

Execute mocked qoqo circuit.

MockedBackend([number_qubits])

Mocked backend to qoqo.

Functions

mocked_call_circuit(circuit, ...[, ...])

Execute mocked qoqo circuit.

mocked_call_operation(operation, ...[, ...])

Execute mocked qoqo operation.

Classes

MockedBackend([number_qubits])

Mocked backend to qoqo.

class qoqo_mock.MockedBackend(number_qubits: int = 1)[source]

Mocked backend to qoqo.

The mocked backend mock-simulates a quantum circuit on a given device by translating the qoqo circuit using the qoqo_mocked interface. This interface produces random measurements coherent with the measured quantity. These results are then output from the run function in this backend and are accessible through the classical registers dictionary.

Initialize backend.

Parameters:

number_qubits -- The number of qubits to use

__init__(number_qubits: int = 1) None[source]

Initialize backend.

Parameters:

number_qubits -- The number of qubits to use

__weakref__

list of weak references to the object

run_circuit(circuit: Circuit) Tuple[Dict[str, List[List[bool]]], Dict[str, List[List[float]]], Dict[str, List[List[complex]]]][source]

Run a circuit with the Mocked backend.

Parameters:

circuit -- The circuit that is run

Returns:

Union[None, Dict[str, 'RegisterOutput']]

run_measurement(measurement: Any) Dict[str, float] | None[source]

Run a circuit with the Mocked backend.

Parameters:

measurement -- The measurement that is run

Returns:

Union[None, Dict[str, 'RegisterOutput']]

run_measurement_registers(measurement: Any) Tuple[Dict[str, List[List[bool]]], Dict[str, List[List[float]]], Dict[str, List[List[complex]]]][source]

Run all circuits of a measurement with the Mocked backend.

Parameters:

measurement -- The measurement that is run

Returns:

Union[None, Dict[str, 'RegisterOutput']]

qoqo_mock.mocked_call_circuit(circuit: Circuit, classical_bit_registers: Dict[str, List[bool]], classical_float_registers: Dict[str, List[float]], classical_complex_registers: Dict[str, List[complex]], output_bit_register_dict: Dict[str, List[List[bool]]], output_complex_register_dict: Dict[str, List[List[complex]]], number_qubits: int = 1, **kwargs) Tuple[Dict[str, List[bool]], Dict[str, List[float]], Dict[str, List[complex]], Dict[str, List[List[bool]]], Dict[str, List[List[complex]]]][source]

Execute mocked qoqo circuit.

The Mocked interface is an interface which mock-simulates a quantum circuit. The quantum gates are not applied and the measurements produce random results coherent with the measured quantity.

Parameters:
  • circuit -- The qoqo circuit that is executed

  • classical_bit_registers -- Dictionary or registers (lists) containing bit readout values

  • classical_float_registers -- Dictionary or registers (lists) containing float readout values

  • classical_complex_registers -- Dictionary or registers (lists) containing complex readout values

  • output_bit_register_dict -- Dictionary or lists of registers (lists) containing a register for each repetition of the circuit

  • output_complex_register_dict -- Dictionary or lists of registers (lists) containing a register for each repetition of the circuit

  • number_qubits -- Number of qubits mocked

  • **kwargs -- Additional keyword arguments

Returns:

Tuple[

Dict[str, List[bool]], Dict[str, List[float]], Dict[str, List[complex]], Dict[str, List[List[bool]]], Dict[str, List[List[complex]]]]: modified registers

qoqo_mock.mocked_call_operation(operation: Any, classical_bit_registers: Dict[str, List[bool]], classical_float_registers: Dict[str, List[float]], classical_complex_registers: Dict[str, List[complex]], output_bit_register_dict: Dict[str, List[List[bool]]], output_complex_register_dict: Dict[str, List[List[complex]]], number_qubits: int = 1) Tuple[Dict[str, List[bool]], Dict[str, List[float]], Dict[str, List[complex]], Dict[str, List[List[bool]]], Dict[str, List[List[complex]]]][source]

Execute mocked qoqo operation.

Parameters:
  • operation -- The qoqo operation that is executed

  • classical_bit_registers -- Dictionary or registers (lists) containing bit readout values

  • classical_float_registers -- Dictionary or registers (lists) containing float readout values

  • classical_complex_registers -- Dictionary or registers (lists) containing complex readout values

  • output_bit_register_dict -- Dictionary or lists of registers (lists) containing a register for each repetition of the circuit

  • output_complex_register_dict -- Dictionary or lists of registers (lists) containing a register for each repetition of the circuit

  • number_qubits -- Number of qubits mocked

  • **kwargs -- Additional keyword arguments

Returns:

stuff

Raises:

RuntimeError -- Operation cannot be mocked