progress.abstraction.qhal
This module contains the Quantum Hardware Abstraction Layer implementation.
- class progress.abstraction.qhal.EntanglementHandlerProtocol(node, name=None)[source]
Bases:
NodeProtocol
- run(self)[source]
Generator or function that runs the protocol.
Starting the protocol will execute this function. If a generator it will run it up to the first yield. All yields should return a
EventExpression
, the generator will only continue when the expression has been triggered.If a function is returned, this protocol may still yield on the generator of its sub-protocols.
Sub-protocols are not started automatically when this method is overridden. Either start them manually in the overridden run() or call start_subprotocols() to start them all at once.
- Returns:
- Any
If this method returns a generator, then the final return of the generator will be set as the value of
FINISHED
.
- class progress.abstraction.qhal.QHAL(device_id, name, qhardware)[source]
Bases:
Node
The Quantum Hardware Abstraction Layer of an SDQN device.
- Parameters:
- device_idint
The ID of the SDQN device (parent node)
- namestr
The name of this node.
- qhardware
QHardware
A reference to the QHardware placed in the same device (for easy access to its services).
Notes
- Ports:
“q_ops” (input): The port on which the Physical layer sends responses and outcomes for quantum operations.
“new_entanglement” (input): The port on which the link layer protocols send signals about new entanglement.
“tokens_ops” (input): The port on which the NET layer sends requests for token operations.
“token_out_{i}” (output): The port on which the QHAL sends tokens to the NET layer. The index of the port is the index of the QNIC token queue it is connected to.
- Attributes:
- qhardware
QHardware
A reference to the quantum hardware placed in the same device.
- token_api_service
QuantumOperationsService
The token operations service of the QHardware. It is used to request quantum operations with a hardware-independent interface.
- entanglement_handler
EntanglementHandlerProtocol
The entanglement handler protocol of this QHAL. It is responsible for processing signals sent by the link layer protocols and allocating tokens in the queues for the NET layer.
- token_out_portslist[
netsquid.components.Port
] A shortcut to the output ports of this module. Each port is used to send tokens to the NET layer from a specific QNIC queue. The index of the port in the list is the index of the QNIC it is connected to.
- socket_tablecollections.deque
A table that keeps track of all tokens currently allocated. The table is implemented as a deque with a fixed size.
- qhardware
- qhardware
A reference to the quantum hardware (
QHardware
) placed in the same device.
- class progress.abstraction.qhal.TokenOperationsService(node, name=None)[source]
Bases:
ServiceProtocol
The Token Operations Service is a service protocol that handles the requests for token operations. An instance is automatically loaded in each QHAL node.
- Parameters:
- node
QHAL
The QHAL node.
- namestr or None, optional
The name of the service protocol. If None, the name will be set to “Token Operations Service”.
- node
Notes
The requests types exposed by this service (see Attributes) are very important as they compose the unified interface for hardware-independent quantum operations.
- Attributes:
req_free
collections.namedtuplereq_free(token,)
req_swap
collections.namedtuplereq_swap(id, token1, token2)
req_dejmps
collections.namedtuplereq_purify(id, token1, token2, role)
req_qcirc
collections.namedtuplereq_qcirc(id, tokens, qcirc)
- free(token)[source]
Free a token from memory. Also free the physical qubit.
- Parameters:
- token
Token
The token to free.
- token
- handle_request(request, identifier, start_time=None, **kwargs)[source]
Schedule the request on the queue.
- Parameters:
- request
The object representing the request.
- identifierstr
The identifier for this request.
- start_timefloat, optional
The time at which the request can be executed. Default current simulation time. [ns]
- kwargsdict, optional
Additional arguments which can be set by the service.
- Returns:
- dict
The dictionary with additional arguments.
Notes
This method is called after
put()
which does the type checking etc.
- class req_correct(id, token)
Bases:
tuple
Request to correct a token. The token is in a custom Bell state, which is represented by an integer between 0 and 3. The token is corrected to the Bell state \(\vert \beta_{00} \rangle\).
- Parameters:
id (int): The id of the requesting module. token (
Token
): The token to correct.
- id
Alias for field number 0
- token
Alias for field number 1
- req_dejmps
Request to perform DEJMPS distillation on two tokens. The first one is the one distilled, the second one is used as ancilla. The “role” field is used to determine which rotation to apply (pi/2 or -pi/2), and can assume two values, either ‘A’ (pi/2) or ‘B’ (-pi/2).
- Parameters:
id (int): The id of the requesting module. token1 (
Token
): The first token to distill. token2 (Token
): The second token to distill. role (str): The role of this device in the distillation. Can be either ‘A’ or ‘B’.
alias of
req_purify
- class req_free(token)
Bases:
tuple
Request to free a token from memory.
- Parameters:
token (
Token
): The token to free.
- token
Alias for field number 0
- class req_qcirc(id, tokens, qcirc)
Bases:
tuple
Request to perform a generic quantum circuit on a list of tokens. When the circuit is executed, the measurement outcomes are sent out from the port tokens_ops. If some tokens are measures, they have to be freed afterwards with a req_free request.
- Parameters:
id (int): The id of the requesting module. tokens (list of
Token
): The list of tokens in input to the quantum operation. qcirc (netsquid.components.qprocessor.QuantumProgram
): The quantum program to execute.
- id
Alias for field number 0
- qcirc
Alias for field number 2
- tokens
Alias for field number 1
- class req_swap(id, token1, token2)
Bases:
tuple
Request to perform entanglement swapping on two tokens.
- Parameters:
id (int): The ID of the requesting module. token1 (
Token
): The first token to swap. token2 (Token
): The second token to swap.
- id
Alias for field number 0
- token1
Alias for field number 1
- token2
Alias for field number 2
- run()[source]
Wait for a new request signal, then run the requests one by one.
Assumes request handlers are generators and not functions.
References
See
netsquid.protocols.Protocol.run()
.
- token_has_socket(token, raise_error=True)[source]
Check if a token is present in the socket table of the QHAL.
- Parameters:
- token
Token
The token to check.
- raise_errorbool
If True, raise an error if the token is not present in the socket table. Default is True.
- token
- Returns:
- bool
True if the token is present in the socket table, False otherwise. Only significant if raise_error is False.