Quantum Storage

Quantum Storage objects are used by the Host components. Each Host has two Quantum Storage objects, one for EPR pairs and the other for data qubits, but in both cases, they store Qubit objects. As further iterations of QuNetSim are developed, we plan to add parameters such that we can better simulate quantum memories.

class qunetsim.objects.storage.quantum_storage.QuantumStorage

Bases: object

An object which stores qubits.

_add_request(args)

Adds a new request to the quantum storage. If a new qubit arrives, it is checked if the request for the qubit is satisfied.

Parameters

args (list) – [Queue, from_host_id, q_id, purpose]

_check_all_requests()

Checks if any of the pending requests is now fulfilled.

Returns

If a request is fulfilled, the request is handled and the function returns the qubit of this request.

_check_memory_limits(host_id)

Checks if another qubit can be added to the storage.

Parameters

host_id (str) – The host_id the qubit should be added to.

Returns

True if no storage limit has been reached, False if a memory limit has occurred.

_check_qubit_in_system(qubit, from_host_id, purpose=None)

True if qubit with same parameters already in the systems

Parameters
  • qubit (Qubit) – The qubit in question

  • from_host_id (str) – The ID of the sending host

  • purpose (int) – Qubit’s purpose

Returns

If the qubit is in the system.

Return type

(bool)

_decrease_qubit_counter(host_id)

Checks if the qubit counter can be decreased and decreases the counter.

Parameters

host_id (str) – From who the qubit comes from.

Returns

True, if the counter could be decreased, False if not.

Return type

(bool)

_increase_qubit_counter(host_id)

Checks if the qubit counter can be increased, because of memory limits, and increases the counter.

Parameters

host_id (str) – From who the qubit comes from.

Returns

True, if the counter could be increased, False if not.

_remove_request(req_id)

Removes a pending request from the request dict.

Parameters

req_id (int) – The id of the request to remove.

_reset_qubit_counter(host_id)
Parameters

host_id (str) –

Returns

True, if the counter could be decreased, False if not.

Return type

(bool)

add_qubit_from_host(qubit, purpose, from_host_id)

Adds a qubit which has been received from a host.

Parameters
  • qubit (Qubit) – qubit which should be stored.

  • from_host_id (str) – Id of the Host from whom the qubit has been received.

  • purpose (str) – Purpose of the Qubit, for example EPR or data.

change_qubit_id(from_host_id, new_id, old_id=None)

Changes the ID of a qubit. If the ID is not given, a random qubit which is from a host is changed to the new id.

Parameters
  • from_host_id (str) – The ID of the owner

  • new_id (str) – The ID to change to

  • old_id (str) – The old ID

Returns

The new ID

Return type

(str)

check_qubit_from_host_exists(from_host_id, purpose=None)

Check if a qubit from a host exists in this quantum storage.

Parameters
  • from_host_id (str) – The host id of the host from which the qubit is from.

  • purpose (int) – Optional, purpose of the qubit which should exist.

Returns

True, if such a qubit is in the storage, false if not.

Return type

(bool)

get_all_qubits_from_host(from_host_id, purpose=None, remove=False)

Get all Qubits from a specific host id. These qubits are not removed from storage!

Parameters
  • from_host_id (str) – The host who the qubits are from

  • purpose (int) – The purpose of the qubits

  • remove (bool) – Also remove from storage

Returns

The list of qubits

Return type

(list)

get_qubit_by_id(q_id)

Return the qubit that has the id q_id

Parameters

q_id (str) – The ID of the qubit

Returns

The qubit with the id q_id or None if it does not exist

Return type

(Qubit)

get_qubit_from_host(from_host_id, q_id=None, purpose=None, wait=0)

Returns next qubit which has been received from a host. If the qubit has not been receives yet, the thread is blocked for a maxiumum of the wait time, till the qubit arrives (The default is 0). If the id is given, the exact qubit with the id is returned, or None if it does not exist. The qubit is removed from the quantum storage.

Parameters
  • from_host_id (str) – Host id from who the qubit has been received.

  • q_id (str) – Optional Id, to return the exact qubit with the Id.

  • purpose (str) – Optional, purpose of the Qubit.

  • wait (int) – Default is 0. The maximum blocking time. -1 if blocking forever.

Returns

If such a qubit exists, it returns the qubit. Otherwise, None is returned.

Return type

(bool)

release_storage()

Releases all qubits in this storage. The storage is not usable anymore after this function has been called.

reset_qubits_from_host(from_host_id, purpose=None)

Remove all stored qubits from the host from_host_id.

Parameters
  • from_host_id (str) – The host who the qubits are from

  • purpose (int) –

reset_storage()

Reset the quantum storage.

set_storage_limit_with_host(new_limit, host_id)

Set a new storage limit for the storage. The implementations depends on the storage mode.

Parameters
  • new_limit (int) – The new max amount of qubit.

  • host_id (str) – optional, if given, and the storage mode is STORAGE_LIMIT_INDIVIDUALLY_PER_HOST, the limit is only set for this specific host.