Skip to main content
KetQat

Appearance

Grover search (statevector)

Simulate Grover's search on up to 20 qubits and get the exact success probability plus seeded measurement counts.

Officially provided by KetQat — method by Grover (1996), Boyer et al. (1998) and others. KetQat prepares, verifies and maintains this product; it does not claim to have invented the method. Read the origin statement.

What it does and who it is for

Runs Grover's quantum search algorithm as a statevector simulation on your machine. You choose the register size and the marked basis states; the product prepares the uniform superposition, applies the phase oracle and the diffusion operator the requested number of times (by default the textbook optimum floor(pi/4 * sqrt(N/M))), and reads the Born-rule distribution off the final state vector.

It is for students checking the amplitude-amplification picture against a real simulation, and for researchers who want an exact, reproducible baseline (success probability from the state vector, plus seeded shot counts) to compare other implementations against.

This is not the older grover-search runner family in this SDK, which samples shots from the analytic success probability without simulating a circuit.

Use cases

  • Check the success probability of Grover search for a given number of qubits, marked states and iterations
  • Show over-rotation: how the success probability falls when iterating past the optimum
  • Produce a reproducible reference distribution to compare another simulator or SDK against

Use it on your computer

This page never runs anything. Copy the commands into your own terminal; the product runs locally with no account and no telemetry.
  1. Install

    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.

    Terminal
    pip install "ketqat[algorithms] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"
  2. Run the example

    Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected] --param n_qubits=N_QUBITS --param marked=MARKED.

    Python
    import json
    from ketqat_runner import catalog
    
    record = catalog.run("[email protected]", seed=7, n_qubits=5, marked=[3, 17], shots=1000)
    result = record.result
    print(json.dumps({
        "status": record.status,
        "iterations": result["iterations"],
        "success_probability": round(result["success_probability"], 6),
        "analytic_success_probability": round(result["analytic_success_probability"], 6),
    }))
    
    Expected output (fields the example must print)
    {
      "status": "succeeded",
      "iterations": 3,
      "success_probability": 0.961319,
      "analytic_success_probability": 0.961319
    }

    Verified with

    SDK
    0.3.0
    Python
    3.12.12
    Platform
    macOS-27.0.1-arm64 Python 3.12.12 (maintainer run) and Ubuntu 26.04 x86_64 Python 3.12.15 (GitHub Actions python-package.yml catalog job, run 40815046070: example executed verbatim in a clean virtualenv)
    Date
    29 Oct 2026
  3. Optional: tell us it ran

    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.

Inputs and outputs

Inputs

Inputs of Grover search (statevector)
NameTypeDefaultAllowed valuesDescription
n_qubitsintegerrequiredmaximum: 20; minimum: 2Register size n; the search space has N = 2^n states. Larger requests are refused with the memory they would need.
markedinteger[]requiredminItems: 1; itemMinimum: 0; uniqueItems: trueMarked basis states as integers in [0, 2^n - 1]; at least one, all distinct, fewer than 2^n.
iterationsintegernullmaximum: 100000; minimum: 0Number of Grover iterations k. null uses floor(pi/4 * sqrt(N/M)).
shotsinteger1000maximum: 10000000; minimum: 1Measurement samples drawn from the final state.

Outputs

Outputs of Grover search (statevector)
NameTypeDescription
success_probabilitynumberSum of |amplitude|^2 over the marked states of the simulated final state vector (exact up to floating point).
analytic_success_probabilitynumbersin^2((2k+1) theta) with sin(theta) = sqrt(M/N), reported beside the simulated value as a cross-check.
iterationsintegerIterations actually applied, and iterations_rule saying whether they were chosen by the user or by the formula.
countsobjectSeeded measurement counts, bitstring (most significant qubit first) to count; only non-zero outcomes.
observed_success_fractionnumberFraction of shots that landed on a marked state.

Sample result

5 qubits, marked states 3 and 17, 3 iterations (the optimum): the simulated success probability is 0.961319, equal to the analytic value; 955 of 1000 seeded shots hit a marked state.

Generated with

