Quantum Algorithms · Search
Grover search (statevector)
Simulate Grover's search on up to 20 qubits and get the exact success probability plus seeded measurement counts.
Apply the QFT gate sequence to a basis, uniform or random state on up to 16 qubits and compare it with the DFT definition.
Officially provided by KetQat — method by Coppersmith (1994), Shor (1994) and others. KetQat prepares, verifies and maintains this product; it does not claim to have invented the method. Read the origin statement.
Applies the quantum Fourier transform, or its inverse, as the real gate sequence (Hadamards, controlled phase rotations and the final qubit reversal) to a state vector on your machine. The input is a computational basis state, the uniform superposition or a seeded random state. The output is compared with an independent reference: the DFT column written straight from its definition for a basis state, the known |0...0> result for the uniform state, and the full DFT matrix product for a random state of up to 10 qubits. The inverse transform is then applied and the round-trip error reported, and the output state is sampled with a seed.
The convention is stated and checked rather than assumed: QFT|j> = (1/sqrt N) sum_k exp(+2 pi i j k / N)|k>, little-endian, so a flipped sign or a reversed bit order would show up as a non-zero deviation. Pure Python: the algorithms extra is used only for seeded sampling.
Installs the KetQat SDK from commit 2cedabbd814f, the exact version whose product definition this page shows. The SDK is not on PyPI yet, so pip install ketqat alone will not work.
pip install "ketqat[algorithms] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected].
import json
from ketqat_runner import catalog
record = catalog.run("[email protected]", seed=7, n_qubits=4, input_state="basis", basis_index=1, shots=1000)
result = record.result
print(json.dumps({
"status": record.status,
"dimension": result["dimension"],
"matches_dft_column": result["max_deviation_from_reference"] < 1e-9,
"round_trip_is_identity": result["round_trip_error"] < 1e-9,
"output_is_flat": result["max_magnitude_deviation_from_flat"] < 1e-9,
"output_norm": round(result["output_norm"], 9),
}))
{
"status": "succeeded",
"dimension": 16,
"output_norm": 1,
"output_is_flat": true,
"matches_dft_column": true,
"round_trip_is_identity": true
}Verified with
ketqat report RUN_ID sends an opt-in usage report: product, version, succeeded/failed, time and SDK version only. It shows you the exact payload first and needs an API token from Settings. Nothing is sent unless you run it.
| Name | Type | Default | Allowed values | Description |
|---|---|---|---|---|
| n_qubits | integer | 4 | maximum: 16; minimum: 1 | Register size n; the state has N = 2^n amplitudes. |
| input_state | string | basis | enum: basis, uniform, random | basis (|basis_index>), uniform ((1/sqrt N) sum_j |j>) or random (seeded complex Gaussian amplitudes, normalised). |
| basis_index | integer | 1 | minimum: 0 | j for input_state=basis, in [0, 2^n - 1]. Ignored otherwise. |
| inverse | boolean | false | — | Apply the inverse transform (negative phases) instead of the forward one. |
| shots | integer | 1000 | maximum: 100000; minimum: 1 | Measurement samples drawn from the output state. |
| Name | Type | Description |
|---|---|---|
| max_deviation_from_reference | number | Largest |amplitude difference| between the circuit output and the independent reference named in reference; null when the O(N^2) matrix reference is skipped (random input above 10 qubits). |
| round_trip_error | number | Largest |amplitude difference| after applying the opposite transform to the output. |
| output_norm | number | Norm of the output state (1 for a unitary transform). |
| max_magnitude_deviation_from_flat | number | For a basis-state input: largest deviation of |amplitude| from 1/sqrt N over the output. |
| output_amplitudes | object[] | [real, imaginary] pairs of the output state, listed up to 5 qubits; null above. |
| counts | object | Seeded measurement counts of the output, bitstring (most significant qubit first) to count; the eight most probable outcomes are listed in top_outcomes. |
4 qubits, basis state |0001>: the gate-level output equals the DFT column to 12 decimals, every output magnitude is 1/4 (flat), the inverse transform returns the input exactly, and 1000 seeded shots spread over all 16 outcomes.
Generated with
{"shots":1000,"inverse":false,"n_qubits":4,"basis_index":1,"input_state":"basis"}{
"shots": 1000,
"counts": {
"1000": 62,
"1001": 64,
"1010": 67,
"1011": 52,
"1100": 73,
"1101": 59,
"1110": 60,
"1111": 61,
"0000": 65,
"0001": 59,
"0010": 73,
"0011": 60,
"0100": 65,
"0101": 57,
"0110": 61,
"0111": 62
},
"inverse": false,
"n_qubits": 4,
"dimension": 16,
"execution": "statevector simulation of the gate sequence (pure Python), seeded sampling of the output",
"reference": "DFT column (1/sqrt(N)) exp(+-2 pi i j k / N), written from the definition",
"convention": "QFT|j> = (1/sqrt(N)) sum_k exp(+2 pi i j k / N)|k>, little-endian (qubit 0 is the least significant bit); the inverse carries the opposite sign",
"input_state": {
"kind": "basis",
"description": "|1> = |0001>"
},
"output_norm": 1,
"top_outcomes": [
{
"integer": 0,
"bitstring": "0000",
"probability": 0.0625
},
{
"integer": 2,
"bitstring": "0010",
"probability": 0.0625
},
{
"integer": 4,
"bitstring": "0100",
"probability": 0.0625
},
{
"integer": 7,
"bitstring": "0111",
"probability": 0.0625
},
{
"integer": 8,
"bitstring": "1000",
"probability": 0.0625
},
{
"integer": 10,
"bitstring": "1010",
"probability": 0.0625
},
{
"integer": 12,
"bitstring": "1100",
"probability": 0.0625
},
{
"integer": 15,
"bitstring": "1111",
"probability": 0.0625
}
],
"round_trip_error": 0,
"distinct_outcomes": 16,
"output_amplitudes": [
[
0.25,
0
],
[
0.230969883128,
0.095670858091
],
[
0.176776695297,
0.176776695297
],
[
0.095670858091,
0.230969883128
],
[
0,
0.25
],
[
-0.095670858091,
0.230969883128
],
[
-0.176776695297,
0.176776695297
],
[
-0.230969883128,
0.095670858091
],
[
-0.25,
0
],
[
-0.230969883128,
-0.095670858091
],
[
-0.176776695297,
-0.176776695297
],
[
-0.095670858091,
-0.230969883128
],
[
0,
-0.25
],
[
0.095670858091,
-0.230969883128
],
[
0.176776695297,
-0.176776695297
],
[
0.230969883128,
-0.095670858091
]
],
"max_deviation_from_reference": 0,
"max_magnitude_deviation_from_flat": 0
}dft column agreement
For every basis state on 1 to 6 qubits, forward and inverse, the circuit output equals the corresponding column of the DFT matrix written from its definition to 1e-12; the product reports the same agreement for a basis input.
python/tests/test_catalog_products.py::test_qft_of_every_basis_state_equals_the_dft_column
inverse round trip
QFT followed by its inverse (and the inverse followed by the QFT) returns random states on 1 to 8 qubits to 1e-12, and the product reports a round-trip error below 1e-12 for random input.
python/tests/test_catalog_products.py::test_qft_followed_by_its_inverse_is_the_identity
analytic outputs
The uniform state transforms to |0...0> with every sampled shot landing there, and a basis state transforms to a flat magnitude distribution with |amplitude| = 1/sqrt N to 1e-12.
python/tests/test_catalog_products.py::test_qft_of_uniform_and_basis_states_match_their_closed_forms
example execution
The example code is executed verbatim in a clean virtual environment with only the algorithms extra installed.
1.0.01 Nov 2026currentShown on this page
Needs SDK 0.3.0 or later with extras: algorithms.
KetQat implementation of published methods
The quantum Fourier transform circuit is due to Coppersmith (1994) and was introduced as the core of Shor's factoring algorithm (1994); the discrete Fourier transform it implements is classical. KetQat wrote this pure-Python gate-level implementation (fourier.py), the DFT reference it is checked against, the validation tests and this catalog entry. KetQat did not invent the method.
Apache-2.0 — see Licensing.
People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.
No usage reports yet
Distinct signed-in accounts that chose to send at least one usage report (ketqat report) for this product in the last 90 days. KetQat staff, test and bot accounts are excluded. Reports are opt-in, so this is not a count of all users.
Computed 10 Nov 2026, 17:24 UTC.
Not yet rated
Be the first to rate this product after you run it.
Mean of visible reviews. Hidden reviews and reviews by KetQat staff, test and bot accounts are excluded. Pro status gives no extra weight.
Sign in to review this product. One review per person; you can edit it later.
No reviews yet.