Action Condition Set

This provides actions, condition, and request functions for generation, purification, and swapping to be used by the resource manager.

## Function Descriptions

  1. Action: an action function defines what action is taken when a rule condition is met.

    This includes creating an instance of the relevant protocol.

  2. Condition: a condition function states requirements that must be met on the local node before a rule can execute.

    Conditions

  3. Match: a match function states requirements on what protocols may be paired during the request handshake in the resource manager.

    Paired protocols coordinate the execution of a specific entanglement primitive (generation, purification, or swapping).

## Function Signatures

Action Signature: def action(memories_info: MemoryInfo, args: Arguments) -> ActionReturn - Args:

  • memories_info: a list of MemoryInfo objects that satisfy the corresponding condition function

  • args: other arguments specific to each action function

  • Returns:
    • ActionReturn: a tuple of (protocol, destination, request_func, request_args)
      • protocol: the protocol to be paired and executed

      • destination: the destination(s) of the request, or None if the protocol does not send a request

      • request_func: the request function to be used, or None if the protocol does not send a request

      • request_args: the arguments for the request function

Condition Signature: def condition(memory_info: MemoryInfo, manager: MemoryManager, args: Arguments) -> list[MemoryInfo] - Args:

  • memory_info: the MemoryInfo object to be checked

  • manager: the memory manager of the local, to get other memory info from if necessary

  • args: other arguments specific to each condition function

  • Returns:
    • list[MemoryInfo]: a list of MemoryInfo objects that satisfy the condition.

Match Signature: def request(protocols: list[EntanglementProtocol], args: Arguments) -> EntanglementProtocol | None - Args:

  • protocols: the list of protocols awaiting pairing on the remote node receiving the request

  • args: other arguments specific to each request function

  • Returns:
    • EntanglementProtocol | None: the protocol to pair on the other node, or None if no protocol is selected

Actions, Conditions, and Match Functions must follow the above signatures. If a function does not use a parameter, it should prefix the unused parameter with _. For example, _manager should be used for a Condition function if the memory manager is not required.

sequence.resource_management.action_condition_set.eg_match_func(protocols: list[EntanglementProtocol], args: dict[str, Any]) EntanglementGenerationA | None

Function used by eg_rule_action_request function for selecting generation protocols on the remote node.

Parameters:
  • protocols – protocols awaiting pairing on the node receiving the request

  • args – arguments from the node which sent the request

Returns:

the protocol to pair on the other node, or None if no protocol is selected.

Return type:

EntanglementGenerationA | None

sequence.resource_management.action_condition_set.eg_rule_action_await(memories_info: list[MemoryInfo], args: Arguments) ActionReturn

Action function used to create an entanglement generation protocol instance and await a Resource Manager request.

Rules with this action are created on all nodes other than the initiator, i.e., where args[‘index’] > 0. The initiator node always creates a request using eg_rule_action_request.

Parameters:
  • memories_info – the list of memory info that satisfy the condition function

  • args – the arguments defined in the rule; should contain “mid”, “path”, and “index”

Returns:

the protocol to be executed, None, None, None.

(this protocol does not send a Resource Manager request, but waits for a request from another node)

Return type:

ActionReturn

sequence.resource_management.action_condition_set.eg_rule_action_request(memories_info: list[MemoryInfo], args: Arguments) ActionReturn

Action function used to create an entanglement generation protocol instance and send a Resource Manager request.

Rules with this action are created on all nodes other than the responder, i.e., where args[‘index’] < len(args[‘path’]) - 1. The responder always awaits a request using eg_rule_action_await.

Parameters:
  • memories_info – the list of memory info that satisfy the condition function

  • args – the arguments defined in the rule. Should contain “mid” (the name of the corresponding BSM node), “path”, and “index” (the index of the current node in the path).

Returns:

the protocol to be executed, the destination of the request, the request function,

and the arguments for request function

Return type:

ActionReturn

sequence.resource_management.action_condition_set.eg_rule_condition(memory_info: MemoryInfo, _manager: MemoryManager, args: Arguments) list[MemoryInfo]

Condition function used by entanglement generation protocol on nodes.

Parameters:
  • memory_info – the memory info to be checked

  • _manager – the memory manager (not used in this condition function)

  • args – the arguments defined in the rule

Returns:

the list of MemoryInfo that satisfy the condition

Return type:

list[MemoryInfo]

sequence.resource_management.action_condition_set.ep_match_func(protocols: list[EntanglementProtocol], args: dict[str, Any]) BBPSSWProtocol | None

Function used by ep_rule_action_request for selecting purification protocols on the remote node.

Note that only one memory will be assigned to each protocol instance within the ep_rule_action_await function; when two memories (protocols) are matched to the requesting protocol, both memories will be reassigned to one protocol instance and the other will be removed.

Parameters:
  • protocols (list) – a list of waiting protocols

  • args (dict) – the arguments for the match function. Should contain “remote_kept” (the kept memory on the remote node) and “remote_meas” (the measured memory on the remote node).

Returns:

the protocol to pair on the other node (or None if no protocol is selected).

Return type:

BBPSSWProtocol | None

sequence.resource_management.action_condition_set.ep_rule_action_await(memories_info: list[MemoryInfo], _args: Arguments) ActionReturn

Action function used to create an entanglement purification protocol instance and await a Resource Manager request.

Rules with this action are created on all nodes other than the responder, i.e., where args[‘index’] < len(args[‘path’]) - 1. The responder node always creates a request using ep_rule_action_request.

Parameters:
  • memories_info – the list of memory info that satisfy the condition function

  • _args – the arguments defined in the rule (not used in this action function)

