Skip to main content
KetQat

Appearance

Quantum state tomography

Reconstruct a known pure state of up to 4 qubits from sampled Pauli measurements by linear inversion, with physicality and fidelity.

Officially provided by KetQat — method by Vogel and Risken (1989), James et al. (2001) 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

Simulates state tomography on your machine. A known pure target state -- a point on the Bloch sphere, |0>, |1>, |+>, |->, |+i>, a Bell state, a GHZ state or a seeded random state -- is measured in every Pauli basis: for each of the 4^n Pauli strings the +1/-1 outcome counts are sampled from the exact Born probabilities with the shots you choose, or taken exactly when exact=true. The density matrix is reconstructed by linear inversion, rho = sum <P> P / 2^n, and reported with its eigenvalues, purity, trace, the fidelity with the target and the largest error in any estimated expectation value.

Physicality is reported, never repaired. From finite statistics linear inversion routinely returns a matrix with a negative eigenvalue -- most often near a pure state, where shot noise pushes the Bloch vector past the unit sphere -- and the product returns that matrix unprojected, with the eigenvalue, so you can see how far outside the state space the data landed. The exact (infinite-shot) reconstruction is reported beside it as the reference.

Use cases

  • See how the reconstruction error and the standard errors of a Bloch vector shrink as shots grow
  • Show why linear inversion from few shots yields unphysical density matrices near pure states
  • Produce a seeded, reproducible tomography dataset and reconstruction for a Bell or GHZ state to test an estimator 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[qinfo] @ 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].

    Python
    import json
    from ketqat_runner import catalog
    
    record = catalog.run("[email protected]", seed=7, preset="bell", exact=True)
    result = record.result
    print(json.dumps({
        "status": record.status,
        "qubits": result["qubits"],
        "pauli_settings": result["pauli_settings"],
        "fidelity_with_target": round(result["fidelity_with_target"], 9),
        "purity": round(result["purity"], 9),
        "physical": result["physical"],
        "reconstruction_error": round(result["reconstruction_error"], 9),
    }))
    
    Expected output (fields the example must print)
    {
      "purity": 1,
      "qubits": 2,
      "status": "succeeded",
      "physical": true,
      "pauli_settings": 16,
      "fidelity_with_target": 1,
      "reconstruction_error": 0
    }

    Verified with

    SDK
    0.3.0
    Python
    3.12.12
    Platform
    macOS-27.0.1-arm64 Python 3.12.12 (maintainer run in a clean virtualenv, test_catalog_examples.py)
    Date
    1 Nov 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 state tomography
NameTypeDefaultAllowed valuesDescription
presetstringblochenum: bloch, zero, one, plus, minus, i-plus, bell, ghz, randomTarget state: bloch (cos(theta/2)|0> + e^{i phi} sin(theta/2)|1>), zero, one, plus, minus, i-plus (one qubit); bell (|Phi+>); ghz or random (qubits sets the size).
thetanumber1maximum: 3.141592653589793; minimum: 0Polar angle for preset=bloch, in [0, pi]. Ignored by the other presets.
phinumber0.5maximum: 6.283185307179586; minimum: 0Azimuthal angle for preset=bloch, in [0, 2 pi]. Ignored by the other presets.
qubitsintegernullmaximum: 4; minimum: 1Register size for preset=ghz (null means 3) and preset=random (null means 2); at most 4 (256 Pauli settings). Not accepted with the one- and two-qubit presets.
shotsinteger1000maximum: 1000000; minimum: 1Measurements per Pauli setting. Ignored when exact=true.
exactbooleanfalse—true uses the exact expectation values (the infinite-shot limit) instead of sampling.

Outputs

Outputs of Quantum state tomography
NameTypeDescription
expectationsobject[]For each Pauli string: the estimate, its binomial standard error and the exact value.
bloch_vectorobjectOne qubit only: x, y, z with standard errors, beside target_bloch_vector and the Bloch length.
density_matrix_realobject[]Real part of the reconstructed density matrix (density_matrix_imaginary holds the imaginary part), with eigenvalues, purity and trace.
physicalbooleanWhether every eigenvalue is non-negative (within 1e-9); physicality_note says why not and that nothing was projected.
fidelity_with_targetnumber<psi|rho|psi> for the pure target (for one qubit, (1 + r . t)/2).
max_expectation_errornumberLargest |estimate - exact| over all Pauli strings; reconstruction_error is the largest matrix-entry error.

Sample result

One qubit at theta = 1, phi = 0.5 with 1000 shots per Pauli setting: Bloch estimate (0.732, 0.428, 0.582) against the target (0.738, 0.403, 0.540), standard errors about 0.02-0.03. The estimate has length 1.028, so the reconstruction has a negative eigenvalue (-0.0142) and is reported as unphysical and unprojected; the linear-inversion fidelity formula then gives 1.014, above 1 for the same reason.

Generated with

