progress.pqnet.p_module

This module contains the base class for all progress modules.

class progress.pqnet.p_module.Module(module_id, device_id, name, num_input, num_output, qhal=None)[source]

Bases: Node

This class is the base class for all progress modules. It is a node acting as a wrapper for its inner behavior, which is implemented in a class that inherits from ModuleBehavior.

Parameters:
module_idint

The id of the module.

device_idint

The id of the device that the module is running on.

namestr

The name of the module.

num_inputint

The number of input ports.

num_outputint

The number of output ports.

qhalQHAL or None, optional

A reference to the QHAL running on the device. If None, the QHAL must be set before starting the module.

Attributes:
module_idint

The id of the module.

device_idint

The id of the device that the module is running on.

qhalQHAL or None, optional

A reference to the QHAL running on the device. Should be set before starting the module.

behaviorModuleBehavior or None, optional

The behavior of the module. Should be set before starting the module.

environmentModuleEnvironment

The environment of the module. It is used to trigger events on the module behavior when needed.

num_inputint

The number of input ports for tokens. It matches the number of incoming edges of this module in the DAG.

num_outputint

The number of output ports for tokens. It matches the number of outgoing edges of this module in the DAG.

token_tableTokenTable

The token table to store and manage owned tokens.

start()[source]

Start the module behavior. Should be called after the qhal and behavior have been set.

stop()[source]

Stop the module behavior.

class progress.pqnet.p_module.ModuleBehavior(node, qnic=None, name=None)[source]

Bases: ServiceProtocol, ABC

This class is the base class for all module behaviors. It follows an event-driven approach, where the behavior is triggered by events. Such events are listed as the abstract methods of this class.

Parameters:
nodeModule

The module that this behavior is associated with.

qnicint or None, optional

If not None, the module will take as input tokens directly from that qnic’s token queue on its first input port. Defaults to None.

namestr or None, optional

The name of the behavior. If None, a default name is used. Defaults to None.

free_token(token)[source]

This method is called when a token is no longer needed and can be freed (together with the physical qubit).

Parameters:
tokenToken

The token to free.

abstract handle_message(request)[source]

This method is called when a classical message is received from another remote module.

Parameters:
requestreq_handle_message

The request containing the message to handle.

abstract handle_new_token(request)[source]

This method is called when a new token is received as input.

Parameters:
requestreq_handle_new_token

The request containing the new token to handle.

abstract handle_response(request)[source]

This method is called when a response to a previous request is received from the qhal.

Parameters:
requestreq_handle_response

The request containing the QHAL response to handle. The response contains the outcome and the originating request piggybacked.

class req_handle_collect_garbage

Bases: tuple

class req_handle_message(sender, message)

Bases: tuple

message

Alias for field number 1

sender

Alias for field number 0

class req_handle_new_token(token)

Bases: tuple

token

Alias for field number 0

class req_handle_response(response, request)

Bases: tuple

request

Alias for field number 1

response

Alias for field number 0

send_message(message, dest_device, dest_module_id)[source]

Send a classical message to another module.

Parameters:
messageMessage

The message to send.

dest_deviceint

The device ID of the destination device.

dest_module_idint

The module ID of the destination module.

start_entanglement_generation(qnic)[source]

Start the entanglement generation process on the given qnic.

Parameters:
qnicint

The qnic to start (or resume) the entanglement generation process on.

stop_entanglement_generation(qnic)[source]

Stop the entanglement generation process on the given qnic.

Parameters:
qnicint

The qnic to stop the entanglement generation process on.

terminate()[source]

Clean up actions before terminating.

token_is_present(token)[source]

Check if a token is mapped to a physical qubit.

Parameters:
tokenToken

The token to check.

Returns:
bool

True if the token is mapped to a physical qubit, False otherwise.

class progress.pqnet.p_module.ProcessingModuleBehavior(node, qnic=None, name=None)[source]

Bases: ModuleBehavior, ABC

This class is extended by those module behaviors that perform some local quantum operations on the input tokens. Processing modules can have either zero or one output ports, otherwise an exception is raised.

apply_qcircuit(tokens, qcircuit)[source]

Apply a custom quantum circuit to a token.

Parameters:
tokenslist of Token

The tokens to apply the circuit to.

qcircuitQuantumProgram

The quantum circuit to apply.

correct_token(token)[source]

Apply the correction circuit to a token to bring it back to \(\vert \phi^+ \rangle\) Bell state from another Bell state which is specified inside the token information.

Parameters:
tokenToken

The token to correct.

dejmps_tokens(token_a, token_b, role)[source]

Apply DEJMPS entanglement distillation (the quantum circuit part) on two tokens.

Parameters:
token_aToken

The token to distill.

token_bToken

The second token as distillation ancilla.

rolestr

The role of the module in the distillation process. Must be one of “A”, “B”. It determines the initial rotation of the protocol. If the role is “A”, the initial rotation is \(\pi/2\), otherwise it is \(-\pi/2\).

References

promote_token(token)[source]

Send out a token out from the output port (to the next module).

Parameters:
tokenToken

The token to promote.

swap_tokens(token_a, token_b)[source]

Swap two tokens.

Parameters:
token_aToken

The first token to swap.

token_bToken

The second token to swap.

class progress.pqnet.p_module.SchedulingModuleBehavior(node, qnic=None, name=None)[source]

Bases: ModuleBehavior, ABC

This class is extended by module behaviors that perform scheduling and routing operations on the input tokens.

promote_token(token, output_port=0)[source]

Send out a token from a specified port.

Parameters:
tokenToken

The token to promote.

output_portint, optional

The index of the output port to use. Defaults to 0.