Skip to main content
KetQat

Appearance

Quantum phase estimation (statevector)

Simulate textbook quantum phase estimation for a given eigenphase and read off the estimate, its probability and seeded counts.

Officially provided by KetQat — method by Kitaev (1995), Cleve 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 textbook quantum phase estimation as a statevector simulation of the gate sequence: Hadamards on the counting register, the controlled-U^(2^j) phase kickback against an eigenstate with eigenphase phi, and an inverse quantum Fourier transform. The output distribution is the Born rule applied to the final state, not a formula for what it should be.

Use it to see how the number of counting qubits sets the resolution, to check that a dyadic phase is recovered with certainty, and to inspect the spread of outcomes for a phase the register cannot represent exactly. Pure Python: no optional dependencies.

Use cases

  • Show that a phase k/2^n is estimated exactly with probability 1
  • Inspect the outcome distribution for a phase between grid points
  • Choose the number of counting qubits needed for a target precision

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 @ 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 phase=PHASE.

    Python
    import json
    from ketqat_runner import catalog
    
    record = catalog.run("[email protected]", seed=11, phase=0.3125, counting_qubits=4, shots=500)
    result = record.result
    print(json.dumps({
        "status": record.status,
        "measured_integer": result["measured_integer"],
        "estimated_phase": result["estimated_phase"],
        "success_probability": round(result["success_probability"], 9),
        "counts": result["counts"],
    }))
    
    Expected output (fields the example must print)
    {
      "counts": {
        "0101": 500
      },
      "status": "succeeded",
      "estimated_phase": 0.3125,
      "measured_integer": 5,
      "success_probability": 1
    }

    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 Quantum phase estimation (statevector)
NameTypeDefaultAllowed valuesDescription
phasenumberrequiredmaximum: 1; minimum: 0Eigenphase phi in [0, 1); the eigenvalue is exp(2 pi i phi).
counting_qubitsinteger8maximum: 16; minimum: 1Size n of the counting register; the resolution is 2^-n.
shotsinteger1000maximum: 1000000; minimum: 1Measurement samples drawn from the exact distribution.

Outputs

Outputs of Quantum phase estimation (statevector)
NameTypeDescription
estimated_phasenumberm / 2^n for the most probable outcome m.
success_probabilitynumberExact probability of that most probable outcome.
phase_errornumberDistance on the circle between the estimate and the true phase.
top_outcomesobject[]The eight most probable outcomes with their exact probabilities.
countsobjectSeeded measurement counts by bitstring.

Sample result

Phase 0.3 is not representable with 6 counting qubits: the most probable estimate is 0.296875 (integer 19) with probability 0.8752; the remaining probability spreads over neighbouring outcomes.

Generated with

Product version
1.0.0
Seed
11
Parameters
{"phase":0.3,"shots":1000,"counting_qubits":6}
SDK
0.3.0
Python
3.12.12
Platform
macOS-27.0.1-arm64-arm-64bit
Result data (JSON)
{
  "true_phase": 0.3,
  "phase_error": 0.003124999999999989,
  "top_outcomes": [
    {
      "phase": 0.296875,
      "integer": 19,
      "bitstring": "010011",
      "probability": 0.875168316795848
    },
    {
      "phase": 0.3125,
      "integer": 20,
      "bitstring": "010100",
      "probability": 0.05472438734954395
    },
    {
      "phase": 0.28125,
      "integer": 18,
      "bitstring": "010010",
      "probability": 0.02433758569494445
    },
    {
      "phase": 0.328125,
      "integer": 21,
      "bitstring": "010101",
      "probability": 0.01083236012661924
    },
    {
      "phase": 0.265625,
      "integer": 17,
      "bitstring": "010001",
      "probability": 0.007260745509113149
    },
    {
      "phase": 0.34375,
      "integer": 22,
      "bitstring": "010110",
      "probability": 0.004493223739427852
    },
    {
      "phase": 0.25,
      "integer": 16,
      "bitstring": "010000",
      "probability": 0.003446771870081909
    },
    {
      "phase": 0.359375,
      "integer": 23,
      "bitstring": "010111",
      "probability": 0.002452523992906569
    }
  ],
  "counting_qubits": 6,
  "estimated_phase": 0.296875,
  "measured_integer": 19,
  "success_probability": 0.875168316795848,
  "most_frequent_integer": 19,
  "phase_is_representable": false
}

Assumptions, scope and limitations

Assumptions

  • The second register is prepared in an exact eigenstate of U, so the controlled powers act only as phases on the counting register.
  • Ideal, noiseless gates and measurement.

Scope

  • Eigenphases in [0, 1) and 1 to 16 counting qubits.
  • Exact output distribution plus seeded sampling of measurement outcomes.

Limitations

  • The unitary U and its eigenstate are not simulated; only the eigenphase enters, so the cost of implementing controlled-U^(2^j) is not represented.
  • No noise model.
  • Only the eight most probable outcomes are copied into the result; the full 2^n distribution is not stored.
  • 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
16 counting qubits: under 1 s and <100 MB; 12 or fewer: well under 0.1 s. Pure Python.
SDK extras
None
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, wrapping the SDK's existing statevector phase-estimation simulation.

    Needs SDK 0.3.0 or later.

All product changelogs

Origin, license and credits

KetQat implementation of published methods

Phase estimation is due to Kitaev (1995) and was given its standard circuit form by Cleve, Ekert, Macchiavello and Mosca (1998). KetQat wrote the pure-Python statevector simulation in this SDK (phase_estimation.py and fourier.py), its validation tests and this catalog entry. KetQat did not invent the method.

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. A. Yu. Kitaev (1995). Quantum measurements and the Abelian Stabilizer Problem. arXiv preprint.arXiv:quant-ph/9511026
  2. Richard Cleve, Artur Ekert, Chiara Macchiavello, Michele Mosca (1998). Quantum algorithms revisited. Proceedings of the Royal Society A 454, 339-354.DOI 10.1098/rspa.1998.0164arXiv:quant-ph/9708016
  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.