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.
- qhal
QHAL
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.
- qhal
QHAL
or None, optional A reference to the QHAL running on the device. Should be set before starting the module.
- behavior
ModuleBehavior
or None, optional The behavior of the module. Should be set before starting the module.
- environment
ModuleEnvironment
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_table
TokenTable
The token table to store and manage owned tokens.
- 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:
- node
Module
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.
- node
- 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:
- token
Token
The token to free.
- token
- abstract handle_message(request)[source]
This method is called when a classical message is received from another remote module.
- Parameters:
- request
req_handle_message
The request containing the message to handle.
- request
- abstract handle_new_token(request)[source]
This method is called when a new token is received as input.
- Parameters:
- request
req_handle_new_token
The request containing the new token to handle.
- request
- abstract handle_response(request)[source]
This method is called when a response to a previous request is received from the qhal.
- Parameters:
- request
req_handle_response
The request containing the QHAL response to handle. The response contains the outcome and the originating request piggybacked.
- request
- 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_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:
- message
Message
The message to send.
- dest_deviceint
The device ID of the destination device.
- dest_module_idint
The module ID of the destination module.
- message
- 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.
- 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.
- qcircuit
QuantumProgram
The quantum circuit to apply.
- tokenslist of
- 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:
- token
Token
The token to correct.
- token
- dejmps_tokens(token_a, token_b, role)[source]
Apply DEJMPS entanglement distillation (the quantum circuit part) on two tokens.
- Parameters:
- token_a
Token
The token to distill.
- token_b
Token
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\).
- token_a
References
- 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.