QuISP
|
The Runtime is an environment for executing RuleSet. This Runtime abstraction allows us to analyze the behavior of RuleSet execution for further research about RuleSet-based quantum networks. The Runtime is a simple register-based machine with a simple key-value memory store. It's responsible for executing RuleSet written in intermediate representations(IR) and managing its states like assigned qubits entangled with a partner, temporary values (Registers and Memory), and flags. The current Runtime design focuses on 1). easy to implement and debug, 2). flexible in tweaking the instructions. See also quisp::runtime
The IR is similar to the Intel syntax so that we can write down the instruction: "load the value of the _KEY_ from the memory to the register _REG0_" into "LOAD REG0 KEY". Be careful about the order of the destination (REG0) and the source (KEY). The IR is like a simple assembly language with labels. Action and Condition in a Rule are written in the IR to describe how it works. We can write a control flow with jump or branch instructions. So there is no if-else statement nor for-loop syntax in the language due to simplicity for implementation and debugging. Here is an pseudo code to perform the random measure action and its C++ representations.
The C++ representation format is INSTR_{instruction name}_{argument1 type}_{argument2 type}_
. These are aliases of the Instruction template class so that you can instantiate by the C++ initializers list with curly braces like INSTR_ADD_RegId_RegId_int_{{REG0, REG1, 7}}
.
The Runtime has two types of storage scopes. One is Program-scope, where the Runtime initializes the storage before every Program execution. Only the Program can read/write the storage. Another is RuleSet-scope, where all Rule can read/write their value and the Runtime initializes it only once.
The Runtime has four types of storage, Register, Memory, Flags, and Qubits.
The Register is Program-scope storage that can store one number. You can use these Registers to perform simple arithmetic or check the number of measurements the RuleSet has done or qubits you can use in The Program.
The Memory is RuleSet-scope storage that can store any value with the MemoryKey. Unlike ordinary computer memory, the Memory is a simple key-value store for simplicity and safety. The RuleSet uses this Memory to keep the RuleSet-wise values like the total measurement count. You should load the value to the Register to use the Memory values.
The Flag is Program-scope storage that can store a value for control flow. The Program cannot access these values directly.
The Qubits is RuleSet-scope storage that can store the qubits entangled with other QNode. The RuleEngine assigns the qubits to some Runtime when it detects the entangled qubits. Then the Runtime can use the assigned qubits as their resources to executing the RuleSet.