Qubit Thread

A qubit thread object contains a list of qubits and there statevectors. The class provides functionality for manipulating the qubits, such as measuring them or applying gates.

class eqsn.qubit_thread.QubitThread(q_id, queue)

The Qubit thread is the smallest object in EQSN. It consists of a statevector and the Qubit IDs of the state vector. Most operations here can be applid asynchronously.

apply_controlled_gate(mat, q_id1, q_id2)

Applies a controlled gate to q_id1

apply_single_gate(gate, q_id)

Applys a single gate to a qubit.

Parameters
  • gate (np.array) – 2x2 unitary array.

  • id (String) – Qubit on which the gate should be applied to.

apply_two_qubit_gate(gate, q_id1, q_id2)

Applies a two qubit gate to the statevector.

Parameters
  • gate (np.ndarray) – 4x4 unitary matrix

  • q_id1 (String) – First qubit id.

  • q_id2 (String) – Second qubit id.

give_statevector(channel)

Sends the Qubit IDs and their state vectors over a channel.

Parameters

channel (Queue) – Channel to return the requested data to.

measure(q_id, channel)

Perform a destructive measurement on qubit with the id.

Parameters
  • q_id (String) – ID of the Qubit to measure.

  • channel (Queue) – Channel to transmit measurement result to.

measure_non_destructive(q_id, channel)

Perform a non destructive measurement on qubit with the id.

Parameters
  • q_id (String) – ID of the Qubit to measure.

  • channel (Queue) – Channel to transmit measurement result to.

merge_accept(channel)

Receive the statevector and qubit information of another thread with this thread and merge the vectors.

Parameters

channel (Queue) – channel to receive qubit ids and statevectors from.

merge_send(channel, chanel2)

Send own process data to another process and suicide.

Parameters
  • channel (Queue) – Channel to send own data to other Qubit Thread.

  • channel2 (Queue) – Channel to send qubit ids to parent, to update the qubit ids in its dictionary.

run()

Run in loop and wait to receive tasks to perform.

swap_qubits(q_id1, q_id2)

Swaps the position of qubit q_id1 with q_id2 in the statevector.

q_id1(String): Qubit id of one of the qubits to swap. q_id2(String): Qubit id of the other qubit to swap.