Product version
1.0.0
Seed
7
Parameters
{"shots":1000,"marked":[3,17],"n_qubits":5,"iterations":null}
SDK
0.3.0
Python
3.12.12
Platform
macOS-27.0.1-arm64-arm-64bit
Result data (JSON)
{
  "shots": 1000,
  "counts": {
    "10000": 2,
    "10001": 474,
    "10010": 4,
    "10101": 2,
    "11000": 2,
    "11001": 1,
    "11010": 3,
    "11011": 2,
    "11100": 1,
    "11101": 1,
    "11110": 1,
    "11111": 2,
    "00000": 1,
    "00001": 3,
    "00010": 2,
    "00011": 481,
    "00100": 3,
    "00110": 2,
    "00111": 2,
    "01000": 1,
    "01001": 1,
    "01010": 1,
    "01100": 1,
    "01101": 1,
    "01110": 1,
    "01111": 5
  },
  "marked": [
    3,
    17
  ],
  "n_qubits": 5,
  "iterations": 3,
  "iterations_rule": "floor(pi/4*sqrt(N/M))",
  "success_probability": 0.9613189697265623,
  "observed_success_count": 955,
  "observed_success_fraction": 0.955,
  "analytic_success_probability": 0.9613189697265625
}

Assumptions, scope and limitations

Assumptions

  • Ideal, noiseless gates: no decoherence, gate error or readout error is modelled.
  • The oracle is a phase oracle that flips the sign of each marked basis state; its cost is not modelled.
  • The diffusion operator is applied in closed form, 2|s><s| - I, which equals H^n (2|0><0| - I) H^n; a test checks the two agree amplitude by amplitude.

Scope

  • 2 to 20 qubits, any non-empty proper subset of marked states, any iteration count up to 100000.
  • Exact success probability from the state vector and seeded multinomial sampling of measurement outcomes.

Limitations

  • A statevector simulation: memory and time grow as 2^n, so 20 qubits is the ceiling. It says nothing about running on hardware.
  • No noise model; real devices will show lower success probabilities.
  • Gate counts and circuit depth are not reported, because the oracle is applied as an operator rather than compiled into gates.
  • Sampled counts are reproducible for the same seed with the same NumPy version; NumPy does not guarantee identical random streams across versions.
  • Tested on macOS and Linux only; Windows is untested.

Environment and resources

Runs
Locally, on your computer
Type
Simulation
Python
>=3.10
Operating systems
Linux, macOS
Resources
n=20 with the optimal 804 iterations: ~1.5 s and ~50 MB on a 2024 laptop; time grows as sqrt(N) iterations x N amplitudes.
SDK extras
algorithms
Minimum SDK
0.3.0

Validation

Verified: the example was executed by CI, validation tests exist and limitations are recorded.

Versions and changelog

  1. 1.0.029 Oct 2026currentShown on this page

    • First catalog release: NumPy statevector Grover search with exact success probability and seeded sampling.

    Needs SDK 0.3.0 or later with extras: algorithms.

All product changelogs

Origin, license and credits

KetQat implementation of published methods

Grover's algorithm was introduced by Lov K. Grover (1996); the multiple-marked-state analysis follows Boyer, Brassard, Hoyer and Tapp (1998). KetQat wrote this NumPy statevector implementation, its validation tests and this catalog entry. KetQat did not invent the method.

Upstream software

License of what you receive

Apache-2.0 — see Licensing.

Contributors

People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.

  • dorakingx · KetQat maintainer: implementation, validation and catalog entry

How to contribute

References

  1. Lov K. Grover (1996). A fast quantum mechanical algorithm for database search. Proceedings of the 28th Annual ACM Symposium on Theory of Computing (STOC '96).DOI 10.1145/237814.237866arXiv:quant-ph/9605043
  2. Michel Boyer, Gilles Brassard, Peter Hoyer, Alain Tapp (1998). Tight bounds on quantum searching. Fortschritte der Physik 46, 493-505.arXiv:quant-ph/9605034
  3. Michael A. Nielsen, Isaac L. Chuang (2010). Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge University Press.DOI 10.1017/CBO9780511976667

Usage

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.

Reviews

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.