Skip to content

Latest commit

 

History

History
649 lines (533 loc) · 15.1 KB

2.2.RuleSetSpec.md

File metadata and controls

649 lines (533 loc) · 15.1 KB

RuleSet Specification

Table of contents

Abstract

TBD

Introduction

TBD

RuleSet

RuleSet contains a set of meta information and Rules.

Meta

⚠️ (Under construction)

types are all json serializable type

  • ruleset_id (integer | string?): A unique value that identifies the connection. RuleSets in the path share the same ruleset_id.
  • owner_address (string): An identifier of the owner of the RuleSet. Typically, this value could be IP address or host name of the repeaters.
  • num_stages (integer): The number of stages that are contained in a RuleSet.
  • ?checksum (string?): A value to validate there is no unexpected changes in the RuleSet.

Body

  • stages (list[Stage]): A set of Stages that are executed one by one from top to bottom.

Stage

Stage is a set of Rules and the only one Rule in a Stage can be executed at one time.

Meta

⚠️ (Under construction)

  • stage_id (integer): An index of stage to tell which stage is now operated.
  • Anything else?

Body

  • rules (list[Rule]): A set of Rules that are evaluated and only one Rule is executed at one time.

Constraints

⚠️ (Under construction)

If there are multiple Rules whose condition is satisfied, only the first Rule is executed.

Rule

Rule is a unit of execution that contains a set of conditions and corresponding actions.

Meta

⚠️ (Under construction)

  • rule_id (integer): An index to identify Rules.
  • name (string): Human readable name of the Rule for debugging
  • send_tag (integer): Identify which Rule receives the message this Rule send
  • receive_tag (integer): A tag to identify the message to be assigned to this Rule

Body

  • condition (Condition): A set of condition clauses to be met
  • action (Action): A set of action clauses to be performed

Do we need to make this Condition instread of list[ConditionClause]?
Do we have meta info for condition and action?

Condition

A condition that contains a set of condition clauses

Meta

  • name (string): A name of this condition for debugging
  • ?num_clauses (integer): The number of conditions to be met

Body

  • condition_clauses (list [ConditionClause]): A set of condition clauses to be evaluated.

Action

An action that contains a set of action clauses

Meta

  • name (string): A name of this action for debugging
  • ?num_clauses (integer): The number of actions to be met

Body

  • action_clauses (list[ActionClause]): A set of action clauses to be evaluated

ConditionClause

Meta

  • name (string): A name of the instruction (e.g. RES, NEW)

Body

  • arguments Arguments to be provided to the instruction.
  • alias (list[string]): If there are return values, from the condition clauses, these values are refered to with these names.

Instruction Set

The following instructions are provided by Rule Engine or RuleSet Runtime as API functions to check the current status of the resources and devices.

⚠️ (Under construction)

  • RES
  • RESBYNAME
  • ANC
  • CMP
  • RECV
  • TIMER

RES

Refer to the resources promoted in the previous stage.

  • Arguments:
    • resource_type (string): a type of resource such as "Bell", "GHZ"
    • num_resource (integer): The number of required resources
    • partner_addresses (list[string]): The list of target partner addresses
  • Alias
    • qubits (list[string]): A set of alias names to refer to the qubits in the action

Example: RES("GHZ", 3, "0.0.0.0") -> ["q1", "q2", "q3"]

{
    // Instructio name `RES`
    "name": "RES",
    "arguments":{
        "resource_type": "GHZ",
        "num_resource": 3,
        "partner_address": "0.0.0.0"
    },
    "alias":{
        "qubits":[
            "q1",
            "q2",
            "q3",
        ]
    }
}

RESBYNAME

Get a resource by its name.

  • Arguments
    • resource_name (string): The name of resource
  • Alias
    • resource_name (string): The name of resource but used as an alias in this Rule

Need this?

Example: RESBYNAME("promoted_qubit") -> "promoted_qubit"

{
  "name": "RESBYNAME",
  "arguments": {
    "resource_name": "promoted_qubit"
  },
  "alias": {
    "resource_name": "promoted_qubit"
  }
}

ANC

Prepare for ancilla qubits for logical qubits

  • Arguments:
    • num_resource (integer): The number of required ancilla qubits
  • Alias
    • qubits (list [string]): A set of alias names to refer to the qubits in the action

Example: ANC(3) -> ["q1", "q2", "q3"]

