qcmet.benchmarks.QScoreSingleInstance#

class qcmet.benchmarks.QScoreSingleInstance(qubits, depth, n_graphs=100, seed=None, save_path=None)[source]#

Implementation of the QScore (MaxCut-based) metric for a fixed number of qubits.

This benchmark samples random graphs over num_qubits, constructs a QAOA-style circuit (alternating RZZ cost layers and RX mixer layers), runs on a target backend, and optimizes the variational parameters to minimize a MaxCut-derived cost. The final figure of merit is beta, an aggregated score, normalized against the optimal solution and a random solution, is computed from the observed costs across n_graphs instances; the benchmark is considered passed if beta > 0.2.

Notes

  • Random graphs are generated with Erdős-Rényi-style edge sampling where each possible edge is included independently with probability 1/2.

  • Variational parameter optimization uses COBYLA via scipy.optimize.minimize.

  • The cost uses a ±1/2 edge contribution convention to match the MaxCut scoring, followed by a shift by len(graph)/2 to align with the reference baseline.

  • The beta aggregation follows the reference implementation’s normalization (see comment in _analyze) using an n^(3/2) scaling.

__init__(qubits, depth, n_graphs=100, seed=None, save_path=None)[source]#

Initialize the single QScore benchmark.

Parameters:
  • qubits (int | List[int]) – Number of qubits as an integer or list of indices.

  • depth (int) – Number of QAOA layers (p), i.e., alternating cost/mixer blocks.

  • n_graphs (int, optional) – Number of random graph instances for benchmarking. Defaults to 100.

  • seed (int | None, optional) – Random seed for reproducibility. If None, a seed is drawn uniformly from [0, 1e8). Defaults to None.

  • save_path (str | Path | FileManager | None, optional) – Directory path to save results. Defaults to None.

Methods

__init__(qubits, depth[, n_graphs, seed, ...])

Initialize the single QScore benchmark.

analyze()

Analyze measurements to return benchmark results.

generate_circuits()

Generate benchmark circuits, user facing.

has_plotting()

Check if _plot function is implemented in benchmark.

load_circuit_measurements(circuit_measurements)

Load measurement counts into the experiment_data DataFrame.

measurements_to_probabilities()

Convert raw measurement counts to normalized probabilities.

plot([axes])

Plot benchmark result, user facing.

run([device, num_shots, max_circs_per_job])

Run benchmark.

save()

Save benchmark current state.

set_save_path(save_path)

Set benchmark save path if not set in class constructor.

Attributes

circuits

Gets all benchmark circuits.

experiment_data

Getter for experiment_data dataframe.

num_qubits

Number of qubits in this benchmark.