Product version
1.0.0
Seed
7
Parameters
{"phi":0.5,"exact":false,"shots":1000,"theta":1,"preset":"bloch","qubits":null}
SDK
0.3.0
Python
3.12.12
Platform
macOS-27.0.1-arm64-arm-64bit
Result data (JSON)
{
  "trace": 1,
  "purity": 1.028866,
  "qubits": 1,
  "target": {
    "phi": 0.5,
    "theta": 1,
    "preset": "bloch",
    "qubits": 1,
    "description": "cos(theta/2)|0> + exp(i phi) sin(theta/2)|1>"
  },
  "physical": false,
  "estimator": "linear inversion: rho = sum_P <P> P / 2^n",
  "execution": "exact Born probabilities from the target state vector; seeded binomial sampling; dense linear algebra",
  "eigenvalues": [
    -0.014230493067,
    1.014230493067
  ],
  "measurement": "each Pauli string measured as a +1/-1 observable; outcome counts sampled from the exact Born probabilities",
  "bloch_length": 1.028460986134,
  "bloch_vector": {
    "x": 0.732,
    "y": 0.428,
    "z": 0.582,
    "x_standard_error": 0.021544744139,
    "y_standard_error": 0.028579993002,
    "z_standard_error": 0.025715287282
  },
  "expectations": [
    {
      "exact": 1,
      "pauli": "I",
      "estimate": 1,
      "standard_error": 0
    },
    {
      "exact": 0.738460262604,
      "pauli": "X",
      "estimate": 0.732,
      "standard_error": 0.021544744139
    },
    {
      "exact": 0.403422680111,
      "pauli": "Y",
      "estimate": 0.428,
      "standard_error": 0.028579993002
    },
    {
      "exact": 0.540302305868,
      "pauli": "Z",
      "estimate": 0.582,
      "standard_error": 0.025715287282
    }
  ],
  "pauli_settings": 4,
  "physicality_note": "The reconstructed Bloch vector has length 1.028461, which exceeds 1, so the smaller eigenvalue is -0.014230 and the matrix is not a density matrix. Linear inversion does this routinely near a pure state, where shot noise pushes the estimate past the state space. It is a statement about the estimator and the shot count, not about the device -- take more shots, or use a maximum-likelihood estimator that is constrained to physical states. The raw estimate is returned unchanged rather than projected, so the size of the excursion stays visible.",
  "shots_per_setting": 1000,
  "density_matrix_real": [
    [
      0.791,
      0.366
    ],
    [
      0.366,
      0.209
    ]
  ],
  "target_bloch_vector": [
    0.738460262604,
    0.403422680111,
    0.540302305868
  ],
  "exact_reconstruction": {
    "note": "linear inversion from exact expectation values (multi_qubit_state_tomography)",
    "purity": 1,
    "physical": true,
    "reconstruction_error": 0
  },
  "fidelity_with_target": 1.013836880665,
  "reconstruction_error": 0.020848847066,
  "max_expectation_error": 0.041697694132,
  "density_matrix_imaginary": [
    [
      0,
      -0.214
    ],
    [
      0.214,
      0
    ]
  ]
}

Assumptions, scope and limitations

Assumptions

  • The target is a pure state prepared perfectly; measurement outcomes follow the exact Born probabilities with no readout error.
  • Each Pauli string is measured as a +1/-1 observable with the same number of shots; the identity string is not measured (its expectation is 1).
  • Linear inversion with no constraint to the state space; standard errors are the binomial ones for a +1/-1 valued mean.

Scope

  • Pure target states on 1 to 4 qubits; sampled or exact expectation values; reconstruction, physicality verdict and fidelity with the target.

Limitations

  • Linear inversion only: no maximum-likelihood or Bayesian estimator is provided, so unphysical reconstructions are reported rather than avoided.
  • The number of Pauli settings grows as 4^n, so 4 qubits is the ceiling and the product is not a scalable tomography tool.
  • Fidelity is computed against the known target; for a real experiment the target is not known and this number would not be available.
  • Mixed target states and readout noise are not modelled.
  • 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
One or two qubits: milliseconds. Four qubits (256 Pauli settings, 16x16 matrices): under 0.1 s and a few MB.
SDK extras
qinfo
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.01 Nov 2026currentShown on this page

    • First catalog release, wrapping the SDK's existing single-qubit linear-inversion tomography and the multi-qubit Pauli reconstruction with seeded measurement sampling.

    Needs SDK 0.3.0 or later with extras: qinfo.

All product changelogs

Origin, license and credits

KetQat implementation of published methods

Quantum state tomography originates with Vogel and Risken (1989); the linear-inversion reconstruction from Pauli expectation values used here is the textbook treatment of Nielsen and Chuang, and the qubit measurement analysis follows James, Kwiat, Munro and White (2001), with the unphysicality of linear inversion discussed by Smolin, Gambetta and Smith (2012). KetQat wrote this NumPy implementation (tomography.py, process_tomography.py and this product's sampling), the 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. K. Vogel, H. Risken (1989). Determination of quasiprobability distributions in terms of probability distributions for the rotated quadrature phase. Physical Review A 40, 2847-2849.DOI 10.1103/PhysRevA.40.2847
  2. Daniel F. V. James, Paul G. Kwiat, William J. Munro, Andrew G. White (2001). Measurement of qubits. Physical Review A 64, 052312.DOI 10.1103/PhysRevA.64.052312arXiv:quant-ph/0103121
  3. John A. Smolin, Jay M. Gambetta, Graeme Smith (2012). Efficient Method for Computing the Maximum-Likelihood Quantum State from Measurements with Additive Gaussian Noise. Physical Review Letters 108, 070502.DOI 10.1103/PhysRevLett.108.070502arXiv:1106.5458
  4. 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:34 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.