Reference

Everything oqft does, in one page. The quick start has worked examples.

Commands

Command What it does
oqft gen Writes a circuit as OpenQASM 3 to standard output
oqft stats Compares gate counts and depth of the textbook and approximate QFT, and the optimistic QFT when --eps is given
oqft check Measures each input’s error against the exact QFT on a simulator
oqft version Prints the version
oqft help Lists the commands

oqft gen

oqft gen --type qft|aqft|oqft -n N [--cutoff K] [--eps E]
Option Meaning Default
-n Number of qubits. Required
--type qft textbook, aqft approximate, oqft optimistic qft
--cutoff For aqft: the largest distance between two qubits that keeps its rotation 2
--eps For oqft: the error target, between 0 and 1 0.01

oqft stats

oqft stats -n N [--cutoff K] [--eps E]

Prints counts of each gate, total gates, two-qubit gates and depth. With --eps it adds a line for the optimistic QFT at that error target.

oqft check

oqft check -n N [--eps E] [--basis X | --samples K] [--format text|csv]
Option Meaning Default
-n Number of qubits, up to 20. Required
--eps Error target used to size the circuit 0.01
--basis Check one input, given as a decimal number
--samples Check this many different inputs, picked at random
--seed Seed for --samples, so a run can be repeated 1
--threshold Flag inputs whose squared error is above this 0.1
--block-width Force a block width instead of sizing from --eps, to study the weak spot 0 (off)
--format text or csv text

Up to 10 qubits, check tests every input unless you pick some. Above 10 you must use --basis or --samples. Each row shows the input, its bits, the values the circuit estimated for each block, the squared error, and whether it passed the threshold. Flagged rows are data, not a failure: the command still exits 0 when it writes the report.

Exit Codes

Code Meaning
0 Done
1 The circuit couldn’t be built, simulated or written
2 A mistake in the command line

Conventions

  • Gates. h, cp (controlled phase, diag(1, 1, 1, e^iθ)) and swap, from the OpenQASM 3 standard library. Angles are in radians.
  • Qubit order. Qubit 0 is the least significant bit of the input number.
  • Sign. The textbook QFT uses the positive sign: input x goes to the sum over y of e^(2πixy/2ⁿ), divided by √2ⁿ. The output order matches, thanks to the swaps at the end.
  • Depth. Every gate is one layer. Gates on separate qubits share a layer.

Error

--eps bounds the average squared distance between the circuit and the exact QFT, taken over every input. That’s the measure the original paper uses, and it doesn’t depend on which inputs you pick. A small target gives wider blocks, which cost more depth and fail on fewer inputs.

For a single input, the squared error is the squared length of the difference between the two output vectors. It runs from 0, a perfect match, to 4, the most different two output states can be.

When the error target calls for blocks so wide that the register would split into only one or two of them, OQFT returns the exact textbook QFT instead. That’s the case for every register small enough to simulate at an error target of 0.01, so checks of the optimistic version itself on small registers use a looser target or --block-width.