Device interface

graphix_ibmq.runner module

class graphix_ibmq.runner.IBMQBackend(pattern)[source]

Interface for MBQC pattern execution on IBM quantum devices.

pattern

MBQC pattern to be run on the device

Type

graphix.pattern.Pattern object

circ

qiskit circuit corresponding to the pattern.

Type

qiskit.circuit.quantumcircuit.QuantumCircuit object

job

job object of the execution.

Type

qiskit_ibm_provider.job.ibm_circuit_job.IBMCircuitJob object

instance

instance name of IBMQ provider.

Type

str

resource

resource name of IBMQ provider.

Type

str

backend

IBMQ device backend

Type

qiskit_ibm_provider.ibm_backend.IBMBackend object

__init__(pattern)[source]
Parameters

pattern (graphix.pattern.Pattern object) – MBQC pattern to be run on the IBMQ device or Aer simulator.

get_backend(instance='ibm-q/open/main', resource=None)[source]

get the backend object

Parameters
  • instance (str) – instance name of IBMQ provider.

  • resource (str) – resource name of IBMQ provider.

to_qiskit(save_statevector=False)[source]

convert the MBQC pattern to the qiskit cuicuit and add to attributes.

Parameters
  • pattern (graphix.pattern.Pattern object) – MBQC pattern to be converted to qiskit circuit.

  • save_statevector (bool, optional) – whether to save the statevector before the measurements of output qubits.

set_input(psi)[source]

set the input state of the circuit. The input states are set to the circuit qubits corresponding to the first n nodes prepared in the pattern.

Parameters

psi (list of list of complex) – list of the input states for each input. Each input state is a list of complex of length 2, representing the coefficient of |0> and |1>.

transpile(backend=None, optimization_level=1)[source]

transpile the circuit for the designated resource.

Parameters
  • backend (qiskit_ibm_provider.ibm_backend.IBMBackend object, optional) – backend to be used for transpilation.

  • optimization_level (int, optional) – the optimization level of the transpilation.

simulate(shots=1024, noise_model=None, format_result=True)[source]

simulate the circuit with Aer.

Parameters
  • shots (int, optional) – the number of shots.

  • noise_model (qiskit_aer.backends.aer_simulator.AerSimulator object, optional) – noise model to be used in the simulation.

  • format_result (bool, optional) – whether to format the result so that only the result corresponding to the output qubit is taken out.

Returns

result – the measurement result.

Return type

dict

run(shots=1024, format_result=True, optimization_level=1)[source]

Run the MBQC pattern on IBMQ devices

Parameters
  • shots (int, optional) – the number of shots.

  • format_result (bool, optional) – whether to format the result so that only the result corresponding to the output qubit is taken out.

  • optimization_level (int, optional) – the optimization level of the transpilation.

Returns

result – the measurement result.

Return type

dict

format_result(result)[source]

Format the result so that only the result corresponding to the output qubit is taken out.

Returns

masked_results – Dictionary of formatted results.

Return type

dict

retrieve_result(job_id, format_result=True)[source]

Retrieve the measurement results.

Parameters
  • job_id (str) – the id of the job.

  • format_result (bool, optional) – whether to format the result so that only the result corresponding to the output qubit is taken out.

Returns

result – the measurement result.

Return type

dict