mqt.core.bench.qaoa

QAOA benchmark instances and options.

Module Contents

class Options(*, qubits: int, depth: int = 1)

Parameters for a QAOA benchmark for MaxCut.

property qubits: int

The cycle’s number of vertices, at least three and representable as a signed 64-bit integer.

property depth: int

The number of cost-mixer layers.

class Evaluation

The sampled cut quality on a cycle graph.

property shots: int

The number of evaluated shots.

property mean_cut: float

The shot-weighted mean number of cut edges.

property approximation_ratio: float

The mean cut divided by the cycle’s maximum cut size.

class QAOA(options: Options)

A validated QAOA benchmark for MaxCut.

The circuit starts in \(|+\rangle^{\otimes n}\) on an unweighted cycle. Each layer applies \(e^{-i\gamma_\ell C}\) followed by \(e^{-i\beta_\ell B}\), where \(C=\sum_{j=0}^{n-1}(1-Z_jZ_{(j+1)\bmod n})/2\) and \(B=\sum_{j=0}^{n-1} X_j\).

For \(d\) layers, the generated program takes two arrays of \(d\) angles: gammas and betas. Bind angles in radians with mqt.core.mlir.QCProgram.bind_parameters() before sampling or export. Copy the program first to reuse it for other angles.

The benchmark does not run an optimizer. Evaluation measures cut quality, not agreement with an ideal output distribution.

property options: Options

The resolved benchmark parameters.

property output: Output

The logical output register.

cut_size(outcome: str) → int

Count cycle edges whose measured endpoint bits differ.

evaluate(counts: Mapping[str, int]) → Evaluation

Compute the mean cut and its ratio to the maximum cut size.

generate() → QCProgram

Generate the benchmark as a QC program.

property instance_specification_json: str

The canonical instance specification JSON.

property manifest_json: str

The canonical manifest JSON.

property case_id: str

The stable semantic case ID.

static from_instance_specification_json(json: str, *, source: str = '<instance-specification>') → QAOA

Parse a strict benchmark instance specification.

static from_manifest_json(json: str, *, source: str = '<manifest>') → QAOA

Parse a strict benchmark manifest.