Modules¶
-
class
quop_mpi.Unitary(operator_function, operator_n_params=0, operator_kwargs=None, parameter_function=None, parameter_kwargs=None, unitary_n_params=1)¶ Used to define a phase-shift or mixing unitary that can be passed to the \(Ansatz\) class
set_unitaries()method.Parameters: - operator_function (callable) – Function returning the local partition of the unitary’s matrix operator exponent, \(\hat{O}\) or \(\hat{W}\).
- operator_n_params (optional, integer, default = 0) – Number of variational parameters \(|\theta|\) associated with \(\hat{O}\) or \(\hat{W}\).
- operator_kwargs (optional, dictionary, default = None) – Keyword arguments associated with operator_function.
- parameter_function (callable) – Function responsible for generation of the \(\theta\) associated with the unitary and its matrix operator exponent.
- parameter_kwargs (optional, dictionary, default = None) – Keyword arguments associated with parameter_function.
- unitary_n_params (optional, integer, default = 0) – Number of variational parameters \(|\theta|\) associated with the unitary time-evolution operator.
-
copy_plan(ex_unitary)¶ Method to perform any setup required by
propagate()based off the partitioning plan of anotherUnitary.
-
destroy()¶ Method to free any memory allocated by
plan()orcopy_plan()that is not managed by the python garbage collector.
-
plan(system_size, MPI_COMM)¶ A method that plans the partitioning scheme used by
Ansatzand performs any other tasks required bypropagate().Parameters: Returns: The array [‘local_i’, ‘alloc_local’] where ‘local_i’ is the number of elements in a row-wise partitioning of \(\hat{O}\), \(\hat{W}\), \(|\psi_0\rangle_\text{ANZ}\) and \(| \boldsymbol{\theta} \rangle\), and alloc_local is the size of the allocated array containing the quantum state vectors.
Return type: array, integer
-
class
quop_mpi.Ansatz(system_size, MPI_communicator=<sphinx.ext.autodoc.importer._MockObject object>)¶ Used to define and simulate a quantum variational algorithm.
Parameters: - system_size (integer) – Size of the quantum system, \(N\).
- MPI_communicator (optional, default = 'MPI.COMM_WORLD') – An MPI4Py MPI communicator object.
-
benchmark(ansatz_depths, repeats, param_persist=False, verbose=True, filename=None, label='test', save_action='a', time_limit=None, suspend_path=None)¶ This provides an method by which to study how a QVA algorithm performs with increases to the circuit depth, \(D\).
Parameters: - ansatz_depths (integer, array) – iterable of \(D\) values.
- repeats (integer) – The number of repeats at each value of \(D\).
- param_persist (boolean, optional) – If True the optimized \(\boldsymbol{\theta}\) values which achieved the lowest objective function value for all repeats at \(D\) will be used as starting parameters for \(D + 1\).
The following parameters specify the output behaviours.
Parameters: - verbose (boolean, optional, default = True) – If True, print current \(D\), repeat number and optimisation results.
- filename (string, optional, default = None) – Name of .h5 file in which to
save()the evolved system. - label (string, optional, default = 'test') – If filename is specified, evolved systems will be saved as ‘filename/label_p_repetition’.
- save_action (string, optional, default = "a") – Action taken during first .5 file write. “a”, append. “w”, over-write.
- time_limit (type) – Total allocated in-program time, entered as “HH:MM:SS”. If the time of the previous simulation exceeds the time remaining, the benchmark run is suspended.
- time_limit – string, optional, default = None
- suspend_path (string, optional, default = "QuOp_benchmark_suspend_data") – If time_limit is defined, benchmark progress is saved to this file with a ‘.pkl’ extension.
-
execute(variational_parameters=None)¶ Execute the QVA algorithm.
Parameters: variational_parameters (float, array) – An array of length \(2 |\boldsymbol{\theta}|\).
-
gen_initial_params(ansatz_depth=None)¶ Generate \(\boldsymbol{\theta}\) using the parameter functions assocaited with each unitary.
Parameters: ansatz_depth (optional, integer, default=None) – The number of ansatz iterations or quantum circuit ‘depth’ \(D\). Returns: \(|\boldsymbol{\theta}| D\) variational parameters \(\boldsymbol{\theta}\) where \(D\) is defined by either the ansatz_depth argument or the current value of Ansatz.ansatz_depth (see set_depth()).Return type: array, float
-
get_expectation_value()¶ \(\langle \hat{Q} \rangle = \langle \boldsymbol{\theta} | \hat{Q} | \boldsymbol{\theta} \rangle\)
Returns: The expectation value of the quality operator, returned to all MPI nodes. Return type: float
-
get_final_state()¶ Gather \(|\boldsymbol{\theta}_f \rangle_\text{ANZ}\) at the root MPI rank following a call to
execute(),evolve_state()or ~Ansatz.benchmark. If called after ~Ansatz.benchmark the gathered state will correspond to the last performed simulation.Returns: \(|\boldsymbol{\theta}_f\rangle_\text{ANZ}\) Return type: array, complex
-
get_probabilities()¶ Gather \(||\boldsymbol{\theta}_f \rangle_\text{ANZ}|^2\) at the root MPI rank following a call to
execute(),evolve_state()or ~Ansatz.benchmark. If called after ~Ansatz.benchmark the gathered probabilities will correspond to the last performed simulation.Returns: \(||\boldsymbol{\theta}_f \rangle_\text{ANZ}|^2\). Return type: array, float
-
objective(variational_parameters)¶ \(f(\boldsymbol{\theta}) = \langle \boldsymbol{\theta} | \hat{Q} | \boldsymbol{\theta} \rangle\) - the function minimised by the calssical optimizer.
Parameters: variational_parameters (float, array) – An array of length \(|\boldsymbol{\theta}| D\).
-
print_optimiser_result()¶ Print the optimisation result.
-
print_summary()¶ Print a summary of the last QuOp_MPI simulation.
-
save(file_name, config_name, action='a')¶ Write the final state, observables and execution results of the current configuration to a HDf5 file.
Parameters: - file_name (string) – Name of the file on disc.
- file_name – Name of the saved configuration in the HDf5 file.
- action (string, optional) – “a”: append to an existing file or create a new file. “w”: overwrite the file if it exists.
Data is saved into a .h5 file with the following structure.
file_name.h5 ├── config_name │ ├── final_state │ ├── observables
The minimization result is saved in the ‘minimize_result’ attribute of ‘config_name’ as a formatted string.
Multiple configurations with a unique config_name can be stored in the same .h5 file. HDF5 files are supported in python by the h5py package. With it, a saved configuration can be accessed as follows:
import h5py config_name = "my_simulation" f = h5py.File(file_name + ".h5", "r") final_state = np.array(f[config_name]['final_state']).view(np.complex128) eigenvalues = np.array(f[config_name]['eigenvalues']).view(np.complex128) observables = np.array(f[config_name]['observables']).view(np.float64) print(f["my_simulation"].attrs["minimize_result"])
Warning
The final_state and observables datasets are saved using Fortran subroutines which make use of parallel HDF5.
The complex values of the final_state array are saved as a compound datatype consisting of contiguous double precision reals. This is equivalent to the np.complex128 NumPy datatype. To access this data without a loss of precision in python, the user must set the view of the NumPy array to np.complex128, rather than casting it to np.complex128 using the dtype keyword.
Similarly, the observables array, which is saved as an array of double-precision reals, should have its view set to np.float64.
-
set_depth(depth)¶ Define the circuit depth, \(D\).
Parameters: depth (integer) – Number of ansatz repetitions.
-
set_initial_state(function, kwargs=None)¶ Define the initial quantum state.
Parameters: - function (callable) – A function that returns a local partition of the quantum state vector \(|\psi_0\rangle_\text{ANZ}\).
- kwargs (Keyword arguments passed to the function.) – optional, dictionary, default = None
-
set_log(filename, label, action='a')¶ Creates a CSV in which to save key QAOA results after a call to
execute().Parameters: - filename (string) – Name of the CSV file.
- label (string) – User-set identifier of the currently defined ansatz.
- action (string, optional, default = "a") – “a”, append. “w”, over-write.
By default the following information is recorded:
- label: User-defined system label.
- p: \(p\).
- objective_function: Final result of objective function minimization.
- objective_evaluations: Number of objective function evaluations needed during optimisation.
- optimization_success: If the minimizer converged to its target tolerances.
- state_norm: Norm of the final state. This should always equal 1 (within the limits of double precision accuracy).
- simulation_time: In-program simulation time.
- MPI_nodes: Number of MPI processes.
-
set_objective_map(func, kwargs=None)¶ Define a function that acts on the expectation value prior to it being passed to the optimiser. The function should take a float as its input and return a float.
Parameters: - func (callable:) – Function to apply to the expectation value.
- kwargs (optional, dictionary, default = None) – Keyword args to pass to the function.
-
set_observable_map(func, kwargs=None)¶ Define a function that acts on the observable values during calculation of the expectation value. The function should take a Numpy array as its input, and return a Numpy array of the same size.
Parameters: func (callable) – Function to apply to the observable values.
-
set_observables(function, kwargs=None)¶ Define the observables used during calculation of the objective function.
Parameters: - function (callable or integer) – A callable returning a local partition of \(\text{diag}(\hat{Q})\) or an integer specifying the index of the phase-shift unitary in the list passed to the
set_observables()whose exponent contains \(\text{diag}(\hat{Q})\). - kwargs (optional, default = None) – Keyword arguments to pass to the observable function during generation of the observables.
- function (callable or integer) – A callable returning a local partition of \(\text{diag}(\hat{Q})\) or an integer specifying the index of the phase-shift unitary in the list passed to the
-
set_optimiser(optimiser, optimiser_args=None, optimiser_log=None)¶ Defines the classical optimiser algorithm used, arguments passed to the optimiser and fields in the optimiser dictionary to write to the log file (when using
log_results()). QuOp_MPI supports optimisers provided by SciPy through its minimize method minimize and optimisers provided by the NLopt package with respect to minimisation with scalar constraints through a SciPy-like interface.The default optimiser is the BFGS algorithm, which is set internally as follows:
self.set_optimiser( 'scipy', {'method':'BFGS','options':{'gtol':1e-3}}, ['fun','nfev','success'])
Parameters: - optimiser (string) – ‘scipy’ to use the SciPy, ‘nlopt’ to use NLopt, or a callable QuOp_MPI-compatible optimisation function.
- optimiser_args (dictionary) – Arguments to pass to the optimiser.
- optimiser_log (array, string) – Results of the optimisation process are stored in a dictionary. These values may be logged by passing a list of the corresponding keys.
-
set_sampling(sample_block_size, function=None, max_sample_iterations=100, kwargs=None)¶ Calculate the QVA objective funtion using simulated sampling. Samples are taken in blocks of sample_block_size. These are passed as a list of lists to function, which returns a value for \(\langle Q \rangle\) and a boolean that indicates wether the sampled result should be passed to the classical optimiser.
If function is None, \(\langle Q \rangle\) is computed as the mean of sample_block_size size shots.
Parameters: - sample_block_size (integer) – Number of shots taken between sucessive computation of \(\langle Q \rangle\).
- function (callable, optional) – Callable that accepts a list of lists of sample values and returns \(\langle Q \rangle\) along with a boolean that indicates wether to pass \(\langle Q \rangle\) to the classical optimiser.
- max_sample_iterations (optional, default = 100) – Maximum number of sample blocks per \(\langle Q \rangle\), if exceeded \(\langle Q \rangle\) is passed to the classical optimiser regardless of the function boolean output.
- kwargs (dictionary, optional, default = None) – Dictionary of keyword arguments for function.
-
set_seed(seed)¶ Define an integer that is used to set the state of initial parameter \(\theta\) generation.
Parameters: seed (integer) – Sets the random seed.
-
set_unitaries(unitaries)¶ Define the phase-shift and mixing unitaries used by the QVA. The untaries are passed in a python list in order of application from left to right.
Parameters: unitaries (list, Unitary) – List of unitaries corresponding to one application of the ansatz \(D=1\).
-
unset_objective_map()¶ Undo the function mapping defined by
set_objective_map().
-
unset_observable_map()¶ Undo the function mapping defined by
set_observable_map().
algorithm¶
-
class
quop_mpi.algorithm.qaoa(*args, **kwargs)¶ A __setup-defined
Ansatzthat implements the Quantum Approximation Optimisation Algorithm.See
phase_and_mixer.
-
class
quop_mpi.algorithm.qwoa(*args, **kwargs)¶ A pre-defined
Ansatzthat implements the Quantum Walk-based Optimisation Algorithm.See
phase_and_mixer.
-
class
quop_mpi.algorithm.phase_and_mixer(*args, **kwargs)¶ An
Ansatzsubclass that used to define a quantum variational algorithm consisting of a phase-shift unitary and mixing unitary.It also implements methods that mimic the interface of QuOp_MPI v0.0.x.
-
set_params(param_function, kwargs=None)¶ Define the initial parameters \(\boldsymbol{\theta} = \{\vec{\gamma}, \vec{t}\}\).
Parameters: - param_function (array, float) – Function that accepts n_params as one of its positional arguments and returns an array of size n_params.
- kwargs (optional, dictionary, default = None) – Keyword arguments associated with param_function.
-
set_qualities(function, kwargs=None)¶ Define the quality operator \(\text{diag}(\hat{Q})\).
Parameters: - function (callable) – Function returning a partition of \(\text{diag}(\hat{Q})\) with local_i elements and a global positional offset of local_i_offset.
- kwargs (optional, dictionary, default = None) – Keyword arguments associated function.
-
-
class
quop_mpi.algorithm.qowe(Ns, deltas, mins, *args, **kwargs)¶
-
class
quop_mpi.algorithm.qmoa(Ns, deltas, mins, *args, **kwargs)¶
observable¶
-
quop_mpi.observable.serial(partition_table, MPI_COMM, function=None, args=None, kwargs=None)¶ Defines \(\hat{Q}\) via a serial function. The serial function is called at rank = 0 of MPI communicator MPI_COMM and its output is distributed over MPI_COMM as described by partition_table. Argument partition_table is a class attribute of the
Unitaryclass.Parameters: - partition_table (array, integer) – Describes the parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator
- function (callable) – Function that returns \(\text{diag}(\hat{Q})\).
- args (optional, list, default = None) – Positional arguments associated with function.
- kwargs (optional, dictionary, default = None) – Keyword arguments associated with function.
-
quop_mpi.observable.csv(system_size, partition_table, MPI_COMM, filename=None, **kwargs)¶ Import \(\text{diag}(\hat{Q})\) from a CSV file.
Parameters: - system_size (integer) – Size of the quantum system \(N\).
- partition_table (array, integer) – Array describing the parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(\text{diag}(\hat{Q})\) is partitioned.
- partition_table – Array describing the parallel partitioning scheme.
- filename (string) – The location of the CSV file.
- **kwargs – An arbitrary number of keyword arguments passed to the Pandas read_csv function.
-
quop_mpi.observable.hdf5(partition_table, MPI_COMM, filename=None, dataset_name=None)¶ Import \(\text{diag}(\hat{Q})\) from a HDF5 file.
Parameters: - local_i (integer) – Number of elements in the local partition of \(\text{diag}(\hat{Q})\).
- local_i_offset – Number of elements preceding the local partition.
- local_i_offset – integer
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(\text{diag}(\hat{Q})\) is partitioned.
- filename (string) – Path to the HDF5 file.
- dataset_name (string) – Path to \(\text{diag}(\hat{Q})\) in the HDF5 file.
-
quop_mpi.observable.array(system_size, partition_table, MPI_COMM, array=None)¶ Define \(\text{diag}(\hat{Q})\) using an array defined at MPI rank = 0.
Parameters: - system_size (integer) – Size of the quantum system \(N\).
- partition_table (array, integer) – Array describing the parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(\text{diag}(\hat{Q})\) is partitioned.
- array (array, float) – Array defining \(\text{diag}(\hat{Q})\).
-
quop_mpi.observable.rand.uniform(system_size, partition_table, seed, MPI_COMM, low=0, high=1)¶ Generates \(\text{diag}(\hat{Q})\) where the \(q_i\) are sampled from a random distribution uniformly distributed between (low, high].
Parameters: - system_size (integer) – Number of observables \(N\).
- partition_table (array, integer) – A class attribute of the
Unitaryclass, an array of length \(M + 1\) where \(M\) is the size of the MPI communicator. For each MPI rank \(m\) index \(m\) of the array returns the starting point of the local partition of local_i observables. The last index of partition_table is equal to \(N + 1\). - seed (integer) – Set the state of the random number generator.
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(\text{diag}(\hat{Q})\) is distributed.
- low (optional, float, default = 0) – Lower bound of the uniform distribution.
- high (optional, float, default = 1) – Upper bound of the uniform distribution.
param¶
-
quop_mpi.param.rand.uniform(n_params, seed, low=0, high=6.283185307179586)¶ Generate variational parameters \(\theta\) randomly from a uniform distribution between (low, high].
Parameters: - n_params (integer) – Number of variational parameters.
- seed (integer) – Sets the state of the random number generator.
- low (optional, float, default = 0.) – Lower bound of the distribution.
- high (optional, float, default = \(2 \pi\)) – Upper bound of the distribution.
state¶
-
quop_mpi.state.equal(system_size, local_i)¶ Generate \(|\psi_0\rangle_\text{ANZ}\) as an equal superposition over \(N\) basis states.
Parameters: - system_size (integer) – Size of the quantum system \(N\).
- local_i (integer) – Number of elements in the local partition of \(|\psi_0\rangle_\text{ANZ}\).
-
quop_mpi.state.basis(local_i, local_i_offset, basis_states=[0])¶ Generate \(|\psi_0\rangle_\text{ANZ}\) localised over a subset of basis states.
Parameters: - local_i (integer) – Number of elements in the local partition of \(|\psi_0\rangle_\text{ANZ}\).
- local_i_offset (integer) – Offset of the local parallel partition relative to its position in \(|\psi_0\rangle_\text{ANZ}\).
- basis_states (optional, list, default = [0]) – List of basis states.
-
quop_mpi.state.serial(partition_table, MPI_COMM, function=None, args=None, kwargs=None)¶ Define \(|\psi_0\rangle_\text{ANZ}\) using a serial function.
Parameters: - partition_table (array, integer) – Array describing the parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(|\psi_0\rangle_\text{ANZ}\) is distributed.
- function (callable) – Serial function that returns \(|\psi_0\rangle_\text{ANZ}\).
- kwargs (optional, dictionary, default = None) – Keyword arguments associated with function.
-
quop_mpi.state.array(local_i, local_i_offset, MPI_COMM, state=None, normalize=True)¶ Define \(|\psi_0\rangle_\text{ANZ}\) via an array at MPI rank = 0.
Parameters: - local_i (integer) – Number of elements in the local partition of \(|\psi_0\rangle_\text{ANZ}\).
- local_i_offset (integer) – Offset of the local parallel partition relative to its position in \(|\psi_0\rangle_\text{ANZ}\).
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(|\psi_0\rangle_\text{ANZ}\) is distributed.
- state (array, complex) – Array defining \(|\psi_0\rangle_\text{ANZ}\).
- normalize (optional, boolean, default = True) – If True, normalize array.
propagator¶
circulant¶
-
class
quop_mpi.propagator.circulant.unitary(operator_function, operator_n_params=0, operator_kwargs=None, parameter_function=None, parameter_kwargs=None)¶ Implements a mixing unitary with a circulant matrix operator exponent.
See
Unitaryfor more information.-
copy_plan(ex_unitary)¶ Method to perform any setup required by
propagate()based off the partitioning plan of anotherUnitary.
-
destroy()¶ Method to free any memory allocated by
plan()orcopy_plan()that is not managed by the python garbage collector.
-
plan(system_size, MPI_COMM)¶ A method that plans the partitioning scheme used by
Ansatzand performs any other tasks required bypropagate().Parameters: - system_size (integer) – Size of the quantum system \(N\).
- MPI_COMM (MPI4py communicator object.) – MPI communicator over which the
UnitaryandAnsatzoperators and quantum state are partitioned.
Returns: The array [‘local_i’, ‘alloc_local’] where ‘local_i’ is the number of elements in a row-wise partitioning of \(\hat{O}\), \(\hat{W}\), \(|\psi_0\rangle_\text{ANZ}\) and \(| \boldsymbol{\theta} \rangle\), and alloc_local is the size of the allocated array containing the quantum state vectors.
Return type: array, integer
-
propagate(x)¶ A method implementing computation of the action of the unitary on the quantum state vector \(| \boldsymbol{\theta} \rangle\). Must be consistent with the QuOp_MPI
Ansatzparallelisation scheme.Parameters: x (array, float) – An array of \(|\theta|\) variational parameters.
-
-
quop_mpi.propagator.circulant.operator.complete(system_size, local_o, local_o_offset)¶ Generates a parallel partition of the eigenvalues of a complete circulant matrix.
Parameters: - system_size (integer) – Size of the graph \(N\).
- local_o (integer) – Number of local elements following FFTW transformation of the state vector.
- local_o_offset (integer) – Offset of the transformed local partition relative to the globally distributed state vector.
Returns: Local parallel partition of the graph eigenvalues.
Return type: array, complex
-
quop_mpi.propagator.circulant.operator.graph(system_size, local_o, local_o_offset, i=1)¶ Returns the eigenvalues of the \(i^{\text{th}}\) symmetric circulant matrix. The eigenvalues of a complete graph are generated by \(i = N//2 + 1\).
Parameters: - system_size (integer) – Size of the graph \(N\).
- local_o (integer) – Number of local elements following FFTW transformation of the state vector.
- local_o_offset (integer) – Offset of the transformed local partition relative to the globally distributed state vector.
- i (optional, integer, default = 1) – Index of the symmetric circulant graph.
Returns: Local parallel partition of the graph eigenvalues.
Return type: array, complex
diagonal¶
-
class
quop_mpi.propagator.diagonal.unitary(*args, **kwargs)¶ Implements a phase-shift unitary with a diagonal matrix operator exponent.
See
Unitaryfor more information.-
copy_plan(ex_unitary)¶ Method to perform any setup required by
propagate()based off the partitioning plan of anotherUnitary.
-
plan(system_size, MPI_COMM)¶ A method that plans the partitioning scheme used by
Ansatzand performs any other tasks required bypropagate().Parameters: - system_size (integer) – Size of the quantum system \(N\).
- MPI_COMM (MPI4py communicator object.) – MPI communicator over which the
UnitaryandAnsatzoperators and quantum state are partitioned.
Returns: The array [‘local_i’, ‘alloc_local’] where ‘local_i’ is the number of elements in a row-wise partitioning of \(\hat{O}\), \(\hat{W}\), \(|\psi_0\rangle_\text{ANZ}\) and \(| \boldsymbol{\theta} \rangle\), and alloc_local is the size of the allocated array containing the quantum state vectors.
Return type: array, integer
-
-
quop_mpi.propagator.diagonal.operator.serial(partition_table, MPI_COMM, variational_parameters, function=None, args=None, kwargs=None)¶ Defines \(\hat{O}\) via a serial function. The serial function is called at rank = 0 of MPI communicator MPI_COMM and its output is distributed over MPI_COMM as described by partition_table. Argument partition_table is a class attribute of the
Unitaryclass.Parameters: - partition_table (array, integer) – Describes the parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator
- variational_parameters (integer) – Number of variational_parameters \(\theta\) associated with \(\hat{O}\), should match
operator_n_params. - function (callable) – Function that returns \(\text{diag}(\hat{O})\).
- args (optional, list, default = None) – Positional arguments associated with function.
- kwargs (optional, dictionary, default = None) – Keyword arguments associated with function.
-
quop_mpi.propagator.diagonal.operator.csv(system_size, partition_table, MPI_COMM, filename=None, **kwargs)¶ Import \(\text{diag}(\hat{O})\) from a CSV file.
Parameters: - system_size (integer) – Size of the quantum system \(N\).
- partition_table (array, integer) – Array describing the parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(\text{diag}(\hat{O})\) is partitioned.
- partition_table – Array describing the parallel partitioning scheme.
- filename (string) – The location of the CSV file.
- **kwargs – An arbitrary number of keyword arguments passed to the Pandas read_csv function.
-
quop_mpi.propagator.diagonal.operator.hdf5(local_i, local_i_offset, MPI_COMM, filename=None, dataset_name=None)¶ Import \(\text{diag}(\hat{O})\) from a HDF5 file.
Parameters: - local_i (integer) – Number of elements in the local partition of \(\text{diag}(\hat{O})\).
- local_i_offset – Number of elements preceeding the local partition.
- local_i_offset – integer
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(\text{diag}(\hat{O})\) is partitioned.
- filename (string) – Path to the HDF5 file.
- dataset_name (string) – Path to \(\text{diag}(\hat{O})\) in the HDF5 file.
-
quop_mpi.propagator.diagonal.operator.array(system_size, partition_table, MPI_COMM, array=None)¶ Define \(\text{diag}(\hat{O})\) using an array defined at MPI rank = 0.
Parameters: - system_size (integer) – Size of the quantum system \(N\).
- partition_table (array, integer) – Array describing the parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator over which \(\text{diag}(\hat{O})\) is partitioned.
- array (array, float) – Array defining \(\text{diag}(\hat{O})\).
sparse¶
-
class
quop_mpi.propagator.sparse.unitary(*args, **kwargs)¶ Implements a mixing unitary with a circulant matrix operator exponent.
See
Unitaryfor more information.-
copy_plan(ex_unitary)¶ Method to perform any setup required by
propagate()based off the partitioning plan of anotherUnitary.
-
evolve_group(x)¶ Evolves the QAOA initial_state to its final_state.
Parameters: - gammas (float, array) – Quality-proportional phase shifts.
- ts (float, array) – Continuous-time quantum walk times.
-
evolve_single(x)¶ Evolves the QAOA initial_state to its final_state.
Parameters: - gammas (float, array) – Quality-proportional phase shifts.
- ts (float, array) – Continuous-time quantum walk times.
-
plan(system_size, MPI_COMM)¶ A method that plans the partitioning scheme used by
Ansatzand performs any other tasks required bypropagate().Parameters: - system_size (integer) – Size of the quantum system \(N\).
- MPI_COMM (MPI4py communicator object.) – MPI communicator over which the
UnitaryandAnsatzoperators and quantum state are partitioned.
Returns: The array [‘local_i’, ‘alloc_local’] where ‘local_i’ is the number of elements in a row-wise partitioning of \(\hat{O}\), \(\hat{W}\), \(|\psi_0\rangle_\text{ANZ}\) and \(| \boldsymbol{\theta} \rangle\), and alloc_local is the size of the allocated array containing the quantum state vectors.
Return type: array, integer
-
-
quop_mpi.propagator.sparse.operator.serial(partition_table, MPI_COMM, variational_parameters, function=None, args=[], kwargs={})¶ Generate a mixing operator, or sequence of mixing operators, from a serial function.
Parameters: - partition_table (array, integer) – Parallel partitioning scheme.
- MPI_COMM (MPI4py communicator object) – MPI communicator
- variational_parameters (array, float) – Variational parameters \(\theta\) associated with the mixing operator.
- function (callable) – Serial function that generates the mixing operators.
- args (optional, list, default = None) – Positional arguments associated with function.
- kwargs (optional, dictionary, default = None) – Keyword arguments associated with function.
-
quop_mpi.propagator.sparse.operator.hypercube(system_size, lb, ub)¶ Generate a parallel partition of a \(N \times N\) hypercube mixing operator where for \(n\) qubits \(N = 2^n\).
Parameters: - system_size (integer) – Size of the quantum system :math`N`.
- lb (integer) – Lower bound of the local partition.
- ub (integer) – Upper bound of the local partition.
Returns: Local parallel parallel of the hypercube.
Return type: QuOp_MPI sparse matrix arrays