Resource Manager

Definition of the Resource Manager.

This module defines the resource manager, which composes the SeQUeNCe resource management module. The manager uses a memory manager and rule manager to track memories and control entanglement operations, respectively. This module also defines the message type used by the resource manager.

class sequence.resource_management.resource_manager.ResourceManager(owner: QuantumRouter, memory_array_name: str)

Class to define the resource manager.

The resource manager uses a memory manager to track memory states for the entanglement protocols. It also uses a rule manager to direct the creation and operation of entanglement protocols.

name

label for manager instance.

Type:

str

owner

node that resource manager is attached to.

Type:

QuantumRouter

memory_manager

internal memory manager object.

Type:

MemoryManager

rule_manager

internal rule manager object.

Type:

RuleManager

pending_protocols

list of protocols awaiting a response for a remote resource request.

Type:

list[Protocol]

waiting_protocols

list of protocols awaiting a request from a remote protocol.

Type:

list[Protocol]

expire(rule: Rule) None

Method to remove expired rule.

Will update (remove) rule in rule manager. Will also update (remove) protocols connected to the rule (if they have already been created, and not finished yet).

Parameters:

rule (Rule) – rule to remove.

expire_rules_by_reservation(reservation: Reservation) None

expire rules created by the reservation

Parameters:

reservation – the rules created by this reservation will expire

generate_load_rules(path: list[str], reservation: Reservation, timecards: list[MemoryTimeCard], memory_array_name: str)

Generate and load rules for a given reservation.

Parameters:
  • path (list[str]) – path from the reservation’s initiator to responder.

  • reservation (Reservation) – the request’s reservation

  • timecards (list[MemoryTimeCard]) – timecards involved in the reservation at this node.

  • memory_array_name (str) – name of memory array component to use for rule conditions and actions at this node.

load(rule: Rule) bool

Method to load rules for entanglement management.

Attempts to add rules to the rule manager. Will automatically execute rule action if conditions met on a memory.

Parameters:

rule (Rule) – rule to load.

Returns:

if rule was loaded successfully.

Return type:

bool

memory_expire(memory: Memory)

Method to receive memory expiration events.

received_message(src: str, msg: ResourceManagerMessage) None

Method to receive resource manager messages.

Messages come in 4 types, as detailed in the ResourceManagerMessage class.

Parameters:
release_remote_memory(dst: str, memory_id: str) None

Method to release memories on distant nodes.

Release the remote memory ‘memory_id’ on the node ‘dst’. The entanglement protocol of remote memory was paired with the local protocol ‘init_protocol’, but local protocol becomes invalid. The resource manager needs to notify the remote node to release the occupied memory.

Parameters:
  • dst (str) – name of destination node.

  • memory_id (str) – name of memory to release.

release_remote_protocol(dst: str, protocol: str) None

Method to release protocols from memories on distant nodes.

Release the remote protocol ‘protocol’ on the remote node ‘dst’. The local protocol was paired with the remote protocol but local protocol becomes invalid. The resource manager needs to notify the remote node to cancel the paired protocol.

Parameters:
  • dst (str) – name of the destination node.

  • protocol (str) – name of protocol to release on node.

send_request(protocol: EntanglementProtocol, req_dst: str | None, req_condition_func: Callable[[list[EntanglementProtocol]], EntanglementProtocol], req_args: dict[str, Any])

Method to send protocol request to another node.

Send the request to pair the local ‘protocol’ with the protocol on the remote node ‘req_dst’. The function req_condition_func describes the desired protocol.

Parameters:
  • protocol (EntanglementProtocol) – protocol sending the request.

  • req_dst (str) – name of destination node.

  • req_condition_func (Callable[[list[EntanglementProtocol]], EntanglementProtocol]) – function used to evaluate condition on distant node.

  • req_args (dict[str, Any]) – arguments for req_cond_func.

update(protocol: EntanglementProtocol | None, memory: Memory, state: str) None

Method to update state of memory after completion of entanglement management protocol.

Parameters:
  • protocol (EntanglementProtocol) – concerned protocol. If not None, then remove all references.

  • memory (Memory) – memory to update.

  • state (str) – new state for the memory.

Side Effects:

May modify memory state, and modify any attached protocols.

class sequence.resource_management.resource_manager.ResourceManagerMessage(msg_type: ResourceManagerMsgType, **kwargs)

Message for resource manager communication.

There are four types of ResourceManagerMessage:

  • REQUEST: request eligible protocols from remote resource manager to pair entanglement protocols.

  • RESPONSE: approve or reject received request.

  • RELEASE_PROTOCOL: release the protocol on the remote node

  • RELEASE_MEMORY: release the memory on the remote node

ini_protocol_name

name of protocol that creates the original REQUEST message.

Type:

str

ini_node_name

name of the node that creates the original REQUEST message.

Type:

str

ini_memories_name

name of the memories.

Type:

str

request_fun

a function using ResourceManager to search eligible protocols on remote node (if msg_type == REQUEST).

Type:

func

is_approved

acceptance/failure of condition function (if msg_type == RESPONSE).

Type:

bool

paired_protocol

protocol that is paired with ini_protocol (if msg-type == RESPONSE).

Type:

str

class sequence.resource_management.resource_manager.ResourceManagerMsgType(*values)

Available message types for the ResourceManagerMessage.