{
    "name": "ANC",
    "arguments": {
        "num_resource": 4
    },
    "alias":{
        "qubits": [
            "q1",
            "q2",
            "q3"
        ]
    }
}

CMP

Compare a variable to a value. If there is no value found in the RuleSet process, return error.

  • Arguments:
    • variable (string): A target variable to be compared
    • operation (string): A comparison operation to compare target and value
    • value (string | integer): A value to compare with
  • Alias
    • None

Example CMP("meas_count", "=", 1000)

{
    "name": "CMP",
    "arguments": {
        // a variable registered by `SET` instruction
        "variable": "measure_count",
        "operation": "=",
        "value": 1000
    },
    "alias": {

    }
}

RECV

Check if a message exists and take the message if it exists. The receive_tag defined in meta information of Rule is used here. ❓

  • Arguments:
    • source_address (string): A partner address that sends a message to this repeater.
  • Alias
    • message (string): An identifier to manipulate the received message

Example RECV("192.168.0.1") -> "msg"

{
    "name": "RECV",
    "arguments": {
        "source_address": "192.168.0.1"
    },
    "alias": {
        "message": "msg"
    }
}

Is the receive_tag used here?
This is similar to the current Wait clause, but possible to specify which message

TIMER

Check if a timer is expired or not

  • Arguments:
    • timer_id (string): An identifier for the timer ❓
  • Alias
    • None

Example TIMER("timer1")

{
    "name": "TIMER",
    "arguments": {
        "timer_id": "timer1"
    },
    "alias": {}
}

Which layer keep the timer? RuleEngine? If the timer expires but still executing prvious rules what happen?

Action Clause

⚠️ (Under construction) Action clauses are performed one by one when all the conditions are met.

Meta

  • name (string): A name of the instruction (e.g. QCIRC, SEND)

Body

  • arguments Arguments to be provided to the instruction.
  • alias (list[string]): If there are return values, from the condition clauses, these values are refered to with these names.

Instruction Set

  • QCIRC
    • QGATE
  • MEAS
  • SET
  • GET
  • SETTIMER
  • PROMOTE
  • FREE
  • SEND
    • MSG

QCIRC

Perform quantum operations to the qubits.

  • Arguments:
    • circ_qubits (list[string]): A list of qubit identifier that are defined in the condition clauses.
    • qgates: (list[QGate]): A set of gate operation with quantum gate annotation.
  • Alias:
    • None

Example QCIRC(["q1", "q2"], [QGATE1...])

{
    "name": "QCIRC",
    // qubit identifier defined in the conditions
    "arguments": {
        "circ_qubits": ["q1", "q2"],
        "qgates": [
            {
                "name": "QGATE",
                "arguments": {
                    "operation": "H",
                    "control_qubit": null,
                    "target_qubit": "q1"
                    }
            },
        //... 
        ]
    },
    "alias": {}
}

QGATE

A gate operation for qubits. QGATE can only be defined in QCIRC

  • Arguments:
    • operation (string): A name of the operation such as "H", "CX"
    • control_qubit (string | null): An identifier for a control qubits used in two qubit gates
    • target_qubit (string): An identifier for a qubit for this operation

Example QGATE("X", None, "qubit")

{
    "name": "QGATE",
    "arguments":{
        "operation": "X",
        "control_qubit": null,
        "target_qubit": "qubit"
    },
    "alias": {}
}

Example QGATE("CX", "q1", "q2")

{
    "name": "QGATE",
    "arguments": {
        "operation": "CX",
        "control_qubit": "q1",
        "target_qubit": "q2"
    },
    "alias": {}
}

MEAS

A measurement operation to read out the qubit information.

  • Arguments
    • basis (string): A bais of the measurement (e.g. "X", "Z")
    • target_qubit (string): An identifier for the qubit to be measured.
  • Alias
    • result (string): A name that referes to this measurement result

Example MEAS("X", "qubit") -> "meas_result"

{
    "name": "MEAS",
    "arguments": {
        "basis": "X",
        "target_qubit": "qubit"
    },
    "alias": {
        "result": "meas_result"
    }
}

could have arbitrary angle for the basis?

SET

Register a local variable (its scope is closed to a Rule) as a global variable.

  • Arguments
    • variable (string): A local variable defined in a Rule
    • ref_name (string): A unique name to make a reference to this value (used in GET instruction)
  • Alias
    • None

