Worker Process

The worker process is a parent of a set of qubit threads. It is responsible to increase the concurrency of the EQSN package. Using a dictionary, it keeps track of all qubits within its thread and provides an interface for the gates class.

class eqsn.worker_process.WorkerProcess(queue)

Object to control a Process. Intermediate object to apply operations to the Qubits which are running on this Process.

add_merged_qubits_to_thread(q_id, qubits)

Add new Qubits from a merge to the dictionary.

apply_controlled_gate(gate, q_id1, q_id2)

Applies a controlled gate, where the gate is applied to q_id1 and controlled by q_id2.

Parameters
  • q_id1 (String) – Id of the Qubit on which the X gate is applied.

  • q_id2 (String) – Id of the Qubit which controls the gate.

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 a thread.

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

  • q_id1 (String) – First qubit id.

  • q_id2 (String) – Second qubit id.

give_statevector_for(q_id, channel)

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

Parameters
  • q_id (String) – ID of the Qubit of the state vector to be returned.

  • 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(q_id, queue)

Handle a merge accept.

Parameters
  • q_id (String) – ID of the qubit which should accept the merge.

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

merge_qubits(q_id1, q_id2)

Merges two qubits to one process, if they are not already running in the same process.

Parameters
  • q_id1 (String) – Id of the Qubit merged into q_id2.

  • q_id2 (String) – Id of the Qubit merged with q_id1.

new_qubit(q_id)

Creates a new qubit with an id.

Parameters

id (String) – Id of the new qubit.

run()

Run in loop and wait to receive tasks to perform.

stop_all()

Stops the simulator from running.