supermarq.benchmarks

Submodules

Classes

BitCode

Creates a circuit for syndrome measurement in a bit-flip error correcting code.

GHZ

Represents the GHZ state preparation benchmark parameterized by the number of qubits n.

HamiltonianSimulation

Quantum benchmark focused on the ability to simulate 1D

MerminBell

The Mermin-Bell benchmark is a test of a quantum computer's ability to exploit purely quantum

PhaseCode

Creates a circuit for syndrome measurement in a phase-flip error correcting code.

QAOAFermionicSwapProxy

Proxy of a full Quantum Approximate Optimization Algorithm (QAOA) benchmark.

QAOAVanillaProxy

Proxy of a full Quantum Approximate Optimization Algorithm (QAOA) benchmark.

VQEProxy

Proxy benchmark of a full VQE application that targets a single iteration

Package Contents

class supermarq.benchmarks.BitCode(num_data_qubits: int, num_rounds: int, bit_state: list[int])

Bases: supermarq.benchmark.Benchmark

Creates a circuit for syndrome measurement in a bit-flip error correcting code.

Parameters:
  • num_data_qubits – The number of data qubits.

  • num_rounds – The number of measurement rounds.

  • 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.

  • TypeError – If bit_state is not a list.

  • ValueError – If bit_state contains values not in {0,1}.

circuit() cirq.Circuit

Generates bit code circuit.

Returns:

A cirq.Circuit.

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.

Parameters:

counts – Dictionary containing the measurement counts from running self.circuit().

Returns:

A float with the computed score.

bit_state
num_data_qubits
num_rounds
class supermarq.benchmarks.GHZ(num_qubits: int, method: str = 'ladder')

Bases: 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.

circuit() cirq.Circuit

Generate an n-qubit GHZ cirq circuit.

Returns:

A cirq.Circuit.

qiskit_circuit() qiskit.QuantumCircuit

Generate an n-qubit GHZ qiskit circuit.

Returns:

A qiskit.QuantumCircuit.

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$.

Parameters:

counts – A dictionary containing the measurement counts from circuit execution.

Returns:

Hellinger fidelity as a float.

method = 'ladder'
num_qubits
class supermarq.benchmarks.HamiltonianSimulation(num_qubits: int, time_step: int = 1, total_time: int = 1)

Bases: 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.

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.

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.

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.

Parameters:

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.

num_qubits
time_step = 1
total_time = 1
class supermarq.benchmarks.MerminBell(num_qubits: int)

Bases: 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.

circuit() cirq.Circuit

The Mermin-Bell circuit, simultaneously measuring Mermin terms in a GHZ circuit.

Returns:

The Mermin-Bell cirq.Circuit.

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.

Parameters:

counts – A dictionary containing the measurement counts from circuit execution.

Returns:

The score for the Mermin-Bell benchmark score.

mermin_operator = []
num_qubits
qubits
class supermarq.benchmarks.PhaseCode(num_data_qubits: int, num_rounds: int, phase_state: list[int])

Bases: supermarq.benchmark.Benchmark

Creates a circuit for syndrome measurement in a phase-flip error correcting code.

Parameters:
  • num_data_qubits – The number of data qubits.

  • num_rounds – The number of measurement rounds.

  • 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.

  • TypeError – If phase_state is not a list.

  • ValueError – If phase_state contains values not in {0,1}.

circuit() cirq.Circuit

Generates phase code circuit.

Returns:

A cirq.Circuit.

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.

Parameters:

counts – Dictionary containing the measurement counts from running self.circuit().

Returns:

A float with the computed score.

num_data_qubits
num_rounds
phase_state
class supermarq.benchmarks.QAOAFermionicSwapProxy(num_qubits: int)

Bases: 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:

  1. Generating a random instance of an SK graph

  2. Finding approximately optimal angles (rather than random values)

class supermarq.benchmarks.QAOAVanillaProxy(num_qubits: int)

Bases: 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:

  1. Generating a random instance of an SK graph

  2. Finding approximately optimal angles (rather than random values)

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.

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.

Parameters:

counts – A dictionary containing the measurement counts from circuit execution.

Returns:

The QAOA proxy benchmark score.

hamiltonian = []
num_qubits
params
class supermarq.benchmarks.VQEProxy(num_qubits: int, num_layers: int = 1)

Bases: 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.

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.

Return type:

A list of circuits for the VQE benchmark

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.

Parameters:

counts – A dictionary containing the measurement counts from circuit execution.

Returns:

The VQE proxy benchmark score.

hamiltonian = []
num_layers = 1
num_qubits