Returns:

the protocol to be executed, None, None, None.

(this protocol does not send Resource Manager request, but wait for the request from the other node)

Return type:

ActionReturn

sequence.resource_management.action_condition_set.ep_rule_action_request(memories_info: list[MemoryInfo], _args: Arguments) ActionReturn

Action function used to create an entanglement purification protocol instance and send a Resource Manager request.

Rules with this action are created on all nodes other than the initiator, i.e., where args[‘index’] > 0. The initiator node always creates a request using ep_rule_action_await.

Parameters:
  • memories_info – the list of memory info that satisfy the condition function

  • _args – the arguments defined in the rule (not used in this action function)

Returns:

the protocol to be executed, the destination of the request, the request function,

and the arguments for request function

Return type:

ActionReturn

sequence.resource_management.action_condition_set.ep_rule_condition_await(memory_info: MemoryInfo, _manager: MemoryManager, args: Arguments) list[MemoryInfo]

Condition function used by BBPSSW protocol on nodes except the responder (see ep_rule_action_await).

Parameters:
  • memory_info – the memory info to be checked

  • _manager – the memory manager to get other memory info (not used in this condition function)

  • args – the arguments defined in the rule should contain “memory_indices”, “fidelity”, and “purification_mode”

Returns:

the list of memory info that satisfy the condition.

Return type:

list[MemoryInfo]

sequence.resource_management.action_condition_set.ep_rule_condition_request(kept_memory: MemoryInfo, memory_manager: MemoryManager, args: Arguments) list[MemoryInfo]

Condition function used by BBPSSW protocol on nodes except the initiator (see ep_rule_action_request).

Parameters:
  • kept_memory – the memory info to be checked

  • memory_manager – the memory manager of the local ndoe, used to get other memory info

  • args – the arguments defined in the rule. Sould contain “memory_indices”, “fidelity”, and “purification_mode”.

Returns:

a list of two memory infos (kept_memory and measured_memory) that satisfy the condition

for purification.

Return type:

list[MemoryInfo]

sequence.resource_management.action_condition_set.es_match_func(protocols: list[EntanglementProtocol], args: dict[str, Any]) EntanglementSwappingB | None

Function used by es_rule_action_A for selecting swapping protocols on the remote node.

Parameters:
  • protocols (list) – a list of waiting protocols

  • args (dict) – the arguments defined in the rule. Should contain “target_memo”.

Returns:

the protocol to pair on the other node (or None if no protocol is selected).

Return type:

EntanglementSwappingB | None

sequence.resource_management.action_condition_set.es_rule_action_A(memories_info: list[MemoryInfo], _args: Arguments) ActionReturn

Action function used to create an EntanglementSwappingA protocol instance on all interior nodes.

Interior nodes of a path are the nodes that are neither the initiator nor the responder.

Since EntanglementSwappingA is always at the center of a swapping attempt, it cannot be located on the initiator

or responder node.

es_rule_action_A additionally initiates the resource manager request for entanglement swapping.

Parameters:
  • memories_info – a list of memory info

  • _args – the arguments defined in the rule (not used in this action function)

Returns:

the protocol to be executed, the destination of the request, the request function,

and the arguments for request function

Return type:

ActionReturn

sequence.resource_management.action_condition_set.es_rule_action_B(memories_info: list[MemoryInfo], _args: Arguments) ActionReturn

Action function used to create an EntanglementSwappingB protocol instance on all nodes.

es_rule_action_B always awaits the resource manager request for entanglement swapping.

Parameters:
  • memories_info – a list of memory info

  • _args – the arguments defined in the rule (not used in this action function)

Returns:

the protocol to be executed, None, None, None

(this protocol does not send a Resource Manager request, but will wait for the request from the other node)

Return type:

ActionReturn

sequence.resource_management.action_condition_set.es_rule_condition_A(memory_info: MemoryInfo, memory_manager: MemoryManager, args: Arguments) list[MemoryInfo]

Condition function used for the EntanglementSwappingA protocol on all interior nodes (see es_rule_action_A).

Parameters:
  • memory_info – the memory info to be checked

  • memory_manager – the memory manager to get other memory info

  • args – the arguments defined in the rule. Should contain “memory_indices”, “left”, “right”, and “fidelity”

Returns:

a list of two memory info (memory_info, memory_info_2) that satisfy the condition

Return type:

list[MemoryInfo]

sequence.resource_management.action_condition_set.es_rule_condition_B(memory_info: MemoryInfo, _manager: MemoryManager, args: Arguments) list[MemoryInfo]

Condition function used by the EntanglementSwappingB protocol on interior nodes of a path.

Parameters:
  • memory_info – the memory info to be checked

  • _manager – the memory manager to get other memory info (not used in this condition function)

  • args – the arguments defined in the rule. Should contain “memory_indices”, “left”, “right”, and “fidelity”.

Returns:

the list of memory info that satisfy the condition

Return type:

list[MemoryInfo]

sequence.resource_management.action_condition_set.es_rule_condition_B_end(memory_info: MemoryInfo, _manager: MemoryManager, args: Arguments) list[MemoryInfo]

Condition function used by the EntanglementSwappingB protocol on either the responder or initiator nodes.

Parameters:
  • memory_info – the memory info to be checked

  • _manager – the memory manager to get other memory info (not used in this condition function)

  • args – the arguments defined in the rule. Should contain “memory_indices”, “target_remote”, and “fidelity”.

Returns:

the list of memory info that satisfy the condition

Return type:

list[MemoryInfo]