measure_quantum_volume

forest.benchmarking.quantum_volume.measure_quantum_volume(qc: pyquil.api._quantum_computer.QuantumComputer, qubits: Sequence[int] = None, program_generator: Callable[[pyquil.api._quantum_computer.QuantumComputer, Sequence[int], Sequence[numpy.ndarray], numpy.ndarray], pyquil.quil.Program] = <function _naive_program_generator>, num_circuits: int = 100, num_shots: int = 1000, depths: numpy.ndarray = None, achievable_threshold: float = 0.6666666666666666, stop_when_fail: bool = True, show_progress_bar: bool = False) → Dict[int, Tuple[float, float]]

Measures the quantum volume of a quantum resource, as described in [QVol].

By default this method scans increasing depths from 2 to len(qubits) and tests whether the qc can adequately implement random model circuits on depth-many qubits such that the given depth is ‘achieved’. A model circuit depth is achieved if the sample distribution for a sample of num_circuits many randomly generated model circuits of the given depth sufficiently matches the ideal distribution of that circuit (See Eq. 6 of [QVol]). The frequency of sampling ‘heavy-outputs’ is used as a measure of closeness of the circuit distributions. This estimated frequency (across all sampled circuits) is reported for each depth along with a bool which indicates whether that depth was achieved. The logarithm of the quantum volume is by definition the largest achievable depth of the circuit; see extract_quantum_volume_from_results() for obtaining the quantum volume from the results returned by this method.

[QVol](1, 2, 3, 4) Validating quantum computers using randomized model circuits. Cross et al. arXiv:1811.12926v1 (2018). https://arxiv.org/abs/1811.12926
Parameters:
  • qc – the quantum resource whose volume you wish to measure
  • qubits – available qubits on which to act during measurement. Default all qubits in qc.
  • program_generator

    a method which

    1. takes in a quantum computer, the qubits on that
      computer available for use, a series of sequences representing the qubit permutations in a model circuit, an array of matrices representing the 2q gates in the model circuit
    2. outputs a native quil program that implements the circuit and measures the appropriate
      qubits in the order implicitly dictated by the model circuit representation created in sample_rand_circuits_for_heavy_out.

    The default option simply picks the smallest qubit labels and lets the compiler do the rest.

  • num_circuits – number of unique random circuits that will be sampled.
  • num_shots – number of shots for each circuit sampled.
  • depths – the circuit depths to scan over. Defaults to all depths from 2 to len(qubits)
  • achievable_threshold – threshold at which a depth is considered ‘achieved’. Eq. 6 of [QVol] defines this to be the default of 2/3. To be considered achievable, the estimated probability of sampling a heavy output at the given depth must be large enough such that the one-sided confidence interval of this estimate is greater than the given threshold.
  • stop_when_fail – if true, the measurement will stop after the first un-achievable depth
  • show_progress_bar – displays a progress bar for each depth if true.
Returns:

dict with key depth: (prob_sample_heavy, ons_sided_conf_interval) gives both the estimated probability of sampling a heavy output at each depth and the 2-sigma lower bound on this estimate; a depth qualifies as being achievable only if this lower bound exceeds the threshold, defined in [QVol] to be 2/3