supermarq.benchmarks ==================== .. py:module:: supermarq.benchmarks Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/supermarq/benchmarks/bit_code/index /autoapi/supermarq/benchmarks/ghz/index /autoapi/supermarq/benchmarks/hamiltonian_simulation/index /autoapi/supermarq/benchmarks/mermin_bell/index /autoapi/supermarq/benchmarks/phase_code/index /autoapi/supermarq/benchmarks/qaoa_fermionic_swap_proxy/index /autoapi/supermarq/benchmarks/qaoa_vanilla_proxy/index /autoapi/supermarq/benchmarks/vqe_proxy/index Classes ------- .. autoapisummary:: supermarq.benchmarks.BitCode supermarq.benchmarks.GHZ supermarq.benchmarks.HamiltonianSimulation supermarq.benchmarks.MerminBell supermarq.benchmarks.PhaseCode supermarq.benchmarks.QAOAFermionicSwapProxy supermarq.benchmarks.QAOAVanillaProxy supermarq.benchmarks.VQEProxy Package Contents ---------------- .. py:class:: BitCode(num_data_qubits: int, num_rounds: int, bit_state: list[int]) Bases: :py:obj:`supermarq.benchmark.Benchmark` Creates a circuit for syndrome measurement in a bit-flip error correcting code. :param num_data_qubits: The number of data qubits. :param num_rounds: The number of measurement rounds. :param bit_state: A list denoting the state to initialize each data qubit to. :returns: A `cirq.Circuit` for the bit-flip error correcting code. :raises ValueError: If `bit_state` is longer than `num_data_qubits`. :raises TypeError: If `bit_state` is not a `list`. :raises ValueError: If `bit_state` contains values not in {0,1}. .. py:method:: circuit() -> cirq.Circuit Generates bit code circuit. :returns: A `cirq.Circuit`. .. py:method:: score(counts: dict[str, float]) -> float Compute benchmark score. Device performance is given by the Hellinger fidelity between the experimental results and the ideal distribution. The ideal is known based on the `bit_state` parameter. :param counts: Dictionary containing the measurement counts from running `self.circuit()`. :returns: A float with the computed score. .. py:attribute:: bit_state .. py:attribute:: num_data_qubits .. py:attribute:: num_rounds .. py:class:: GHZ(num_qubits: int, method: str = 'ladder') Bases: :py:obj:`supermarq.benchmark.Benchmark` Represents the GHZ state preparation benchmark parameterized by the number of qubits n. Device performance is based on the Hellinger fidelity between the experimental and ideal probability distributions. .. py:method:: circuit() -> cirq.Circuit Generate an n-qubit GHZ cirq circuit. :returns: A `cirq.Circuit`. .. py:method:: qiskit_circuit() -> qiskit.QuantumCircuit Generate an n-qubit GHZ qiskit circuit. :returns: A `qiskit.QuantumCircuit`. .. py:method:: score(counts: dict[str, float]) -> float Compute the Hellinger fidelity between the experimental and ideal results. The ideal results are 50% probabilty of measuring the all-zero state and 50% probability of measuring the all-one state. The formula for the Hellinger fidelity between two distributions p and q is given by $(\sum_i{p_i q_i})^2$. :param counts: A dictionary containing the measurement counts from circuit execution. :returns: Hellinger fidelity as a float. .. py:attribute:: method :value: 'ladder' .. py:attribute:: num_qubits .. py:class:: HamiltonianSimulation(num_qubits: int, time_step: int = 1, total_time: int = 1) Bases: :py:obj:`supermarq.benchmark.Benchmark` Quantum benchmark focused on the ability to simulate 1D Transverse Field Ising Models (TFIM) of variable length. Device performance is based on how closely the experimentally obtained average magnetization (along the Z-axis) matches the noiseless value. Since the 1D TFIM is efficiently simulatable with classical algorithms, computing the noiseless average magnetization remains scalable over a large range of benchmark sizes. .. py:method:: circuit() -> cirq.Circuit Generates a circuit to simulate the evolution of an n-qubit TFIM. The TFIM chain evolves under the Hamiltonian: H(t) = - Jz * sum_{i=1}^{n-1}(sigma_{z}^{i} * sigma_{z}^{i+1}) - e_ph * cos(w_ph * t) * sum_{i=1}^{n}(sigma_{x}^{i}) where, w_ph: frequency of E" phonon in MoSe2. e_ph: strength of electron-phonon coupling. :returns: The circuit for Hamiltonian simulation. .. py:method:: qiskit_circuit() -> qiskit.QuantumCircuit Generates a circuit to simulate the evolution of an n-qubit TFIM. The TFIM chain evolves under the Hamiltonian: H(t) = - Jz * sum_{i=1}^{n-1}(sigma_{z}^{i} * sigma_{z}^{i+1}) - e_ph * cos(w_ph * t) * sum_{i=1}^{n}(sigma_{x}^{i}) where, w_ph: frequency of E" phonon in MoSe2. e_ph: strength of electron-phonon coupling. :returns: The circuit for Hamiltonian simulation. .. py:method:: score(counts: collections.abc.Mapping[str, float]) -> float Compute the average magnetization of the TFIM chain along the Z-axis for the experimental results and via noiseless simulation. :param counts: Dictionary of the experimental results. The keys are bitstrings represented the measured qubit state, and the values are the number of times that state of observed. :returns: The Hamiltonian simulation benchmark score. .. py:attribute:: num_qubits .. py:attribute:: time_step :value: 1 .. py:attribute:: total_time :value: 1 .. py:class:: MerminBell(num_qubits: int) Bases: :py:obj:`supermarq.benchmark.Benchmark` The Mermin-Bell benchmark is a test of a quantum computer's ability to exploit purely quantum phenomemna such as superposition and entanglement. It is based on the famous Bell-inequality tests of locality. Performance is based on a QPU's ability to prepare a GHZ state and measure the Mermin operator. .. py:method:: circuit() -> cirq.Circuit The Mermin-Bell circuit, simultaneously measuring Mermin terms in a GHZ circuit. :returns: The Mermin-Bell `cirq.Circuit`. .. py:method:: score(counts: dict[str, float]) -> float Compute the score for the N-qubit Mermin-Bell benchmark. This function assumes the regular big endian ordering of bitstring results. :param counts: A dictionary containing the measurement counts from circuit execution. :returns: The score for the Mermin-Bell benchmark score. .. py:attribute:: mermin_operator :value: [] .. py:attribute:: num_qubits .. py:attribute:: qubits .. py:class:: PhaseCode(num_data_qubits: int, num_rounds: int, phase_state: list[int]) Bases: :py:obj:`supermarq.benchmark.Benchmark` Creates a circuit for syndrome measurement in a phase-flip error correcting code. :param num_data_qubits: The number of data qubits. :param num_rounds: The number of measurement rounds. :param phase_state: A list of zeros and ones denoting the state to initialize each data qubit to. Currently just + or - states. 0 -> +, 1 -> -. :returns: A `cirq.Circuit` for the phase-flip error correcting code. :raises ValueError: If `phase_state` is longer than `num_data_qubits`. :raises TypeError: If `phase_state` is not a `list`. :raises ValueError: If `phase_state` contains values not in {0,1}. .. py:method:: circuit() -> cirq.Circuit Generates phase code circuit. :returns: A `cirq.Circuit`. .. py:method:: score(counts: dict[str, float]) -> float Compute benchmark score. Device performance is given by the Hellinger fidelity between the experimental results and the ideal distribution. The ideal is known based on the `phase_state` parameter. :param counts: Dictionary containing the measurement counts from running `self.circuit()`. :returns: A float with the computed score. .. py:attribute:: num_data_qubits .. py:attribute:: num_rounds .. py:attribute:: phase_state .. py:class:: QAOAFermionicSwapProxy(num_qubits: int) Bases: :py:obj:`supermarq.benchmarks.qaoa_vanilla_proxy.QAOAVanillaProxy` Proxy of a full Quantum Approximate Optimization Algorithm (QAOA) benchmark. This benchmark targets MaxCut on a Sherrington-Kirkpatrick (SK) model. Device performance is given by the Hellinger fidelity between the experimental output distribution and the true distribution obtained via scalable, classical simulation. The ansatz for this QAOA problem utilizes the fermionic SWAP network which is able to perform all of the required O(N^2) interactions in linear circuit depth. This ansatz is especially well-suited to QPU architectures which only support nearest-neighbor connectivity. See https://doi.org/10.3390/electronics10141690 for an example of this ansatz used in practice. When a new instance of this benchmark is created, the ansatz parameters will be initialized by: #. Generating a random instance of an SK graph #. Finding approximately optimal angles (rather than random values) .. py:class:: QAOAVanillaProxy(num_qubits: int) Bases: :py:obj:`supermarq.benchmark.Benchmark` Proxy of a full Quantum Approximate Optimization Algorithm (QAOA) benchmark. This benchmark targets MaxCut on a Sherrington-Kirkpatrick (SK) model. Device performance is given by the Hellinger fidelity between the experimental output distribution and the true distribution obtained via scalable, classical simulation. The ansatz for this QAOA problem follows the typical structure obtained when directly translating the objective Hamiltonian to the quantum circuit. Since the SK model is completely connected there are O(N^2) interactions that need to take place. These are implementation by pairs of CNOTs and Rz rotations between the participating qubits. This ansatz is well-suited to QPU architectures which support all-to-all connectivity. When a new instance of this benchmark is created, the ansatz parameters will be initialized by: #. Generating a random instance of an SK graph #. Finding approximately optimal angles (rather than random values) .. py:method:: circuit() -> cirq.Circuit Generate a QAOA circuit for the Sherrington-Kirkpatrick model. The ansatz structure is given by the form of the Hamiltonian and requires interactions between every pair of qubits. We restrict the depth of this proxy benchmark to p=1 to keep the classical simulation scalable. :returns: The S-K model QAOA `cirq.Circuit`. .. py:method:: score(counts: collections.abc.Mapping[str, float]) -> float Compare the experimental output to the output of noiseless simulation. The implementation here has exponential runtime and would not scale. However, it could in principle be done efficiently via https://arxiv.org/abs/1706.02998, so we're good. :param counts: A dictionary containing the measurement counts from circuit execution. :returns: The QAOA proxy benchmark score. .. py:attribute:: hamiltonian :value: [] .. py:attribute:: num_qubits .. py:attribute:: params .. py:class:: VQEProxy(num_qubits: int, num_layers: int = 1) Bases: :py:obj:`supermarq.benchmark.Benchmark` Proxy benchmark of a full VQE application that targets a single iteration of the whole variational optimization. The benchmark is parameterized by the number of qubits, n. For each value of n, we classically optimize the ansatz, sample 3 iterations near convergence, and use the sampled parameters to execute the corresponding circuits on the QPU. We take the measured energies from these experiments and average their values and compute a score based on how closely the experimental results are to the noiseless values. .. py:method:: circuit() -> list[cirq.Circuit] Construct a parameterized ansatz. The counts obtained from evaluating these two circuits should be passed to `score` in the same order they are returned here. :returns: the ansatz measured in the Z basis, and the ansatz measured in the X basis. :rtype: A list of circuits for the VQE benchmark .. py:method:: score(counts: list[dict[str, float]]) -> float Compare the average energy measured by the experiments to the ideal value. The ideal value is obtained via noiseless simulation. In principle the ideal value can be obtained through efficient classical means since the 1D TFIM is analytically solvable. :param counts: A dictionary containing the measurement counts from circuit execution. :returns: The VQE proxy benchmark score. .. py:attribute:: hamiltonian :value: [] .. py:attribute:: num_layers :value: 1 .. py:attribute:: num_qubits