execute_graph
boulderopal.execute_graph(graph, output_node_names, execution_mode=ExecutionMode.COMPILED, *, run_async=False)
Evaluate a graph corresponding to a set of generic functions.
Use this function to carry out computations expressed as a graph representing a collection of arbitrary functions.
Parameters
- graph (Graph) – The graph describing the outputs. It must contain nodes with names (giving the output functions).
- output_node_names (str or list [ str ]) – The names of the graph nodes that define the output functions. The function evaluates these and returns them in the output. You can pass a string for a single node or a list of node names.
- execution_mode (ExecutionMode , optional) – The execution mode to use for the calculation. Choosing a custom execution mode can lead to faster computations in certain cases. Defaults to compiled execution mode.
- run_async (bool , optional) – Whether to execute the cloud calculation job asynchronously. If set to True, the function is a non-blocking operation and returns a BoulderOpalJob object. If set to False (the default), the function is blocking and on completion returns the calculation result as a dictionary.
Returns
When run_async is True, the function returns a BoulderOpalJob to manage the remote job. When run_async is False, the function returns a dictionary containing the graph execution result, with the following keys:
output
: The dictionary giving the value of each requested output node.
The keys of the dictionary are the names of the output nodes.
metadata
: Metadata associated with the calculation.
No guarantees are made about the contents of this metadata dictionary;
the contained information is intended purely to help interpret the results of the
calculation on a one-off basis.
Return type
dict or BoulderOpalJob
SEE ALSO
boulderopal.closed_loop.optimize
: Run a closed-loop optimization to find a minimum of the given cost function.
boulderopal.closed_loop.step
: Perform a single step in a closed-loop optimization.
boulderopal.run_gradient_free_optimization
: Perform model-based optimization without using gradient values.
boulderopal.run_optimization
: Perform gradient-based deterministic optimization of generic real-valued functions.
boulderopal.run_stochastic_optimization
: Perform gradient-based stochastic optimization of generic real-valued functions.
boulderopal.cloud.BoulderOpalJob
: An async Boulder Opal job submitted to the cloud.
Notes
This function computes arbitrary functions represented by a graph.
The graph is made up of primitive nodes, where each node represents a function of the output of the nodes (or constant values) it depends on. You can assign a name to any node and request a list of named nodes {sj} as the outputs to be evaluated.
Examples
See the How to represent quantum systems using graphs user guide.