netqasm.backend.executor
NetQASM execution interface for simulators.
This module provides the Executor class which can be used by simulators as a base class for executing NetQASM instructions.
- class netqasm.backend.executor.EprCmdData(subroutine_id, ent_results_array_address, q_array_address, request, tot_pairs, pairs_left)
Bases:
objectContainer for info about EPR pending requests.
- Parameters:
subroutine_id (
int)ent_results_array_address (
int)q_array_address (
Optional[int])request (
Optional[LinkLayerCreate])tot_pairs (
int)pairs_left (
int)
-
subroutine_id:
int
-
ent_results_array_address:
int
-
q_array_address:
Optional[int]
-
request:
Optional[LinkLayerCreate]
-
tot_pairs:
int
-
pairs_left:
int
- netqasm.backend.executor.inc_program_counter(method)
Decorator that automatically increases the current program counter.
Should be used on functions that interpret a single NetQASM instruction.
- class netqasm.backend.executor.Executor(name=None, instr_log_dir=None, **kwargs)
Bases:
objectBase class for entities that execute NetQASM applications.
An Executor represents the component in a quantum node controller that handles the registration and execution of NetQASM applications. It can execute NetQASM subroutines by interpreting their instructions.
This base class provides handlers for classical NetQASM instructions. These are methods with names _instr_XXX. Methods that handle quantum instructions are a no-op and should be overridden by subclasses. Entanglement instructions are handled and forwarded to the network stack.
- Parameters:
name (
Optional[str])instr_log_dir (
Optional[str])
- instr_logger_class
alias of
InstrLogger
- __init__(name=None, instr_log_dir=None, **kwargs)
Executor constructor.
- Parameters:
name (
Optional[str]) – name of the executor for logging purposes, defaults to Noneinstr_log_dir (
Optional[str]) – directory to log instructions to, defaults to None
- property name: str
Get the name of this executor.
- Returns:
name
- property node_id: int
Get the ID of the node this Executor runs on
- Raises:
NotImplementedError – This should be overridden by a subclass
- Returns:
ID of the node
- set_instr_logger(instr_log_dir)
Let the executor use an instruction logger that logs to instr_log_dir
- Parameters:
instr_log_dir (
str) – path to the log directory- Return type:
None
- classmethod get_instr_logger(node_name, instr_log_dir, executor, force_override=False)
- Parameters:
node_name (
str)instr_log_dir (
str)executor (
Executor)force_override (
bool)
- Return type:
- property network_stack: BaseNetworkStack | None
Get the network stack (if any) connected to this Executor.
- Returns:
the network stack
- init_new_application(app_id, max_qubits)
Register a new application.
- Parameters:
app_id (
int) – App ID of the application.max_qubits (
int) – Maximum number of qubits the application is allowed to allocate at the same time.
- Return type:
None
- setup_epr_socket(epr_socket_id, remote_node_id, remote_epr_socket_id)
Instruct the Executor to open an EPR Socket.
The Executor forwards this instruction to the Network Stack.
- Parameters:
epr_socket_id (
int) – ID of local EPR socketremote_node_id (
int) – ID of remote noderemote_epr_socket_id (
int) – ID of remote EPR socket
- Yield:
[description]
- Return type:
Generator[Any,None,None]
- stop_application(app_id)
Stop an application and clear all qubits and classical memories.
- Parameters:
app_id (
int) – ID of the application to stop- Yield:
[description]
- Return type:
Generator[Any,None,None]
- consume_execute_subroutine(subroutine)
Consume the generator returned by execute_subroutine.
- Parameters:
subroutine (
Subroutine) – subroutine to execute- Return type:
None
- execute_subroutine(subroutine)
Execute a NetQASM subroutine.
This is a generator to allow simulators to yield at certain points during execution, e.g. to yield control to a asynchronous runtime.
- Parameters:
subroutine (
Subroutine) – subroutine to execute- Yield:
[description]
- Return type:
Generator[Any,None,None]
- allocate_new_qubit_unit_module(app_id, num_qubits)
- Parameters:
app_id (
int)num_qubits (
int)
- Return type:
None