Graphs
Boulder Opal uses graphs to represent all computations. All usage of graphs is via the
Graph
object, which you can construct directly or using the
qctrl.Qctrl.create_graph()
method.
This page documents the available graph operations, together with the auxiliary features in the graphs module, namely the graph object itself and the classes representing the types of possible graph nodes.
For context on the role of graphs and their usage in Boulder Opal see the Understanding graphs in Boulder Opal topic. To develop handson experience with graphs, complete the Get familiar with graphs tutorial. The How to calculate and optimize with graphs and How to represent quantum systems using graphs user guides can show you how to solve relevant problems with Boulder Opal using graphs.
Boulder Opal also provides toolkits to simplify the workflow for common computation tasks. Some toolkits host graph nodes that you can access from their namespaces of the Graph object. See the reference for details.
Graph object
The graph object is the main entrypoint to the QCTRL graph ecosystem.
Utility class for representing and building a QCTRL data flow graph. 
Data types
Each graph operation creates a node, and each node has a type corresponding to the type of the data it produces.
A kernel to be used in a convolution. 

A tensorvalued filter function result. 

A piecewiseconstant tensorvalued function of time (or batch of such functions). 

A piecewiseconstant sparsematrixvalued function of time. 

A sampleable tensorvalued function of time (or batch of such functions). 

A target gate for an infidelity calculation. 

A multidimensional array of data. 
Optimization variables
When performing optimizations, you can use these operations to create the optimizable variables that can be tuned by the optimizer in order to minimize your cost function.
Create a sequence of optimizable variables with an anchored difference bound. 

Create optimization variables, which can be bounded, semibounded, or unbounded. 

Create a piecewiseconstant signal constructed from Fourier components. 

Create a real sampleable signal constructed from Fourier components. 
Piecewiseconstant tensor functions (PWCs)
You can use these operations to create piecewiseconstant functions either to represent control signals or system Hamiltonians.
Create a complex piecewiseconstant signal from moduli and phases. 

Create a piecewiseconstant function of time that is constant over a specified duration. 

Create a constant piecewiseconstant operator over a specified duration. 

Create a piecewiseconstant function of time. 

Create a constant operator multiplied by a piecewiseconstant signal. 

Create a piecewiseconstant signal (scalarvalued function of time). 

Create the sum of multiple piecewiseconstant terms. 

Create a piecewiseconstant signal constructed from Fourier components. 

Sample a Pwc at the given times. 

Create the symmetrization of a piecewiseconstant function. 

Concatenate multiple piecewiseconstant functions in the time dimension. 

Reverse in time a piecewiseconstant function. 
Sampleable tensor functions (STFs)
You can use these functions to represent timedependent functions in Boulder Opal.
Create a constant sampleable tensorvalued function of time. 

Create a constant operator. 

Create an Stf representing the identity function, f(t) = t. 

Sample the onesided power spectral density (PSD) of a random noise process in the time domain and returns the resultant noise trajectories as an Stf. 

Create a real sampleable signal constructed from Fourier components. 

Sample an Stf at the given times. 

Create a constant operator multiplied by a sampleable signal. 

Create the sum of multiple sampleable functions. 
Filtering and discretizing
You can use these functions to filter or resample the control signals.
Create the convolution of a piecewiseconstant function with a kernel. 

Create a piecewiseconstant function by discretizing a sampleable function. 

Create a convolution kernel representing a normalized Gaussian. 

Create a convolution kernel representing the sinc function. 
Quantum information
You can use these operations to calculate common operations and metrics from quantum information theory.
Create an annihilation operator in the truncated Fock space. 

Create a coherent state (or a batch of them). 

Create a creation operator in the truncated Fock space. 

Calculate the expectation value of an operator with respect to a density matrix. 

Calculate the infidelity between two states represented by density matrices. 

Create a displacement operator (or a batch of them). 

Embed an operator or set of operators into a larger Hilbert space. 

Calculate the expectation value of an operator with respect to a state. 

Create a Fock state (or a batch of them). 

Calculate the inner product of two vectors. 

Calculate the Kronecker product between a list of operators. 

Create a number operator in the truncated Fock space. 

Calculate the outer product of two vectors. 

Calculate the partial trace of a density matrix. 

Place Pauli matrices into their twodimensional subsystems of a system and returns the Kronecker product. 

Create a Pauli matrix from a label. 

Create a squeeze operator (or a batch of them). 

Calculate the infidelity of two pure states. 

Calculate the infidelity between a target operation and the actual implemented unitary. 

Transform a density matrix into a Wigner function (or a batch of them). 
Time evolution
You can use these operations to calculate the time evolution of your open or closed quantum system, either for simulations or optimizations.
Calculate the state evolution of an open system described by the GKS–Lindblad master equation. 

Calculate an appropriate Krylov subspace dimension (\(k\)) to use in the Lanczos integrator while keeping the total error in the evolution below a given error tolerance. 

Evaluate the filter function for a control Hamiltonian and a noise operator at the given frequency elements. 

Create a controlframe noise operator in the frequency domain for a control Hamiltonian and a noise operator at the given frequencies. 

Obtain the range of the eigenvalues of a Hermitian operator. 

Calculate the time evolution of a state generated by a piecewiseconstant Hamiltonian by using the Lanczos method. 

Find the steady state of a timeindependent open quantum system. 

Calculate the unitary timeevolution operators for a system defined by a piecewiseconstant Hamiltonian. 

