mqt.core.bench.qft_adder

QFT adder benchmark instances and options.

Module Contents

class Method

Bases: enum.Enum

How the addend enters the circuit.

REGISTER = 0
CONSTANT = 1
class Overflow

Bases: enum.Enum

Wrap the sum or retain carry.

WRAP = 0
CARRY = 1
class Options(*, addend: str, accumulator: str, method: Method = Method.REGISTER, overflow: Overflow = Overflow.WRAP)

Parameters for a QFT adder.

property addend: str

Big-endian addend; register inputs also accept + for a \(|+\rangle\) qubit.

property accumulator: str

Binary accumulator with the same width as the addend.

property method: Method

Register or constant addition.

property overflow: Overflow

Wrap or carry behavior.

class QFTAdder(options: Options)

A validated QFT adder benchmark.

Register addition uses controlled phases and returns the addend followed by the sum. Constant addition compiles the addend into phases and returns only the sum. Wrap mode computes \((a + b) \bmod 2^n\); carry mode retains one extra sum bit. All strings are big-endian, and leading zeros determine the operand width.

Register addends may contain + for independent \(|+\rangle\) qubits. The accumulator and constant addends must be binary. The circuit follows Draper’s register addition and its constant-input Fourier specialization.

property options: Options

The resolved benchmark parameters.

property output: Output

The logical output register.

property expected_result: str | None

The unique logical outcome, or None for a superposed addend.

probability(outcome: str) → float

Return the ideal probability of an outcome.

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

Compare sampled counts with the ideal distribution.

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>') → QFTAdder

Parse a strict benchmark instance specification.

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

Parse a strict benchmark manifest.