progress.sockets

This module contains the classes that are used to represent sockets and tokens. Sockets are an internal abstraction that are used to represent qubits. Tokens are the external abstraction of qubits that is used at the NET layer. A token is created when Link Layer protocols signal the generation of a new entangled pair.

class progress.sockets.Socket(node, qnic, idx)[source]

Bases: object

A socket is an internal logical abstraction for an entangled qubit. The name derives from the fact that the qubit is entangled with (at least) another qubit, and thus it represents one end of the entangling connection.

Parameters:
nodeint

The node the qubit is located on.

qnicint

The interface the qubit is assigned on.

idxint

The index of the qubit on the interface.

class progress.sockets.Token(socket, other_end, current_state, pct, purified, additional_info)

Bases: tuple

A token is an external logical abstraction for an entangled qubit. It is used at the NET layer to manage quantum resources in a hardware-independent fashion.

Parameters:
socketSocket

The local socket related to this token.

other_endSocket

The other end of the entangled connection.

current_stateint

The current state of the qubit (0 -> \(\vert\beta_{00}\rangle\), 1 -> \(\vert\beta_{01}\rangle\), 2 -> \(\vert\beta_{10}\rangle\), 3 -> \(\vert\beta_{11}\rangle\)).

pctfloat

The Pair Coherence Timeout of the socket pair.

purifiedint

Whether or not the socket is purified. 0 -> not purified, 1 -> purified, >1 -> number of purification rounds.

additional_infodict[any, any]

Additional information about the socket.

additional_info

Alias for field number 5

current_state

Alias for field number 2

other_end

Alias for field number 1

pct

Alias for field number 3

purified

Alias for field number 4

socket

Alias for field number 0

class progress.sockets.TokenMessage(token)[source]

Bases: Message

A message containing a token. Used to transfer tokens from a module to another.

Parameters:
tokenToken

The token to be transmitted along with the message.

class progress.sockets.TokenTable[source]

Bases: object

A table that stores tokens. This is used to keep track of the tokens that are currently owned by a specific module.

add_token(token)[source]

Add a socket descriptor to the socket table.

Parameters:
tokenToken

The token to add.

collect_garbage(current_time)[source]

Remove all expired tokens from the token table.

Parameters:
current_timefloat

The current time in the simulation. [ns]

Returns:
list[Token]

The list of tokens that were removed.

get_snapshot()[source]

Get a snapshot of the socket table.

Returns:
list[Token]

The list of tokens in the table.

get_target_token(other_end_node, additional_info_filters=None, policy='LRTF')[source]

Get a token having a specific other end node.

Parameters:
other_end_nodeint or list[int]

The other end node of the token to get. if a list is provided, the first token with a matching other end node is returned.

additional_info_filtersdict

A dictionary of filters to apply to the additional info of the token.

policystr

The policy to use when selecting the socket. Currently only “LRTF” (Longest Remaining Time First) is supported.

Returns:
Token or None

The socket descriptor with the specified other end node. None if not found

get_token(local_end, raise_error=True)[source]

Get a token from the table identified by the local_end. Does not remove it from the table.

Parameters:
local_endSocket

The local end of the token to get.

raise_errorbool

Whether to raise a ValueError if the token is not found. If False, the function will return None.

Returns:
Token or None

The token that was found. None if the token was not found and raise_error is False.

pop_token(local_end, raise_error=True)[source]

Pop a token from the table identified by the local_end. If the token is not found, a ValueError is raised.

Parameters:
local_endSocket

The local end of the token to pop.

raise_errorbool

Whether to raise a ValueError if the token is not found. If False, the function will return None.

Returns:
Token

The socket descriptor that was popped.

replace_token(local_end, new_token, raise_error=True)[source]

Replace a token in the table identified by its local end.

Parameters:
local_endSocket

The local end of the socket descriptor to replace.

new_tokenToken

The new descriptor to replace the old one with.

raise_errorbool

Whether to raise a ValueError if the socket is not found. If False, the function will return False.

Returns:
bool

Whether or not the socket was found and replaced.