Calculate the timeevolution operators for a system defined by an STF Hamiltonian by using a 4th order Runge–Kutta method. 
Optimal and robust control
You can use these operations, together with the operations for creating optimization variables to define convenient cost functions for optimal and robust control.
Create the total infidelity of the given piecewiseconstant system. 

Create the total infidelity of a given system with a sampleable Hamiltonian. 

Create information about the target for system time evolution. 
Large systems
You can use these operations to build graphs that efficiently handle large quantum systems.
Create a constant sparse piecewiseconstant operator over a specified duration. 

Calculate the state evolution of an open system described by the GKS–Lindblad master equation. 

Calculate an appropriate Krylov subspace dimension (\(k\)) to use in the Lanczos integrator while keeping the total error in the evolution below a given error tolerance. 

Create the Hermitian part of a piecewiseconstant operator. 

Create a sparse piecewiseconstant operator (sparsematrixvalued function of time). 

Create the sum of multiple sparsematrixvalued piecewiseconstant functions. 

Obtain the range of the eigenvalues of a Hermitian operator. 

Calculate the time evolution of a state generated by a piecewiseconstant Hamiltonian by using the Lanczos method. 

Find the steady state of a timeindependent open quantum system. 
Mølmer–Sørensen gates
You can use these operations to efficiently model systems described by Mølmer–Sørensen interactions.
Calculate the cost for robust optimization of a Mølmer–Sørensen gate. 

Calculate the displacements for each mode and ion combination where ions are described by a Mølmer–Sørensentype interaction. 

Calculate the final operational infidelity of the Mølmer–Sørensen gate. 

Calculate the relative phases for all pairs of ions described by a Mølmer–Sørensentype interaction when singletone individuallyaddressed laser beams are used. 

Calculate the relative phases for all pairs of ions described by a Mølmer–Sørensentype interaction where the ions are being addressed by a multitone global beam. 
Random operations
You can use these operations to create random quantities, which take different values each time they are evaluated. These operations are most useful in simulations and stochastic optimizations.
Create random samples from the data that you provide. 

Sample the onesided power spectral density (PSD) of a random noise process in the time domain and returns the resultant noise trajectories as an Stf. 

Create a sample of normally distributed random numbers. 

Create a sample of uniformly distributed random numbers. 
Manipulating tensors
You can use these operations to manipulate the structures of tensors.
Concatenate a list of tensors along a specified dimension. 

Calculate the cumulative sum of a tensor along a specified dimension. 

Perform tensor contraction via Einstein summation convention. 

Find the maximum value in a tensor along one or multiple of its axes. 

Find the minimum value in a tensor along one or multiple of its axes. 

Repeat elements of a tensor. 

Reshape a tensor into a new shape, keeping the order of its elements. 

Reverse a tensor along some specified dimensions. 

Sum the elements in a tensor (or a list of tensors with the same shape) along one or multiple of its axes. 

Create a real or complex Tensor with the data provided. 

Reorder the dimensions of a tensor. 
Arithmetic
Calculate the elementwise sum between numbers, np.ndarrays, Tensors, Pwcs, or Stfs. 

Calculate the cumulative sum of a tensor along a specified dimension. 

Calculate the elementwise roundeddown division between real numbers, np.ndarrays, Tensors, Pwcs, or Stfs. 

Calculate the elementwise product between numbers, np.ndarrays, Tensors, Pwcs, or Stfs. 

Calculate the elementwise numerical negative value of an object. 

Calculate the elementwise power between numbers, np.ndarrays, Tensors, Pwcs, or Stfs. 

Calculate the elementwise difference between numbers, np.ndarrays, Tensors, Pwcs, or Stfs. 

Sum the elements in a tensor (or a list of tensors with the same shape) along one or multiple of its axes. 

Calculate the elementwise division between numbers, np.ndarrays, Tensors, Pwcs, or Stfs. 
Linear algebra
Calculate the elementwise adjoint of the last two dimensions of an object. 

Calculate the expectation value of an operator with respect to a density matrix. 

Perform tensor contraction via Einstein summation convention. 

Embed an operator or set of operators into a larger Hilbert space. 

Calculate the expectation value of an operator with respect to a state. 

Calculate the Hermitian part of an object. 

Calculate a single Hessian matrix for all the variables. 

Calculate the inner product of two vectors. 

Calculate the Kronecker product between np.ndarrays, Tensors, Pwcs, or Stfs. 

Calculate the Kronecker product between a list of operators. 

Calculate the matrix multiplication between np.ndarrays, Tensors, Pwcs, or Stfs. 

Calculate the outer product of two vectors. 

Calculate the partial trace of a density matrix. 

Calculate the trace of an object. 

Reorder the dimensions of a tensor. 
Basic mathematical functions
Calculate the elementwise absolute value of an object. 

Calculate the elementwise argument of an object. 

Calculate the elementwise arccosine of an object. 

Calculate the elementwise arcsine of an object. 

Calculate the elementwise arctangent of an object. 

Create elementwise complex values from real numbers, np.ndarrays, Tensors, Pwcs, or Stfs, that is, the real and imaginary parts. 

Calculate the elementwise complex conjugate of an object. 

Calculate the elementwise cosine of an object. 

Calculate the elementwise hyperbolic cosine of an object. 

Calculate the elementwise exponential of an object. 

Calculate the elementwise imaginary part of an object. 

Calculate the elementwise natural logarithm of an object. 

Calculate the elementwise real part of an object. 

Calculate the elementwise sine of an object. 

Calculate the elementwise hyperbolic sine of an object. 

Calculate the elementwise square root of an object. 

Calculate the elementwise tangent of an object. 

Calculate the elementwise hyperbolic tangent of an object. 