Computables

Computables are data structures designed for deferred evaluation, representing physical quantities that will, at some point, be measured on a quantum computer. They essentially function as placeholders, separating the construction of complex hierarchical structures from the measurement processes on quantum devices. This separation ensures that the actual evaluation only occurs once the measurement results are obtained from the quantum device.

A prime example of a computable is the ExpectationValue, which represents the expectation value of an operator with respect to a specific state. When an instance such as

exp_val_computable = ExpectationValue(state, operator)

is created, no immediate calculation occurs. Instead, the actual evaluation happens when the evaluate() method is invoked with an evaluator function:

exp_val = exp_val_computable.evaluate(evaluator = evaluator_function)

The evaluator_function must be capable of managing the details of quantum measurements in an independent workflow. This workflow may be custom-tailored to different simulators, hardware configurations, measurement protocols, or optimization methods. Regardless of the evaluation process, the exp_val_computable instance can effectively serve as a placeholder in complex expressions, for example, in Reduced Density Matrices (RDMs) or Green’s functions, facilitating the construction of complex composite structures.

The underlying data structure of a general computable is a tree; each computable is a node, and the root node represents the final data structure to be evaluated. When the evaluate() method is called on the root node, the result will be calculated by calling the evaluate() method on the child nodes. This process is repeated recursively until the leaf nodes are reached, which will be evaluated by the evaluator_function passed at the root level.

We categorize computables into three main groups, introduced below:

1. Atomic Computables: These computables are leaf nodes in a computable expression tree; individual units that do not contain other computables, and are directly calculated using InQuanto protocols. An evaluator function must be able to handle them. A full list of atomic computables is given below:

2. Composite Computables: These objects describe computable quantities that may be represented in terms of smaller, atomic computables. Using these constructs can help to minimize redundant quantum measurements when computing complex chemical quantites such as Reduced Density Matrices (RDMs). Some examples of composite computables are discussed in more detail here.

3. Primitive Computables: Primitive computables do not represent physical quantities themselves, but facilitate the construction of composite structures. These primitives can be parent classes, or collections such as arrays, lists, or tuples, functioning as building blocks for more complex computables. These computables are discussed in more detail here.