generate_experiment_programs

forest.benchmarking.observable_estimation.generate_experiment_programs(obs_expt: forest.benchmarking.observable_estimation.ObservablesExperiment, active_reset: bool = False, use_basic_compile: bool = True) → Tuple[List[pyquil.quil.Program], List[List[int]]]

Generate the programs necessary to estimate the observables in an ObservablesExperiment.

Grouping of settings to be run in parallel, e.g. by a call to group_settings, should be done before this method is called.

By default the program field of the input obs_expt is assumed to hold a program composed of gates which are either native quil gates or else can be compiled to native quil by the method basic_compile. If this is not the case, then use_basic_compile should be set to False and each returned program must be compiled before being executed on a QPU; NOTE however that compiling a program may change the qubit indices so meas_qubits might need to be re-ordered as well if the MEASURE instructions were not compiled with the program. For this reason it is recommended that obs_expt.program be compiled before this method is called. If one is careful then it is still possible to add the measurement instructions first and subsequently compile the programs before running, e.g. by setting use_compilation = True in the call to _measure_bitstrings (but compiling in this way could interfere with symmetrization).

Parameters:
  • obs_expt – a single ObservablesExperiment to be translated to a series of programs that when run serially can be used to estimate each of obs_expt’s observables.
  • active_reset – whether or not to begin the program by actively resetting. If true, execution of each of the returned programs in a loop on the QPU will generally be faster.
  • use_basic_compile – whether or not to call basic_compile on the programs after they are created. To run on a QPU it is necessary that programs use only native quil gates. See the warning above about setting use_basic_compile to false.
Returns:

a list of programs along with a corresponding list of the groups of qubits that are measured by that program. The returned programs may be run on a qc after measurement instructions are added for the corresponding group of qubits in meas_qubits – see estimate_observables and _measure_bitstrings for possible usage.