Example SET("measurement_count", "mc")

{
    "name": "SET",
    "arguments": {
        // A variable defined in the condition
        "variable": "measurement_count",
        // A later Rules can refere this value by "mc"
        "ref_name": "mc"
    },
    "alias": {}
}

GET

Get a global variable registered by SET instruction

  • Arguments
    • ref_name (string): A name of the target value set by SET instruction.
  • Alias
    • local_name (string): A name that can be used in the same Rule

Example GET("mc") -> "meas_count"

{
    "name": "GET",
    "arguments": {
        "ref_name": "mc"
    },
    "alias": {
        "local_name": "meas_count"
    }
}

SETTIMER

Set a timer with a timer id. The unit of timer is nano second (ns)

  • Arguments
    • nano_sec (integer): A timer in nano second
    • timer_id (string): An identifier for the timer
  • Alias
    • None

Do we need other units (sec, microsec, ...)? Example SETTIMER(100, "notification_timer")

{
    "name": "SETTIMER",
    "arguments": {
        // Timer expires in 100 sec
        "nano_sec": 100,
        "timer_id": "notification_timer"
    },
    "alias": {}
}

PROMOTE

Promote a qubit to the next stage.

  • Arguments
    • qubit_refs (list[string]): A set of the names of qubits to be promoted.
    • stage_id (integer): The stage identifier defined in Stage meta.
  • Alias
    • None

Example PROMOTE(["qubit1"], 2)

{
    "name": "PROMOTE",
    "arguments": {
        "qubit_refs": "qubit1",
        "stage_id": 2
    },
    "alias":{}
}

FREE

Free the consumed qubits

  • Arguments
    • qubit_ref (list[string]): A set of qubit identifiers to be freed
  • Alias
    • None

Example FREE(["q1", "q2"])

{
    "name": "FREE",
    "arguments": {
        "qubit_refs": ["q1", "q2"]
    },
    "alias": {}
}

SEND

Send a protocol message to another quantum repeater.

  • Arguments
    • destination (string): Address of the partner
    • message (MSG): A content of the message to be sent
    • dst_stg_id (integer): The id of the destination stage
  • Alias
    • None

Example SEND("0.0.0.0", <MSG>)

{
    "name": "SEND",
    "dst_stg_id": 10,
    "arguments": {
        "destination": "0.0.0.0",
        "message": {
            "name": "MEASRES",
            //...
        }
    }
}

MSG

A protocol message to be sent. This is a basis class of following protcol messages.

How to read out the message and make conditions with it?

MSGMEAS(MSG)

A message that contains a measurement results

  • Arguments
    • meas_result_ref (string): The reference to the measurement result. This might contains information about result, basis, timestamp, qubit address, etc.

Example MSGMEAS("meas_result")

{
    "name": "MSGMEAS",
    "arguments": {
        // An alias to the previous measurement results
        "meas_result_ref": "meas_result"
    }
}

Note how to resolve resource names later

MSGFREE(MSG)

A message to request free a remote resource

  • Arguments
    • qubit_refs (list[string]): Identifiers for the qubits. Internally, these names are translated into addresses and corresponding partner qubits would be freed.

Example MSGFREE("qubit")

{
    "name": "MSGFREE",
    "arguments": {
        "qubit_ref": ["qubit"]
    }
}

MSGUPDATE(MSG)

A message to notify the Pauli correction to the partner node.

  • Arguments
    • qubit_refs (list[string]): A set of reference to the qubits.
    • pauli_corrections (list[string]): A list of pauli corrections.

Example MSGUPDATE(["qubit1", "qubit2"], ["X", "Z"])

{
    "name": "MSGUPDATE",
    "arguments": {
        "qubit_ref": ["qubit1", "qubit2"],
        "pauli_corrections": ["X", "Z"]
    }
}

MSGTRANSFER(MSG)

A message to tell the swapping result and transfer the ownership of the entanglement to the partner nodes.

  • Arguments
    • qubit_refs (list[string]): A set of references of the qubits that are freed in the swapping.
    • pauli_corrections (list[string]): A list of paulications.

Example MSGTRANSFER(["qubit1", "qubit2"], ["X", "X"])

{
    "name": "MSGTRANSFER",
    "arguments": {
        "qubit_ref": ["qubit1", "qubit2"],
        "pauli_corrections": ["X", "X"]
    }
}