bitstring_prep

forest.benchmarking.utils.bitstring_prep(qubits: Sequence[int], bitstring: Sequence[int], append_measure: bool = False, in_x_basis: bool = False) → pyquil.quil.Program

Produces a program that prepares the given bitstring on the given qubits.

See also _readout_group_parameterized_bitstring which produces an analogous parameterized program that measures any run-time specified bitstring on the given qubits. Parameterization speeds up the collective measurement of all bitstrings on a group of qubits. Note that the program generated by _readout_group_parameterized_bitstring executes three gates on each qubit to prepare either a 0 or a 1 on that qubit; meanwhile, this method creates a program which executes no gates to prepare the 0 state and only one gate to prepare the 1 state on a particular qubit.

Parameters:
  • qubits – labels of qubits on which some bitstring will be prepared and, perhaps, measured
  • bitstring – a sequence of bits (0 or 1) to prepare on the given qubits. The qubit qubits[idx] is prepare in the state bitstring[idx]
  • append_measure – dictates whether to measure the qubits after preparing the bitstring
  • in_x_basis – if true, prepare the bitstring in the x basis, where plus <==> zero, minus <==> one.
Returns:

a program for preparing, optionally measuring, the given bitstring on the given qubits